*/
#ifndef lint
-static char sccsid[] = "@(#)prim.c 5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)prim.c 5.7 (Berkeley) %G%";
#endif /* not lint */
/*
/*
* Display n lines, scrolling forward, starting at position pos in the
- * input file. "force" means display the n lines even if we hit end of
- * file. "only_last" means display only the last screenful if n > screen
- * size.
+ * input file. "only_last" means display only the last screenful if
+ * n > screen size.
*/
-forw(n, pos, force, only_last)
+forw(n, pos, only_last)
register int n;
off_t pos;
- int force;
int only_last;
{
+ extern int short_file;
static int first_time = 1;
int eof = 0, do_repaint;
*/
clear();
home();
- force = 1;
} else {
lower_left();
clear_eol();
if (pos != position(BOTTOM_PLUS_ONE)) {
pos_clear();
add_forw_pos(pos);
- force = 1;
if (top_scroll) {
clear();
home();
}
}
- while (--n >= 0) {
+ for (short_file = 0; --n >= 0;) {
/*
* Read the next line of input.
*/
pos = forw_line(pos);
if (pos == NULL_POSITION) {
/*
- * End of file: stop here unless the top line
- * is still empty, or "force" is true.
+ * end of file; copy the table if the file was
+ * too small for an entire screen.
*/
eof = 1;
- if (!force && position(TOP) != NULL_POSITION)
- break;
- line = NULL;
+ if (position(TOP) == NULL_POSITION) {
+ copytable();
+ if (!position(TOP))
+ short_file = 1;
+ }
+ break;
}
/*
* Add the position of the next line to the position table.
/*
* Display n lines, scrolling backward.
*/
-back(n, pos, force, only_last)
+back(n, pos, only_last)
register int n;
off_t pos;
- int force;
int only_last;
{
int do_repaint;
*/
pos = back_line(pos);
if (pos == NULL_POSITION)
- {
- /*
- * Beginning of file: stop here unless "force" is true.
- */
- if (!force)
- break;
- line = NULL;
- }
+ break;
/*
* Add the position of the previous line to the position table.
* Display the line on the screen.
hit_eof++;
return;
}
- forw(n, pos, 0, only_last);
+ forw(n, pos, only_last);
}
/*
*/
if (pos == NULL_POSITION)
return;
- back(n, pos, 0, only_last);
+ back(n, pos, only_last);
}
/*
off_t pos;
{
hit_eof = 0;
- forw(sc_height-1, pos, 1, 0);
+ forw(sc_height-1, pos, 0);
screen_trashed = 0;
}
clear();
pos_clear();
add_back_pos(pos);
- back(sc_height - 1, pos, 0, 0);
+ back(sc_height - 1, pos, 0);
}
/*
* The line is currently displayed.
* Just scroll there.
*/
- forw(nline, position(BOTTOM_PLUS_ONE), 1, 0);
+ forw(nline, position(BOTTOM_PLUS_ONE), 0);
return;
}
/*
* Note that back() will repaint() if nline > back_scroll.
*/
- back(nline, npos, 1, 0);
+ back(nline, npos, 0);
return;
}
/*
*/
#ifndef lint
-static char sccsid[] = "@(#)screen.c 5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)screen.c 5.6 (Berkeley) %G%";
#endif /* not lint */
/*
/*
* Get size of the screen.
*/
- if (sc_height == -1)
#ifdef TIOCGWINSZ
- if (ioctl(2, TIOCGWINSZ, &w) == 0 && w.ws_row > 0)
- sc_height = w.ws_row;
+ if (ioctl(2, TIOCGWINSZ, &w) == 0 && w.ws_row > 0)
+ sc_height = w.ws_row;
#else
#ifdef WIOCGETD
- if (ioctl(2, WIOCGETD, &w) == 0 && w.uw_height > 0)
- sc_height = w.uw_height/w.uw_vs;
+ if (ioctl(2, WIOCGETD, &w) == 0 && w.uw_height > 0)
+ sc_height = w.uw_height/w.uw_vs;
#endif
#endif
- else
- sc_height = tgetnum("li");
+ else
+ sc_height = tgetnum("li");
hard = (sc_height < 0 || tgetflag("hc"));
if (hard) {
/* Oh no, this is a hardcopy terminal. */
tputs(sc_addline, sc_height, putchr);
}
-/*
- * Move cursor to lower left corner of screen.
- */
+int short_file; /* if file less than a screen */
lower_left()
{
- tputs(sc_lower_left, 1, putchr);
+ if (short_file) {
+ putchr('\r');
+ flush();
+ }
+ else
+ tputs(sc_lower_left, 1, putchr);
}
/*