mirror of
https://github.com/weechat/weechat.git
synced 2026-07-04 08:43:13 +02:00
core: add more intuitive buffer searching (closes #76)
This commit is contained in:
@@ -1379,12 +1379,14 @@ msgid ""
|
||||
" 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"
|
||||
|
||||
+19
-12
@@ -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)
|
||||
@@ -7338,12 +7342,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"
|
||||
@@ -7392,18 +7398,19 @@ 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|search_switch_case|"
|
||||
"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|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|"
|
||||
"switch_active_buffer|switch_active_buffer_previous|zoom_merged_buffer|"
|
||||
"insert|send|paste_start|paste_stop",
|
||||
"return|complete_next|complete_previous|search_text_here|search_text|"
|
||||
"search_switch_case|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_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|switch_active_buffer|"
|
||||
"switch_active_buffer_previous|zoom_merged_buffer|insert|send|"
|
||||
"paste_start|paste_stop",
|
||||
&command_input, NULL);
|
||||
hook_command (
|
||||
NULL, "key",
|
||||
|
||||
@@ -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");
|
||||
|
||||
+36
-2
@@ -571,7 +571,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
|
||||
@@ -722,7 +739,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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -980,6 +980,9 @@ gui_line_remove_from_list (struct t_gui_buffer *buffer,
|
||||
ptr_scroll->start_line_pos = 0;
|
||||
gui_buffer_ask_chat_refresh (buffer, 2);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
+65
-16
@@ -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) ?
|
||||
@@ -1618,6 +1620,28 @@ gui_window_search_start (struct t_gui_window *window)
|
||||
gui_input_delete_line (window->buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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).
|
||||
*/
|
||||
@@ -1625,7 +1649,7 @@ gui_window_search_start (struct t_gui_window *window)
|
||||
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) ?
|
||||
@@ -1646,11 +1670,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;
|
||||
@@ -1671,8 +1695,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);
|
||||
}
|
||||
@@ -1792,6 +1839,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);
|
||||
}
|
||||
@@ -1936,15 +1984,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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user