mirror of
https://github.com/weechat/weechat.git
synced 2026-07-04 08:43:13 +02:00
Add option "get" for command /buffer, add completions with buffer properties
This commit is contained in:
@@ -68,6 +68,33 @@ int gui_buffers_visited_frozen = 0; /* 1 to forbid list updates */
|
||||
char *gui_buffer_notify_string[GUI_BUFFER_NUM_NOTIFY] =
|
||||
{ "none", "highlight", "message", "all" };
|
||||
|
||||
char *gui_buffer_properties_get_integer[] =
|
||||
{ "number", "layout_number", "type", "notify", "num_displayed", "active",
|
||||
"print_hooks_enabled", "lines_hidden", "prefix_max_length",
|
||||
"time_for_each_line", "nicklist", "nicklist_case_sensitive",
|
||||
"nicklist_max_length", "nicklist_display_groups", "nicklist_visible_count",
|
||||
"input", "input_get_unknown_commands", "input_size", "input_length",
|
||||
"input_pos", "input_1st_display", "num_history", "text_search",
|
||||
"text_search_exact", "text_search_found",
|
||||
NULL
|
||||
};
|
||||
char *gui_buffer_properties_get_string[] =
|
||||
{ "plugin", "name", "short_name", "title", "input", "text_search_input",
|
||||
"highlight_words", "highlight_tags",
|
||||
NULL
|
||||
};
|
||||
char *gui_buffer_properties_get_pointer[] =
|
||||
{ "plugin",
|
||||
NULL
|
||||
};
|
||||
char *gui_buffer_properties_set[] =
|
||||
{ "unread", "display", "print_hooks_enabled", "number", "name", "short_name",
|
||||
"type", "notify", "title", "time_for_each_line", "nicklist",
|
||||
"nicklist_case_sensitive", "nicklist_display_groups", "highlight_words",
|
||||
"highlight_tags", "input", "input_pos", "input_get_unknown_commands",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* gui_buffer_find_pos: find position for buffer in list
|
||||
@@ -639,6 +666,29 @@ gui_buffer_set_plugin_for_upgrade (char *name, struct t_weechat_plugin *plugin)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_property_in_list: return 1 if buffer property name is in a list
|
||||
* 0 if property is not in list
|
||||
*/
|
||||
|
||||
int
|
||||
gui_buffer_property_in_list (char *properties[], char *property)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!properties || !property)
|
||||
return 0;
|
||||
|
||||
for (i = 0; properties[i]; i++)
|
||||
{
|
||||
if (strcmp (properties[i], property) == 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* property not found in list */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_get_integer: get a buffer property as integer
|
||||
*/
|
||||
|
||||
@@ -186,6 +186,10 @@ extern int gui_buffers_visited_index;
|
||||
extern int gui_buffers_visited_count;
|
||||
extern int gui_buffers_visited_frozen;
|
||||
extern char *gui_buffer_notify_string[];
|
||||
extern char *gui_buffer_properties_get_integer[];
|
||||
extern char *gui_buffer_properties_get_string[];
|
||||
extern char *gui_buffer_properties_get_pointer[];
|
||||
extern char *gui_buffer_properties_set[];
|
||||
|
||||
/* buffer functions */
|
||||
|
||||
@@ -206,6 +210,7 @@ extern char *gui_buffer_string_replace_local_var (struct t_gui_buffer *buffer,
|
||||
const char *string);
|
||||
extern void gui_buffer_set_plugin_for_upgrade (char *name,
|
||||
struct t_weechat_plugin *plugin);
|
||||
extern int gui_buffer_property_in_list (char *properties[], char *property);
|
||||
extern int gui_buffer_get_integer (struct t_gui_buffer *buffer,
|
||||
const char *property);
|
||||
extern const char *gui_buffer_get_string (struct t_gui_buffer *buffer,
|
||||
|
||||
+92
-16
@@ -498,6 +498,76 @@ gui_completion_list_add_buffers_plugins_names_cb (void *data,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_completion_list_add_buffer_properties_set_cb: add buffer properties
|
||||
* (that can be set) to
|
||||
* completion list
|
||||
*/
|
||||
|
||||
int
|
||||
gui_completion_list_add_buffer_properties_set_cb (void *data,
|
||||
const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
for (i = 0; gui_buffer_properties_set[i]; i++)
|
||||
{
|
||||
gui_completion_list_add (completion,
|
||||
gui_buffer_properties_set[i],
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_completion_list_add_buffer_properties_get_cb: add buffer properties
|
||||
* (that can be read) to
|
||||
* completion list
|
||||
*/
|
||||
|
||||
int
|
||||
gui_completion_list_add_buffer_properties_get_cb (void *data,
|
||||
const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
for (i = 0; gui_buffer_properties_get_integer[i]; i++)
|
||||
{
|
||||
gui_completion_list_add (completion,
|
||||
gui_buffer_properties_get_integer[i],
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
for (i = 0; gui_buffer_properties_get_string[i]; i++)
|
||||
{
|
||||
gui_completion_list_add (completion,
|
||||
gui_buffer_properties_get_string[i],
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
for (i = 0; gui_buffer_properties_get_pointer[i]; i++)
|
||||
{
|
||||
gui_completion_list_add (completion,
|
||||
gui_buffer_properties_get_pointer[i],
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_completion_list_add_config_files_cb: add config files to completion list
|
||||
*/
|
||||
@@ -2210,55 +2280,61 @@ gui_completion_print_log (struct t_gui_completion *completion)
|
||||
void
|
||||
gui_completion_init ()
|
||||
{
|
||||
hook_completion (NULL, "buffers_names", /* it was %b */
|
||||
hook_completion (NULL, "buffers_names", /* formerly "%b" */
|
||||
N_("names of buffers"),
|
||||
&gui_completion_list_add_buffers_names_cb, NULL);
|
||||
hook_completion (NULL, "buffers_numbers",
|
||||
N_("numbers of buffers"),
|
||||
&gui_completion_list_add_buffers_numbers_cb, NULL);
|
||||
hook_completion (NULL, "buffers_plugins_names", /* it was %B */
|
||||
hook_completion (NULL, "buffers_plugins_names", /* formerly "%B" */
|
||||
N_("names of buffers (including plugins names)"),
|
||||
&gui_completion_list_add_buffers_plugins_names_cb, NULL);
|
||||
hook_completion (NULL, "config_files", /* it was %c */
|
||||
hook_completion (NULL, "buffer_properties_set",
|
||||
N_("properties that can be set on a buffer"),
|
||||
&gui_completion_list_add_buffer_properties_set_cb, NULL);
|
||||
hook_completion (NULL, "buffer_properties_get",
|
||||
N_("properties that can be read on a buffer"),
|
||||
&gui_completion_list_add_buffer_properties_get_cb, NULL);
|
||||
hook_completion (NULL, "config_files", /* formerly "%c" */
|
||||
N_("configuration files"),
|
||||
&gui_completion_list_add_config_files_cb, NULL);
|
||||
hook_completion (NULL, "filename", /* it was %f */
|
||||
hook_completion (NULL, "filename", /* formerly "%f" */
|
||||
N_("filename"),
|
||||
&gui_completion_list_add_filename_cb, NULL);
|
||||
hook_completion (NULL, "filters_names", /* it was %F */
|
||||
hook_completion (NULL, "filters_names", /* formerly "%F" */
|
||||
N_("names of filters"),
|
||||
&gui_completion_list_add_filters_cb, NULL);
|
||||
hook_completion (NULL, "commands", /* it was %h */
|
||||
hook_completion (NULL, "commands", /* formerly "%h" */
|
||||
N_("commands (weechat and plugins)"),
|
||||
&gui_completion_list_add_commands_cb, NULL);
|
||||
hook_completion (NULL, "infos", /* it was %i */
|
||||
hook_completion (NULL, "infos", /* formerly "%i" */
|
||||
N_("names of infos hooked"),
|
||||
&gui_completion_list_add_infos_cb, NULL);
|
||||
hook_completion (NULL, "infolists", /* it was %I */
|
||||
hook_completion (NULL, "infolists", /* formerly "%I" */
|
||||
N_("names of infolists hooked"),
|
||||
&gui_completion_list_add_infolists_cb, NULL);
|
||||
hook_completion (NULL, "nicks", /* it was %n */
|
||||
hook_completion (NULL, "nicks", /* formerly "%n" */
|
||||
N_("nicks in nicklist of current buffer"),
|
||||
&gui_completion_list_add_nicks_cb, NULL);
|
||||
hook_completion (NULL, "config_options", /* it was %o */
|
||||
hook_completion (NULL, "config_options", /* formerly "%o" */
|
||||
N_("configuration options"),
|
||||
&gui_completion_list_add_config_options_cb, NULL);
|
||||
hook_completion (NULL, "plugins_names", /* it was %p */
|
||||
hook_completion (NULL, "plugins_names", /* formerly "%p" */
|
||||
N_("names of plugins"),
|
||||
&gui_completion_list_add_plugins_cb, NULL);
|
||||
hook_completion (NULL, "plugins_commands", /* it was %P */
|
||||
hook_completion (NULL, "plugins_commands", /* formerly "%P" */
|
||||
N_("commands defined by plugins"),
|
||||
&gui_completion_list_add_plugins_commands_cb, NULL);
|
||||
hook_completion (NULL, "bars_names", /* it was %r */
|
||||
hook_completion (NULL, "bars_names", /* formerly "%r" */
|
||||
N_("names of bars"),
|
||||
&gui_completion_list_add_bars_names_cb, NULL);
|
||||
hook_completion (NULL, "config_option_values", /* it was %v */
|
||||
hook_completion (NULL, "config_option_values", /* formerly "%v" */
|
||||
N_("values for a configuration option"),
|
||||
&gui_completion_list_add_config_option_values_cb, NULL);
|
||||
hook_completion (NULL, "weechat_commands", /* it was %w */
|
||||
hook_completion (NULL, "weechat_commands", /* formerly "%w" */
|
||||
N_("weechat commands"),
|
||||
&gui_completion_list_add_weechat_commands_cb, NULL);
|
||||
hook_completion (NULL, "proxies_names", /* it was %y */
|
||||
hook_completion (NULL, "proxies_names", /* formerly "%y" */
|
||||
N_("names of proxies"),
|
||||
&gui_completion_list_add_proxies_names_cb, NULL);
|
||||
hook_completion (NULL, "proxies_options",
|
||||
|
||||
Reference in New Issue
Block a user