summaryrefslogtreecommitdiff
path: root/src/gui/gui-input.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-11-07 18:42:48 +0100
committerSébastien Helleu <flashcode@flashtux.org>2023-11-11 08:54:24 +0100
commit97a90ac65a3e19fd3963b806b4688ebdb106c006 (patch)
treed1d755656e0c828c4fb087e003b9a904e442e62e /src/gui/gui-input.c
parentb83b428c5cc48043cb625844b87e94acbc194ba1 (diff)
downloadweechat-97a90ac65a3e19fd3963b806b4688ebdb106c006.zip
core: add key ctrl+o to send command found and insert next one in input (issue #2040)
Diffstat (limited to 'src/gui/gui-input.c')
-rw-r--r--src/gui/gui-input.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c
index 0eb3d5986..046404d42 100644
--- a/src/gui/gui-input.c
+++ b/src/gui/gui-input.c
@@ -1804,6 +1804,54 @@ gui_input_history_global_next (struct t_gui_buffer *buffer)
}
/*
+ * Sends the current history entry (found with search or recalled with
+ * "up" key) and inserts the next one in the command line without sending it
+ * (default key: ctrl-o, in contexts "default" and "histsearch").
+ */
+
+void
+gui_input_history_use_get_next (struct t_gui_buffer *buffer)
+{
+ struct t_gui_window *window;
+ struct t_gui_history *ptr_history, **ptr_ptr_history;;
+
+ window = gui_window_search_with_buffer (buffer);
+ if (!window)
+ return;
+
+ ptr_history = NULL;
+ ptr_ptr_history = NULL;
+ if (window->buffer->text_search == GUI_BUFFER_SEARCH_HISTORY)
+ {
+ ptr_history = window->buffer->text_search_ptr_history;
+ if (!ptr_history)
+ return;
+ ptr_ptr_history = (window->buffer->text_search_history == GUI_BUFFER_SEARCH_HISTORY_LOCAL) ?
+ &(window->buffer->ptr_history) : &gui_history_ptr;
+ gui_window_search_stop (window, 1);
+ }
+ else if (window->buffer->ptr_history)
+ {
+ ptr_history = window->buffer->ptr_history;
+ ptr_ptr_history = &(window->buffer->ptr_history);
+ }
+ else if (gui_history_ptr)
+ {
+ ptr_history = gui_history_ptr;
+ ptr_ptr_history = &gui_history_ptr;
+ }
+
+ gui_input_return (buffer);
+
+ if (ptr_history && ptr_history->prev_history)
+ {
+ gui_input_insert_string (buffer, ptr_history->prev_history->text);
+ if (ptr_ptr_history)
+ *ptr_ptr_history = ptr_history->prev_history;
+ }
+}
+
+/*
* Initializes "grab key mode" (next key will be inserted into input buffer)
* (default key: alt-k).
*/