summaryrefslogtreecommitdiffstats
path: root/contrib/less/command.c
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2012-06-26 23:17:33 +0000
committerdelphij <delphij@FreeBSD.org>2012-06-26 23:17:33 +0000
commit922d40fed4b7f6bb0aafe327600825f9680ce0e7 (patch)
tree1acc67942c59e279c426e0a72ee0ad94cb0ed3ba /contrib/less/command.c
parentbd43c5e6d640101f1bd6cca7e83586ae41e1a065 (diff)
downloadFreeBSD-src-922d40fed4b7f6bb0aafe327600825f9680ce0e7.zip
FreeBSD-src-922d40fed4b7f6bb0aafe327600825f9680ce0e7.tar.gz
MFV: less v449.
Diffstat (limited to 'contrib/less/command.c')
-rw-r--r--contrib/less/command.c85
1 files changed, 56 insertions, 29 deletions
diff --git a/contrib/less/command.c b/contrib/less/command.c
index def3d36..de8f52a 100644
--- a/contrib/less/command.c
+++ b/contrib/less/command.c
@@ -1,13 +1,12 @@
/* $FreeBSD$ */
-/*
- * Copyright (C) 1984-2011 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.
- *
- * For more information about less, or for information on how to
- * contact the author, see the README file.
- */
+/*
+ * Copyright (C) 1984-2012 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.
+ *
+ * For more information, see the README file.
+ */
/*
@@ -38,6 +37,7 @@ extern int secure;
extern int hshift;
extern int show_attn;
extern int less_is_more;
+extern POSITION highest_hilite;
extern char *every_first_cmd;
extern char *curr_altfilename;
extern char version[];
@@ -104,8 +104,8 @@ cmd_exec()
static void
start_mca(action, prompt, mlist, cmdflags)
int action;
- char *prompt;
- void constant *mlist;
+ constant char *prompt;
+ constant void *mlist;
int cmdflags;
{
mca = action;
@@ -686,7 +686,7 @@ make_display()
static void
prompt()
{
- register char constant *p;
+ register constant char *p;
if (ungot != NULL)
{
@@ -962,6 +962,44 @@ multi_search(pattern, n)
}
/*
+ * Forward forever, or until a highlighted line appears.
+ */
+ static int
+forw_loop(until_hilite)
+ int until_hilite;
+{
+ POSITION curr_len;
+
+ if (ch_getflags() & CH_HELPFILE)
+ return (A_NOACTION);
+
+ cmd_exec();
+ jump_forw();
+ curr_len = ch_length();
+ highest_hilite = until_hilite ? curr_len : NULL_POSITION;
+ ignore_eoi = 1;
+ while (!sigs)
+ {
+ if (until_hilite && highest_hilite > curr_len)
+ {
+ bell();
+ break;
+ }
+ make_display();
+ forward(1, 0, 0);
+ }
+ ignore_eoi = 0;
+
+ /*
+ * This gets us back in "F mode" after processing
+ * a non-abort signal (e.g. window-change).
+ */
+ if (sigs && !ABORT_SIGS())
+ return (A_F_FOREVER);
+ return (A_NOACTION);
+}
+
+/*
* Main command processor.
* Accept and execute commands until a quit command.
*/
@@ -979,6 +1017,7 @@ commands()
IFILE old_ifile;
IFILE new_ifile;
char *tagfile;
+ int until_hilite = 0;
search_type = SRCH_FORW;
wscroll = (sc_height + 1) / 2;
@@ -1206,23 +1245,11 @@ commands()
/*
* Forward forever, ignoring EOF.
*/
- if (ch_getflags() & CH_HELPFILE)
- break;
- cmd_exec();
- jump_forw();
- ignore_eoi = 1;
- while (!sigs)
- {
- make_display();
- forward(1, 0, 0);
- }
- ignore_eoi = 0;
- /*
- * This gets us back in "F mode" after processing
- * a non-abort signal (e.g. window-change).
- */
- if (sigs && !ABORT_SIGS())
- newaction = A_F_FOREVER;
+ newaction = forw_loop(0);
+ break;
+
+ case A_F_UNTIL_HILITE:
+ newaction = forw_loop(1);
break;
case A_F_SCROLL:
OpenPOWER on IntegriCloud