=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/forwback.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.2 diff -u -r1.1.1.1 -r1.1.1.2 --- src/usr.bin/less/forwback.c 1996/09/21 05:39:42 1.1.1.1 +++ src/usr.bin/less/forwback.c 2003/04/13 18:21:21 1.1.1.2 @@ -1,27 +1,11 @@ /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice in the documentation and/or other materials provided with - * the distribution. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -36,6 +20,7 @@ public int hit_eof; /* Keeps track of how many times we hit end of file */ public int screen_trashed; public int squished; +public int no_back_scroll = 0; extern int sigs; extern int top_scroll; @@ -45,8 +30,9 @@ extern int plusoption; extern int forw_scroll; extern int back_scroll; -extern int need_clr; extern int ignore_eoi; +extern int clear_bg; +extern int final_attr; #if TAGS extern char *tagoption; #endif @@ -138,6 +124,13 @@ if (!do_repaint) { + /* + * Forget any current line shift we might have + * (from the last line of the previous screenful). + */ + extern int cshift; + cshift = 0; + if (top_scroll && n >= sc_height - 1 && pos != ch_length()) { /* @@ -146,10 +139,12 @@ * to hit eof in the middle of this screen, * but we don't yet know if that will happen. }} */ + pos_clear(); + add_forw_pos(pos); + force = 1; if (top_scroll == OPT_ONPLUS || first_time) clear(); home(); - force = 1; } else { clear_bot(); @@ -203,10 +198,16 @@ /* * End of file: stop here unless the top line * is still empty, or "force" is true. + * Even if force is true, stop when the last + * line in the file reaches the top of screen. */ eof = 1; if (!force && position(TOP) != NULL_POSITION) break; + if (!empty_lines(0, 0) && + !empty_lines(1, 1) && + empty_lines(2, sc_height-1)) + break; } } /* @@ -236,9 +237,20 @@ squished = 1; continue; } - if (top_scroll == 1) + if (top_scroll == OPT_ON) clear_eol(); put_line(); + if (clear_bg && final_attr != AT_NORMAL) + { + /* + * Writing the last character on the last line + * of the display may have scrolled the screen. + * If we were in standout mode, clear_bg terminals + * will fill the new line with the standout color. + * Now we're in normal mode again, so clear the line. + */ + clear_eol(); + } } if (ignore_eoi) @@ -319,7 +331,7 @@ { POSITION pos; - if (quit_at_eof && hit_eof) + if (quit_at_eof && hit_eof && !(ch_getflags() & CH_HELPFILE)) { /* * If the -e flag is set and we're trying to go @@ -390,6 +402,8 @@ public int get_back_scroll() { + if (no_back_scroll) + return (0); if (back_scroll >= 0) return (back_scroll); if (top_scroll)