unless editing or movement attempted, including at exit. Correct dumb
mistake in window signal handling. Add routine to copy portions of the table.
SCCS-vsn: usr.bin/more/prim.c 5.7
SCCS-vsn: usr.bin/more/position.c 5.4
SCCS-vsn: usr.bin/more/screen.c 5.6
-static char sccsid[] = "@(#)position.c 5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)position.c 5.4 (Berkeley) %G%";
+copytable()
+{
+ register int a, b;
+
+ for (a = 0; a < sc_height && table[a] == NULL_POSITION; a++);
+ for (b = 0; a < sc_height; a++, b++) {
+ table[b] = table[a];
+ table[a] = NULL_POSITION;
+ }
+}
+
/*
* Initialize the position table, done whenever we clear the screen.
*/
/*
* Initialize the position table, done whenever we clear the screen.
*/
-static char sccsid[] = "@(#)prim.c 5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)prim.c 5.7 (Berkeley) %G%";
/*
* Display n lines, scrolling forward, starting at position pos in the
/*
* 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)
register int n;
off_t pos;
register int n;
off_t pos;
static int first_time = 1;
int eof = 0, do_repaint;
static int first_time = 1;
int eof = 0, do_repaint;
} else {
lower_left();
clear_eol();
} else {
lower_left();
clear_eol();
if (pos != position(BOTTOM_PLUS_ONE)) {
pos_clear();
add_forw_pos(pos);
if (pos != position(BOTTOM_PLUS_ONE)) {
pos_clear();
add_forw_pos(pos);
if (top_scroll) {
clear();
home();
if (top_scroll) {
clear();
home();
+ for (short_file = 0; --n >= 0;) {
/*
* Read the next line of input.
*/
pos = forw_line(pos);
if (pos == NULL_POSITION) {
/*
/*
* 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.
- 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.
}
/*
* Add the position of the next line to the position table.
/*
* Display n lines, scrolling backward.
*/
/*
* Display n lines, scrolling backward.
*/
-back(n, pos, force, only_last)
register int n;
off_t pos;
register int n;
off_t pos;
int only_last;
{
int do_repaint;
int only_last;
{
int do_repaint;
*/
pos = back_line(pos);
if (pos == NULL_POSITION)
*/
pos = back_line(pos);
if (pos == NULL_POSITION)
- {
- /*
- * Beginning of file: stop here unless "force" is true.
- */
- if (!force)
- break;
- line = NULL;
- }
/*
* Add the position of the previous line to the position table.
* Display the line on the screen.
/*
* Add the position of the previous line to the position table.
* Display the line on the screen.
- forw(n, pos, 0, only_last);
+ forw(n, pos, only_last);
*/
if (pos == NULL_POSITION)
return;
*/
if (pos == NULL_POSITION)
return;
- back(n, pos, 0, only_last);
+ back(n, pos, only_last);
off_t pos;
{
hit_eof = 0;
off_t pos;
{
hit_eof = 0;
- forw(sc_height-1, pos, 1, 0);
+ forw(sc_height-1, pos, 0);
clear();
pos_clear();
add_back_pos(pos);
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.
*/
* The line is currently displayed.
* Just scroll there.
*/
- forw(nline, position(BOTTOM_PLUS_ONE), 1, 0);
+ forw(nline, position(BOTTOM_PLUS_ONE), 0);
/*
* Note that back() will repaint() if nline > back_scroll.
*/
/*
* Note that back() will repaint() if nline > back_scroll.
*/
- back(nline, npos, 1, 0);
-static char sccsid[] = "@(#)screen.c 5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)screen.c 5.6 (Berkeley) %G%";
/*
* Get size of the screen.
*/
/*
* Get size of the screen.
*/
- 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;
- 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;
- 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. */
hard = (sc_height < 0 || tgetflag("hc"));
if (hard) {
/* Oh no, this is a hardcopy terminal. */
tputs(sc_addline, sc_height, putchr);
}
tputs(sc_addline, sc_height, putchr);
}
-/*
- * Move cursor to lower left corner of screen.
- */
+int short_file; /* if file less than a screen */
- tputs(sc_lower_left, 1, putchr);
+ if (short_file) {
+ putchr('\r');
+ flush();
+ }
+ else
+ tputs(sc_lower_left, 1, putchr);