M gnot/screen.c => gnot/screen.c +21 -12
@@ 21,6 21,8 @@ struct{
int bwid;
}out;
+Lock screenlock;
+
GBitmap gscreen =
{
(ulong*)((4*1024*1024-256*1024)|KZERO), /* BUG */
@@ 47,12 49,24 @@ screeninit(void)
}
void
+screenputnl(void)
+{
+ out.pos.x = MINX;
+ out.pos.y += defont0.height;
+ if(out.pos.y > gscreen.r.max.y-defont0.height)
+ out.pos.y = gscreen.r.min.y;
+ gbitblt(&gscreen, Pt(0, out.pos.y), &gscreen,
+ Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height), 0);
+}
+
+void
screenputs(char *s, int n)
{
Rune r;
int i;
char buf[4];
+ lock(&screenlock);
while(n > 0){
i = chartorune(&r, s);
if(i == 0){
@@ 64,29 78,24 @@ screenputs(char *s, int n)
buf[i] = 0;
n -= i;
s += i;
- if(r == '\n'){
- out.pos.x = MINX;
- out.pos.y += defont0.height;
- if(out.pos.y > gscreen.r.max.y-defont0.height)
- out.pos.y = gscreen.r.min.y;
- gbitblt(&gscreen, Pt(0, out.pos.y), &gscreen,
- Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height), 0);
- }else if(r == '\t'){
+ if(r == '\n')
+ screenputnl();
+ else if(r == '\t'){
out.pos.x += (8-((out.pos.x-MINX)/out.bwid&7))*out.bwid;
if(out.pos.x >= gscreen.r.max.x)
- screenputs("\n", 1);
+ screenputnl();
}else if(r == '\b'){
if(out.pos.x >= out.bwid+MINX){
out.pos.x -= out.bwid;
- screenputs(" ", 1);
- out.pos.x -= out.bwid;
+ gstring(&gscreen, out.pos, defont, " ", S);
}
}else{
if(out.pos.x >= gscreen.r.max.x-out.bwid)
- screenputs("\n", 1);
+ screenputnl();
out.pos = gstring(&gscreen, out.pos, defont, buf, S);
}
}
+ unlock(&screenlock);
}
int
M pc/u.h => pc/u.h +1 -0
@@ 3,6 3,7 @@ typedef unsigned char uchar;
typedef unsigned long ulong;
typedef long vlong;
typedef union Length Length;
+typedef ushort Rune;
union Length
{
M pc/vga.c => pc/vga.c +41 -30
@@ 193,42 193,53 @@ screeninit(void)
}
void
-screenputc(int c)
+screenputnl(void)
{
- char buf[2];
- int nx;
-
- if(c == '\n'){
- out.pos.x = MINX;
- out.pos.y += defont0.height;
- if(out.pos.y > gscreen.r.max.y-defont0.height)
- out.pos.y = gscreen.r.min.y;
- gbitblt(&gscreen, Pt(0, out.pos.y), &gscreen,
- Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height), flipD[0]);
- }else if(c == '\t'){
- out.pos.x += (8-((out.pos.x-MINX)/out.bwid&7))*out.bwid;
- if(out.pos.x >= gscreen.r.max.x)
- screenputc('\n');
- }else if(c == '\b'){
- if(out.pos.x >= out.bwid+MINX){
- out.pos.x -= out.bwid;
- screenputc(' ');
- out.pos.x -= out.bwid;
- }
- }else{
- if(out.pos.x >= gscreen.r.max.x-out.bwid)
- screenputc('\n');
- buf[0] = c&0x7F;
- buf[1] = 0;
- out.pos = gstring(&gscreen, out.pos, defont, buf, flipD[S]);
- }
+ out.pos.x = MINX;
+ out.pos.y += defont0.height;
+ if(out.pos.y > gscreen.r.max.y-defont0.height)
+ out.pos.y = gscreen.r.min.y;
+ gbitblt(&gscreen, Pt(0, out.pos.y), &gscreen,
+ Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height), flipD[0]);
}
void
screenputs(char *s, int n)
{
- while(n-- > 0)
- screenputc(*s++);
+ Rune r;
+ int i;
+ char buf[4];
+
+ lock(&printq);
+ while(n > 0){
+ i = chartorune(&r, s);
+ if(i == 0){
+ s++;
+ --n;
+ continue;
+ }
+ memmove(buf, s, i);
+ buf[i] = 0;
+ n -= i;
+ s += i;
+ if(r == '\n')
+ screenputnl();
+ else if(r == '\t'){
+ out.pos.x += (8-((out.pos.x-MINX)/out.bwid&7))*out.bwid;
+ if(out.pos.x >= gscreen.r.max.x)
+ screenputnl();
+ }else if(r == '\b'){
+ if(out.pos.x >= out.bwid+MINX){
+ out.pos.x -= out.bwid;
+ gstring(&gscreen, out.pos, defont, " ", flipD[S]);
+ }
+ }else{
+ if(out.pos.x >= gscreen.r.max.x-out.bwid)
+ screenputnl();
+ out.pos = gstring(&gscreen, out.pos, defont, buf, flipD[S]);
+ }
+ }
+ unlock(&printq);
}
int
M port/devdk.c => port/devdk.c +4 -4
@@ 159,12 159,12 @@ enum {
};
char* dkerr[]={
[DKok]"",
- [DKbusy]"host overloaded",
+ [DKbusy]"destination busy",
[DKnetotl]"network not answering",
- [DKdestotl]"host not answering",
+ [DKdestotl]"destination not answering",
[DKbadnet]"unknown address",
- [DKnetbusy]"network overloaded",
- [DKinuse]"server in use",
+ [DKnetbusy]"network busy",
+ [DKinuse]"service in use",
[DKreject]"connection refused",
};
#define DKERRS sizeof(dkerr)/sizeof(char*)
M ss/screen.c => ss/screen.c +21 -12
@@ 33,6 33,8 @@ GBitmap gscreen =
0
};
+Lock screenlock;
+
void
screeninit(void)
{
@@ 44,12 46,24 @@ screeninit(void)
}
void
+screenputnl(void)
+{
+ out.pos.x = MINX;
+ out.pos.y += defont0.height;
+ if(out.pos.y > gscreen.r.max.y-defont0.height)
+ out.pos.y = gscreen.r.min.y;
+ gbitblt(&gscreen, Pt(0, out.pos.y), &gscreen,
+ Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height), 0);
+}
+
+void
screenputs(char *s, int n)
{
Rune r;
int i;
char buf[4];
+ lock(&screenlock);
while(n > 0){
i = chartorune(&r, s);
if(i == 0){
@@ 61,29 75,24 @@ screenputs(char *s, int n)
buf[i] = 0;
n -= i;
s += i;
- if(r == '\n'){
- out.pos.x = MINX;
- out.pos.y += defont0.height;
- if(out.pos.y > gscreen.r.max.y-defont0.height)
- out.pos.y = gscreen.r.min.y;
- gbitblt(&gscreen, Pt(0, out.pos.y), &gscreen,
- Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height), 0);
- }else if(r == '\t'){
+ if(r == '\n')
+ screenputnl();
+ else if(r == '\t'){
out.pos.x += (8-((out.pos.x-MINX)/out.bwid&7))*out.bwid;
if(out.pos.x >= gscreen.r.max.x)
- screenputs("\n", 1);
+ screenputnl();
}else if(r == '\b'){
if(out.pos.x >= out.bwid+MINX){
out.pos.x -= out.bwid;
- screenputs(" ", 1);
- out.pos.x -= out.bwid;
+ gstring(&gscreen, out.pos, defont, " ", S);
}
}else{
if(out.pos.x >= gscreen.r.max.x-out.bwid)
- screenputs("\n", 1);
+ screenputnl();
out.pos = gstring(&gscreen, out.pos, defont, buf, S);
}
}
+ unlock(&screenlock);
}
/*