From: David Lawrence Ramsey Date: Mon, 15 May 2006 15:17:50 +0000 (+0000) Subject: improve NANO_REFRESH_KEY handling X-Git-Tag: v1.3.12~160 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=60edb0a989db84ea92acf71c02203ef14b8c6605;p=nano.git improve NANO_REFRESH_KEY handling git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3520 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 337f1546..fa9ae147 100644 --- a/ChangeLog +++ b/ChangeLog @@ -191,7 +191,11 @@ CVS code - do_statusbar_input() - Remove redundant check for allow_funcs' being TRUE when we get KEY_MOUSE. (DLR) - do_yesno() + - Improve the handling of NANO_REFRESH_KEY. (DLR) + total_statusbar_refresh() + - New function, called when we get NANO_REFRESH_KEY in + do_statusbar_input(). (DLR) + do_yesno_prompt() - Handle the keys in a switch statement instead of a long if block, for simplicity. (DLR) - rcfile.c: diff --git a/src/browser.c b/src/browser.c index c91b20d5..a3d5cc55 100644 --- a/src/browser.c +++ b/src/browser.c @@ -150,6 +150,10 @@ char *do_browser(char *path, DIR *dir) } break; #endif /* !DISABLE_MOUSE */ + /* Redraw the screen. */ + case NANO_REFRESH_KEY: + total_redraw(); + break; case NANO_HELP_KEY: #ifndef DISABLE_HELP do_browser_help(); @@ -331,10 +335,6 @@ char *do_browser(char *path, DIR *dir) /* Start over again with the new path value. */ free_chararray(filelist, filelist_len); goto change_browser_directory; - /* Redraw the screen. */ - case NANO_REFRESH_KEY: - total_redraw(); - break; /* Abort the browser. */ case NANO_EXIT_KEY: abort = TRUE; diff --git a/src/prompt.c b/src/prompt.c index 31016349..140d2bfd 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -148,6 +148,9 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t, if (have_shortcut) { switch (input) { /* Handle the "universal" statusbar prompt shortcuts. */ + case NANO_REFRESH_KEY: + total_statusbar_refresh(refresh_func); + break; case NANO_CUT_KEY: /* If we're using restricted mode, the filename * isn't blank, and we're at the "Write File" @@ -222,9 +225,6 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t, '\0' || currshortcut != writefile_list) do_statusbar_backspace(); break; - case NANO_REFRESH_KEY: - refresh_func(); - break; /* Handle the normal statusbar prompt shortcuts, setting * ran_func to TRUE if we try to run their associated * functions and setting finished to TRUE to indicate @@ -837,6 +837,16 @@ size_t get_statusbar_page_start(size_t start_col, size_t column) start_col - 1); } +/* Put the cursor in the statusbar prompt at statusbar_x. */ +void reset_statusbar_cursor(void) +{ + size_t start_col = strlenpt(prompt) + 1; + size_t xpt = statusbar_xplustabs(); + + wmove(bottomwin, 0, start_col + 1 + xpt - + get_statusbar_page_start(start_col, start_col + xpt)); +} + /* Repaint the statusbar when getting a character in * get_prompt_string(). The statusbar text line will be displayed * starting with curranswer[index]. */ @@ -869,16 +879,6 @@ void update_statusbar_line(const char *curranswer, size_t index) wattroff(bottomwin, reverse_attr); } -/* Put the cursor in the statusbar prompt at statusbar_x. */ -void reset_statusbar_cursor(void) -{ - size_t start_col = strlenpt(prompt) + 1; - size_t xpt = statusbar_xplustabs(); - - wmove(bottomwin, 0, start_col + 1 + xpt - - get_statusbar_page_start(start_col, start_col + xpt)); -} - /* Return TRUE if we need an update after moving horizontally, and FALSE * otherwise. We need one if old_pww and statusbar_pww are on different * pages. */ @@ -890,6 +890,14 @@ bool need_statusbar_horizontal_update(size_t old_pww) get_statusbar_page_start(start_col, start_col + statusbar_pww); } +/* Unconditionally redraw the entire screen, and then refresh it using + * refresh_func(). */ +void total_statusbar_refresh(void (*refresh_func)(void)) +{ + total_redraw(); + refresh_func(); +} + /* Get a string of input at the statusbar prompt. This should only be * called from do_prompt(). */ int get_prompt_string(bool allow_tabs, diff --git a/src/proto.h b/src/proto.h index d78267ce..4eccffa7 100644 --- a/src/proto.h +++ b/src/proto.h @@ -495,9 +495,10 @@ void do_statusbar_find_bracket(void); #endif size_t statusbar_xplustabs(void); size_t get_statusbar_page_start(size_t start_col, size_t column); -void update_statusbar_line(const char *curranswer, size_t index); void reset_statusbar_cursor(void); +void update_statusbar_line(const char *curranswer, size_t index); bool need_statusbar_horizontal_update(size_t old_pww); +void total_statusbar_refresh(void (*refresh_func)(void)); int get_prompt_string(bool allow_tabs, #ifndef DISABLE_TABCOMP bool allow_files,