From 12be3b8c332c75a398f77478fd8d62304c632a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Tue, 31 Aug 2021 22:32:38 +0200 Subject: [PATCH] core: add options in command /input and new keys to remove/restore buffers in hotlist New options in command /input: - hotlist_remove_buffer - hotlist_restore_buffer - hotlist_restore_all New keys: - alt+h, alt+c: clear the whole hotlist (former key: alt+h) - alt+h, alt+m: mark the current buffer as read by removing it from the hotlist - alt+h, alt+r: restore latest hotlist removed in the current buffer - alt+h, alt+shift+R: restore latest hotlist removed in all buffers --- ChangeLog.adoc | 2 + ReleaseNotes.adoc | 27 ++++++++++- doc/de/weechat_user.de.adoc | 13 ++++- doc/en/weechat_user.en.adoc | 9 +++- doc/fr/weechat_user.fr.adoc | 9 +++- doc/it/weechat_user.it.adoc | 13 ++++- doc/ja/weechat_user.ja.adoc | 13 ++++- doc/pl/weechat_user.pl.adoc | 13 ++++- doc/sr/weechat_user.sr.adoc | 13 ++++- src/core/wee-command.c | 20 ++++++-- src/gui/curses/gui-curses-key.c | 5 +- src/gui/gui-buffer.c | 4 ++ src/gui/gui-buffer.h | 1 + src/gui/gui-hotlist.c | 86 ++++++++++++++++++++++++--------- src/gui/gui-hotlist.h | 1 + src/gui/gui-input.c | 56 +++++++++++++++++---- src/gui/gui-input.h | 3 ++ 17 files changed, 240 insertions(+), 48 deletions(-) diff --git a/ChangeLog.adoc b/ChangeLog.adoc index deb307a1f..35b270596 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -20,6 +20,8 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] New features:: + * core: change key kbd:[Alt+h] to kbd:[Alt+h], kbd:[Alt+c] (clear hotlist) + * core: add options "hotlist_remove_buffer", "hotlist_restore_buffer" and "hotlist_restore_all" in command /input, add default keys kbd:[Alt+h], kbd:[Alt+m] (remove buffer), kbd:[Alt+h], kbd:[Alt+r] (restore hotlist in current buffer) and kbd:[Alt+h], kbd:[Alt+Shift+R] (restore hotlist in all buffers) * core: add option "certs" in command /debug * api: add `${re:repl_index}` to get the index of replacement in function string_eval_expression (issue #1689) * api: add random integer number in evaluation of expressions with "random:min,max" diff --git a/ReleaseNotes.adoc b/ReleaseNotes.adoc index f05282144..1fc625f36 100644 --- a/ReleaseNotes.adoc +++ b/ReleaseNotes.adoc @@ -20,6 +20,29 @@ https://weechat.org/files/changelog/ChangeLog-devel.html[ChangeLog] [[v3.3]] == Version 3.3 (under dev) +[[v3.3_hotlist_keys_clear_restore]] +=== New keys for hotlist + +New keys have been added to manipulate the hotlist: + +* kbd:[Alt+h], kbd:[Alt+c]: clear the whole hotlist (former key: kbd:[Alt+h]) +* kbd:[Alt+h], kbd:[Alt+m]: mark the current buffer as read by removing it from the hotlist +* kbd:[Alt+h], kbd:[Alt+r]: restore latest hotlist removed in the current buffer +* kbd:[Alt+h], kbd:[Alt+Shift+R]: restore latest hotlist removed in all buffers + +You can add them with the following command: + +---- +/key missing +---- + +Since the key kbd:[Alt+h] has been moved to kbd:[Alt+h], kbd:[Alt+c], you must +manually remove the old key: + +---- +/key unbind meta-h +---- + [[v3.3_typing_bar_item]] === Bar item "typing" @@ -1581,7 +1604,7 @@ The command `/input jump_last_buffer` still works for compatibility reasons, but it should not be used any more. Similarly, a new key has been added to jump to first buffer: kbd:[Alt+j], kbd:[Alt+f]. -You can add it with following command: +You can add it with the following command: ---- /key missing @@ -2321,7 +2344,7 @@ All users of version 0.3.1 should upgrade to this version. === Aliases IRC commands /ame and /amsg are now aliases, if you are upgrading from version -0.3.0, you must create aliases with following commands: +0.3.0, you must create aliases with the following commands: ---- /alias aaway allserv /away diff --git a/doc/de/weechat_user.de.adoc b/doc/de/weechat_user.de.adoc index 79cb6962a..2e5fac379 100644 --- a/doc/de/weechat_user.de.adoc +++ b/doc/de/weechat_user.de.adoc @@ -2022,7 +2022,18 @@ und um eine Hilfe zu erhalten wie man es nutzt: `+/help buffer_autoset+`. | kbd:[Alt+F12] | springt zum Ende der Benutzerliste. | `+/bar scroll nicklist * e+` | kbd:[Alt+a] | wechselt zum nächsten Buffer mit Aktivität (nach Priorität: highlight, Nachricht, ...). | `+/input jump_smart+` | kbd:[Alt+Shift+B] | buflist-Bar umschalten. | `+/buflist toggle+` -| kbd:[Alt+h] | löscht Hotliste (Aktivitätsanzeige für die Buffer). | `+/input hotlist_clear+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+c] | Clear hotlist (activity notification on buffers). | `+/input hotlist_clear+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+m] | Remove current buffer from hotlist. | `+/input hotlist_remove_buffer+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+r] | Restore latest hotlist removed in the current buffer. | `+/input hotlist_restore_buffer+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+Shift+R] | Restore latest hotlist removed in all buffers. | `+/input hotlist_restore_all+` | kbd:[Alt+j], kbd:[Alt+f] | wechselt zum ersten Buffer. | `+/buffer -+` | kbd:[Alt+j], diff --git a/doc/en/weechat_user.en.adoc b/doc/en/weechat_user.en.adoc index e3e271b37..8c0e5057e 100644 --- a/doc/en/weechat_user.en.adoc +++ b/doc/en/weechat_user.en.adoc @@ -1986,7 +1986,14 @@ with `+/script install buffer_autoset.py+` and get help with | kbd:[Alt+F12] | Go to the end of nicklist. | `+/bar scroll nicklist * e+` | kbd:[Alt+a] | Switch to next buffer with activity (with priority: highlight, message, other). | `+/input jump_smart+` | kbd:[Alt+Shift+B] | Toggle buflist. | `+/buflist toggle+` -| kbd:[Alt+h] | Clear hotlist (activity notification on other buffers). | `+/input hotlist_clear+` +| kbd:[Alt+h], + kbd:[Alt+c] | Clear hotlist (activity notification on buffers). | `+/input hotlist_clear+` +| kbd:[Alt+h], + kbd:[Alt+m] | Remove current buffer from hotlist. | `+/input hotlist_remove_buffer+` +| kbd:[Alt+h], + kbd:[Alt+r] | Restore latest hotlist removed in the current buffer. | `+/input hotlist_restore_buffer+` +| kbd:[Alt+h], + kbd:[Alt+Shift+R] | Restore latest hotlist removed in all buffers. | `+/input hotlist_restore_all+` | kbd:[Alt+j], kbd:[Alt+f] | Switch to first buffer. | `+/buffer -+` | kbd:[Alt+j], diff --git a/doc/fr/weechat_user.fr.adoc b/doc/fr/weechat_user.fr.adoc index 50565b851..102365d62 100644 --- a/doc/fr/weechat_user.fr.adoc +++ b/doc/fr/weechat_user.fr.adoc @@ -2052,7 +2052,14 @@ avec `+/help buffer_autoset+`. | kbd:[Alt+F12] | Aller à la fin de la liste des pseudos. | `+/bar scroll nicklist * e+` | kbd:[Alt+a] | Sauter au prochain tampon avec activité (avec priorité : highlight, message, autre). | `+/input jump_smart+` | kbd:[Alt+Shift+B] | Activer/désactiver buflist. | `+/buflist toggle+` -| kbd:[Alt+h] | Vider la hotlist (notification d'activité sur les autres tampons). | `+/input hotlist_clear+` +| kbd:[Alt+h], + kbd:[Alt+c] | Vider la hotlist (notification d'activité sur les tampons). | `+/input hotlist_clear+` +| kbd:[Alt+h], + kbd:[Alt+m] | Supprimer le tampon courant de la hotlist. | `+/input hotlist_remove_buffer+` +| kbd:[Alt+h], + kbd:[Alt+r] | Restaurer la dernière hotlist supprimée dans le tampon courant. | `+/input hotlist_restore_buffer+` +| kbd:[Alt+h], + kbd:[Alt+Shift+R] | Restaurer la dernière hotlist supprimée dans tous les tampons. | `+/input hotlist_restore_all+` | kbd:[Alt+j], kbd:[Alt+f] | Sauter au premier tampon. | `+/buffer -+` | kbd:[Alt+j], diff --git a/doc/it/weechat_user.it.adoc b/doc/it/weechat_user.it.adoc index b9af560a5..97e5a5c22 100644 --- a/doc/it/weechat_user.it.adoc +++ b/doc/it/weechat_user.it.adoc @@ -2118,7 +2118,18 @@ with `+/script install buffer_autoset.py+` and get help with `+/help buffer_auto | kbd:[Alt+a] | Passa al buffer successivo con attività (con priorità: highligh, messagge, altro). | `+/input jump_smart+` // TRANSLATION MISSING | kbd:[Alt+Shift+B] | Toggle buflist. | `+/buflist toggle+` -| kbd:[Alt+h] | Pulisce hotlist (notifica di attività su altri buffer). | `+/input hotlist_clear+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+c] | Clear hotlist (activity notification on buffers). | `+/input hotlist_clear+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+m] | Remove current buffer from hotlist. | `+/input hotlist_remove_buffer+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+r] | Restore latest hotlist removed in the current buffer. | `+/input hotlist_restore_buffer+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+Shift+R] | Restore latest hotlist removed in all buffers. | `+/input hotlist_restore_all+` // TRANSLATION MISSING | kbd:[Alt+j], kbd:[Alt+f] | Switch to first buffer. | `+/buffer -+` diff --git a/doc/ja/weechat_user.ja.adoc b/doc/ja/weechat_user.ja.adoc index c0f730320..caae446c2 100644 --- a/doc/ja/weechat_user.ja.adoc +++ b/doc/ja/weechat_user.ja.adoc @@ -2048,7 +2048,18 @@ irc サーバ "libera" に含まれる全てのバッファに対して設定す | kbd:[Alt+a] | 変更のあった次のバッファに移動 (優先順位: ハイライト、新規メッセージ、その他) | `+/input jump_smart+` // TRANSLATION MISSING | kbd:[Alt+Shift+B] | Toggle buflist. | `+/buflist toggle+` -| kbd:[Alt+h] | ホットリスト (他のバッファにあった変更通知リスト) を消去 | `+/input hotlist_clear+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+c] | Clear hotlist (activity notification on buffers). | `+/input hotlist_clear+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+m] | Remove current buffer from hotlist. | `+/input hotlist_remove_buffer+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+r] | Restore latest hotlist removed in the current buffer. | `+/input hotlist_restore_buffer+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+Shift+R] | Restore latest hotlist removed in all buffers. | `+/input hotlist_restore_all+` | kbd:[Alt+j], kbd:[Alt+f] | 最初のバッファに移動 | `+/buffer -+` | kbd:[Alt+j], diff --git a/doc/pl/weechat_user.pl.adoc b/doc/pl/weechat_user.pl.adoc index 5895d7433..57a041e1d 100644 --- a/doc/pl/weechat_user.pl.adoc +++ b/doc/pl/weechat_user.pl.adoc @@ -1999,7 +1999,18 @@ Można ją zapisać za pomocą skryptu _buffer_autoset.py_: można go zaintalowa | kbd:[Alt+F12] | Idź na koniec listy nicków. | `+/bar scroll nicklist * e+` | kbd:[Alt+a] | Przełącz na następny bufor z aktywnością (z priorytetem: powiadomienie, wiadomość, inne). | `+/input jump_smart+` | kbd:[Alt+Shift+B] | Przełącza widoczność listy buforów. | `+/buflist toggle+` -| kbd:[Alt+h] | Wyczyść hotlistę (powiadomienia o aktywności w innych buforach). | `+/input hotlist_clear+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+c] | Clear hotlist (activity notification on buffers). | `+/input hotlist_clear+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+m] | Remove current buffer from hotlist. | `+/input hotlist_remove_buffer+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+r] | Restore latest hotlist removed in the current buffer. | `+/input hotlist_restore_buffer+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+Shift+R] | Restore latest hotlist removed in all buffers. | `+/input hotlist_restore_all+` | kbd:[Alt+j], kbd:[Alt+f] | Przełącz na pierwszy bufor. | `+/buffer -+` | kbd:[Alt+j], diff --git a/doc/sr/weechat_user.sr.adoc b/doc/sr/weechat_user.sr.adoc index 5932f97bb..8f7d5f288 100644 --- a/doc/sr/weechat_user.sr.adoc +++ b/doc/sr/weechat_user.sr.adoc @@ -1840,7 +1840,18 @@ _трака_ је површина уз разговор која може да | kbd:[Alt+F12] | Скок на крај листе надимака. | `+/bar scroll nicklist * e+` | kbd:[Alt+a] | Пребацивање на следећи бафер у коме има активности (са приоритетом: истицање, порука, остало). | `+/input jump_smart+` | kbd:[Alt+Shift+B] | Пребацивање активности листе бафера. | `+/buflist toggle+` -| kbd:[Alt+h] | Чишћење вруће листе (обавештавање о активности у осталим баферима). | `+/input hotlist_clear+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+c] | Clear hotlist (activity notification on buffers). | `+/input hotlist_clear+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+m] | Remove current buffer from hotlist. | `+/input hotlist_remove_buffer+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+r] | Restore latest hotlist removed in the current buffer. | `+/input hotlist_restore_buffer+` +// TRANSLATION MISSING +| kbd:[Alt+h], + kbd:[Alt+Shift+R] | Restore latest hotlist removed in all buffers. | `+/input hotlist_restore_all+` | kbd:[Alt+j], kbd:[Alt+f] | Пребацивање на први бафер. | `+/buffer -+` | kbd:[Alt+j], diff --git a/src/core/wee-command.c b/src/core/wee-command.c index beacd126f..9142dc5f2 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -3329,6 +3329,12 @@ COMMAND_CALLBACK(input) gui_input_jump_next_visited_buffer (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) @@ -7815,6 +7821,11 @@ command_init () "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 " @@ -7846,10 +7857,11 @@ command_init () "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", + "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 || " + "zoom_merged_buffer || insert || send || paste_start || paste_stop", &command_input, NULL, NULL); hook_command ( NULL, "key", diff --git a/src/gui/curses/gui-curses-key.c b/src/gui/curses/gui-curses-key.c index 16ebdf91b..3ee703080 100644 --- a/src/gui/curses/gui-curses-key.c +++ b/src/gui/curses/gui-curses-key.c @@ -137,7 +137,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 */ "meta-h", "/input hotlist_clear"); + 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-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-buffer.c b/src/gui/gui-buffer.c index 87493bcc4..411d48f4d 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -790,6 +790,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin, /* hotlist */ new_buffer->hotlist = NULL; + new_buffer->hotlist_removed = NULL; new_buffer->hotlist_max_level_nicks = hashtable_new ( 32, WEECHAT_HASHTABLE_STRING, @@ -2900,6 +2901,8 @@ gui_buffer_close (struct t_gui_buffer *buffer) } gui_hotlist_remove_buffer (buffer, 1); + if (buffer->hotlist_removed) + free (buffer->hotlist_removed); if (gui_hotlist_initial_buffer == buffer) gui_hotlist_initial_buffer = NULL; @@ -4798,6 +4801,7 @@ gui_buffer_print_log () log_printf (" highlight_tags_count. . : %d", ptr_buffer->highlight_tags_count); log_printf (" highlight_tags_array. . : 0x%lx", ptr_buffer->highlight_tags_array); log_printf (" hotlist . . . . . . . . : 0x%lx", ptr_buffer->hotlist); + log_printf (" hotlist_removed . . . . : 0x%lx", ptr_buffer->hotlist_removed); log_printf (" keys. . . . . . . . . . : 0x%lx", ptr_buffer->keys); log_printf (" last_key. . . . . . . . : 0x%lx", ptr_buffer->last_key); log_printf (" keys_count. . . . . . . : %d", ptr_buffer->keys_count); diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h index 8da63d62a..bcc8d4137 100644 --- a/src/gui/gui-buffer.h +++ b/src/gui/gui-buffer.h @@ -206,6 +206,7 @@ struct t_gui_buffer /* hotlist */ struct t_gui_hotlist *hotlist; /* hotlist entry for buffer */ + struct t_gui_hotlist *hotlist_removed; /* hotlist that can be restored */ struct t_hashtable *hotlist_max_level_nicks; /* max hotlist level for */ /* some nicks */ diff --git a/src/gui/gui-hotlist.c b/src/gui/gui-hotlist.c index 87eb46cd1..2de62215c 100644 --- a/src/gui/gui-hotlist.c +++ b/src/gui/gui-hotlist.c @@ -85,6 +85,32 @@ gui_hotlist_search (struct t_gui_hotlist *hotlist, struct t_gui_buffer *buffer) return NULL; } +/* + * Duplicates a hotlist element. + * + * Returns pointer to new hotlist, NULL if error. + */ + +struct t_gui_hotlist * +gui_hotlist_dup (struct t_gui_hotlist *hotlist) +{ + struct t_gui_hotlist *new_hotlist; + + new_hotlist = malloc (sizeof (*new_hotlist)); + if (!new_hotlist) + return NULL; + + new_hotlist->priority = hotlist->priority; + memcpy (&(new_hotlist->creation_time), &(hotlist->creation_time), + sizeof (new_hotlist->creation_time)); + new_hotlist->buffer = hotlist->buffer; + memcpy (new_hotlist->count, hotlist->count, sizeof (hotlist->count)); + new_hotlist->prev_hotlist = NULL; + new_hotlist->next_hotlist = NULL; + + return new_hotlist; +} + /* * Frees a hotlist and removes it from hotlist queue. */ @@ -92,13 +118,23 @@ gui_hotlist_search (struct t_gui_hotlist *hotlist, struct t_gui_buffer *buffer) void gui_hotlist_free (struct t_gui_hotlist **hotlist, struct t_gui_hotlist **last_hotlist, - struct t_gui_hotlist *ptr_hotlist) + struct t_gui_hotlist *ptr_hotlist, + int save_removed_hotlist) { struct t_gui_hotlist *new_hotlist; if (!ptr_hotlist) return; + if (save_removed_hotlist) + { + if (ptr_hotlist->buffer->hotlist_removed) + free (ptr_hotlist->buffer->hotlist_removed); + ptr_hotlist->buffer->hotlist_removed = gui_hotlist_dup (ptr_hotlist); + ptr_hotlist->buffer->hotlist_removed->prev_hotlist = NULL; + ptr_hotlist->buffer->hotlist_removed->next_hotlist = NULL; + } + ptr_hotlist->buffer->hotlist = NULL; /* remove hotlist from queue */ @@ -130,7 +166,7 @@ gui_hotlist_free_all (struct t_gui_hotlist **hotlist, /* remove all hotlists */ while (*hotlist) { - gui_hotlist_free (hotlist, last_hotlist, *hotlist); + gui_hotlist_free (hotlist, last_hotlist, *hotlist, 1); } } @@ -391,7 +427,7 @@ gui_hotlist_add (struct t_gui_buffer *buffer, * and go on */ memcpy (count, ptr_hotlist->count, sizeof (ptr_hotlist->count)); - gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, ptr_hotlist); + gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, ptr_hotlist, 1); } new_hotlist = malloc (sizeof (*new_hotlist)); @@ -421,29 +457,31 @@ gui_hotlist_add (struct t_gui_buffer *buffer, } /* - * Duplicates a hotlist element. - * - * Returns pointer to new hotlist, NULL if error. + * Restores a hotlist that was removed from a buffer. */ -struct t_gui_hotlist * -gui_hotlist_dup (struct t_gui_hotlist *hotlist) +void +gui_hotlist_restore_buffer (struct t_gui_buffer *buffer) { - struct t_gui_hotlist *new_hotlist; + struct t_gui_hotlist *ptr_hotlist; - new_hotlist = malloc (sizeof (*new_hotlist)); - if (new_hotlist) - { - new_hotlist->priority = hotlist->priority; - memcpy (&(new_hotlist->creation_time), &(hotlist->creation_time), - sizeof (new_hotlist->creation_time)); - new_hotlist->buffer = hotlist->buffer; - memcpy (new_hotlist->count, hotlist->count, sizeof (hotlist->count)); - new_hotlist->prev_hotlist = NULL; - new_hotlist->next_hotlist = NULL; - return new_hotlist; - } - return NULL; + if (!buffer->hotlist_removed) + return; + + /* remove hotlist with buffer from list (if found) */ + ptr_hotlist = gui_hotlist_search (gui_hotlist, buffer); + if (ptr_hotlist) + gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, ptr_hotlist, 0); + + /* restore the removed hotlist */ + buffer->hotlist_removed->buffer = buffer; + ptr_hotlist = gui_hotlist_dup (buffer->hotlist_removed); + gui_hotlist_add_hotlist (&gui_hotlist, &last_gui_hotlist, ptr_hotlist); + + free (buffer->hotlist_removed); + buffer->hotlist_removed = NULL; + + gui_hotlist_changed_signal (buffer); } /* @@ -503,7 +541,7 @@ gui_hotlist_clear (int level_mask) ptr_next_hotlist = ptr_hotlist->next_hotlist; if (level_mask & (1 << ptr_hotlist->priority)) { - gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, ptr_hotlist); + gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, ptr_hotlist, 1); hotlist_changed = 1; } ptr_hotlist = ptr_next_hotlist; @@ -554,7 +592,7 @@ gui_hotlist_remove_buffer (struct t_gui_buffer *buffer, if (buffer_to_remove) { - gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, ptr_hotlist); + gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, ptr_hotlist, 1); hotlist_changed = 1; } diff --git a/src/gui/gui-hotlist.h b/src/gui/gui-hotlist.h index 5904f149d..06dad0802 100644 --- a/src/gui/gui-hotlist.h +++ b/src/gui/gui-hotlist.h @@ -61,6 +61,7 @@ extern int gui_add_hotlist; 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_resort (); extern void gui_hotlist_clear (int level_mask); extern void gui_hotlist_remove_buffer (struct t_gui_buffer *buffer, diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c index 97456275e..537d37487 100644 --- a/src/gui/gui-input.c +++ b/src/gui/gui-input.c @@ -642,7 +642,7 @@ gui_input_search_compile_regex (struct t_gui_buffer *buffer) } /* - * Switches case for search in buffer (default key: meta-c during search). + * Switches case for search in buffer (default key: alt-c during search). */ void @@ -894,7 +894,7 @@ gui_input_delete_previous_word (struct t_gui_buffer *buffer) } /* - * Deletes next word (default key: meta-d). + * Deletes next word (default key: alt-d). */ void @@ -1006,7 +1006,7 @@ gui_input_delete_end_of_line (struct t_gui_buffer *buffer) } /* - * Deletes entire line (default key: meta-r). + * Deletes entire line (default key: alt-r). */ void @@ -1121,7 +1121,7 @@ gui_input_move_next_char (struct t_gui_buffer *buffer) } /* - * Moves cursor to beginning of previous word (default key: meta-b or + * Moves cursor to beginning of previous word (default key: alt-b or * ctrl-left). */ @@ -1160,7 +1160,7 @@ gui_input_move_previous_word (struct t_gui_buffer *buffer) } /* - * Moves cursor to the beginning of next word (default key: meta-f or + * Moves cursor to the beginning of next word (default key: alt-f or * ctrl-right). */ @@ -1469,7 +1469,7 @@ gui_input_jump_smart (struct t_gui_buffer *buffer) /* * Jumps to last buffer displayed (before last jump to a buffer) (default key: - * meta-/). + * alt-/). */ void @@ -1489,7 +1489,7 @@ gui_input_jump_last_buffer_displayed (struct t_gui_buffer *buffer) /* * Jumps to previously visited buffer (buffer displayed before current one) - * (default key: meta-<). + * (default key: alt-<). */ void @@ -1523,7 +1523,7 @@ gui_input_jump_previously_visited_buffer (struct t_gui_buffer *buffer) /* * Jumps to next visited buffer (buffer displayed after current one) (default - * key: meta->). + * key: alt->). */ void @@ -1555,7 +1555,7 @@ gui_input_jump_next_visited_buffer (struct t_gui_buffer *buffer) } /* - * Clears hotlist (default key: meta-h). + * Clears hotlist (default key: alt-h, alt-c). */ void @@ -1620,9 +1620,45 @@ gui_input_hotlist_clear (struct t_gui_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: meta-k). + * (default key: alt-k). */ void diff --git a/src/gui/gui-input.h b/src/gui/gui-input.h index 070bb98cc..4fe8eba4c 100644 --- a/src/gui/gui-input.h +++ b/src/gui/gui-input.h @@ -77,6 +77,9 @@ extern void gui_input_jump_previously_visited_buffer (struct t_gui_buffer *buffe extern void gui_input_jump_next_visited_buffer (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);