diff --git a/src/proto.h b/src/proto.h index 2d269992..1e15d053 100644 --- a/src/proto.h +++ b/src/proto.h @@ -677,8 +677,8 @@ void spotlight(bool active, const char *word); void xon_complaint(void); void xoff_complaint(void); void do_suspend_void(void); -void enable_nodelay(void); -void disable_nodelay(void); +void disable_waiting(void); +void enable_waiting(void); #ifndef DISABLE_EXTRA void do_credits(void); #endif diff --git a/src/search.c b/src/search.c index 1452a1af..152045e0 100644 --- a/src/search.c +++ b/src/search.c @@ -234,8 +234,10 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region, size_t found_x; /* The x coordinate of a found occurrence. */ time_t lastkbcheck = time(NULL); + /* The time we last looked at the keyboard. */ - enable_nodelay(); + /* Set non-blocking input so that we can just peek for a Cancel. */ + disable_waiting(); if (begin == NULL) came_full_circle = FALSE; @@ -252,7 +254,7 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region, while (input) { if (func_from_key(&input) == do_cancel) { statusbar(_("Cancelled")); - disable_nodelay(); + enable_waiting(); return -2; } input = parse_kbinput(NULL); @@ -303,7 +305,7 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region, /* If we're back at the beginning, then there is no needle. */ if (came_full_circle) { not_found_msg(needle); - disable_nodelay(); + enable_waiting(); return 0; } @@ -317,7 +319,7 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region, * but stop when spell-checking or replacing in a region. */ if (line == NULL) { if (whole_word_only || have_region) { - disable_nodelay(); + enable_waiting(); return 0; } @@ -343,16 +345,15 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region, found_x = found - line->data; + enable_waiting(); + /* Ensure that the found occurrence is not beyond the starting x. */ if (came_full_circle && ((!ISSET(BACKWARDS_SEARCH) && found_x > begin_x) || (ISSET(BACKWARDS_SEARCH) && found_x < begin_x))) { not_found_msg(needle); - disable_nodelay(); return 0; } - disable_nodelay(); - /* Set the current position to point at what we found. */ openfile->current = line; openfile->current_x = found_x; diff --git a/src/winio.c b/src/winio.c index ded81ad6..0d776da1 100644 --- a/src/winio.c +++ b/src/winio.c @@ -45,8 +45,8 @@ static size_t key_buffer_len = 0; /* The length of the keystroke buffer. */ static bool solitary = FALSE; /* Whether an Esc arrived by itself -- not as leader of a sequence. */ -static nodelay_mode = FALSE; - /* Whether we will check for a Cancel now and then during a search. */ +static waiting_mode = TRUE; + /* Whether getting a character will wait for a key to be pressed. */ static int statusblank = 0; /* The number of keystrokes left before we blank the statusbar. */ #ifdef USING_OLD_NCURSES @@ -135,7 +135,7 @@ void get_key_buffer(WINDOW *win) } #endif - if (input == ERR && nodelay_mode) + if (input == ERR && !waiting_mode) return; while (input == ERR) { @@ -188,7 +188,7 @@ void get_key_buffer(WINDOW *win) } /* Restore waiting mode if it was on. */ - if (!nodelay_mode) + if (waiting_mode) nodelay(win, FALSE); #ifdef DEBUG @@ -327,7 +327,7 @@ int parse_kbinput(WINDOW *win) /* Read in a character. */ kbinput = get_input(win, 1); - if (kbinput == NULL && nodelay_mode) + if (kbinput == NULL && !waiting_mode) return 0; while (kbinput == NULL) @@ -3228,15 +3228,15 @@ void do_cursorpos_void(void) do_cursorpos(TRUE); } -void enable_nodelay(void) +void disable_waiting(void) { - nodelay_mode = TRUE; + waiting_mode = FALSE; nodelay(edit, TRUE); } -void disable_nodelay(void) +void enable_waiting(void) { - nodelay_mode = FALSE; + waiting_mode = TRUE; nodelay(edit, FALSE); }