diff options
Diffstat (limited to 'command.c')
| -rw-r--r-- | command.c | 186 |
1 files changed, 132 insertions, 54 deletions
diff --git a/command.c b/command.c index fcb6ec13569b..0fc2b7ae21fa 100644 --- a/command.c +++ b/command.c @@ -23,10 +23,11 @@ extern int erase_char, erase2_char, kill_char; extern int sigs; extern int quit_if_one_screen; -extern int one_screen; +extern lbool one_screen; extern int sc_width; extern int sc_height; extern char *kent; +extern lbool kent_mapped; extern int swindow; extern int jump_sline; extern lbool quitting; @@ -47,13 +48,16 @@ extern void *ml_search; extern void *ml_examine; extern int wheel_lines; extern int def_search_type; +extern int hilite_target; extern lbool search_wrapped; extern int no_paste; extern lbool pasting; extern int no_edit_warn; +extern lbool read_error; extern POSITION soft_eof; extern POSITION search_incr_start; extern char *first_cmd_at_prompt; +extern lbool prompting; #if SHELL_ESCAPE || PIPEC extern void *ml_shell; #endif @@ -64,9 +68,9 @@ extern constant char *editproto; extern char *osc8_uri; #endif extern int shift_count; -extern int forw_prompt; +extern lbool forw_prompt; extern int incr_search; -extern int full_screen; +extern lbool full_screen; #if MSDOS_COMPILER==WIN32C extern int utf_mode; extern unsigned less_acp; @@ -84,6 +88,7 @@ static struct loption *curropt; static lbool opt_lower; static int optflag; static lbool optgetname; +static POSITION toppos; static POSITION bottompos; static int save_hshift; static int save_bs_mode; @@ -207,7 +212,7 @@ static void mca_search1(void) cmd_putstr("/"); else cmd_putstr("?"); - forw_prompt = 0; + forw_prompt = FALSE; } static void mca_search(void) @@ -247,7 +252,7 @@ static void mca_opt_toggle(void) cmd_putstr("!"); break; } - forw_prompt = 0; + forw_prompt = FALSE; set_mlist(NULL, CF_OPTION); } @@ -846,12 +851,6 @@ public int is_screen_trashed(void) static void make_display(void) { /* - * If not full_screen, we can't rely on scrolling to fill the screen. - * We need to clear and repaint screen before any change. - */ - if (!full_screen && !(quit_if_one_screen && one_screen)) - lclear(); - /* * If nothing is displayed yet, display starting from initial_scrpos. */ if (empty_screen()) @@ -880,11 +879,46 @@ static void make_display(void) } /* + * Display any message that needs to be displayed before the prompt. + */ +static void prompt_message(void) +{ + if (read_error) + { + error("read error", NULL_PARG); + read_error = FALSE; + } + if (search_wrapped) + { + if (search_type & SRCH_BACK) + error("Search hit top; continuing at bottom", NULL_PARG); + else + error("Search hit bottom; continuing at top", NULL_PARG); + search_wrapped = FALSE; + } +#if OSC8_LINK + if (osc8_uri != NULL) + { + PARG parg; + parg.p_string = osc8_uri; + error("Link: %s", &parg); + free(osc8_uri); + osc8_uri = NULL; + } +#endif +} + +/* * Display the appropriate prompt. */ static void prompt(void) { constant char *p; + int attr; +#if MSDOS_COMPILER==WIN32C + WCHAR w[MAX_PATH*2]; + char a[MAX_PATH*2]; +#endif if (ungot != NULL && !ungot->ug_end_command) { @@ -899,6 +933,10 @@ static void prompt(void) * Make sure the screen is displayed. */ make_display(); + + if (hilite_target) + draw_target_attn(TRUE); /* Redraw target line for --hilite-target. */ + toppos = position(TOP); bottompos = position(BOTTOM_PLUS_ONE); /* @@ -916,7 +954,7 @@ static void prompt(void) entire_file_displayed() && !(ch_getflags() & CH_HELPFILE) && next_ifile(curr_ifile) == NULL_IFILE) quit(QUIT_OK); - quit_if_one_screen = FALSE; /* only get one chance at this */ + quit_if_one_screen = 0; /* only get one chance at this */ if (first_cmd_at_prompt != NULL) { ungetsc(first_cmd_at_prompt); @@ -927,6 +965,7 @@ static void prompt(void) #if MSDOS_COMPILER==WIN32C /* * In Win32, display the file name in the window title. + * {{ Seems like this should be done in edit_ifile, not on every prompt. }} */ if (!(ch_getflags() & CH_HELPFILE)) { @@ -953,50 +992,43 @@ static void prompt(void) if (!forw_prompt) clear_bot(); clear_cmd(); - forw_prompt = 0; + forw_prompt = FALSE; + prompt_message(); + /* We called make_display above, but if prompt_message displayed + * a message longer than the screen width, we may have trashed + * the screen and need to call make_display again. */ + if (is_screen_trashed()) + make_display(); p = pr_string(); -#if HILITE_SEARCH - if (is_filtering()) - putstr("& "); -#endif - if (search_wrapped) - { - if (search_type & SRCH_BACK) - error("Search hit top; continuing at bottom", NULL_PARG); - else - error("Search hit bottom; continuing at top", NULL_PARG); - search_wrapped = FALSE; - } -#if OSC8_LINK - if (osc8_uri != NULL) - { - PARG parg; - parg.p_string = osc8_uri; - error("Link: %s", &parg); - free(osc8_uri); - osc8_uri = NULL; - } -#endif if (p == NULL || *p == '\0') { - at_enter(AT_NORMAL|AT_COLOR_PROMPT); - putchr(':'); - at_exit(); + p = ":"; + attr = AT_NORMAL|AT_COLOR_PROMPT; } else { + attr = AT_STANDOUT|AT_COLOR_PROMPT; #if MSDOS_COMPILER==WIN32C - WCHAR w[MAX_PATH*2]; - char a[MAX_PATH*2]; MultiByteToWideChar(less_acp, 0, p, -1, w, countof(w)); WideCharToMultiByte(utf_mode ? CP_UTF8 : GetConsoleOutputCP(), 0, w, -1, a, sizeof(a), NULL, NULL); p = a; #endif - load_line(p); - put_line(FALSE); } +#if HILITE_SEARCH + if (is_filtering()) + { + constant char *amp = "& "; + load_line(p, attr, strlen(amp)+1); + putstr(amp); + } else +#endif + { + load_line(p, attr, 1); + } + put_line(FALSE); clear_eol(); resume_screen(); + prompting = TRUE; } /* @@ -1134,8 +1166,9 @@ static char getcc_repl(char constant *orig, char constant *repl, char (*gr_getc) */ public char getcc(void) { - /* Replace kent (keypad Enter) with a newline. */ - return getcc_repl(kent, "\n", getccu, ungetcc); + /* Replace kent (keypad Enter) with a newline. + * However don't do this if kent is mapped to a command via lesskey. */ + return getcc_repl(kent_mapped ? NULL : kent, "\n", getccu, ungetcc); } /* @@ -1286,7 +1319,14 @@ static void multi_search(constant char *pattern, int n, int silent) * Print an error message if we haven't already. */ if (n > 0 && !silent) - error("Pattern not found", NULL_PARG); + { + PARG parg; + parg.p_string = prev_pattern_text(); + if (parg.p_string == NULL) /* {{ can this happen? }} */ + error("Pattern not found", NULL_PARG); + else + error("Pattern not found: %s", &parg); + } if (changed_file) { @@ -1343,7 +1383,7 @@ static int forw_loop(int action) /* * Ignore subsequent (pasted) input chars. */ -public void start_ignoring_input() +public void start_ignoring_input(void) { ignoring_input = TRUE; #if HAVE_TIME @@ -1354,7 +1394,7 @@ public void start_ignoring_input() /* * Stop ignoring input chars. */ -public void stop_ignoring_input() +public void stop_ignoring_input(void) { ignoring_input = FALSE; pasting = FALSE; @@ -1438,6 +1478,8 @@ public void commands(void) c = getcc(); again: + if (c == READ_AGAIN) + continue; if (sigs) continue; @@ -1577,12 +1619,13 @@ public void commands(void) if (number <= 0) number = get_swindow(); cmd_exec(); + if (show_attn && toppos != NULL_POSITION && toppos > ch_zero()) + set_attnpos(toppos-1); backward((int) number, FALSE, TRUE, FALSE); break; case A_F_LINE: case A_F_NEWLINE: - /* * Forward N (default 1) line. */ @@ -1602,6 +1645,8 @@ public void commands(void) if (number <= 0) number = 1; cmd_exec(); + if (show_attn == OPT_ONPLUS && number > 1 && toppos != NULL_POSITION && toppos > ch_zero()) + set_attnpos(toppos-1); backward((int) number, FALSE, FALSE, action == A_B_NEWLINE && !chopline); break; @@ -1621,6 +1666,29 @@ public void commands(void) backward(wheel_lines, FALSE, FALSE, FALSE); break; + case A_L_MOUSE: + /* + * Left wheel_lines columns. + */ + cmd_exec(); + pos_rehead(FALSE); + if (wheel_lines > hshift) + hshift = 0; + else + hshift -= wheel_lines; + screen_trashed(); + break; + + case A_R_MOUSE: + /* + * Right wheel_lines columns. + */ + cmd_exec(); + pos_rehead(FALSE); + hshift += wheel_lines; + screen_trashed(); + break; + case A_FF_LINE: /* * Force forward N (default 1) line. @@ -1640,6 +1708,8 @@ public void commands(void) if (number <= 0) number = 1; cmd_exec(); + if (show_attn == OPT_ONPLUS && number > 1 && toppos != NULL_POSITION && toppos > ch_zero()) + set_attnpos(toppos-1); backward((int) number, TRUE, FALSE, FALSE); break; @@ -1662,6 +1732,8 @@ public void commands(void) if (number <= 0) number = get_swindow(); cmd_exec(); + if (show_attn == OPT_ONPLUS && toppos != NULL_POSITION && toppos > ch_zero()) + set_attnpos(toppos-1); backward((int) number, TRUE, FALSE, FALSE); break; @@ -1699,6 +1771,8 @@ public void commands(void) if (number > 0) wscroll = (int) number; cmd_exec(); + if (show_attn == OPT_ONPLUS && toppos != NULL_POSITION && toppos > ch_zero()) + set_attnpos(toppos-1); backward(wscroll, FALSE, FALSE, FALSE); break; @@ -1958,6 +2032,7 @@ public void commands(void) /* * Clear search string highlighting. */ + cmd_exec(); undo_search(action == A_CLR_SEARCH); break; @@ -2224,9 +2299,11 @@ public void commands(void) } start_mca(A_SETMARK, "set mark: ", NULL, 0); c = getcc(); + make_display(); + cmd_exec(); if (is_erase_char(c) || is_newline_char(c)) break; - setmark(c, action == A_SETMARKBOT ? BOTTOM : TOP); + setmark(c, action == A_SETMARKBOT ? BOTTOM : TOP, number); repaint(); break; @@ -2236,6 +2313,7 @@ public void commands(void) */ start_mca(A_CLRMARK, "clear mark: ", NULL, 0); c = getcc(); + cmd_exec(); if (is_erase_char(c) || is_newline_char(c)) break; clrmark(c); @@ -2251,7 +2329,7 @@ public void commands(void) if (is_erase_char(c) || is_newline_char(c)) break; cmd_exec(); - gomark(c); + gomark(c, number); break; case A_PIPE: @@ -2294,7 +2372,7 @@ public void commands(void) number = (shift_count > 0) ? shift_count : sc_width / 2; if (number > hshift) number = hshift; - pos_rehead(); + pos_rehead(FALSE); hshift -= (int) number; screen_trashed(); cmd_exec(); @@ -2308,7 +2386,7 @@ public void commands(void) shift_count = (int) number; else number = (shift_count > 0) ? shift_count : sc_width / 2; - pos_rehead(); + pos_rehead(FALSE); hshift += (int) number; screen_trashed(); cmd_exec(); @@ -2318,7 +2396,7 @@ public void commands(void) /* * Shift view left to margin. */ - pos_rehead(); + pos_rehead(FALSE); hshift = 0; screen_trashed(); cmd_exec(); @@ -2328,7 +2406,7 @@ public void commands(void) /* * Shift view right to view rightmost char on screen. */ - pos_rehead(); + pos_rehead(FALSE); hshift = rrshift(); screen_trashed(); cmd_exec(); |
