mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 05:36:00 +01:00
Delete last character of the buffer
It is now possible to delete the last character of the buffer using the backspace key
This commit is contained in:
parent
7b17a793c7
commit
acf114b2ec
2 changed files with 30 additions and 1 deletions
|
@ -70,6 +70,7 @@ Shortcut shortcuts[] = {
|
|||
{0, GDK_N, sc_search, -1, { BACKWARD } },
|
||||
{0, GDK_a, sc_adjust_window, -1, { ADJUST_BESTFIT } },
|
||||
{0, GDK_s, sc_adjust_window, -1, { ADJUST_WIDTH } },
|
||||
{0, GDK_BackSpace, sc_change_buffer, -1, { DELETE_LAST } },
|
||||
};
|
||||
|
||||
/* inputbar shortcuts */
|
||||
|
|
30
zathura.c
30
zathura.c
|
@ -26,7 +26,7 @@ enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN,
|
|||
ERROR, WARNING, NEXT_GROUP, PREVIOUS_GROUP,
|
||||
ZOOM_IN, ZOOM_OUT, ZOOM_ORIGINAL, ZOOM_SPECIFIC,
|
||||
FORWARD, BACKWARD, ADJUST_BESTFIT, ADJUST_WIDTH,
|
||||
CONTINUOUS };
|
||||
CONTINUOUS, DELETE_LAST };
|
||||
|
||||
/* typedefs */
|
||||
struct CElement
|
||||
|
@ -230,6 +230,7 @@ void* search(void*);
|
|||
/* shortcut declarations */
|
||||
void sc_abort(Argument*);
|
||||
void sc_adjust_window(Argument*);
|
||||
void sc_change_buffer(Argument*);
|
||||
void sc_change_mode(Argument*);
|
||||
void sc_focus_inputbar(Argument*);
|
||||
void sc_navigate(Argument*);
|
||||
|
@ -884,6 +885,33 @@ sc_adjust_window(Argument* argument)
|
|||
draw(Zathura.PDF.page_number);
|
||||
}
|
||||
|
||||
void
|
||||
sc_change_buffer(Argument* argument)
|
||||
{
|
||||
if(!Zathura.Global.buffer)
|
||||
return;
|
||||
|
||||
int buffer_length = Zathura.Global.buffer->len;
|
||||
|
||||
if(argument->n == DELETE_LAST)
|
||||
{
|
||||
if((buffer_length - 1) == 0)
|
||||
{
|
||||
g_string_free(Zathura.Global.buffer, TRUE);
|
||||
Zathura.Global.buffer = NULL;
|
||||
gtk_label_set_markup((GtkLabel*) Zathura.Global.status_buffer, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
GString* temp = g_string_new_len(Zathura.Global.buffer->str, buffer_length - 1);
|
||||
g_string_free(Zathura.Global.buffer, TRUE);
|
||||
Zathura.Global.buffer = temp;
|
||||
gtk_label_set_markup((GtkLabel*) Zathura.Global.status_buffer, Zathura.Global.buffer->str);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
sc_change_mode(Argument* argument)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue