From 6a2b5055f5c2827d66c18f2c6e5aed284956f980 Mon Sep 17 00:00:00 2001 From: ppatience0 Date: Wed, 8 May 2013 17:47:48 -0400 Subject: [PATCH] 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). --- sys/src/cmd/samterm/main.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/sys/src/cmd/samterm/main.c b/sys/src/cmd/samterm/main.c index 6ee72c94a..c20091acb 100644 --- a/sys/src/cmd/samterm/main.c +++ b/sys/src/cmd/samterm/main.c @@ -359,19 +359,29 @@ getcol(Rasp *r, long p) 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=o && raspc(r, p-1)==' ' && i=o && raspc(r, p-1)==' ' && i=o? p : o; } @@ -622,6 +632,8 @@ type(Flayer *l, int res) /* what a bloody mess this is */ switch(c){ case '\b': case 0x7F: /* del */ + if(spacesindent) + a += sptotab(&t->rasp, a); l->p0 = del(&t->rasp, l->origin, a); break; case 0x15: /* ctrl-u */