better cr handling
This commit is contained in:
parent
ac39f01949
commit
dcc0b3ca1d
1 changed files with 9 additions and 2 deletions
|
|
@ -1136,6 +1136,7 @@ conswrite(char *p, int n)
|
||||||
void
|
void
|
||||||
runewrite(Rune *r, int n)
|
runewrite(Rune *r, int n)
|
||||||
{
|
{
|
||||||
|
static int havecr;
|
||||||
int i;
|
int i;
|
||||||
uint initial;
|
uint initial;
|
||||||
uint q0, q1;
|
uint q0, q1;
|
||||||
|
|
@ -1146,8 +1147,13 @@ runewrite(Rune *r, int n)
|
||||||
if(n == 0)
|
if(n == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* get rid of backspaces */
|
/* process trailing \r from previous write */
|
||||||
initial = 0;
|
initial = 0;
|
||||||
|
if(havecr && *r != '\r' && *r != '\n')
|
||||||
|
initial = bswidth(0x15, t.qh, 0);
|
||||||
|
havecr = 0;
|
||||||
|
|
||||||
|
/* get rid of backspaces */
|
||||||
p = q = r;
|
p = q = r;
|
||||||
for(i=0; i<n; i++) {
|
for(i=0; i<n; i++) {
|
||||||
if(*p == '\b') {
|
if(*p == '\b') {
|
||||||
|
|
@ -1167,7 +1173,8 @@ runewrite(Rune *r, int n)
|
||||||
q--;
|
q--;
|
||||||
if(q==r)
|
if(q==r)
|
||||||
initial = bswidth(0x15, t.qh, 0);
|
initial = bswidth(0x15, t.qh, 0);
|
||||||
}
|
}else if(i == n-1)
|
||||||
|
havecr = 1;
|
||||||
} else if(*p)
|
} else if(*p)
|
||||||
*q++ = *p;
|
*q++ = *p;
|
||||||
p++;
|
p++;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue