=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/jump.c,v retrieving revision 1.1.1.2 retrieving revision 1.1.1.3 diff -u -r1.1.1.2 -r1.1.1.3 --- src/usr.bin/less/jump.c 2003/04/13 18:21:21 1.1.1.2 +++ src/usr.bin/less/jump.c 2011/09/16 17:47:05 1.1.1.3 @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2002 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -16,12 +16,12 @@ #include "less.h" #include "position.h" -extern int hit_eof; extern int jump_sline; extern int squished; extern int screen_trashed; extern int sc_width, sc_height; extern int show_attn; +extern int top_scroll; /* * Jump to the end of the file. @@ -30,22 +30,35 @@ jump_forw() { POSITION pos; + POSITION end_pos; if (ch_end_seek()) { error("Cannot seek to end of file", NULL_PARG); return; } + /* + * Note; lastmark will be called later by jump_loc, but it fails + * because the position table has been cleared by pos_clear below. + * So call it here before calling pos_clear. + */ + lastmark(); /* * Position the last line in the file at the last screen line. * Go back one line from the end of the file * to get to the beginning of the last line. */ - pos = back_line(ch_tell()); + pos_clear(); + end_pos = ch_tell(); + pos = back_line(end_pos); if (pos == NULL_POSITION) jump_loc((POSITION)0, sc_height-1); else + { jump_loc(pos, sc_height-1); + if (position(sc_height-1) != end_pos) + repaint(); + } } /* @@ -101,8 +114,9 @@ * Jump to a specified percentage into the file. */ public void -jump_percent(percent) +jump_percent(percent, fraction) int percent; + long fraction; { POSITION pos, len; @@ -120,7 +134,7 @@ error("Don't know length of file", NULL_PARG); return; } - pos = percent_pos(len, percent); + pos = percent_pos(len, percent, fraction); if (pos >= len) pos = len-1; @@ -185,8 +199,10 @@ forw(nline, position(BOTTOM_PLUS_ONE), 1, 0, 0); else back(-nline, position(TOP), 1, 0); +#if HILITE_SEARCH if (show_attn) repaint_hilite(1); +#endif return; } @@ -224,8 +240,10 @@ * that we can just scroll there after all. */ forw(sc_height-sline+nline-1, bpos, 1, 0, 0); +#if HILITE_SEARCH if (show_attn) repaint_hilite(1); +#endif return; } pos = back_line(pos); @@ -241,7 +259,6 @@ } } lastmark(); - hit_eof = 0; squished = 0; screen_trashed = 0; forw(sc_height-1, pos, 1, 0, sline-nline); @@ -273,13 +290,18 @@ * that we can just scroll there after all. */ back(nline+1, tpos, 1, 0); +#if HILITE_SEARCH if (show_attn) repaint_hilite(1); +#endif return; } } lastmark(); - clear(); + if (!top_scroll) + clear(); + else + home(); screen_trashed = 0; add_back_pos(pos); back(sc_height-1, pos, 1, 0);