diff options
author | delphij <delphij@FreeBSD.org> | 2009-05-08 23:45:27 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2009-05-08 23:45:27 +0000 |
commit | 40472e4d24727eb8c2cf003fa10c3d4c6a89e22b (patch) | |
tree | a3b19b698e154070851f613743d2c3b6467b5828 /command.c | |
parent | d069efd47cacc3156036ed37d5532d6a1d4f55c3 (diff) | |
download | FreeBSD-src-40472e4d24727eb8c2cf003fa10c3d4c6a89e22b.zip FreeBSD-src-40472e4d24727eb8c2cf003fa10c3d4c6a89e22b.tar.gz |
Vendor import of less v429
Diffstat (limited to 'command.c')
-rw-r--r-- | command.c | 67 |
1 files changed, 48 insertions, 19 deletions
@@ -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. @@ -25,7 +25,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; @@ -84,7 +83,9 @@ static void multi_search(); static void cmd_exec() { +#if HILITE_SEARCH clear_attn(); +#endif clear_bot(); flush(); } @@ -118,6 +119,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 @@ -137,6 +143,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 @@ -195,6 +206,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. @@ -467,6 +484,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 @@ -486,14 +504,17 @@ mca_char(c) { case CONTROL('E'): /* ignore END of file */ case '*': - flag = SRCH_PAST_EOF; + if (mca != A_FILTER) + flag = SRCH_PAST_EOF; break; case CONTROL('F'): /* FIRST file */ case '@': - 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; @@ -630,25 +651,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 /* @@ -675,6 +691,8 @@ prompt() clear_cmd(); forw_prompt = 0; p = pr_string(); + if (is_filtering()) + putstr("& "); if (p == NULL || *p == '\0') putchr(':'); else @@ -1131,7 +1149,6 @@ commands() cmd_exec(); jump_forw(); ignore_eoi = 1; - hit_eof = 0; while (!sigs) { make_display(); @@ -1308,6 +1325,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. @@ -1432,7 +1460,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) " : ""; @@ -1596,6 +1624,7 @@ commands() if (c == erase_char || c == erase2_char || c == kill_char || c == '\n' || c == '\r') break; + cmd_exec(); gomark(c); break; |