mirror of
https://github.com/weechat/weechat.git
synced 2026-06-28 05:46:38 +02:00
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.
This commit is contained in:
committed by
Sébastien Helleu
parent
99f6f9e454
commit
37decf3a7c
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-2
@@ -2841,12 +2841,21 @@ 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.
|
||||
*
|
||||
@@ -3008,6 +3017,7 @@ gui_key_paste_accept ()
|
||||
|
||||
gui_key_paste_pending = 0;
|
||||
gui_input_paste_pending_signal ();
|
||||
gui_key_paste_finish ();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
Reference in New Issue
Block a user