aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-12-31 19:23:31 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-12-31 19:23:31 +0000
commit95b307103a60b7d023929c29952e1e6798564bef (patch)
tree78d677112a4626a51b1e1cb2c8ae2f5654509270 /miscutils
parentc519320000972421e6dbc197e504dd1f0c546c1d (diff)
downloadbusybox-95b307103a60b7d023929c29952e1e6798564bef.tar.gz
less: interpret backspace.
less is officially declared PAGER-capable! ;) (this includes viewing of manpages)
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/less.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/miscutils/less.c b/miscutils/less.c
index 916213082..ae936c2fb 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -212,11 +212,21 @@ static void read_lines(void)
}
}
c = readbuf[readpos];
+ /* backspace? [need this for manpage display] */
+ if (c == '\x8' && linepos) {
+ readpos++; /* eat it */
+ /* We do not consider the case of <tab><bs> */
+ /* Anyone who has that is pure evil :) */
+ linepos--;
+ *p-- = '\0';
+ continue;
+ }
if (c == '\t')
linepos += (linepos^7) & 7;
linepos++;
if (linepos >= w)
break;
+ /* ok, we will eat this char */
readpos++;
if (c == '\n') { terminated = 1; break; }
/* NUL is substituted by '\n'! */
@@ -1175,6 +1185,9 @@ int less_main(int argc, char **argv)
{
int keypress;
+ /* TODO: -x: do not interpret backspace, -xx: tab also */
+ /* -xxx: newline also */
+ /* -w N: assume width N (-xxx -w 32: hex viewer of sorts) */
getopt32(argc, argv, "EMmN~");
argc -= optind;
argv += optind;