Commit ef16a2a2 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

Doing the copying of typed stuff from input to output just once.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5643 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
parent 15947ac8
Showing with 18 additions and 26 deletions
+18 -26
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
them centered when found offscreen. This fixes Savannah bug #47127. them centered when found offscreen. This fixes Savannah bug #47127.
* src/text.c (do_int_spell_fix): Restore the above behavior also for * src/text.c (do_int_spell_fix): Restore the above behavior also for
the internal spell fixer. the internal spell fixer.
* src/prompt.c (do_statusbar_input, do_statusbar_verbatim_input,
do_statusbar_output): Do the copying from input to output just once.
2016-02-13 Benno Schulenberg <bensberg@justemail.net> 2016-02-13 Benno Schulenberg <bensberg@justemail.net>
* src/browser.c (do_browser, browser_refresh): Rebuild the file list * src/browser.c (do_browser, browser_refresh): Rebuild the file list
......
...@@ -120,20 +120,11 @@ int do_statusbar_input(bool *ran_func, bool *finished, ...@@ -120,20 +120,11 @@ int do_statusbar_input(bool *ran_func, bool *finished,
* characters in the input buffer if it isn't empty. */ * characters in the input buffer if it isn't empty. */
if (have_shortcut || get_key_buffer_len() == 0) { if (have_shortcut || get_key_buffer_len() == 0) {
if (kbinput != NULL) { if (kbinput != NULL) {
bool dummy;
/* Display all the characters in the input buffer at /* Display all the characters in the input buffer at
* once, filtering out control characters. */ * once, filtering out control characters. */
char *output = charalloc(kbinput_len + 1); do_statusbar_output(kbinput, kbinput_len, &dummy, FALSE);
size_t i;
bool got_enter;
/* Whether we got the Enter key. */
for (i = 0; i < kbinput_len; i++)
output[i] = (char)kbinput[i];
output[i] = '\0';
do_statusbar_output(output, kbinput_len, &got_enter, FALSE);
free(output);
/* Empty the input buffer. */ /* Empty the input buffer. */
kbinput_len = 0; kbinput_len = 0;
...@@ -255,17 +246,24 @@ int do_statusbar_mouse(void) ...@@ -255,17 +246,24 @@ int do_statusbar_mouse(void)
* statusbar prompt, setting got_enter to TRUE if we get a newline, and * statusbar prompt, setting got_enter to TRUE if we get a newline, and
* filtering out all ASCII control characters if allow_cntrls is * filtering out all ASCII control characters if allow_cntrls is
* TRUE. */ * TRUE. */
void do_statusbar_output(char *output, size_t output_len, bool void do_statusbar_output(int *the_input, size_t output_len, bool
*got_enter, bool allow_cntrls) *got_enter, bool allow_cntrls)
{ {
size_t answer_len, i = 0; size_t answer_len, i;
char *output = charalloc(output_len + 1);
char *char_buf = charalloc(mb_cur_max()); char *char_buf = charalloc(mb_cur_max());
int char_buf_len; int char_buf_len;
assert(answer != NULL); assert(answer != NULL);
/* Copy the typed stuff so it can be treated. */
for (i = 0; i < output_len; i++)
output[i] = (char)the_input[i];
output[i] = '\0';
answer_len = strlen(answer); answer_len = strlen(answer);
*got_enter = FALSE; *got_enter = FALSE;
i = 0;
while (i < output_len) { while (i < output_len) {
/* If allow_cntrls is TRUE, convert nulls and newlines /* If allow_cntrls is TRUE, convert nulls and newlines
...@@ -311,6 +309,7 @@ void do_statusbar_output(char *output, size_t output_len, bool ...@@ -311,6 +309,7 @@ void do_statusbar_output(char *output, size_t output_len, bool
} }
free(char_buf); free(char_buf);
free(output);
statusbar_pww = statusbar_xplustabs(); statusbar_pww = statusbar_xplustabs();
...@@ -453,8 +452,7 @@ void do_statusbar_prev_word(void) ...@@ -453,8 +452,7 @@ void do_statusbar_prev_word(void)
void do_statusbar_verbatim_input(bool *got_enter) void do_statusbar_verbatim_input(bool *got_enter)
{ {
int *kbinput; int *kbinput;
size_t kbinput_len, i; size_t kbinput_len;
char *output;
*got_enter = FALSE; *got_enter = FALSE;
...@@ -463,15 +461,7 @@ void do_statusbar_verbatim_input(bool *got_enter) ...@@ -463,15 +461,7 @@ void do_statusbar_verbatim_input(bool *got_enter)
/* Display all the verbatim characters at once, not filtering out /* Display all the verbatim characters at once, not filtering out
* control characters. */ * control characters. */
output = charalloc(kbinput_len + 1); do_statusbar_output(kbinput, kbinput_len, got_enter, TRUE);
for (i = 0; i < kbinput_len; i++)
output[i] = (char)kbinput[i];
output[i] = '\0';
do_statusbar_output(output, kbinput_len, got_enter, TRUE);
free(output);
} }
/* Return the placewewant associated with statusbar_x, i.e. the /* Return the placewewant associated with statusbar_x, i.e. the
......
...@@ -517,7 +517,7 @@ int do_statusbar_input(bool *ran_func, bool *finished, ...@@ -517,7 +517,7 @@ int do_statusbar_input(bool *ran_func, bool *finished,
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
int do_statusbar_mouse(void); int do_statusbar_mouse(void);
#endif #endif
void do_statusbar_output(char *output, size_t output_len, bool void do_statusbar_output(int *the_input, size_t output_len, bool
*got_enter, bool allow_cntrls); *got_enter, bool allow_cntrls);
void do_statusbar_home(void); void do_statusbar_home(void);
void do_statusbar_end(void); void do_statusbar_end(void);
......
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