summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-command.c22
-rw-r--r--src/gui/curses/gui-curses-key.c7
-rw-r--r--src/gui/gui-input.c38
-rw-r--r--src/gui/gui-input.h2
-rw-r--r--src/gui/gui-line.c3
-rw-r--r--src/gui/gui-window.c81
-rw-r--r--src/gui/gui-window.h4
7 files changed, 128 insertions, 29 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index ef1ce1db1..fefc1dc06 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -2933,6 +2933,8 @@ COMMAND_CALLBACK(input)
gui_input_complete_next (buffer);
else if (string_strcasecmp (argv[1], "complete_previous") == 0)
gui_input_complete_previous (buffer);
+ else if (string_strcasecmp (argv[1], "search_text_here") == 0)
+ gui_input_search_text_here (buffer);
else if (string_strcasecmp (argv[1], "search_text") == 0)
gui_input_search_text (buffer);
else if (string_strcasecmp (argv[1], "search_previous") == 0)
@@ -2945,6 +2947,8 @@ COMMAND_CALLBACK(input)
gui_input_search_switch_regex (buffer);
else if (string_strcasecmp (argv[1], "search_switch_where") == 0)
gui_input_search_switch_where (buffer);
+ else if (string_strcasecmp (argv[1], "search_stop_here") == 0)
+ gui_input_search_stop_here (buffer);
else if (string_strcasecmp (argv[1], "search_stop") == 0)
gui_input_search_stop (buffer);
else if (string_strcasecmp (argv[1], "delete_previous_char") == 0)
@@ -7385,12 +7389,14 @@ command_init ()
" return: simulate key \"enter\"\n"
" complete_next: complete word with next completion\n"
" complete_previous: complete word with previous completion\n"
+ " search_text_here: search text in buffer at current position\n"
" search_text: search text in buffer\n"
" search_switch_case: switch exact case for search\n"
" search_switch_regex: switch search type: string/regular expression\n"
" search_switch_where: switch search in messages/prefixes\n"
" search_previous: search previous line\n"
" search_next: search next line\n"
+ " search_stop_here: stop search at current position\n"
" search_stop: stop search\n"
" delete_previous_char: delete previous char\n"
" delete_next_char: delete next char\n"
@@ -7439,15 +7445,15 @@ command_init ()
" paste_stop: stop paste (bracketed paste mode)\n"
"\n"
"This command is used by key bindings or plugins."),
- "return|complete_next|complete_previous|search_text|"
+ "return|complete_next|complete_previous|search_text_here|search_text|"
"search_switch_case|search_switch_regex|search_switch_where|"
- "search_previous|search_next|search_stop|delete_previous_char|"
- "delete_next_char|delete_previous_word|delete_next_word|"
- "delete_beginning_of_line|delete_end_of_line|delete_line|"
- "clipboard_paste|transpose_chars|undo|redo|move_beginning_of_line|"
- "move_end_of_line|move_previous_char|move_next_char|"
- "move_previous_word|move_next_word|history_previous|history_next|"
- "history_global_previous|history_global_next|jump_smart|"
+ "search_previous|search_next|search_stop_here|search_stop|"
+ "delete_previous_char|delete_next_char|delete_previous_word|"
+ "delete_next_word|delete_beginning_of_line|delete_end_of_line|"
+ "delete_line|clipboard_paste|transpose_chars|undo|redo|"
+ "move_beginning_of_line|move_end_of_line|move_previous_char|"
+ "move_next_char|move_previous_word|move_next_word|history_previous|"
+ "history_next|history_global_previous|history_global_next|jump_smart|"
"jump_last_buffer_displayed|jump_previously_visited_buffer|"
"jump_next_visited_buffer|hotlist_clear|grab_key|grab_key_command|"
"grab_mouse|grab_mouse_area|set_unread|set_unread_current_buffer|"
diff --git a/src/gui/curses/gui-curses-key.c b/src/gui/curses/gui-curses-key.c
index 30705f0d1..b1205b400 100644
--- a/src/gui/curses/gui-curses-key.c
+++ b/src/gui/curses/gui-curses-key.c
@@ -85,7 +85,7 @@ gui_key_default_bindings (int context)
BIND(/* <enter> */ "ctrl-J", "/input return");
BIND(/* <tab> */ "ctrl-I", "/input complete_next");
BIND(/* s-<tab> */ "meta2-Z", "/input complete_previous");
- BIND(/* ^R */ "ctrl-R", "/input search_text");
+ BIND(/* ^R */ "ctrl-R", "/input search_text_here");
BIND(/* <backspace> */ "ctrl-H", "/input delete_previous_char");
BIND(/* <backspace> */ "ctrl-?", "/input delete_previous_char");
BIND(/* ^_ */ "ctrl-_", "/input undo");
@@ -228,8 +228,9 @@ gui_key_default_bindings (int context)
}
else if (context == GUI_KEY_CONTEXT_SEARCH)
{
- BIND(/* <enter> */ "ctrl-M", "/input search_stop");
- BIND(/* <enter> */ "ctrl-J", "/input search_stop");
+ BIND(/* <enter> */ "ctrl-M", "/input search_stop_here");
+ BIND(/* <enter> */ "ctrl-J", "/input search_stop_here");
+ BIND(/* ^Q */ "ctrl-Q", "/input search_stop");
BIND(/* m-c */ "meta-c", "/input search_switch_case");
BIND(/* ^R */ "ctrl-R", "/input search_switch_regex");
BIND(/* <tab> */ "ctrl-I", "/input search_switch_where");
diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c
index 2b46cb16a..d052429d1 100644
--- a/src/gui/gui-input.c
+++ b/src/gui/gui-input.c
@@ -567,7 +567,24 @@ gui_input_complete_previous (struct t_gui_buffer *buffer)
}
/*
- * Searches for text in buffer (default key: ctrl-R).
+ * Searches for text in buffer at current position (default key: ctrl-R).
+ */
+
+void
+gui_input_search_text_here (struct t_gui_buffer *buffer)
+{
+ struct t_gui_window *window;
+
+ window = gui_window_search_with_buffer (buffer);
+ if (window && (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
+ {
+ gui_window_search_start_here (window);
+ gui_input_search_signal (buffer);
+ }
+}
+
+/*
+ * Searches for text in buffer.
*/
void
@@ -718,7 +735,24 @@ gui_input_search_next (struct t_gui_buffer *buffer)
}
/*
- * Stops text search (default key: return during search).
+ * Stops text search at current position (default key: return during search).
+ */
+
+void
+gui_input_search_stop_here (struct t_gui_buffer *buffer)
+{
+ struct t_gui_window *window;
+
+ window = gui_window_search_with_buffer (buffer);
+ if (window && (window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED))
+ {
+ gui_window_search_stop_here (window);
+ gui_input_search_signal (buffer);
+ }
+}
+
+/*
+ * Stops text search (default key: ctrl-Q during search).
*/
void
diff --git a/src/gui/gui-input.h b/src/gui/gui-input.h
index b46a9e0a0..832c80671 100644
--- a/src/gui/gui-input.h
+++ b/src/gui/gui-input.h
@@ -43,6 +43,7 @@ extern void gui_input_clipboard_paste (struct t_gui_buffer *buffer);
extern void gui_input_return (struct t_gui_buffer *buffer);
extern void gui_input_complete_next (struct t_gui_buffer *buffer);
extern void gui_input_complete_previous (struct t_gui_buffer *buffer);
+extern void gui_input_search_text_here (struct t_gui_buffer *buffer);
extern void gui_input_search_text (struct t_gui_buffer *buffer);
extern void gui_input_search_compile_regex (struct t_gui_buffer *buffer);
extern void gui_input_search_switch_case (struct t_gui_buffer *buffer);
@@ -50,6 +51,7 @@ extern void gui_input_search_switch_regex (struct t_gui_buffer *buffer);
extern void gui_input_search_switch_where (struct t_gui_buffer *buffer);
extern void gui_input_search_previous (struct t_gui_buffer *buffer);
extern void gui_input_search_next (struct t_gui_buffer *buffer);
+extern void gui_input_search_stop_here (struct t_gui_buffer *buffer);
extern void gui_input_search_stop (struct t_gui_buffer *buffer);
extern void gui_input_delete_previous_char (struct t_gui_buffer *buffer);
extern void gui_input_delete_next_char (struct t_gui_buffer *buffer);
diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c
index 73a8a28b9..9b3ad32fe 100644
--- a/src/gui/gui-line.c
+++ b/src/gui/gui-line.c
@@ -990,6 +990,9 @@ gui_line_remove_from_list (struct t_gui_buffer *buffer,
gui_window_ask_refresh (1);
}
}
+
+ if (ptr_scroll->text_search_start_line == line)
+ ptr_scroll->text_search_start_line = NULL;
}
/* remove line from coords */
gui_window_coords_remove_line (ptr_win, line);
diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c
index b055f2262..83534dc80 100644
--- a/src/gui/gui-window.c
+++ b/src/gui/gui-window.c
@@ -384,6 +384,7 @@ gui_window_scroll_init (struct t_gui_window_scroll *window_scroll,
window_scroll->scrolling = 0;
window_scroll->start_col = 0;
window_scroll->lines_after = 0;
+ window_scroll->text_search_start_line = NULL;
window_scroll->prev_scroll = NULL;
window_scroll->next_scroll = NULL;
}
@@ -443,7 +444,8 @@ gui_window_scroll_remove_not_scrolled (struct t_gui_window *window)
&& (ptr_scroll->start_line_pos == 0)
&& (ptr_scroll->scrolling == 0)
&& (ptr_scroll->start_col == 0)
- && (ptr_scroll->lines_after == 0))
+ && (ptr_scroll->lines_after == 0)
+ && (ptr_scroll->text_search_start_line == NULL))
{
gui_window_scroll_free (window, ptr_scroll);
}
@@ -1567,11 +1569,11 @@ gui_window_search_text (struct t_gui_window *window)
}
/*
- * Starts search in a buffer.
+ * Begins search in a buffer (helper function).
*/
void
-gui_window_search_start (struct t_gui_window *window)
+gui_window_search_begin (struct t_gui_window *window)
{
window->buffer->text_search =
(window->buffer->type == GUI_BUFFER_TYPE_FORMATTED) ?
@@ -1619,13 +1621,35 @@ gui_window_search_start (struct t_gui_window *window)
}
/*
+ * Starts search in a buffer at current position.
+ */
+
+void
+gui_window_search_start_here (struct t_gui_window *window)
+{
+ gui_window_search_begin (window);
+ window->scroll->text_search_start_line = window->scroll->start_line;
+}
+
+/*
+ * Starts search in a buffer.
+ */
+
+void
+gui_window_search_start (struct t_gui_window *window)
+{
+ gui_window_search_begin (window);
+ window->scroll->text_search_start_line = NULL;
+}
+
+/*
* Restarts search (after input changes or exact flag (un)set).
*/
void
gui_window_search_restart (struct t_gui_window *window)
{
- window->scroll->start_line = NULL;
+ window->scroll->start_line = window->scroll->text_search_start_line;
window->scroll->start_line_pos = 0;
window->buffer->text_search =
(window->buffer->type == GUI_BUFFER_TYPE_FORMATTED) ?
@@ -1647,11 +1671,11 @@ gui_window_search_restart (struct t_gui_window *window)
}
/*
- * Stops search in a buffer.
+ * Ends search mode in a buffer (helper function).
*/
void
-gui_window_search_stop (struct t_gui_window *window)
+gui_window_search_end (struct t_gui_window *window)
{
window->buffer->text_search = GUI_TEXT_SEARCH_DISABLED;
window->buffer->text_search = 0;
@@ -1672,8 +1696,31 @@ gui_window_search_stop (struct t_gui_window *window)
free (window->buffer->text_search_input);
window->buffer->text_search_input = NULL;
}
- window->scroll->start_line = NULL;
+}
+
+/*
+ * Stops search in a buffer at current position.
+ */
+
+void
+gui_window_search_stop_here (struct t_gui_window *window)
+{
+ gui_window_search_end (window);
+ window->scroll->text_search_start_line = NULL;
+ gui_buffer_ask_chat_refresh (window->buffer, 2);
+}
+
+/*
+ * Stops search in a buffer.
+ */
+
+void
+gui_window_search_stop (struct t_gui_window *window)
+{
+ gui_window_search_end (window);
+ window->scroll->start_line = window->scroll->text_search_start_line;
window->scroll->start_line_pos = 0;
+ window->scroll->text_search_start_line = NULL;
gui_hotlist_remove_buffer (window->buffer, 0);
gui_buffer_ask_chat_refresh (window->buffer, 2);
}
@@ -1793,6 +1840,7 @@ gui_window_hdata_window_scroll_cb (void *data, const char *hdata_name)
HDATA_VAR(struct t_gui_window_scroll, scrolling, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_window_scroll, start_col, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_window_scroll, lines_after, INTEGER, 0, NULL, NULL);
+ HDATA_VAR(struct t_gui_window_scroll, text_search_start_line, POINTER, 0, NULL, "line");
HDATA_VAR(struct t_gui_window_scroll, prev_scroll, POINTER, 0, NULL, hdata_name);
HDATA_VAR(struct t_gui_window_scroll, next_scroll, POINTER, 0, NULL, hdata_name);
}
@@ -1937,15 +1985,16 @@ gui_window_print_log ()
{
log_printf ("");
log_printf (" [scroll (addr:0x%lx)]", ptr_scroll);
- log_printf (" buffer. . . . . . . : 0x%lx", ptr_scroll->buffer);
- log_printf (" first_line_displayed: %d", ptr_scroll->first_line_displayed);
- log_printf (" start_line. . . . . : 0x%lx", ptr_scroll->start_line);
- log_printf (" start_line_pos. . . : %d", ptr_scroll->start_line_pos);
- log_printf (" scrolling . . . . . : %d", ptr_scroll->scrolling);
- log_printf (" start_col . . . . . : %d", ptr_scroll->start_col);
- log_printf (" lines_after . . . . : %d", ptr_scroll->lines_after);
- log_printf (" prev_scroll . . . . : 0x%lx", ptr_scroll->prev_scroll);
- log_printf (" next_scroll . . . . : 0x%lx", ptr_scroll->next_scroll);
+ log_printf (" buffer. . . . . . . . : 0x%lx", ptr_scroll->buffer);
+ log_printf (" first_line_displayed. : %d", ptr_scroll->first_line_displayed);
+ log_printf (" start_line. . . . . . : 0x%lx", ptr_scroll->start_line);
+ log_printf (" start_line_pos. . . . : %d", ptr_scroll->start_line_pos);
+ log_printf (" scrolling . . . . . . : %d", ptr_scroll->scrolling);
+ log_printf (" start_col . . . . . . : %d", ptr_scroll->start_col);
+ log_printf (" lines_after . . . . . : %d", ptr_scroll->lines_after);
+ log_printf (" text_search_start_line: 0x%lx", ptr_scroll->text_search_start_line);
+ log_printf (" prev_scroll . . . . . : 0x%lx", ptr_scroll->prev_scroll);
+ log_printf (" next_scroll . . . . . : 0x%lx", ptr_scroll->next_scroll);
}
for (ptr_bar_win = ptr_window->bar_windows; ptr_bar_win;
diff --git a/src/gui/gui-window.h b/src/gui/gui-window.h
index f3439142a..4f64bf993 100644
--- a/src/gui/gui-window.h
+++ b/src/gui/gui-window.h
@@ -96,6 +96,8 @@ struct t_gui_window_scroll
/* (for horizontal scrolling) */
int lines_after; /* number of lines after last line */
/* displayed (with scrolling) */
+ struct t_gui_line *text_search_start_line; /* starting line for search */
+
struct t_gui_window_scroll *prev_scroll; /* link to prev. buf. scrolled */
struct t_gui_window_scroll *next_scroll; /* link to next buf. scrolled */
};
@@ -181,8 +183,10 @@ extern void gui_window_scroll_horiz (struct t_gui_window *window, char *scroll);
extern void gui_window_scroll_previous_highlight (struct t_gui_window *window);
extern void gui_window_scroll_next_highlight (struct t_gui_window *window);
extern void gui_window_scroll_unread (struct t_gui_window *window);
+extern void gui_window_search_start_here (struct t_gui_window *window);
extern void gui_window_search_start (struct t_gui_window *window);
extern void gui_window_search_restart (struct t_gui_window *window);
+extern void gui_window_search_stop_here (struct t_gui_window *window);
extern void gui_window_search_stop (struct t_gui_window *window);
extern int gui_window_search_text (struct t_gui_window *window);
extern void gui_window_zoom (struct t_gui_window *window);