From c10b313c9b53c7d08991ac2fcf2963b6663b1335 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Mon, 23 Dec 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-12-23 --- port/devcons.c | 41 ++++++++++++++++++++++++----------------- port/lib.h | 7 +++++++ power/u.h | 1 + ss/screen.c | 40 ++++++++++++++++++++++++++++++++++++++-- ss/u.h | 1 + 5 files changed, 71 insertions(+), 19 deletions(-) diff --git a/port/devcons.c b/port/devcons.c index b90832aea48ed544ec0fb840fb60d348c88b0aa8..b18595703f7be27297e69a866701a5fe9d8d9b50 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -209,15 +209,14 @@ prflush(void) } void -echo(int c) +echo(Rune r, char *buf, int n) { - char ch; static int ctrlt; /* * ^p hack */ - if(c==0x10 && conf.cntrlp) + if(r==0x10 && conf.cntrlp) panic("^p"); /* @@ -225,7 +224,7 @@ echo(int c) */ if(ctrlt == 2){ ctrlt = 0; - switch(c){ + switch(r){ case 0x14: break; /* pass it on */ case 'm': @@ -241,19 +240,17 @@ echo(int c) exit(); break; } - }else if(c == 0x14){ + }else if(r == 0x14){ ctrlt++; return; } ctrlt = 0; if(raw.ref) return; - if(c == 0x15) + if(r == 0x15) putstrn("^U\n", 3); - else{ - ch = c; - putstrn(&ch, 1); - } + else + putstrn(buf, n); } /* @@ -268,19 +265,29 @@ kbdcr2nl(IOQ *q, int ch) } /* - * Put character into read queue at interrupt time. + * Put character, possibly a rune, into read queue at interrupt time. * Always called splhi from processor 0. */ int kbdputc(IOQ *q, int ch) { + int i, n; + char buf[3]; + Rune r; + USED(q); - echo(ch); - kbdq.c = ch; - *kbdq.in++ = ch; - if(kbdq.in == kbdq.buf+sizeof(kbdq.buf)) - kbdq.in = kbdq.buf; - if(raw.ref || ch=='\n' || ch==0x04) + r = ch; + n = runetochar(buf, &r); + if(n == 0) + return 0; + echo(r, buf, n); + kbdq.c = r; + for(i=0; i 0) - screenputc(*s++); + Rune r; + int i; + char buf[4]; + + 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'){ + 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'){ + out.pos.x += (8-((out.pos.x-MINX)/out.bwid&7))*out.bwid; + if(out.pos.x >= gscreen.r.max.x) + screenputs("\n", 1); + }else if(r == '\b'){ + if(out.pos.x >= out.bwid+MINX){ + out.pos.x -= out.bwid; + screenputs(" ", 1); + out.pos.x -= out.bwid; + } + }else{ + if(out.pos.x >= gscreen.r.max.x-out.bwid) + screenputs("\n", 1); + out.pos = gstring(&gscreen, out.pos, defont, buf, S); + } + } } /* diff --git a/ss/u.h b/ss/u.h index 81dfccf482a2af1e3a96426b21223e1c14af86d6..e73f66c7aa18b0d670b3e8a7c9cda8e66a208e89 100644 --- a/ss/u.h +++ b/ss/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 {