mirror of
https://github.com/weechat/weechat.git
synced 2026-07-10 03:33:12 +02:00
core: add option weechat.look.buffer_position
The value of option can be: - "end": buffer is added after the end of list (number = last number + 1) - "first_gap": buffer is added at first number available in the list (after the end of list if no number is available)
This commit is contained in:
@@ -86,6 +86,7 @@ struct t_config_option *config_look_bar_more_up;
|
||||
struct t_config_option *config_look_bar_more_down;
|
||||
struct t_config_option *config_look_buffer_auto_renumber;
|
||||
struct t_config_option *config_look_buffer_notify_default;
|
||||
struct t_config_option *config_look_buffer_position;
|
||||
struct t_config_option *config_look_buffer_search_case_sensitive;
|
||||
struct t_config_option *config_look_buffer_search_force_default;
|
||||
struct t_config_option *config_look_buffer_search_regex;
|
||||
@@ -2008,6 +2009,15 @@ config_weechat_init_options ()
|
||||
"none=never display in hotlist"),
|
||||
"none|highlight|message|all", 0, 0, "all", NULL, 0,
|
||||
NULL, NULL, &config_change_buffer_notify_default, NULL, NULL, NULL);
|
||||
config_look_buffer_position = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"buffer_position", "integer",
|
||||
N_("position of a new buffer: end = after the end of list (number = "
|
||||
"last number + 1) (default), first_gap = at first available "
|
||||
"number in the list (after the end of list if no number is "
|
||||
"available); this option is used only if the buffer has no layout "
|
||||
"number"),
|
||||
"end|first_gap", 0, 0, "end", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
config_look_buffer_search_case_sensitive = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"buffer_search_case_sensitive", "boolean",
|
||||
|
||||
@@ -37,6 +37,12 @@ enum t_config_look_align_end_of_lines
|
||||
CONFIG_LOOK_ALIGN_END_OF_LINES_MESSAGE,
|
||||
};
|
||||
|
||||
enum t_config_look_buffer_position
|
||||
{
|
||||
CONFIG_LOOK_BUFFER_POSITION_END = 0,
|
||||
CONFIG_LOOK_BUFFER_POSITION_FIRST_GAP,
|
||||
};
|
||||
|
||||
enum t_config_look_buffer_search_where
|
||||
{
|
||||
CONFIG_LOOK_BUFFER_SEARCH_PREFIX = 0,
|
||||
@@ -110,6 +116,7 @@ extern struct t_config_option *config_look_bar_more_up;
|
||||
extern struct t_config_option *config_look_bar_more_down;
|
||||
extern struct t_config_option *config_look_buffer_auto_renumber;
|
||||
extern struct t_config_option *config_look_buffer_notify_default;
|
||||
extern struct t_config_option *config_look_buffer_position;
|
||||
extern struct t_config_option *config_look_buffer_search_case_sensitive;
|
||||
extern struct t_config_option *config_look_buffer_search_force_default;
|
||||
extern struct t_config_option *config_look_buffer_search_regex;
|
||||
|
||||
+50
-9
@@ -313,7 +313,11 @@ gui_buffer_notify_set_all ()
|
||||
}
|
||||
|
||||
/*
|
||||
* Searches for position of buffer in list (to keep buffers sorted by number).
|
||||
* Searches for position of buffer in list using its layout number
|
||||
* (to keep buffers sorted by number).
|
||||
*
|
||||
* Returns the pointer to the buffer that will be after the new buffer in list.
|
||||
* Returns NULL if position is undefined.
|
||||
*/
|
||||
|
||||
struct t_gui_buffer *
|
||||
@@ -321,7 +325,7 @@ gui_buffer_find_pos (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
/* if no number is asked by layout, then add to the end by default */
|
||||
/* if no number is asked by layout, position is undefined */
|
||||
if (buffer->layout_number < 1)
|
||||
return NULL;
|
||||
|
||||
@@ -342,7 +346,7 @@ gui_buffer_find_pos (struct t_gui_buffer *buffer)
|
||||
}
|
||||
}
|
||||
|
||||
/* position not found, add to the end */
|
||||
/* position not found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -375,17 +379,54 @@ gui_buffer_shift_numbers (struct t_gui_buffer *buffer)
|
||||
void
|
||||
gui_buffer_insert (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_buffer *pos_buffer;
|
||||
struct t_gui_buffer *pos_buffer, *ptr_buffer;
|
||||
int force_number;
|
||||
|
||||
force_number = 0;
|
||||
|
||||
pos_buffer = gui_buffer_find_pos (buffer);
|
||||
|
||||
/*
|
||||
* if position was not forced by layout and that buffer position is set
|
||||
* to "first gap", search for the first available number in the list
|
||||
* (if there is not, buffer will be added to the end of list)
|
||||
*/
|
||||
if (!pos_buffer
|
||||
&& (CONFIG_INTEGER(config_look_buffer_position) == CONFIG_LOOK_BUFFER_POSITION_FIRST_GAP))
|
||||
{
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
if (ptr_buffer->prev_buffer)
|
||||
{
|
||||
if (ptr_buffer->number > ptr_buffer->prev_buffer->number + 1)
|
||||
{
|
||||
pos_buffer = ptr_buffer;
|
||||
force_number = ptr_buffer->prev_buffer->number + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (ptr_buffer->number > 1)
|
||||
{
|
||||
pos_buffer = ptr_buffer;
|
||||
force_number = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pos_buffer)
|
||||
{
|
||||
/* add buffer into the list (before position found) */
|
||||
if (!CONFIG_BOOLEAN(config_look_buffer_auto_renumber)
|
||||
&& (buffer->layout_number > 0)
|
||||
&& (buffer->layout_number < pos_buffer->number)
|
||||
&& (!pos_buffer->prev_buffer
|
||||
|| (buffer->layout_number > pos_buffer->prev_buffer->number)))
|
||||
if (force_number > 0)
|
||||
{
|
||||
buffer->number = force_number;
|
||||
}
|
||||
else if (!CONFIG_BOOLEAN(config_look_buffer_auto_renumber)
|
||||
&& (buffer->layout_number > 0)
|
||||
&& (buffer->layout_number < pos_buffer->number)
|
||||
&& (!pos_buffer->prev_buffer
|
||||
|| (buffer->layout_number > pos_buffer->prev_buffer->number)))
|
||||
{
|
||||
buffer->number = buffer->layout_number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user