diff options
author | rsc <devnull@localhost> | 2005-11-10 22:53:38 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-11-10 22:53:38 +0000 |
commit | f535642f304ebfec5182ab97be53e1fbf23056dc (patch) | |
tree | a57a9f520ecdb40f1e010d763ffee73c30aefc47 /src/cmd/9term | |
parent | 69555c0e28ad207b5f7e9ca63232cab474580c65 (diff) | |
download | plan9port-f535642f304ebfec5182ab97be53e1fbf23056dc.tar.gz plan9port-f535642f304ebfec5182ab97be53e1fbf23056dc.tar.bz2 plan9port-f535642f304ebfec5182ab97be53e1fbf23056dc.zip |
attempt at \r
Diffstat (limited to 'src/cmd/9term')
-rw-r--r-- | src/cmd/9term/wind.c | 69 |
1 files changed, 40 insertions, 29 deletions
diff --git a/src/cmd/9term/wind.c b/src/cmd/9term/wind.c index 69dec8a7..c59f08ec 100644 --- a/src/cmd/9term/wind.c +++ b/src/cmd/9term/wind.c @@ -190,7 +190,7 @@ wclose(Window *w) void winctl(void *arg) { - Rune *rp, *bp, *tp, *up, *kbdr; + Rune *rp, *bp, *up, *kbdr; uint qh; int nr, nb, c, wid, i, npart, initial, lastb; char *s, *t, part[3]; @@ -328,37 +328,48 @@ winctl(void *arg) recv(cwm.cw, &pair); rp = pair.s; nr = pair.ns; - bp = rp; - for(i=0; i<nr; i++) - if(*bp++ == '\b'){ - --bp; - initial = 0; - tp = runemalloc(nr); - runemove(tp, rp, i); - up = tp+i; - for(; i<nr; i++){ - *up = *bp++; - if(*up == '\b') - if(up == tp) - initial++; - else - --up; - else - up++; - } - if(initial){ - if(initial > w->qh) - initial = w->qh; - qh = w->qh-initial; - wdelete(w, qh, qh+initial); - w->qh = qh; + up = bp = rp; + initial = 0; + for(i=0; i<nr; i++){ + switch(*bp){ + case 0: + break; + case '\b': + if(up == rp) + initial++; + else + --up; + break; +/* + case '\r': + while(i<nr-1 && *(bp+1) == '\r'){ + bp++; + i++; } - free(rp); - rp = tp; - nr = up-tp; - rp[nr] = 0; + if(i<nr-1 && *(bp+1) != '\n'){ + while(up > rp && *(up-1) != '\n') + up--; + if(up == rp) + initial = wbswidth(w, 0x15); + }else if(i == nr-1) + *up = '\n'; + break; +*/ + default: + *up++ = *bp; break; } + bp++; + } + if(initial){ + if(initial > w->qh) + initial = w->qh; + qh = w->qh - initial; + wdelete(w, qh, qh+initial); + w->qh = qh; + } + nr = rp - up; + rp[nr] = 0; w->qh = winsert(w, rp, nr, w->qh)+nr; if(w->scrolling || w->mouseopen) wshow(w, w->qh); |