CTRl-g (search mode): cancel search and clear text entry

This commit is contained in:
wdlkmpx 2020-12-29 16:54:40 +08:00
parent b3dbc9ca9a
commit 8e028445ca
2 changed files with 9 additions and 0 deletions

View File

@ -25,6 +25,7 @@ Features
* CTRL-S to search forward through history.
* "!" enters a special search mode, matching only the start of strings.
-- Esc to cancel search (only once).
-- CTRL-G to cancel search and clear the text entry
* URL handlers allowing you to enter lines like "http://www.google.com"
to start your favorite browser on www.google.com.

View File

@ -1089,6 +1089,14 @@ on_key_press(GtkCompletionLine *cl, GdkEventKey *event, gpointer data)
}
return TRUE; /* stop signal emission */
case GDK_KEY_G:
case GDK_KEY_g:
if ((event->state & GDK_CONTROL_MASK) && cl->hist_search_mode) {
search_off(cl);
gtk_entry_set_text (GTK_ENTRY (cl), "");
return TRUE; /* stop signal emission */
} else goto ordinary;
ordinary:
default:
if (cl->win_compl != NULL) {