=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/jump.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/jump.c 1996/09/21 05:39:42 1.1.1.1 +++ src/usr.bin/less/jump.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. */ @@ -37,6 +21,7 @@ extern int squished; extern int screen_trashed; extern int sc_width, sc_height; +extern int show_attn; /* * Jump to the end of the file. @@ -67,8 +52,8 @@ * Jump to line n in the file. */ public void -jump_back(n) - int n; +jump_back(linenum) + LINENUM linenum; { POSITION pos; PARG parg; @@ -79,18 +64,20 @@ * If we can't seek, but we're trying to go to line number 1, * use ch_beg_seek() to get as close as we can. */ - pos = find_pos(n); + pos = find_pos(linenum); if (pos != NULL_POSITION && ch_seek(pos) == 0) { + if (show_attn) + set_attnpos(pos); jump_loc(pos, jump_sline); - } else if (n <= 1 && ch_beg_seek() == 0) + } else if (linenum <= 1 && ch_beg_seek() == 0) { jump_loc(ch_tell(), jump_sline); error("Cannot seek to beginning of file", NULL_PARG); } else { - parg.p_int = n; - error("Cannot seek to line number %d", &parg); + parg.p_linenum = linenum; + error("Cannot seek to line number %n", &parg); } } @@ -133,10 +120,7 @@ error("Don't know length of file", NULL_PARG); return; } - /* - * {{ This calculation may overflow! }} - */ - pos = (percent * len) / 100; + pos = percent_pos(len, percent); if (pos >= len) pos = len-1; @@ -166,6 +150,8 @@ (void) ch_forw_get(); pos = ch_tell(); } + if (show_attn) + set_attnpos(pos); jump_loc(pos, sline); } @@ -199,6 +185,8 @@ forw(nline, position(BOTTOM_PLUS_ONE), 1, 0, 0); else back(-nline, position(TOP), 1, 0); + if (show_attn) + repaint_hilite(1); return; } @@ -236,6 +224,8 @@ * that we can just scroll there after all. */ forw(sc_height-sline+nline-1, bpos, 1, 0, 0); + if (show_attn) + repaint_hilite(1); return; } pos = back_line(pos); @@ -283,6 +273,8 @@ * that we can just scroll there after all. */ back(nline+1, tpos, 1, 0); + if (show_attn) + repaint_hilite(1); return; } }