refactor history to use history_entries list

this allows access to the global history even when a using /window history
named or /set window_history on, and you want to recall something from one
of the other windows' histories.

usage (default): ctrl+up/down
This commit is contained in:
ailin-nemui 2017-10-06 14:58:47 +02:00
commit 1fd285dccf
4 changed files with 183 additions and 27 deletions

View file

@ -530,6 +530,28 @@ 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_beginning_of_line(void)
{
gui_entry_set_pos(active_entry, 0);
@ -1176,6 +1198,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 +1241,8 @@ 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);
/* line editing */
key_bind("backspace", "Delete the previous character", "backspace", NULL, (SIGNAL_FUNC) key_backspace);
@ -1310,6 +1336,8 @@ 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("backspace", (SIGNAL_FUNC) key_backspace);
key_unbind("delete_character", (SIGNAL_FUNC) key_delete_character);