summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2022-12-31 10:40:00 +0100
committerSébastien Helleu <flashcode@flashtux.org>2022-12-31 10:40:00 +0100
commit73bac5491bf1cecf7f550b9b1b985e3fcd0faf4f (patch)
treeb41ea9ddefc60ae2bed679228968167ec077a206 /src/gui
parent05839983d45af29a383a8e702753eb9617b4e260 (diff)
downloadweechat-73bac5491bf1cecf7f550b9b1b985e3fcd0faf4f.zip
core: move function gui_input_move_to_buffer to gui-buffer.c
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/curses/gui-curses-window.c5
-rw-r--r--src/gui/gui-buffer.c68
-rw-r--r--src/gui/gui-buffer.h2
-rw-r--r--src/gui/gui-input.c68
-rw-r--r--src/gui/gui-input.h2
5 files changed, 72 insertions, 73 deletions
diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c
index 416db4c0c..35fa5746a 100644
--- a/src/gui/curses/gui-curses-window.c
+++ b/src/gui/curses/gui-curses-window.c
@@ -48,7 +48,6 @@
#include "../gui-color.h"
#include "../gui-cursor.h"
#include "../gui-hotlist.h"
-#include "../gui-input.h"
#include "../gui-key.h"
#include "../gui-layout.h"
#include "../gui-line.h"
@@ -1365,7 +1364,7 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
window->buffer->lines->last_read_line = window->buffer->lines->last_line;
}
- gui_input_move_to_buffer (old_buffer, window->buffer);
+ gui_buffer_input_move_to_buffer (old_buffer, window->buffer);
if (old_buffer != buffer)
{
@@ -1407,7 +1406,7 @@ gui_window_switch (struct t_gui_window *window)
old_window->refresh_needed = 1;
- gui_input_move_to_buffer (old_window->buffer, window->buffer);
+ gui_buffer_input_move_to_buffer (old_window->buffer, window->buffer);
(void) hook_signal_send ("window_switch",
WEECHAT_HOOK_SIGNAL_POINTER, gui_current_window);
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index f871e5593..b4f0d9ce0 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -4391,6 +4391,74 @@ gui_buffer_undo_free_all (struct t_gui_buffer *buffer)
}
/*
+ * Moves buffer input content and undo data to another buffer.
+ */
+
+void
+gui_buffer_input_move_to_buffer (struct t_gui_buffer *from_buffer,
+ struct t_gui_buffer *to_buffer)
+{
+ int is_command;
+
+ /*
+ * move of input is allowed if:
+ * - 2 buffers are different
+ * - input_share is not set to "none"
+ * - input buffer in first buffer is not empty
+ */
+ if (!from_buffer || !to_buffer || (from_buffer == to_buffer)
+ || (CONFIG_INTEGER(config_look_input_share) == CONFIG_LOOK_INPUT_SHARE_NONE)
+ || !from_buffer->input_buffer || !from_buffer->input_buffer[0])
+ return;
+
+ /*
+ * if input is command and that only text is allowed,
+ * or if input is text and that only command is allowed,
+ * then do nothing
+ */
+ is_command = (string_input_for_buffer (from_buffer->input_buffer) == NULL) ? 1 : 0;
+ if ((is_command && (CONFIG_INTEGER(config_look_input_share) == CONFIG_LOOK_INPUT_SHARE_TEXT))
+ || (!is_command && (CONFIG_INTEGER(config_look_input_share) == CONFIG_LOOK_INPUT_SHARE_COMMANDS)))
+ return;
+
+ /*
+ * if overwrite is off and that input of target buffer is not empty,
+ * then do nothing
+ */
+ if ((!CONFIG_BOOLEAN(config_look_input_share_overwrite))
+ && to_buffer->input_buffer && to_buffer->input_buffer[0])
+ return;
+
+ /* move input_buffer */
+ if (to_buffer->input_buffer)
+ free (to_buffer->input_buffer);
+ to_buffer->input_buffer = from_buffer->input_buffer;
+ to_buffer->input_buffer_alloc = from_buffer->input_buffer_alloc;
+ to_buffer->input_buffer_size = from_buffer->input_buffer_size;
+ to_buffer->input_buffer_length = from_buffer->input_buffer_length;
+ to_buffer->input_buffer_pos = from_buffer->input_buffer_pos;
+ to_buffer->input_buffer_1st_display = from_buffer->input_buffer_1st_display;
+ gui_buffer_input_buffer_init (from_buffer);
+
+ /* move undo data */
+ gui_buffer_undo_free_all (to_buffer);
+ (to_buffer->input_undo_snap)->data = (from_buffer->input_undo_snap)->data;
+ (to_buffer->input_undo_snap)->pos = (from_buffer->input_undo_snap)->pos;
+ to_buffer->input_undo = from_buffer->input_undo;
+ to_buffer->last_input_undo = from_buffer->last_input_undo;
+ to_buffer->ptr_input_undo = from_buffer->ptr_input_undo;
+ to_buffer->input_undo_count = from_buffer->input_undo_count;
+ (from_buffer->input_undo_snap)->data = NULL;
+ (from_buffer->input_undo_snap)->pos = 0;
+ from_buffer->input_undo = NULL;
+ from_buffer->last_input_undo = NULL;
+ from_buffer->ptr_input_undo = NULL;
+ from_buffer->input_undo_count = 0;
+
+ gui_completion_stop (from_buffer->completion);
+}
+
+/*
* Searches for a visited buffer in list of visited buffers.
*/
diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h
index d7302566d..c37683240 100644
--- a/src/gui/gui-buffer.h
+++ b/src/gui/gui-buffer.h
@@ -383,6 +383,8 @@ extern void gui_buffer_undo_add (struct t_gui_buffer *buffer);
extern void gui_buffer_undo_free (struct t_gui_buffer *buffer,
struct t_gui_input_undo *undo);
extern void gui_buffer_undo_free_all (struct t_gui_buffer *buffer);
+extern void gui_buffer_input_move_to_buffer (struct t_gui_buffer *from_buffer,
+ struct t_gui_buffer *to_buffer);
extern struct t_gui_buffer_visited *gui_buffer_visited_search_by_number (int number);
extern void gui_buffer_visited_remove (struct t_gui_buffer_visited *buffer_visited);
extern void gui_buffer_visited_remove_by_buffer (struct t_gui_buffer *buffer);
diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c
index 11e11ccd7..387aa72cb 100644
--- a/src/gui/gui-input.c
+++ b/src/gui/gui-input.c
@@ -277,74 +277,6 @@ gui_input_insert_string (struct t_gui_buffer *buffer, const char *string)
}
/*
- * Moves input content and undo data from a buffer to another buffer.
- */
-
-void
-gui_input_move_to_buffer (struct t_gui_buffer *from_buffer,
- struct t_gui_buffer *to_buffer)
-{
- int is_command;
-
- /*
- * move of input is allowed if:
- * - 2 buffers are different
- * - input_share is not set to "none"
- * - input buffer in first buffer is not empty
- */
- if (!from_buffer || !to_buffer || (from_buffer == to_buffer)
- || (CONFIG_INTEGER(config_look_input_share) == CONFIG_LOOK_INPUT_SHARE_NONE)
- || !from_buffer->input_buffer || !from_buffer->input_buffer[0])
- return;
-
- /*
- * if input is command and that only text is allowed,
- * or if input is text and that only command is allowed,
- * then do nothing
- */
- is_command = (string_input_for_buffer (from_buffer->input_buffer) == NULL) ? 1 : 0;
- if ((is_command && (CONFIG_INTEGER(config_look_input_share) == CONFIG_LOOK_INPUT_SHARE_TEXT))
- || (!is_command && (CONFIG_INTEGER(config_look_input_share) == CONFIG_LOOK_INPUT_SHARE_COMMANDS)))
- return;
-
- /*
- * if overwrite is off and that input of target buffer is not empty,
- * then do nothing
- */
- if ((!CONFIG_BOOLEAN(config_look_input_share_overwrite))
- && to_buffer->input_buffer && to_buffer->input_buffer[0])
- return;
-
- /* move input_buffer */
- if (to_buffer->input_buffer)
- free (to_buffer->input_buffer);
- to_buffer->input_buffer = from_buffer->input_buffer;
- to_buffer->input_buffer_alloc = from_buffer->input_buffer_alloc;
- to_buffer->input_buffer_size = from_buffer->input_buffer_size;
- to_buffer->input_buffer_length = from_buffer->input_buffer_length;
- to_buffer->input_buffer_pos = from_buffer->input_buffer_pos;
- to_buffer->input_buffer_1st_display = from_buffer->input_buffer_1st_display;
- gui_buffer_input_buffer_init (from_buffer);
-
- /* move undo data */
- gui_buffer_undo_free_all (to_buffer);
- (to_buffer->input_undo_snap)->data = (from_buffer->input_undo_snap)->data;
- (to_buffer->input_undo_snap)->pos = (from_buffer->input_undo_snap)->pos;
- to_buffer->input_undo = from_buffer->input_undo;
- to_buffer->last_input_undo = from_buffer->last_input_undo;
- to_buffer->ptr_input_undo = from_buffer->ptr_input_undo;
- to_buffer->input_undo_count = from_buffer->input_undo_count;
- (from_buffer->input_undo_snap)->data = NULL;
- (from_buffer->input_undo_snap)->pos = 0;
- from_buffer->input_undo = NULL;
- from_buffer->last_input_undo = NULL;
- from_buffer->ptr_input_undo = NULL;
- from_buffer->input_undo_count = 0;
-
- gui_completion_stop (from_buffer->completion);
-}
-
-/*
* Copies string into the internal clipboard.
*/
diff --git a/src/gui/gui-input.h b/src/gui/gui-input.h
index 2e401a6c5..400d97e56 100644
--- a/src/gui/gui-input.h
+++ b/src/gui/gui-input.h
@@ -37,8 +37,6 @@ extern void gui_input_text_changed_modifier_and_signal (struct t_gui_buffer *buf
extern void gui_input_set_pos (struct t_gui_buffer *buffer, int pos);
extern void gui_input_insert_string (struct t_gui_buffer *buffer,
const char *string);
-extern void gui_input_move_to_buffer (struct t_gui_buffer *from_buffer,
- struct t_gui_buffer *to_buffer);
extern void gui_input_clipboard_paste (struct t_gui_buffer *buffer);
extern void gui_input_return (struct t_gui_buffer *buffer);
extern void gui_input_complete_next (struct t_gui_buffer *buffer);