From 42a027d5d0c10de40ac2e347b4991aa20d2d5ac3 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 28 Dec 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-12-28 --- gnot/screen.c | 33 +++++++++++++++--------- pc/u.h | 1 + pc/vga.c | 71 +++++++++++++++++++++++++++++---------------------- port/devdk.c | 8 +++--- ss/screen.c | 33 +++++++++++++++--------- 5 files changed, 88 insertions(+), 58 deletions(-) diff --git a/gnot/screen.c b/gnot/screen.c index 31a03736d2fc3de6e39cc17b070d22dd74da04f5..528e7a0057ecba4c093536f3ffbd176f8f5516c8 100644 --- a/gnot/screen.c +++ b/gnot/screen.c @@ -21,6 +21,8 @@ struct{ int bwid; }out; +Lock screenlock; + GBitmap gscreen = { (ulong*)((4*1024*1024-256*1024)|KZERO), /* BUG */ @@ -46,6 +48,17 @@ screeninit(void) out.bwid = defont0.info[' '].width; } +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) { @@ -53,6 +66,7 @@ screenputs(char *s, int n) 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 diff --git a/pc/u.h b/pc/u.h index 81dfccf482a2af1e3a96426b21223e1c14af86d6..c6367e3fd7f95de2125bbd3732eed57e8a5d14ae 100644 --- a/pc/u.h +++ b/pc/u.h @@ -3,6 +3,7 @@ typedef unsigned char uchar; typedef unsigned long ulong; typedef long vlong; typedef union Length Length; +typedef ushort Rune; union Length { diff --git a/pc/vga.c b/pc/vga.c index 43287b74c85788d237e8254700ea7d5ffd24f5d2..062d96e79c903827ddee77157e8d74cb03ac56ea 100644 --- a/pc/vga.c +++ b/pc/vga.c @@ -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 diff --git a/port/devdk.c b/port/devdk.c index c9160704bd360d16224340d8ccb29fd8e6bedc31..1a26bac108e7fb115fd29173ebbf73fdcef6c32b 100644 --- a/port/devdk.c +++ b/port/devdk.c @@ -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*) diff --git a/ss/screen.c b/ss/screen.c index d7a3996d2fd019ff6ecbda5c78721101d0cbcf9d..6c94941d6ac55035112e9c4ed198d4da8f998698 100644 --- a/ss/screen.c +++ b/ss/screen.c @@ -33,6 +33,8 @@ GBitmap gscreen = 0 }; +Lock screenlock; + void screeninit(void) { @@ -43,6 +45,17 @@ screeninit(void) out.bwid = defont0.info[' '].width; } +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) { @@ -50,6 +63,7 @@ screenputs(char *s, int n) 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); } /*