1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-30 14:56:39 +02:00

core: add optional argument "lowest", "highest" or level mask in command /input hotlist_clear

This commit is contained in:
Sébastien Helleu
2016-08-16 21:22:28 +02:00
parent ebb43c4a54
commit a01ecb276f
27 changed files with 357 additions and 217 deletions
+22 -16
View File
@@ -3047,7 +3047,7 @@ COMMAND_CALLBACK(input)
else if (string_strcasecmp (argv[1], "jump_next_visited_buffer") == 0)
gui_input_jump_next_visited_buffer (buffer);
else if (string_strcasecmp (argv[1], "hotlist_clear") == 0)
gui_input_hotlist_clear (buffer);
gui_input_hotlist_clear (buffer, (argc > 2) ? argv[2] : NULL);
else if (string_strcasecmp (argv[1], "grab_key") == 0)
gui_input_grab_key (buffer, 0, (argc > 2) ? argv[2] : NULL);
else if (string_strcasecmp (argv[1], "grab_key_command") == 0)
@@ -7412,7 +7412,10 @@ command_init ()
"last jump to a buffer)\n"
" jump_previously_visited_buffer: jump to previously visited buffer\n"
" jump_next_visited_buffer: jump to next visited buffer\n"
" hotlist_clear: clear hotlist\n"
" hotlist_clear: clear hotlist (optional argument: \"lowest\" to "
"clear only lowest level in hotlist, \"highest\" to clear only "
"highest level in hotlist, or level mask: integer which is a "
"combination of 1=join/part, 2=message, 4=private, 8=highlight)\n"
" grab_key: grab a key (optional argument: delay for end of grab, "
"default is 500 milliseconds)\n"
" grab_key_command: grab a key with its associated command (optional "
@@ -7431,20 +7434,23 @@ command_init ()
" paste_stop: stop paste (bracketed paste mode)\n"
"\n"
"This command is used by key bindings or plugins."),
"return|complete_next|complete_previous|search_text_here|search_text|"
"search_switch_case|search_switch_regex|search_switch_where|"
"search_previous|search_next|search_stop_here|search_stop|"
"delete_previous_char|delete_next_char|delete_previous_word|"
"delete_next_word|delete_beginning_of_line|delete_end_of_line|"
"delete_line|clipboard_paste|transpose_chars|undo|redo|"
"move_beginning_of_line|move_end_of_line|move_previous_char|"
"move_next_char|move_previous_word|move_next_word|history_previous|"
"history_next|history_global_previous|history_global_next|jump_smart|"
"jump_last_buffer_displayed|jump_previously_visited_buffer|"
"jump_next_visited_buffer|hotlist_clear|grab_key|grab_key_command|"
"grab_mouse|grab_mouse_area|set_unread|set_unread_current_buffer|"
"switch_active_buffer|switch_active_buffer_previous|"
"zoom_merged_buffer|insert|send|paste_start|paste_stop",
"return || complete_next || complete_previous || search_text_here || "
"search_text || search_switch_case || search_switch_regex || "
"search_switch_where || search_previous || search_next || "
"search_stop_here || search_stop || delete_previous_char || "
"delete_next_char || delete_previous_word || delete_next_word || "
"delete_beginning_of_line || delete_end_of_line || delete_line || "
"clipboard_paste || transpose_chars || undo || redo || "
"move_beginning_of_line || move_end_of_line || move_previous_char || "
"move_next_char || move_previous_word || move_next_word || "
"history_previous || history_next || history_global_previous || "
"history_global_next || jump_smart || jump_last_buffer_displayed || "
"jump_previously_visited_buffer || jump_next_visited_buffer || "
"hotlist_clear 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|lowest|highest || "
"grab_key || grab_key_command || grab_mouse || grab_mouse_area || "
"set_unread || set_unread_current_buffer || switch_active_buffer || "
"switch_active_buffer_previous || zoom_merged_buffer || insert || "
"send || paste_start || paste_stop",
&command_input, NULL, NULL);
hook_command (
NULL, "key",
+1 -1
View File
@@ -2813,7 +2813,7 @@ config_weechat_init_options ()
N_("level for displaying names in hotlist (combination "
"of: 1=join/part, 2=message, 4=private, 8=highlight, "
"for example: 12=private+highlight)"),
NULL, 1, 15, "12", NULL, 0,
NULL, 1, GUI_HOTLIST_MASK_MAX, "12", NULL, 0,
NULL, NULL, NULL,
&config_change_buffer_content, NULL, NULL,
NULL, NULL, NULL);
+2 -2
View File
@@ -723,7 +723,7 @@ upgrade_weechat_read_hotlist (struct t_infolist *infolist)
if (!hotlist_reset)
{
gui_hotlist_clear ();
gui_hotlist_clear (GUI_HOTLIST_MASK_MAX);
hotlist_reset = 1;
}
plugin_name = infolist_string (infolist, "plugin_name");
@@ -846,7 +846,7 @@ upgrade_weechat_load ()
upgrade_file_close (upgrade_file);
if (!hotlist_reset)
gui_hotlist_clear ();
gui_hotlist_clear (GUI_HOTLIST_MASK_MAX);
gui_color_buffer_assign ();
gui_color_buffer_display ();
+31 -3
View File
@@ -470,13 +470,41 @@ gui_hotlist_resort ()
/*
* Clears hotlist.
*
* Argument "level_mask" is a combination of:
* 1 = join/part
* 2 = message
* 4 = private
* 8 = highlight
*
* So for example :
* 1 = clear only join/part
* 12 = clear only private and highlight
* 15 = clear whole hotlist
*/
void
gui_hotlist_clear ()
gui_hotlist_clear (int level_mask)
{
gui_hotlist_free_all (&gui_hotlist, &last_gui_hotlist);
gui_hotlist_changed_signal ();
struct t_gui_hotlist *ptr_hotlist, *ptr_next_hotlist;
int hotlist_changed;
hotlist_changed = 0;
ptr_hotlist = gui_hotlist;
while (ptr_hotlist)
{
ptr_next_hotlist = ptr_hotlist->next_hotlist;
if (level_mask & (1 << ptr_hotlist->priority))
{
gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, ptr_hotlist);
hotlist_changed = 1;
}
ptr_hotlist = ptr_next_hotlist;
}
if (hotlist_changed)
gui_hotlist_changed_signal ();
}
/*
+3 -1
View File
@@ -34,6 +34,8 @@ enum t_gui_hotlist_priority
#define GUI_HOTLIST_MIN 0
#define GUI_HOTLIST_MAX (GUI_HOTLIST_NUM_PRIORITIES - 1)
#define GUI_HOTLIST_MASK_MAX ((1 << GUI_HOTLIST_NUM_PRIORITIES) - 1)
struct t_gui_hotlist
{
enum t_gui_hotlist_priority priority; /* 0=crappy msg (join/part), */
@@ -58,7 +60,7 @@ extern struct t_gui_hotlist *gui_hotlist_add (struct t_gui_buffer *buffer,
enum t_gui_hotlist_priority priority,
struct timeval *creation_time);
extern void gui_hotlist_resort ();
extern void gui_hotlist_clear ();
extern void gui_hotlist_clear (int level_mask);
extern void gui_hotlist_remove_buffer (struct t_gui_buffer *buffer,
int force_remove_buffer);
extern struct t_hdata *gui_hotlist_hdata_hotlist_cb (const void *pointer,
+58 -3
View File
@@ -1540,10 +1540,65 @@ gui_input_jump_next_visited_buffer (struct t_gui_buffer *buffer)
*/
void
gui_input_hotlist_clear (struct t_gui_buffer *buffer)
gui_input_hotlist_clear (struct t_gui_buffer *buffer,
const char *str_level_mask)
{
gui_hotlist_clear ();
gui_hotlist_initial_buffer = buffer;
long level_mask;
char *error;
struct t_gui_hotlist *ptr_hotlist;
int priority;
if (str_level_mask)
{
if (strcmp (str_level_mask, "lowest") == 0)
{
/* clear only lowest priority currently in hotlist */
priority = GUI_HOTLIST_MAX + 1;
for (ptr_hotlist = gui_hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
{
if ((int)ptr_hotlist->priority < priority)
priority = ptr_hotlist->priority;
}
if (priority <= GUI_HOTLIST_MAX)
{
gui_hotlist_clear (1 << priority);
gui_hotlist_initial_buffer = buffer;
}
}
else if (strcmp (str_level_mask, "highest") == 0)
{
/* clear only highest priority currently in hotlist */
priority = GUI_HOTLIST_MIN - 1;
for (ptr_hotlist = gui_hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
{
if ((int)ptr_hotlist->priority > priority)
priority = ptr_hotlist->priority;
}
if (priority >= GUI_HOTLIST_MIN)
{
gui_hotlist_clear (1 << priority);
gui_hotlist_initial_buffer = buffer;
}
}
else
{
/* clear hotlist using a mask of levels */
error = NULL;
level_mask = strtol (str_level_mask, &error, 10);
if (error && !error[0] && (level_mask > 0))
{
gui_hotlist_clear ((int)level_mask);
gui_hotlist_initial_buffer = buffer;
}
}
}
else
{
gui_hotlist_clear (GUI_HOTLIST_MASK_MAX);
gui_hotlist_initial_buffer = buffer;
}
}
/*
+2 -1
View File
@@ -75,7 +75,8 @@ extern void gui_input_jump_smart (struct t_gui_buffer *buffer);
extern void gui_input_jump_last_buffer_displayed (struct t_gui_buffer *buffer);
extern void gui_input_jump_previously_visited_buffer (struct t_gui_buffer *buffer);
extern void gui_input_jump_next_visited_buffer (struct t_gui_buffer *buffer);
extern void gui_input_hotlist_clear (struct t_gui_buffer *buffer);
extern void gui_input_hotlist_clear (struct t_gui_buffer *buffer,
const char *level_mask);
extern void gui_input_grab_key (struct t_gui_buffer *buffer, int command,
const char *delay);
extern void gui_input_grab_mouse (struct t_gui_buffer *buffer, int area);