summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2022-12-25 18:50:57 +0100
committerSébastien Helleu <flashcode@flashtux.org>2022-12-25 18:50:57 +0100
commitbabe1e7a423a097cb4a6dcf709d31cfbc548afb7 (patch)
tree6204cfddbd5df18e2e0b1283286565f6a8533945 /src/gui
parent574a4c88346dacf1945fad827d90843c66e4e1a6 (diff)
downloadweechat-babe1e7a423a097cb4a6dcf709d31cfbc548afb7.zip
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`
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/curses/gui-curses-key.c8
-rw-r--r--src/gui/gui-hotlist.c85
-rw-r--r--src/gui/gui-hotlist.h3
-rw-r--r--src/gui/gui-input.c102
-rw-r--r--src/gui/gui-input.h5
5 files changed, 91 insertions, 112 deletions
diff --git a/src/gui/curses/gui-curses-key.c b/src/gui/curses/gui-curses-key.c
index 0d9ac53c6..89b0c31e2 100644
--- a/src/gui/curses/gui-curses-key.c
+++ b/src/gui/curses/gui-curses-key.c
@@ -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");
diff --git a/src/gui/gui-hotlist.c b/src/gui/gui-hotlist.c
index 4bf985949..9debccc9e 100644
--- a/src/gui/gui-hotlist.c
+++ b/src/gui/gui-hotlist.c
@@ -485,6 +485,23 @@ gui_hotlist_restore_buffer (struct t_gui_buffer *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
@@ -561,6 +578,72 @@ gui_hotlist_clear (int level_mask)
}
/*
+ * 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.
*/
diff --git a/src/gui/gui-hotlist.h b/src/gui/gui-hotlist.h
index 4f7235c56..f7876f500 100644
--- a/src/gui/gui-hotlist.h
+++ b/src/gui/gui-hotlist.h
@@ -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,
diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c
index 3208ca08d..df8cdebfe 100644
--- a/src/gui/gui-input.c
+++ b/src/gui/gui-input.c
@@ -1461,108 +1461,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).
*/
diff --git a/src/gui/gui-input.h b/src/gui/gui-input.h
index 49e6c1eb2..035e6f8dd 100644
--- a/src/gui/gui-input.h
+++ b/src/gui/gui-input.h
@@ -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);