1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-05 17:23:15 +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
+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;
}
}
/*