Commit 6a70d2b6 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: rename two functions and a variable, and invert its logic

No related merge requests found
Showing with 19 additions and 18 deletions
+19 -18
...@@ -677,8 +677,8 @@ void spotlight(bool active, const char *word); ...@@ -677,8 +677,8 @@ void spotlight(bool active, const char *word);
void xon_complaint(void); void xon_complaint(void);
void xoff_complaint(void); void xoff_complaint(void);
void do_suspend_void(void); void do_suspend_void(void);
void enable_nodelay(void); void disable_waiting(void);
void disable_nodelay(void); void enable_waiting(void);
#ifndef DISABLE_EXTRA #ifndef DISABLE_EXTRA
void do_credits(void); void do_credits(void);
#endif #endif
......
...@@ -234,8 +234,10 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region, ...@@ -234,8 +234,10 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
size_t found_x; size_t found_x;
/* The x coordinate of a found occurrence. */ /* The x coordinate of a found occurrence. */
time_t lastkbcheck = time(NULL); 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) if (begin == NULL)
came_full_circle = FALSE; came_full_circle = FALSE;
...@@ -252,7 +254,7 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region, ...@@ -252,7 +254,7 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
while (input) { while (input) {
if (func_from_key(&input) == do_cancel) { if (func_from_key(&input) == do_cancel) {
statusbar(_("Cancelled")); statusbar(_("Cancelled"));
disable_nodelay(); enable_waiting();
return -2; return -2;
} }
input = parse_kbinput(NULL); input = parse_kbinput(NULL);
...@@ -303,7 +305,7 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region, ...@@ -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 we're back at the beginning, then there is no needle. */
if (came_full_circle) { if (came_full_circle) {
not_found_msg(needle); not_found_msg(needle);
disable_nodelay(); enable_waiting();
return 0; return 0;
} }
...@@ -317,7 +319,7 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region, ...@@ -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. */ * but stop when spell-checking or replacing in a region. */
if (line == NULL) { if (line == NULL) {
if (whole_word_only || have_region) { if (whole_word_only || have_region) {
disable_nodelay(); enable_waiting();
return 0; return 0;
} }
...@@ -343,16 +345,15 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region, ...@@ -343,16 +345,15 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
found_x = found - line->data; found_x = found - line->data;
enable_waiting();
/* Ensure that the found occurrence is not beyond the starting x. */ /* Ensure that the found occurrence is not beyond the starting x. */
if (came_full_circle && ((!ISSET(BACKWARDS_SEARCH) && found_x > begin_x) || if (came_full_circle && ((!ISSET(BACKWARDS_SEARCH) && found_x > begin_x) ||
(ISSET(BACKWARDS_SEARCH) && found_x < begin_x))) { (ISSET(BACKWARDS_SEARCH) && found_x < begin_x))) {
not_found_msg(needle); not_found_msg(needle);
disable_nodelay();
return 0; return 0;
} }
disable_nodelay();
/* Set the current position to point at what we found. */ /* Set the current position to point at what we found. */
openfile->current = line; openfile->current = line;
openfile->current_x = found_x; openfile->current_x = found_x;
......
...@@ -45,8 +45,8 @@ static size_t key_buffer_len = 0; ...@@ -45,8 +45,8 @@ static size_t key_buffer_len = 0;
/* The length of the keystroke buffer. */ /* The length of the keystroke buffer. */
static bool solitary = FALSE; static bool solitary = FALSE;
/* Whether an Esc arrived by itself -- not as leader of a sequence. */ /* Whether an Esc arrived by itself -- not as leader of a sequence. */
static nodelay_mode = FALSE; static waiting_mode = TRUE;
/* Whether we will check for a Cancel now and then during a search. */ /* Whether getting a character will wait for a key to be pressed. */
static int statusblank = 0; static int statusblank = 0;
/* The number of keystrokes left before we blank the statusbar. */ /* The number of keystrokes left before we blank the statusbar. */
#ifdef USING_OLD_NCURSES #ifdef USING_OLD_NCURSES
...@@ -135,7 +135,7 @@ void get_key_buffer(WINDOW *win) ...@@ -135,7 +135,7 @@ void get_key_buffer(WINDOW *win)
} }
#endif #endif
if (input == ERR && nodelay_mode) if (input == ERR && !waiting_mode)
return; return;
while (input == ERR) { while (input == ERR) {
...@@ -188,7 +188,7 @@ void get_key_buffer(WINDOW *win) ...@@ -188,7 +188,7 @@ void get_key_buffer(WINDOW *win)
} }
/* Restore waiting mode if it was on. */ /* Restore waiting mode if it was on. */
if (!nodelay_mode) if (waiting_mode)
nodelay(win, FALSE); nodelay(win, FALSE);
#ifdef DEBUG #ifdef DEBUG
...@@ -327,7 +327,7 @@ int parse_kbinput(WINDOW *win) ...@@ -327,7 +327,7 @@ int parse_kbinput(WINDOW *win)
/* Read in a character. */ /* Read in a character. */
kbinput = get_input(win, 1); kbinput = get_input(win, 1);
if (kbinput == NULL && nodelay_mode) if (kbinput == NULL && !waiting_mode)
return 0; return 0;
while (kbinput == NULL) while (kbinput == NULL)
...@@ -3228,15 +3228,15 @@ void do_cursorpos_void(void) ...@@ -3228,15 +3228,15 @@ void do_cursorpos_void(void)
do_cursorpos(TRUE); do_cursorpos(TRUE);
} }
void enable_nodelay(void) void disable_waiting(void)
{ {
nodelay_mode = TRUE; waiting_mode = FALSE;
nodelay(edit, TRUE); nodelay(edit, TRUE);
} }
void disable_nodelay(void) void enable_waiting(void)
{ {
nodelay_mode = FALSE; waiting_mode = TRUE;
nodelay(edit, FALSE); nodelay(edit, FALSE);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment