mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-27 13:36:00 +01:00
Delete line to start
Thanks to n0nsense
This commit is contained in:
parent
162ae295b7
commit
eae4e48877
2 changed files with 37 additions and 27 deletions
|
@ -134,6 +134,7 @@ InputbarShortcut inputbar_shortcuts[] = {
|
|||
{GDK_CONTROL_MASK, GDK_ISO_Left_Tab, isc_completion, { PREVIOUS_GROUP } },
|
||||
{0, GDK_BackSpace, isc_string_manipulation, { DELETE_LAST_CHAR } },
|
||||
{GDK_CONTROL_MASK, GDK_h, isc_string_manipulation, { DELETE_LAST_CHAR } },
|
||||
{GDK_CONTROL_MASK, GDK_u, isc_string_manipulation, { DELETE_TO_LINE_START } },
|
||||
{GDK_CONTROL_MASK, GDK_w, isc_string_manipulation, { DELETE_LAST_WORD } },
|
||||
{GDK_CONTROL_MASK, GDK_f, isc_string_manipulation, { NEXT_CHAR } },
|
||||
{GDK_CONTROL_MASK, GDK_b, isc_string_manipulation, { PREVIOUS_CHAR } },
|
||||
|
|
29
zathura.c
29
zathura.c
|
@ -26,7 +26,8 @@ enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN, BOTTOM, TOP, HIDE, HIGHLIGHT,
|
|||
PREVIOUS_GROUP, ZOOM_IN, ZOOM_OUT, ZOOM_ORIGINAL, ZOOM_SPECIFIC, FORWARD,
|
||||
BACKWARD, ADJUST_BESTFIT, ADJUST_WIDTH, ADJUST_NONE, CONTINUOUS, DELETE_LAST,
|
||||
ADD_MARKER, EVAL_MARKER, EXPAND, COLLAPSE, SELECT, GOTO_DEFAULT, GOTO_LABELS,
|
||||
GOTO_OFFSET, HALF_UP, HALF_DOWN, FULL_UP, FULL_DOWN, NEXT_CHAR, PREVIOUS_CHAR };
|
||||
GOTO_OFFSET, HALF_UP, HALF_DOWN, FULL_UP, FULL_DOWN, NEXT_CHAR, PREVIOUS_CHAR,
|
||||
DELETE_TO_LINE_START };
|
||||
|
||||
/* define modes */
|
||||
#define ALL (1 << 0)
|
||||
|
@ -2604,10 +2605,11 @@ isc_string_manipulation(Argument* argument)
|
|||
gchar *input = gtk_editable_get_chars(GTK_EDITABLE(Zathura.UI.inputbar), 0, -1);
|
||||
int length = strlen(input);
|
||||
int pos = gtk_editable_get_position(GTK_EDITABLE(Zathura.UI.inputbar));
|
||||
int i;
|
||||
|
||||
if(argument->n == DELETE_LAST_WORD)
|
||||
{
|
||||
int i = pos - 1;
|
||||
switch (argument->n) {
|
||||
case DELETE_LAST_WORD:
|
||||
i = pos - 1;
|
||||
|
||||
if(!pos)
|
||||
return;
|
||||
|
@ -2621,18 +2623,25 @@ isc_string_manipulation(Argument* argument)
|
|||
|
||||
gtk_editable_delete_text(GTK_EDITABLE(Zathura.UI.inputbar), i, pos);
|
||||
gtk_editable_set_position(GTK_EDITABLE(Zathura.UI.inputbar), i);
|
||||
}
|
||||
else if(argument->n == DELETE_LAST_CHAR)
|
||||
{
|
||||
break;
|
||||
case DELETE_LAST_CHAR:
|
||||
if((length - 1) <= 0)
|
||||
isc_abort(NULL);
|
||||
|
||||
gtk_editable_delete_text(GTK_EDITABLE(Zathura.UI.inputbar), pos - 1, pos);
|
||||
}
|
||||
else if(argument->n == NEXT_CHAR)
|
||||
break;
|
||||
case DELETE_TO_LINE_START:
|
||||
gtk_editable_delete_text(GTK_EDITABLE(Zathura.UI.inputbar), 1, pos);
|
||||
break;
|
||||
case NEXT_CHAR:
|
||||
gtk_editable_set_position(GTK_EDITABLE(Zathura.UI.inputbar), pos + 1);
|
||||
else if(argument->n == PREVIOUS_CHAR)
|
||||
break;
|
||||
case PREVIOUS_CHAR:
|
||||
gtk_editable_set_position(GTK_EDITABLE(Zathura.UI.inputbar), (pos == 0) ? 0 : pos - 1);
|
||||
break;
|
||||
default: /* unreachable */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* command implementation */
|
||||
|
|
Loading…
Reference in a new issue