summaryrefslogtreecommitdiffstats
path: root/contrib/less/command.c
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2009-05-09 01:35:27 +0000
committerdelphij <delphij@FreeBSD.org>2009-05-09 01:35:27 +0000
commit810e5a84b4607c4d0fc76e9a418ae9fd2b0eeeb2 (patch)
tree5e0628caeff31611fab89dbdf72053148a59a873 /contrib/less/command.c
parent8583a840068803e7fd9e0fc2452605bca6e822d8 (diff)
downloadFreeBSD-src-810e5a84b4607c4d0fc76e9a418ae9fd2b0eeeb2.zip
FreeBSD-src-810e5a84b4607c4d0fc76e9a418ae9fd2b0eeeb2.tar.gz
Update to less v429.
Diffstat (limited to 'contrib/less/command.c')
-rw-r--r--contrib/less/command.c67
1 files changed, 48 insertions, 19 deletions
diff --git a/contrib/less/command.c b/contrib/less/command.c
index e42d9ce..582926f 100644
--- a/contrib/less/command.c
+++ b/contrib/less/command.c
@@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*
- * 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.
@@ -26,7 +26,6 @@ extern int erase_char, erase2_char, kill_char;
extern int sigs;
extern int quit_if_one_screen;
extern int squished;
-extern int hit_eof;
extern int sc_width;
extern int sc_height;
extern int swindow;
@@ -86,7 +85,9 @@ static void multi_search();
static void
cmd_exec()
{
+#if HILITE_SEARCH
clear_attn();
+#endif
clear_bot();
flush();
}
@@ -120,6 +121,11 @@ in_mca()
static void
mca_search()
{
+#if HILITE_SEARCH
+ if (search_type & SRCH_FILTER)
+ mca = A_FILTER;
+ else
+#endif
if (search_type & SRCH_FORW)
mca = A_F_SEARCH;
else
@@ -139,6 +145,11 @@ mca_search()
if (search_type & SRCH_NO_REGEX)
cmd_putstr("Regex-off ");
+#if HILITE_SEARCH
+ if (search_type & SRCH_FILTER)
+ cmd_putstr("&/");
+ else
+#endif
if (search_type & SRCH_FORW)
cmd_putstr("/");
else
@@ -197,6 +208,12 @@ exec_mca()
case A_B_SEARCH:
multi_search(cbuf, (int) number);
break;
+#if HILITE_SEARCH
+ case A_FILTER:
+ search_type ^= SRCH_NO_MATCH;
+ set_filter_pattern(cbuf, search_type);
+ break;
+#endif
case A_FIRSTCMD:
/*
* Skip leading spaces or + signs in the string.
@@ -469,6 +486,7 @@ mca_char(c)
case A_F_SEARCH:
case A_B_SEARCH:
+ case A_FILTER:
/*
* Special case for search commands.
* Certain characters as the first char of
@@ -490,16 +508,19 @@ mca_char(c)
if (less_is_more)
break;
case CONTROL('E'): /* ignore END of file */
- flag = SRCH_PAST_EOF;
+ if (mca != A_FILTER)
+ flag = SRCH_PAST_EOF;
break;
case '@':
if (less_is_more)
break;
case CONTROL('F'): /* FIRST file */
- flag = SRCH_FIRST_FILE;
+ if (mca != A_FILTER)
+ flag = SRCH_FIRST_FILE;
break;
case CONTROL('K'): /* KEEP position */
- flag = SRCH_NO_MOVE;
+ if (mca != A_FILTER)
+ flag = SRCH_NO_MOVE;
break;
case CONTROL('R'): /* Don't use REGULAR EXPRESSIONS */
flag = SRCH_NO_REGEX;
@@ -636,25 +657,20 @@ prompt()
bottompos = position(BOTTOM_PLUS_ONE);
/*
- * If we've hit EOF on the last file, and the -E flag is set
- * (or -F is set and this is the first prompt), then quit.
- * {{ Relying on "first prompt" to detect a single-screen file
- * fails if +G is used, for example. }}
+ * If we've hit EOF on the last file and the -E flag is set, quit.
*/
- if ((get_quit_at_eof() == OPT_ONPLUS || quit_if_one_screen) &&
- hit_eof && !(ch_getflags() & CH_HELPFILE) &&
+ if (get_quit_at_eof() == OPT_ONPLUS &&
+ eof_displayed() && !(ch_getflags() & CH_HELPFILE) &&
next_ifile(curr_ifile) == NULL_IFILE)
quit(QUIT_OK);
- quit_if_one_screen = FALSE;
-#if 0 /* This doesn't work well because some "te"s clear the screen. */
+
/*
- * If the -e flag is set and we've hit EOF on the last file,
- * and the file is squished (shorter than the screen), quit.
+ * If the entire file is displayed and the -F flag is set, quit.
*/
- if (get_quit_at_eof() && squished &&
+ if (quit_if_one_screen &&
+ entire_file_displayed() && !(ch_getflags() & CH_HELPFILE) &&
next_ifile(curr_ifile) == NULL_IFILE)
quit(QUIT_OK);
-#endif
#if MSDOS_COMPILER==WIN32C
/*
@@ -681,6 +697,8 @@ prompt()
clear_cmd();
forw_prompt = 0;
p = pr_string();
+ if (is_filtering())
+ putstr("& ");
if (p == NULL || *p == '\0')
putchr(':');
else
@@ -1137,7 +1155,6 @@ commands()
cmd_exec();
jump_forw();
ignore_eoi = 1;
- hit_eof = 0;
while (!sigs)
{
make_display();
@@ -1314,6 +1331,17 @@ commands()
c = getcc();
goto again;
+ case A_FILTER:
+#if HILITE_SEARCH
+ search_type = SRCH_FORW | SRCH_FILTER;
+ mca_search();
+ c = getcc();
+ goto again;
+#else
+ error("Command not available", NULL_PARG);
+ break;
+#endif
+
case A_AGAIN_SEARCH:
/*
* Repeat previous search.
@@ -1438,7 +1466,7 @@ commands()
number = 1;
if (edit_next((int) number))
{
- if (get_quit_at_eof() && hit_eof &&
+ if (get_quit_at_eof() && eof_displayed() &&
!(ch_getflags() & CH_HELPFILE))
quit(QUIT_OK);
parg.p_string = (number > 1) ? "(N-th) " : "";
@@ -1602,6 +1630,7 @@ commands()
if (c == erase_char || c == erase2_char ||
c == kill_char || c == '\n' || c == '\r')
break;
+ cmd_exec();
gomark(c);
break;
OpenPOWER on IntegriCloud