diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2020-10-11 16:03:07 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-03-25 18:53:12 +0100 |
commit | 37decf3a7c611fab1b6449b2c8ef4cfa374140dd (patch) | |
tree | b83f67687f172d68e71130e2a8ea3a5e04089b54 /src | |
parent | 99f6f9e454adb4385dc6b9db5c2c7ca8d05efa13 (diff) | |
download | weechat-37decf3a7c611fab1b6449b2c8ef4cfa374140dd.zip |
core: Replace newline/tabs after paste is accepted
Instead of replacing newline/tabs when paste is started, do it when the
paste is accepted instead. This makes a difference if you paste again
while the paste confirmation is active, where instead of running it
again for each paste, it will now be run for all the text at the end.
For now this doesn't make a practical difference, but the next commit
will remove the final newline when multiple lines are pasted too, which
we only want to do for the final paste.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/curses/gui-curses-key.c | 9 | ||||
-rw-r--r-- | src/gui/gui-key.c | 14 | ||||
-rw-r--r-- | src/gui/gui-key.h | 1 |
3 files changed, 16 insertions, 8 deletions
diff --git a/src/gui/curses/gui-curses-key.c b/src/gui/curses/gui-curses-key.c index a24a105dd..7c07ffd3e 100644 --- a/src/gui/curses/gui-curses-key.c +++ b/src/gui/curses/gui-curses-key.c @@ -578,19 +578,16 @@ gui_key_read_cb (const void *pointer, void *data, int fd) /* remove the code for end of bracketed paste (ESC[201~) */ gui_key_buffer_remove (pos, GUI_KEY_BRACKETED_PASTE_LENGTH); - /* remove final newline (if needed) */ - gui_key_paste_remove_newline (); - - /* replace tabs by spaces */ - gui_key_paste_replace_tabs (); - /* stop bracketed mode */ gui_key_paste_bracketed_timer_remove (); gui_key_paste_bracketed_stop (); /* if paste confirmation not displayed, flush buffer now */ if (!gui_key_paste_pending) + { + gui_key_paste_finish (); gui_key_flush (1); + } } } diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c index 5455b6d13..30e30a8e0 100644 --- a/src/gui/gui-key.c +++ b/src/gui/gui-key.c @@ -2841,13 +2841,22 @@ gui_key_paste_replace_tabs () void gui_key_paste_start () { - gui_key_paste_remove_newline (); - gui_key_paste_replace_tabs (); gui_key_paste_pending = 1; gui_input_paste_pending_signal (); } /* + * Finishes paste of text. Does necessary modifications before flush of text. + */ + +void +gui_key_paste_finish () +{ + gui_key_paste_remove_newline (); + gui_key_paste_replace_tabs (); +} + +/* * Returns real number of lines in buffer. * * Returns number of lines (lines+1 if last key is not return). @@ -3008,6 +3017,7 @@ gui_key_paste_accept () gui_key_paste_pending = 0; gui_input_paste_pending_signal (); + gui_key_paste_finish (); } /* diff --git a/src/gui/gui-key.h b/src/gui/gui-key.h index 4684c8301..e767c6150 100644 --- a/src/gui/gui-key.h +++ b/src/gui/gui-key.h @@ -135,6 +135,7 @@ extern void gui_key_buffer_remove (int index, int number); extern void gui_key_paste_remove_newline (); extern void gui_key_paste_replace_tabs (); extern void gui_key_paste_start (); +extern void gui_key_paste_finish (); extern int gui_key_get_paste_lines (); extern int gui_key_paste_check (int bracketed_paste); extern void gui_key_paste_bracketed_timer_remove (); |