version 1.4, 2003/04/13 18:26:25 |
version 1.5, 2011/09/16 18:12:09 |
|
|
/* |
/* |
* Copyright (C) 1984-2002 Mark Nudelman |
* Copyright (C) 1984-2011 Mark Nudelman |
* |
* |
* You may distribute under the terms of either the GNU General Public |
* You may distribute under the terms of either the GNU General Public |
* License or the Less License, as specified in the README file. |
* License or the Less License, as specified in the README file. |
|
|
#include "less.h" |
#include "less.h" |
#include "position.h" |
#include "position.h" |
|
|
extern int hit_eof; |
|
extern int jump_sline; |
extern int jump_sline; |
extern int squished; |
extern int squished; |
extern int screen_trashed; |
extern int screen_trashed; |
extern int sc_width, sc_height; |
extern int sc_width, sc_height; |
extern int show_attn; |
extern int show_attn; |
|
extern int top_scroll; |
|
|
/* |
/* |
* Jump to the end of the file. |
* Jump to the end of the file. |
|
|
jump_forw() |
jump_forw() |
{ |
{ |
POSITION pos; |
POSITION pos; |
|
POSITION end_pos; |
|
|
if (ch_end_seek()) |
if (ch_end_seek()) |
{ |
{ |
error("Cannot seek to end of file", NULL_PARG); |
error("Cannot seek to end of file", NULL_PARG); |
return; |
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. |
* Position the last line in the file at the last screen line. |
* Go back one line from the end of the file |
* Go back one line from the end of the file |
* to get to the beginning of the last line. |
* 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) |
if (pos == NULL_POSITION) |
jump_loc((POSITION)0, sc_height-1); |
jump_loc((POSITION)0, sc_height-1); |
else |
else |
|
{ |
jump_loc(pos, sc_height-1); |
jump_loc(pos, sc_height-1); |
|
if (position(sc_height-1) != end_pos) |
|
repaint(); |
|
} |
} |
} |
|
|
/* |
/* |
|
|
* Jump to a specified percentage into the file. |
* Jump to a specified percentage into the file. |
*/ |
*/ |
public void |
public void |
jump_percent(percent) |
jump_percent(percent, fraction) |
int percent; |
int percent; |
|
long fraction; |
{ |
{ |
POSITION pos, len; |
POSITION pos, len; |
|
|
|
|
error("Don't know length of file", NULL_PARG); |
error("Don't know length of file", NULL_PARG); |
return; |
return; |
} |
} |
pos = percent_pos(len, percent); |
pos = percent_pos(len, percent, fraction); |
if (pos >= len) |
if (pos >= len) |
pos = len-1; |
pos = len-1; |
|
|
|
|
forw(nline, position(BOTTOM_PLUS_ONE), 1, 0, 0); |
forw(nline, position(BOTTOM_PLUS_ONE), 1, 0, 0); |
else |
else |
back(-nline, position(TOP), 1, 0); |
back(-nline, position(TOP), 1, 0); |
|
#if HILITE_SEARCH |
if (show_attn) |
if (show_attn) |
repaint_hilite(1); |
repaint_hilite(1); |
|
#endif |
return; |
return; |
} |
} |
|
|
|
|
* that we can just scroll there after all. |
* that we can just scroll there after all. |
*/ |
*/ |
forw(sc_height-sline+nline-1, bpos, 1, 0, 0); |
forw(sc_height-sline+nline-1, bpos, 1, 0, 0); |
|
#if HILITE_SEARCH |
if (show_attn) |
if (show_attn) |
repaint_hilite(1); |
repaint_hilite(1); |
|
#endif |
return; |
return; |
} |
} |
pos = back_line(pos); |
pos = back_line(pos); |
|
|
} |
} |
} |
} |
lastmark(); |
lastmark(); |
hit_eof = 0; |
|
squished = 0; |
squished = 0; |
screen_trashed = 0; |
screen_trashed = 0; |
forw(sc_height-1, pos, 1, 0, sline-nline); |
forw(sc_height-1, pos, 1, 0, sline-nline); |
|
|
* that we can just scroll there after all. |
* that we can just scroll there after all. |
*/ |
*/ |
back(nline+1, tpos, 1, 0); |
back(nline+1, tpos, 1, 0); |
|
#if HILITE_SEARCH |
if (show_attn) |
if (show_attn) |
repaint_hilite(1); |
repaint_hilite(1); |
|
#endif |
return; |
return; |
} |
} |
} |
} |
lastmark(); |
lastmark(); |
clear(); |
if (!top_scroll) |
|
clear(); |
|
else |
|
home(); |
screen_trashed = 0; |
screen_trashed = 0; |
add_back_pos(pos); |
add_back_pos(pos); |
back(sc_height-1, pos, 1, 0); |
back(sc_height-1, pos, 1, 0); |