From d844f05a1e8634eca5170449bacc027ca1da8b38 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 6 Feb 2016 11:40:15 +0000 Subject: [PATCH] Chopping two parameters that are always the same, and that are global variables anyway. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5611 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 2 ++ src/prompt.c | 35 ++++++++++++++++------------------- src/proto.h | 2 +- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index d7cc89de..c0d3ac47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ message has been posted on the status bar. * src/winio.c (statusbar), src/nano.c (do_input): Turn the cursor off when writing in the status bar, and on when waiting for input. + * src/prompt.c (update_the_statusbar): Chop two parameters that are + always the same, and that are global variables anyway. 2016-02-05 Benno Schulenberg * doc/texinfo/nano.texi: Condense the descriptions of command-key diff --git a/src/prompt.c b/src/prompt.c index cfcf5cb2..679b052a 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -316,7 +316,7 @@ void do_statusbar_output(char *output, size_t output_len, bool statusbar_pww = statusbar_xplustabs(); - update_statusbar_line(answer, statusbar_x); + update_the_statusbar(); } /* Move to the beginning of the prompt text. */ @@ -378,7 +378,7 @@ void do_statusbar_delete(void) null_at(&answer, statusbar_x + line_len - char_buf_len); - update_statusbar_line(answer, statusbar_x); + update_the_statusbar(); } } @@ -398,7 +398,7 @@ void do_statusbar_cut_text(void) statusbar_pww = statusbar_xplustabs(); } - update_statusbar_line(answer, statusbar_x); + update_the_statusbar(); } #ifndef NANO_TINY @@ -511,18 +511,16 @@ void reset_statusbar_cursor(void) 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]. */ -void update_statusbar_line(const char *curranswer, size_t index) +/* Repaint the statusbar. */ +void update_the_statusbar(void) { - size_t start_col, page_start; + size_t start_col, index, page_start; char *expanded; - assert(prompt != NULL && index <= strlen(curranswer)); + assert(prompt != NULL && statusbar_x <= strlen(answer)); start_col = strlenpt(prompt) + 2; - index = strnlenpt(curranswer, index); + index = strnlenpt(answer, statusbar_x); page_start = get_statusbar_page_start(start_col, start_col + index); if (interface_color_pair[TITLE_BAR].bright) @@ -535,8 +533,7 @@ void update_statusbar_line(const char *curranswer, size_t index) waddch(bottomwin, ':'); waddch(bottomwin, (page_start == 0) ? ' ' : '$'); - expanded = display_string(curranswer, page_start, COLS - start_col - - 1, FALSE); + expanded = display_string(answer, page_start, COLS - start_col - 1, FALSE); waddstr(bottomwin, expanded); free(expanded); @@ -557,7 +554,7 @@ void update_the_bar(void) if (get_statusbar_page_start(start_col, start_col + statusbar_pww) != get_statusbar_page_start(start_col, start_col + was_pww)) - update_statusbar_line(answer, statusbar_x); + update_the_statusbar(); } /* Get a string of input at the statusbar prompt. */ @@ -605,7 +602,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs, fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answer, (unsigned long) statusbar_x); #endif - update_statusbar_line(answer, statusbar_x); + update_the_statusbar(); /* Refresh the edit window and the statusbar before getting * input. */ @@ -624,7 +621,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs, #ifndef NANO_TINY if (kbinput == KEY_WINCH) { refresh_func(); - update_statusbar_line(answer, statusbar_x); + update_the_statusbar(); continue; } #endif @@ -655,7 +652,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs, answer = input_tab(answer, allow_files, &statusbar_x, &tabbed, refresh_func, list); - update_statusbar_line(answer, statusbar_x); + update_the_statusbar(); } else #endif /* !DISABLE_TABCOMP */ #ifndef DISABLE_HISTORIES @@ -673,7 +670,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs, statusbar_x = strlen(answer); } - update_statusbar_line(answer, statusbar_x); + update_the_statusbar(); /* This key has a shortcut-list entry when it's used to * move to an older search, which means that finished has @@ -699,7 +696,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs, statusbar_x = strlen(answer); } - update_statusbar_line(answer, statusbar_x); + update_the_statusbar(); /* This key has a shortcut-list entry when it's used to * move to a newer search, which means that finished has @@ -710,7 +707,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs, } else #endif /* !DISABLE_HISTORIES */ if (func == do_help_void) { - update_statusbar_line(answer, statusbar_x); + update_the_statusbar(); /* This key has a shortcut-list entry when it's used to go to * the help browser or display a message indicating that help diff --git a/src/proto.h b/src/proto.h index f8ca6a8a..0b563f8d 100644 --- a/src/proto.h +++ b/src/proto.h @@ -534,7 +534,7 @@ void do_statusbar_verbatim_input(bool *got_enter); size_t statusbar_xplustabs(void); size_t get_statusbar_page_start(size_t start_col, size_t column); void reset_statusbar_cursor(void); -void update_statusbar_line(const char *curranswer, size_t index); +void update_the_statusbar(void); void update_the_bar(void); void total_statusbar_refresh(void (*refresh_func)(void)); functionptrtype get_prompt_string(int *value, bool allow_tabs, -- 2.39.5