summaryrefslogtreecommitdiff
path: root/src/fe-text
diff options
context:
space:
mode:
authorailin-nemui <ailin-nemui@users.noreply.github.com>2017-11-26 00:28:58 +0100
committerGitHub <noreply@github.com>2017-11-26 00:28:58 +0100
commit3792bc9ba95b8b9fd12ad60b86b8bbb06e913dc1 (patch)
treecf884a32f94ed03b349b2b3acbcfcb47352443b1 /src/fe-text
parent4e8c1548e01c15a9934b1a2d02ce2396ab859957 (diff)
parent5da0b73a12b3b319a2c7d6b18657ec13d52b6476 (diff)
downloadirssi-3792bc9ba95b8b9fd12ad60b86b8bbb06e913dc1.zip
Merge pull request #762 from ailin-nemui/global-history
allow access to global command history when using a specifc history
Diffstat (limited to 'src/fe-text')
-rw-r--r--src/fe-text/gui-readline.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c
index 3688f15e..b3a78396 100644
--- a/src/fe-text/gui-readline.c
+++ b/src/fe-text/gui-readline.c
@@ -530,6 +530,39 @@ static void key_forward_history(void)
g_free(line);
}
+static void key_backward_global_history(void)
+{
+ const char *text;
+ char *line;
+
+ line = gui_entry_get_text(active_entry);
+ text = command_global_history_prev(active_win, line);
+ gui_entry_set_text(active_entry, text);
+ g_free(line);
+}
+
+static void key_forward_global_history(void)
+{
+ const char *text;
+ char *line;
+
+ line = gui_entry_get_text(active_entry);
+ text = command_global_history_next(active_win, line);
+ gui_entry_set_text(active_entry, text);
+ g_free(line);
+}
+
+static void key_erase_history_entry(void)
+{
+ const char *text;
+ char *line;
+
+ line = gui_entry_get_text(active_entry);
+ text = command_history_delete_current(active_win, line);
+ gui_entry_set_text(active_entry, text);
+ g_free(line);
+}
+
static void key_beginning_of_line(void)
{
gui_entry_set_pos(active_entry, 0);
@@ -1176,6 +1209,8 @@ void gui_readline_init(void)
key_bind("key", NULL, "meta2-5C", "cright", (SIGNAL_FUNC) key_combo);
key_bind("key", NULL, "meta2-1;5D", "cleft", (SIGNAL_FUNC) key_combo);
key_bind("key", NULL, "meta2-1;5C", "cright", (SIGNAL_FUNC) key_combo);
+ key_bind("key", NULL, "meta2-1;5A", "cup", (SIGNAL_FUNC) key_combo);
+ key_bind("key", NULL, "meta2-1;5B", "cdown", (SIGNAL_FUNC) key_combo);
key_bind("key", NULL, "meta2-1;3A", "mup", (SIGNAL_FUNC) key_combo);
key_bind("key", NULL, "meta2-1;3B", "mdown", (SIGNAL_FUNC) key_combo);
@@ -1217,6 +1252,9 @@ void gui_readline_init(void)
/* history */
key_bind("backward_history", "Go back one line in the history", "up", NULL, (SIGNAL_FUNC) key_backward_history);
key_bind("forward_history", "Go forward one line in the history", "down", NULL, (SIGNAL_FUNC) key_forward_history);
+ key_bind("backward_global_history", "Go back one line in the global history", "cup", NULL, (SIGNAL_FUNC) key_backward_global_history);
+ key_bind("forward_global_history", "Go forward one line in the global history", "cdown", NULL, (SIGNAL_FUNC) key_forward_global_history);
+ key_bind("erase_history_entry", "Erase the currently active entry from the history", NULL, NULL, (SIGNAL_FUNC) key_erase_history_entry);
/* line editing */
key_bind("backspace", "Delete the previous character", "backspace", NULL, (SIGNAL_FUNC) key_backspace);
@@ -1310,6 +1348,9 @@ void gui_readline_deinit(void)
key_unbind("backward_history", (SIGNAL_FUNC) key_backward_history);
key_unbind("forward_history", (SIGNAL_FUNC) key_forward_history);
+ key_unbind("backward_global_history", (SIGNAL_FUNC) key_backward_global_history);
+ key_unbind("forward_global_history", (SIGNAL_FUNC) key_forward_global_history);
+ key_unbind("erase_history_entry", (SIGNAL_FUNC) key_erase_history_entry);
key_unbind("backspace", (SIGNAL_FUNC) key_backspace);
key_unbind("delete_character", (SIGNAL_FUNC) key_delete_character);