mirror of
https://github.com/weechat/weechat.git
synced 2026-06-28 05:46:38 +02:00
core: move /input hotlist actions to new command /hotlist
Actions moved to command `/hotlist`: * `/input hotlist_clear` -> `/hotlist clear` * `/input hotlist_remove_buffer` -> `/hotlist remove` * `/input hotlist_restore_buffer` -> `/hotlist restore` * `/input hotlist_restore_all` -> `/hotlist restore -all`
This commit is contained in:
+64
-20
@@ -3269,6 +3269,43 @@ COMMAND_CALLBACK(history)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for command "/hotlist": manages hotlist.
|
||||
*/
|
||||
|
||||
COMMAND_CALLBACK(hotlist)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) argv_eol;
|
||||
|
||||
COMMAND_MIN_ARGS(2, "");
|
||||
|
||||
if (string_strcasecmp (argv[1], "clear") == 0)
|
||||
{
|
||||
gui_hotlist_clear_level_string (buffer, (argc > 2) ? argv[2] : NULL);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
if (string_strcasecmp (argv[1], "remove") == 0)
|
||||
{
|
||||
gui_hotlist_remove_buffer (buffer, 1);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
if (string_strcasecmp (argv[1], "restore") == 0)
|
||||
{
|
||||
if ((argc > 2) && (string_strcasecmp (argv[2], "-all") == 0))
|
||||
gui_hotlist_restore_all_buffers ();
|
||||
else
|
||||
gui_hotlist_restore_buffer (buffer);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for command "/input": input actions (used by key bindings).
|
||||
*/
|
||||
@@ -3345,14 +3382,6 @@ COMMAND_CALLBACK(input)
|
||||
gui_input_history_global_previous (buffer);
|
||||
else if (string_strcasecmp (argv[1], "history_global_next") == 0)
|
||||
gui_input_history_global_next (buffer);
|
||||
else if (string_strcasecmp (argv[1], "hotlist_clear") == 0)
|
||||
gui_input_hotlist_clear (buffer, (argc > 2) ? argv[2] : NULL);
|
||||
else if (string_strcasecmp (argv[1], "hotlist_remove_buffer") == 0)
|
||||
gui_input_hotlist_remove_buffer (buffer);
|
||||
else if (string_strcasecmp (argv[1], "hotlist_restore_buffer") == 0)
|
||||
gui_input_hotlist_restore_buffer (buffer);
|
||||
else if (string_strcasecmp (argv[1], "hotlist_restore_all") == 0)
|
||||
gui_input_hotlist_restore_all ();
|
||||
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)
|
||||
@@ -3412,6 +3441,18 @@ COMMAND_CALLBACK(input)
|
||||
/* since WeeChat 3.8: "/buffer jump next_visited" */
|
||||
else if (string_strcasecmp (argv[1], "jump_next_visited_buffer") == 0)
|
||||
gui_buffer_jump_next_visited_buffer (gui_current_window);
|
||||
/* since WeeChat 3.8: "/hotlist clear" */
|
||||
else if (string_strcasecmp (argv[1], "hotlist_clear") == 0)
|
||||
gui_hotlist_clear_level_string (buffer, (argc > 2) ? argv[2] : NULL);
|
||||
/* since WeeChat 3.8: "/hotlist remove" */
|
||||
else if (string_strcasecmp (argv[1], "hotlist_remove_buffer") == 0)
|
||||
gui_hotlist_remove_buffer (buffer, 1);
|
||||
/* since WeeChat 3.8: "/hotlist restore" */
|
||||
else if (string_strcasecmp (argv[1], "hotlist_restore_buffer") == 0)
|
||||
gui_hotlist_restore_buffer (buffer);
|
||||
/* since WeeChat 3.8: "/hotlist restore -all" */
|
||||
else if (string_strcasecmp (argv[1], "hotlist_restore_all") == 0)
|
||||
gui_hotlist_restore_all_buffers ();
|
||||
else
|
||||
COMMAND_ERROR;
|
||||
}
|
||||
@@ -8023,6 +8064,21 @@ command_init ()
|
||||
"value: number of history entries to show"),
|
||||
"clear",
|
||||
&command_history, NULL, NULL);
|
||||
hook_command (
|
||||
NULL, "hotlist",
|
||||
N_("manage hotlist"),
|
||||
N_("clear [<level>] || remove || restore [-all]"),
|
||||
N_("clear: clear hotlist\n"
|
||||
"level: \"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"
|
||||
"remove: remove current buffer from hotlist\n"
|
||||
"restore: restore latest hotlist removed in the current buffer "
|
||||
"(or all buffers with -all)"),
|
||||
"clear 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|lowest|highest || "
|
||||
"remove || restore -all",
|
||||
&command_hotlist, NULL, NULL);
|
||||
/*
|
||||
* give high priority (50000) so that an alias will not take precedence
|
||||
* over this command
|
||||
@@ -8069,15 +8125,6 @@ command_init ()
|
||||
" history_next: recall next command in current buffer history\n"
|
||||
" history_global_previous: recall previous command in global history\n"
|
||||
" history_global_next: recall next command in global history\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"
|
||||
" hotlist_remove_buffer: remove current buffer from hotlist\n"
|
||||
" hotlist_restore_buffer: restore latest hotlist removed in the "
|
||||
"current buffer\n"
|
||||
" hotlist_restore_all: restore latest hotlist removed in all "
|
||||
"buffers\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 "
|
||||
@@ -8111,9 +8158,6 @@ command_init ()
|
||||
"move_next_char || move_previous_word || move_next_word || "
|
||||
"history_previous || history_next || history_global_previous || "
|
||||
"history_global_next || "
|
||||
"hotlist_clear 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|lowest|highest || "
|
||||
"hotlist_remove_buffer || hotlist_restore_buffer || "
|
||||
"hotlist_restore_all || "
|
||||
"grab_key || grab_key_command || grab_mouse || grab_mouse_area || "
|
||||
"set_unread || set_unread_current_buffer || "
|
||||
"switch_active_buffer || switch_active_buffer_previous || "
|
||||
|
||||
@@ -138,10 +138,10 @@ gui_key_default_bindings (int context)
|
||||
BIND(/* m-j,m-l */ "meta-jmeta-l", "/buffer +");
|
||||
BIND(/* m-j,m-r */ "meta-jmeta-r", "/server raw");
|
||||
BIND(/* m-j,m-s */ "meta-jmeta-s", "/server jump");
|
||||
BIND(/* m-h,m-c */ "meta-hmeta-c", "/input hotlist_clear");
|
||||
BIND(/* m-h,m-m */ "meta-hmeta-m", "/input hotlist_remove_buffer");
|
||||
BIND(/* m-h,m-r */ "meta-hmeta-r", "/input hotlist_restore_buffer");
|
||||
BIND(/* m-h,m-R */ "meta-hmeta-R", "/input hotlist_restore_all");
|
||||
BIND(/* m-h,m-c */ "meta-hmeta-c", "/hotlist clear");
|
||||
BIND(/* m-h,m-m */ "meta-hmeta-m", "/hotlist remove");
|
||||
BIND(/* m-h,m-r */ "meta-hmeta-r", "/hotlist restore");
|
||||
BIND(/* m-h,m-R */ "meta-hmeta-R", "/hotlist restore -all");
|
||||
BIND(/* m-k */ "meta-k", "/input grab_key_command");
|
||||
BIND(/* m-s */ "meta-s", "/mute spell toggle");
|
||||
BIND(/* m-u */ "meta-u", "/window scroll_unread");
|
||||
|
||||
+84
-1
@@ -484,6 +484,23 @@ gui_hotlist_restore_buffer (struct t_gui_buffer *buffer)
|
||||
gui_hotlist_changed_signal (buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Restores latest hotlist removed in all buffers.
|
||||
*/
|
||||
|
||||
void
|
||||
gui_hotlist_restore_all_buffers ()
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
gui_hotlist_restore_buffer (ptr_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Resorts hotlist with new sort type.
|
||||
*/
|
||||
@@ -522,7 +539,7 @@ gui_hotlist_resort ()
|
||||
}
|
||||
|
||||
/*
|
||||
* Clears hotlist.
|
||||
* Clears hotlist with a level mask (integer).
|
||||
*
|
||||
* Argument "level_mask" is a combination of:
|
||||
* 1 = join/part
|
||||
@@ -560,6 +577,72 @@ gui_hotlist_clear (int level_mask)
|
||||
gui_hotlist_changed_signal (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Clears hotlist with a level mask (string).
|
||||
*/
|
||||
|
||||
void
|
||||
gui_hotlist_clear_level_string (struct t_gui_buffer *buffer,
|
||||
const char *str_level_mask)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Removes a buffer from hotlist.
|
||||
*/
|
||||
|
||||
@@ -62,8 +62,11 @@ 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_restore_buffer (struct t_gui_buffer *buffer);
|
||||
extern void gui_hotlist_restore_all_buffers ();
|
||||
extern void gui_hotlist_resort ();
|
||||
extern void gui_hotlist_clear (int level_mask);
|
||||
extern void gui_hotlist_clear_level_string (struct t_gui_buffer *buffer,
|
||||
const char *str_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,
|
||||
|
||||
@@ -1460,108 +1460,6 @@ gui_input_history_global_next (struct t_gui_buffer *buffer)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Clears hotlist (default key: alt-h, alt-c).
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_hotlist_clear (struct t_gui_buffer *buffer,
|
||||
const char *str_level_mask)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Removes buffer from hotlist (default key: alt-h, alt-m).
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_hotlist_remove_buffer (struct t_gui_buffer *buffer)
|
||||
{
|
||||
gui_hotlist_remove_buffer (buffer, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Restores latest hotlist removed in a buffer (default key: alt-h, alt-r).
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_hotlist_restore_buffer (struct t_gui_buffer *buffer)
|
||||
{
|
||||
gui_hotlist_restore_buffer (buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Restores latest hotlist removed in all buffers (default key: alt-h, alt-R).
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_hotlist_restore_all ()
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
gui_hotlist_restore_buffer (ptr_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initializes "grab key mode" (next key will be inserted into input buffer)
|
||||
* (default key: alt-k).
|
||||
|
||||
@@ -72,11 +72,6 @@ extern void gui_input_history_local_previous (struct t_gui_buffer *buffer);
|
||||
extern void gui_input_history_local_next (struct t_gui_buffer *buffer);
|
||||
extern void gui_input_history_global_previous (struct t_gui_buffer *buffer);
|
||||
extern void gui_input_history_global_next (struct t_gui_buffer *buffer);
|
||||
extern void gui_input_hotlist_clear (struct t_gui_buffer *buffer,
|
||||
const char *level_mask);
|
||||
extern void gui_input_hotlist_remove_buffer (struct t_gui_buffer *buffer);
|
||||
extern void gui_input_hotlist_restore_buffer (struct t_gui_buffer *buffer);
|
||||
extern void gui_input_hotlist_restore_all ();
|
||||
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