mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 12:56:37 +02:00
core: move function gui_input_move_to_buffer to gui-buffer.c
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -4390,6 +4390,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.
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -276,74 +276,6 @@ gui_input_insert_string (struct t_gui_buffer *buffer, const char *string)
|
||||
free (string_utf8);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1337,6 +1337,16 @@ TEST(GuiBuffer, UndoFreeAll)
|
||||
/* TODO: write tests */
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* gui_buffer_input_move_to_buffer
|
||||
*/
|
||||
|
||||
TEST(GuiBuffer, InputMoveToBuffer)
|
||||
{
|
||||
/* TODO: write tests */
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* gui_buffer_visited_search
|
||||
|
||||
@@ -155,16 +155,6 @@ TEST(GuiInput, InsertString)
|
||||
LONGS_EQUAL(4, gui_buffers->input_buffer_pos);
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* gui_input_move_to_buffer
|
||||
*/
|
||||
|
||||
TEST(GuiInput, MoveToBuffer)
|
||||
{
|
||||
/* TODO: write tests */
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* gui_input_clipboard_copy
|
||||
|
||||
Reference in New Issue
Block a user