mirror of
https://github.com/weechat/weechat.git
synced 2026-07-03 16:23:14 +02:00
core: add optional argument "lowest", "highest" or level mask in command /input hotlist_clear
This commit is contained in:
+31
-3
@@ -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 ();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user