samterm: move cursor to next tabstop or non-space character before backspacing in spaces mode. this makes it less annoying to backspace (it's more like tabs).
This commit is contained in:
parent
36287edc88
commit
6a2b5055f5
|
@ -359,19 +359,29 @@ getcol(Rasp *r, long p)
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
sptotab(Rasp *r, long p)
|
||||||
|
{
|
||||||
|
int i, col, n;
|
||||||
|
|
||||||
|
col = getcol(r, p);
|
||||||
|
if((n = maxtab - col % maxtab) == maxtab)
|
||||||
|
n = 0;
|
||||||
|
for(i = 0; p < r->nrunes && raspc(r, p)==' ' && i<n; p++, i++)
|
||||||
|
;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
long
|
long
|
||||||
del(Rasp *r, long o, long p)
|
del(Rasp *r, long o, long p)
|
||||||
{
|
{
|
||||||
int i, col, n;
|
int i;
|
||||||
|
|
||||||
if(--p < o)
|
if(--p < o)
|
||||||
return o;
|
return o;
|
||||||
if(!spacesindent || raspc(r, p)!=' ')
|
if(!spacesindent || raspc(r, p)!=' ')
|
||||||
return p;
|
return p;
|
||||||
col = getcol(r, p) + 1;
|
for(i = 0; p-1>=o && raspc(r, p-1)==' ' && i<maxtab-1; --p, i++)
|
||||||
if((n = col % maxtab) == 0)
|
|
||||||
n = maxtab;
|
|
||||||
for(i = 0; p-1>=o && raspc(r, p-1)==' ' && i<n-1; --p, i++)
|
|
||||||
;
|
;
|
||||||
return p>=o? p : o;
|
return p>=o? p : o;
|
||||||
}
|
}
|
||||||
|
@ -622,6 +632,8 @@ type(Flayer *l, int res) /* what a bloody mess this is */
|
||||||
switch(c){
|
switch(c){
|
||||||
case '\b':
|
case '\b':
|
||||||
case 0x7F: /* del */
|
case 0x7F: /* del */
|
||||||
|
if(spacesindent)
|
||||||
|
a += sptotab(&t->rasp, a);
|
||||||
l->p0 = del(&t->rasp, l->origin, a);
|
l->p0 = del(&t->rasp, l->origin, a);
|
||||||
break;
|
break;
|
||||||
case 0x15: /* ctrl-u */
|
case 0x15: /* ctrl-u */
|
||||||
|
|
Loading…
Reference in a new issue