From 61f768b81cdecfa4109ddd9c6ea004882e411678 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 25 Feb 2016 13:07:19 +0100 Subject: [PATCH 2/3] Don't show the cursor in the help screen and the file browser. And show it in the edit window when linting. (This fuses revisions 5640, 5667, and 5668 from SVN.) Signed-off-by: Benno Schulenberg --- src/browser.c | 10 ++++------ src/files.c | 5 +---- src/help.c | 4 +--- src/nano.c | 5 +++-- src/prompt.c | 3 +++ src/search.c | 3 +-- src/text.c | 10 +++++++++- src/winio.c | 5 +---- 8 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/browser.c b/src/browser.c index 39b7715..857bec5 100644 --- a/src/browser.c +++ b/src/browser.c @@ -61,6 +61,7 @@ char *do_browser(char *path, DIR *dir) functionptrtype func; /* The function of the key the user typed in. */ + /* Don't show a cursor in the file list. */ curs_set(0); blank_statusbar(); bottombars(MBROWSER); @@ -115,6 +116,9 @@ char *do_browser(char *path, DIR *dir) /* The path we switch to at the "Go to Directory" * prompt. */ + /* Make sure that the cursor is off. */ + curs_set(0); + #ifndef NANO_TINY if (kbinput == KEY_WINCH) { /* Rebuild the file list and sort it. */ @@ -180,15 +184,12 @@ char *do_browser(char *path, DIR *dir) do_help_void(); /* The window dimensions might have changed, so act as if. */ kbinput = KEY_WINCH; - curs_set(0); #else say_there_is_no_help(); #endif } else if (func == do_search) { /* Search for a filename. */ - curs_set(1); do_filesearch(); - curs_set(0); } else if (func == do_research) { /* Search for another filename. */ do_fileresearch(); @@ -207,7 +208,6 @@ char *do_browser(char *path, DIR *dir) selected = filelist_len - 1; } else if (func == goto_dir_void) { /* Go to a specific directory. */ - curs_set(1); i = do_prompt(TRUE, #ifndef DISABLE_TABCOMP FALSE, @@ -219,7 +219,6 @@ char *do_browser(char *path, DIR *dir) /* TRANSLATORS: This is a prompt. */ browser_refresh, _("Go To Directory")); - curs_set(0); bottombars(MBROWSER); /* If the directory begins with a newline (i.e. an @@ -346,7 +345,6 @@ char *do_browser(char *path, DIR *dir) } titlebar(NULL); edit_refresh(); - curs_set(1); if (old_const_update) SET(CONST_UPDATE); diff --git a/src/files.c b/src/files.c index c16b927..9df472f 100644 --- a/src/files.c +++ b/src/files.c @@ -2907,7 +2907,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place, bool blank_edit(); wmove(edit, 0, 0); - /* Disable el cursor. */ + /* Don't show a cursor in the list of completions. */ curs_set(0); for (match = 0; match < num_matches; match++) { @@ -2946,9 +2946,6 @@ char *input_tab(char *buf, bool allow_files, size_t *place, bool if (!*list) refresh_func(); - /* Enable el cursor. */ - curs_set(1); - return buf; } #endif /* !DISABLE_TABCOMP */ diff --git a/src/help.c b/src/help.c index 8b3a0d5..7dd0bfd 100644 --- a/src/help.c +++ b/src/help.c @@ -56,6 +56,7 @@ void do_help(void) functionptrtype func; /* The function of the key the user typed in. */ + /* Don't show a cursor in the help screen. */ curs_set(0); blank_edit(); blank_statusbar(); @@ -123,7 +124,6 @@ void do_help(void) #ifndef NANO_TINY if (kbinput == KEY_WINCH) { kbinput = ERR; - curs_set(0); continue; /* Redraw the screen. */ } #endif @@ -174,8 +174,6 @@ void do_help(void) } else bottombars(oldmenu); - curs_set(1); - #ifndef DISABLE_BROWSER if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == MGOTODIR) browser_refresh(); diff --git a/src/nano.c b/src/nano.c index 272b41b..f9169ed 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1099,8 +1099,6 @@ int no_help(void) * name with the TEMP_FILE flag set, just before the filename prompt. */ void no_current_file_name_warning(void) { - curs_set(0); - /* Warn that the current file has no name. */ statusbar(_("No file name")); beep(); @@ -2676,6 +2674,9 @@ int main(int argc, char **argv) currmenu = MMAIN; + /* Turn the cursor on when waiting for input. */ + curs_set(1); + /* Read in and interpret characters. */ do_input(TRUE); } diff --git a/src/prompt.c b/src/prompt.c index dcf7ad1..13d913c 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -610,6 +610,9 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs, * this case, disable all keys that would change the text if the * filename isn't blank and we're at the "Write File" prompt. */ while (TRUE) { + /* Ensure the cursor is on when waiting for input. */ + curs_set(1); + kbinput = do_statusbar_input(&ran_func, &finished, refresh_func); assert(statusbar_x <= strlen(answer)); diff --git a/src/search.c b/src/search.c index 45164b2..9d63f7b 100644 --- a/src/search.c +++ b/src/search.c @@ -710,6 +710,7 @@ ssize_t do_replace_loop( edit_refresh(); + /* Don't show cursor, to not distract from highlighted match. */ curs_set(0); do_replace_highlight(TRUE, exp_word); @@ -721,8 +722,6 @@ ssize_t do_replace_loop( free(exp_word); - curs_set(1); - if (i == -1) { /* We canceled the replace. */ if (canceled != NULL) *canceled = TRUE; diff --git a/src/text.c b/src/text.c index 708e1c1..c838e44 100644 --- a/src/text.c +++ b/src/text.c @@ -2235,6 +2235,7 @@ void do_justify(bool full_justify) do { #endif statusbar(_("Can now UnJustify!")); + curs_set(1); kbinput = do_input(FALSE); #ifndef NANO_TINY } while (kbinput == KEY_WINCH); @@ -3130,8 +3131,11 @@ void do_linter(void) char *msg = charalloc(1024 + strlen(curlint->filename)); int i; - sprintf(msg, _("This message is for unopened file %s, open it in a new buffer?"), + sprintf(msg, _("This message is for unopened file %s," + " open it in a new buffer?"), curlint->filename); + /* Show a cursor after the question. */ + curs_set(1); i = do_yesno_prompt(FALSE, msg); free(msg); if (i == -1) { @@ -3163,6 +3167,10 @@ void do_linter(void) bottombars(MLINTER); } + /* Show the cursor to indicate the affected line. */ + reset_cursor(); + curs_set(1); + kbinput = get_kbinput(bottomwin); #ifndef NANO_TINY diff --git a/src/winio.c b/src/winio.c index e53054f..2bfb7bf 100644 --- a/src/winio.c +++ b/src/winio.c @@ -311,9 +311,6 @@ int get_kbinput(WINDOW *win) { int kbinput; - /* Turn the cursor on when waiting for input. */ - curs_set(1); - /* Read in a character and interpret it. Continue doing this until * we get a recognized value or sequence. */ while ((kbinput = parse_kbinput(win)) == ERR) @@ -1126,6 +1123,7 @@ int parse_escape_sequence(WINDOW *win, int kbinput) if (retval == ERR) { if (win == edit) { statusbar(_("Unknown Command")); + curs_set(1); beep(); } } @@ -3354,7 +3352,6 @@ void do_credits(void) UNSET(NO_HELP); window_init(); - curs_set(1); nodelay(edit, FALSE); total_refresh(); -- 1.7.0.4