aboutsummaryrefslogtreecommitdiff
path: root/forwback.c
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2009-05-08 23:45:27 +0000
committerXin LI <delphij@FreeBSD.org>2009-05-08 23:45:27 +0000
commite1193b7bca0eca8d5c2740fdfa576746303bb993 (patch)
treea3b19b698e154070851f613743d2c3b6467b5828 /forwback.c
parentad5f463cf975eb6a9c4cb335fc2ce7a84c7d49a7 (diff)
downloadsrc-e1193b7bca0eca8d5c2740fdfa576746303bb993.tar.gz
src-e1193b7bca0eca8d5c2740fdfa576746303bb993.zip
Vendor import of less v429vendor/less/v429
Notes
Notes: svn path=/vendor/less/dist/; revision=191927 svn path=/vendor/less/v429/; revision=191928; tag=vendor/less/v429
Diffstat (limited to 'forwback.c')
-rw-r--r--forwback.c52
1 files changed, 32 insertions, 20 deletions
diff --git a/forwback.c b/forwback.c
index 7b5bb2d26039..c5bd2568fd06 100644
--- a/forwback.c
+++ b/forwback.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2007 Mark Nudelman
+ * Copyright (C) 1984-2008 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@@ -17,7 +17,6 @@
#include "less.h"
#include "position.h"
-public int hit_eof; /* Keeps track of how many times we hit end of file */
public int screen_trashed;
public int squished;
public int no_back_scroll = 0;
@@ -51,25 +50,47 @@ eof_bell()
}
/*
- * Check to see if the end of file is currently "displayed".
+ * Check to see if the end of file is currently displayed.
*/
- static void
-eof_check()
+ public int
+eof_displayed()
{
POSITION pos;
if (ignore_eoi)
- return;
- if (ABORT_SIGS())
- return;
+ return (0);
+
+ if (ch_length() == NULL_POSITION)
+ /*
+ * If the file length is not known,
+ * we can't possibly be displaying EOF.
+ */
+ return (0);
+
/*
* If the bottom line is empty, we are at EOF.
* If the bottom line ends at the file length,
* we must be just at EOF.
*/
pos = position(BOTTOM_PLUS_ONE);
- if (pos == NULL_POSITION || pos == ch_length())
- hit_eof++;
+ return (pos == NULL_POSITION || pos == ch_length());
+}
+
+/*
+ * Check to see if the entire file is currently displayed.
+ */
+ public int
+entire_file_displayed()
+{
+ POSITION pos;
+
+ /* Make sure last line of file is displayed. */
+ if (!eof_displayed())
+ return (0);
+
+ /* Make sure first line of file is displayed. */
+ pos = position(0);
+ return (pos == NULL_POSITION || pos == 0);
}
/*
@@ -251,12 +272,6 @@ forw(n, pos, force, only_last, nblank)
forw_prompt = 1;
}
- if (ignore_eoi)
- hit_eof = 0;
- else if (eof && !ABORT_SIGS())
- hit_eof++;
- else
- eof_check();
if (nlines == 0)
eof_bell();
else if (do_repaint)
@@ -280,7 +295,6 @@ back(n, pos, force, only_last)
squish_check();
do_repaint = (n > get_back_scroll() || (only_last && n > sc_height-1));
- hit_eof = 0;
while (--n >= 0)
{
/*
@@ -309,7 +323,6 @@ back(n, pos, force, only_last)
}
}
- eof_check();
if (nlines == 0)
eof_bell();
else if (do_repaint)
@@ -331,7 +344,7 @@ forward(n, force, only_last)
{
POSITION pos;
- if (get_quit_at_eof() && hit_eof && !(ch_getflags() & CH_HELPFILE))
+ if (get_quit_at_eof() && eof_displayed() && !(ch_getflags() & CH_HELPFILE))
{
/*
* If the -e flag is set and we're trying to go
@@ -365,7 +378,6 @@ forward(n, force, only_last)
} else
{
eof_bell();
- hit_eof++;
return;
}
}