From 464501a8bf6415e8337a98f2931a57b67df8cfea Mon Sep 17 00:00:00 2001 From: Xin LI Date: Fri, 16 Nov 2007 22:22:17 +0000 Subject: Virgin import of less v415. --- contrib/less/command.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) (limited to 'contrib/less/command.c') diff --git a/contrib/less/command.c b/contrib/less/command.c index ff48909f8ca8..ef6dfa464e8c 100644 --- a/contrib/less/command.c +++ b/contrib/less/command.c @@ -551,6 +551,21 @@ mca_char(c) return (MCA_MORE); } +/* + * Discard any buffered file data. + */ + static void +clear_buffers() +{ + if (!(ch_getflags() & CH_CANSEEK)) + return; + ch_flush(); + clr_linenum(); +#if HILITE_SEARCH + clr_hilite(); +#endif +} + /* * Make sure the screen is displayed. */ @@ -574,11 +589,20 @@ make_display() jump_loc(initial_scrpos.pos, initial_scrpos.ln); } else if (screen_trashed) { - int save_top_scroll; - save_top_scroll = top_scroll; + int save_top_scroll = top_scroll; + int save_ignore_eoi = ignore_eoi; top_scroll = 1; + ignore_eoi = 0; + if (screen_trashed == 2) + { + /* Special case used by ignore_eoi: re-open the input file + * and jump to the end of the file. */ + reopen_curr_ifile(); + jump_forw(); + } repaint(); top_scroll = save_top_scroll; + ignore_eoi = save_ignore_eoi; } } @@ -1109,7 +1133,10 @@ commands() ignore_eoi = 1; hit_eof = 0; while (!sigs) + { + make_display(); forward(1, 0, 0); + } ignore_eoi = 0; /* * This gets us back in "F mode" after processing @@ -1148,14 +1175,7 @@ commands() * Flush buffers, then repaint screen. * Don't flush the buffers on a pipe! */ - if (ch_getflags() & CH_CANSEEK) - { - ch_flush(); - clr_linenum(); -#if HILITE_SEARCH - clr_hilite(); -#endif - } + clear_buffers(); /* FALLTHRU */ case A_REPAINT: /* @@ -1257,7 +1277,8 @@ commands() /* * Define abbreviation for a commonly used sequence below. */ -#define DO_SEARCH() if (number <= 0) number = 1; \ +#define DO_SEARCH() \ + if (number <= 0) number = 1; \ mca_search(); \ cmd_exec(); \ multi_search((char *)NULL, (int) number); -- cgit v1.2.3