Skip to content

Commit

Permalink
Enable emptying of command buffer with escape key
Browse files Browse the repository at this point in the history
This patch is meant to allow the user to cancel a command they've
partially written in the session buffer. For example, if a user in
zathura has mistakenly typed the `g' key instead of `G', they can
cancel their partial command by pressing the Escape key.
  • Loading branch information
Petar Kapriš authored and sebastinas committed Jul 17, 2024
1 parent 7368f9d commit 28db863
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions girara/callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ gboolean girara_callback_view_key_press_event(GtkWidget* widget, GdkEventKey* ev
session_private->buffer.command = g_string_append_unichar(session_private->buffer.command, codepoint);
}

if (session->events.buffer_changed != NULL) {
session->events.buffer_changed(session);
}
} else if (keyval == GDK_KEY_Escape) {
if (session_private->buffer.command != NULL) {
g_string_free(session_private->buffer.command, TRUE);
session_private->buffer.command = NULL;
}
if (session->global.buffer != NULL) {
g_string_free(session->global.buffer, TRUE);
session->global.buffer = NULL;
}
if (session->events.buffer_changed != NULL) {
session->events.buffer_changed(session);
}
Expand Down

0 comments on commit 28db863

Please sign in to comment.