less: interpret backspace.
less is officially declared PAGER-capable! ;) (this includes viewing of manpages)
This commit is contained in:
parent
c519320000
commit
95b307103a
@ -212,11 +212,21 @@ static void read_lines(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
c = readbuf[readpos];
|
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')
|
if (c == '\t')
|
||||||
linepos += (linepos^7) & 7;
|
linepos += (linepos^7) & 7;
|
||||||
linepos++;
|
linepos++;
|
||||||
if (linepos >= w)
|
if (linepos >= w)
|
||||||
break;
|
break;
|
||||||
|
/* ok, we will eat this char */
|
||||||
readpos++;
|
readpos++;
|
||||||
if (c == '\n') { terminated = 1; break; }
|
if (c == '\n') { terminated = 1; break; }
|
||||||
/* NUL is substituted by '\n'! */
|
/* NUL is substituted by '\n'! */
|
||||||
@ -1175,6 +1185,9 @@ int less_main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int keypress;
|
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~");
|
getopt32(argc, argv, "EMmN~");
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
Loading…
Reference in New Issue
Block a user