fix bug in handling of backspace in output.

This commit is contained in:
rsc 2003-12-04 00:31:14 +00:00
parent 5af29cd3a9
commit d2a414f28d

View file

@ -3,7 +3,7 @@
Rectangle scrollr; /* scroll bar rectangle */ Rectangle scrollr; /* scroll bar rectangle */
Rectangle lastsr; /* used for scroll bar */ Rectangle lastsr; /* used for scroll bar */
int holdon; /* hold mode */ int holdon; /* hold mode */
int rawon; /* raw mode */ int rawon(void); /* raw mode */
int scrolling; /* window scrolls */ int scrolling; /* window scrolls */
int clickmsec; /* time of last click */ int clickmsec; /* time of last click */
uint clickq0; /* point of last click */ uint clickq0; /* point of last click */
@ -162,6 +162,16 @@ hoststart(void)
proccreate(hostproc, hostc, 32*1024); proccreate(hostproc, hostc, 32*1024);
} }
int crawon = -1;
int
rawon(void)
{
if(crawon != -1)
return crawon;
return 0;
}
void void
loop(void) loop(void)
{ {
@ -183,7 +193,7 @@ loop(void)
a[2].op = CHANRCV; a[2].op = CHANRCV;
if(!scrolling && t.qh > t.org+t.f->nchars) if(!scrolling && t.qh > t.org+t.f->nchars)
a[2].op = CHANNOP;; a[2].op = CHANNOP;;
crawon = -1;
switch(alt(a)) { switch(alt(a)) {
default: default:
fatal("impossible"); fatal("impossible");
@ -519,7 +529,7 @@ key(Rune r)
return; return;
} }
if(rawon && t.q0==t.nr){ if(rawon() && t.q0==t.nr){
addraw(&r, 1); addraw(&r, 1);
return; return;
} }
@ -600,7 +610,7 @@ consready(void)
if(holdon) if(holdon)
return 0; return 0;
if(rawon) if(rawon())
return t.nraw != 0; return t.nraw != 0;
/* look to see if there is a complete line */ /* look to see if there is a complete line */
@ -636,7 +646,7 @@ consread(void)
c = *p; c = *p;
p += width; p += width;
n -= width; n -= width;
if(!rawon && (c == '\n' || c == '\004')) if(!rawon() && (c == '\n' || c == '\004'))
break; break;
} }
/* take out control-d when not doing a zero length write */ /* take out control-d when not doing a zero length write */
@ -685,7 +695,6 @@ conswrite(char *p, int n)
n2--; n2--;
q++; q++;
} }
runewrite(buf2, q-buf2); runewrite(buf2, q-buf2);
} }
@ -713,7 +722,7 @@ runewrite(Rune *r, int n)
if(n == 0) if(n == 0)
return; return;
/* get ride of backspaces */ /* get rid of backspaces */
initial = 0; initial = 0;
p = q = r; p = q = r;
for(i=0; i<n; i++) { for(i=0; i<n; i++) {
@ -763,7 +772,6 @@ runewrite(Rune *r, int n)
fill(); fill();
} }
updatesel(); updatesel();
return;
} }
if(t.nr>HiWater && t.qh>=t.org){ if(t.nr>HiWater && t.qh>=t.org){
@ -885,7 +893,7 @@ paste(Rune *r, int n, int advance)
uint m; uint m;
uint q0; uint q0;
if(rawon && t.q0==t.nr){ if(rawon() && t.q0==t.nr){
addraw(r, n); addraw(r, n);
return; return;
} }