diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-04-13 18:26:27 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-04-13 18:26:27 +0000 |
commit | 5569f8a6b6c831077f77d24e2c23d2e2d41fb95f (patch) | |
tree | b79fe763d81906631382fbdc80f3b42a44b6c668 /usr.bin/less/jump.c | |
parent | 6b9d6b99a4fdda2ee6d9a30dec452d8202fb2017 (diff) |
Merge in less-381 w/ local changes and remove obsolete files.
Diffstat (limited to 'usr.bin/less/jump.c')
-rw-r--r-- | usr.bin/less/jump.c | 58 |
1 files changed, 24 insertions, 34 deletions
diff --git a/usr.bin/less/jump.c b/usr.bin/less/jump.c index c93fb0af34c..b919b2549f7 100644 --- a/usr.bin/less/jump.c +++ b/usr.bin/less/jump.c @@ -1,29 +1,11 @@ -/* $OpenBSD: jump.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */ - /* - * 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. */ @@ -39,6 +21,7 @@ extern int jump_sline; extern int squished; extern int screen_trashed; extern int sc_width, sc_height; +extern int show_attn; /* * Jump to the end of the file. @@ -69,8 +52,8 @@ jump_forw() * Jump to line n in the file. */ public void -jump_back(n) - int n; +jump_back(linenum) + LINENUM linenum; { POSITION pos; PARG parg; @@ -81,18 +64,20 @@ jump_back(n) * 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); } } @@ -135,10 +120,7 @@ jump_percent(percent) 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; @@ -168,6 +150,8 @@ jump_line_loc(pos, sline) (void) ch_forw_get(); pos = ch_tell(); } + if (show_attn) + set_attnpos(pos); jump_loc(pos, sline); } @@ -181,7 +165,7 @@ jump_loc(pos, sline) POSITION pos; int sline; { - int nline; + register int nline; POSITION tpos; POSITION bpos; @@ -201,6 +185,8 @@ jump_loc(pos, sline) forw(nline, position(BOTTOM_PLUS_ONE), 1, 0, 0); else back(-nline, position(TOP), 1, 0); + if (show_attn) + repaint_hilite(1); return; } @@ -238,6 +224,8 @@ jump_loc(pos, sline) * 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); @@ -285,6 +273,8 @@ jump_loc(pos, sline) * that we can just scroll there after all. */ back(nline+1, tpos, 1, 0); + if (show_attn) + repaint_hilite(1); return; } } |