1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Fix #432, Control+k removes till eol.

This commit is contained in:
Dave Davenport 2016-07-25 11:32:30 +02:00
parent dd8f09dab8
commit fe230eb95c
8 changed files with 46 additions and 30 deletions

View file

@ -35,6 +35,8 @@ typedef enum
REMOVE_CHAR_FORWARD,
/** Remove previous character */
REMOVE_CHAR_BACK,
/** Remove till EOL */
REMOVE_TO_EOL,
/** Accept the current selected entry */
ACCEPT_ENTRY,
ACCEPT_ALT,

View file

@ -47,6 +47,7 @@ DefaultBinding bindings[NUM_ABE] =
{ .id = REMOVE_WORD_FORWARD, .name = "kb-remove-word-forward", .keybinding = "Control+Alt+d", .comment = "Delete next word" },
{ .id = REMOVE_CHAR_FORWARD, .name = "kb-remove-char-forward", .keybinding = "Delete,Control+d", .comment = "Delete next char" },
{ .id = REMOVE_CHAR_BACK, .name = "kb-remove-char-back", .keybinding = "BackSpace,Control+h", .comment = "Delete previous char" },
{ .id = REMOVE_TO_EOL, .name = "kb-remove-to-eol", .keybinding = "Control+k", .comment = "Delete till the end of line" },
{ .id = ACCEPT_ENTRY, .name = "kb-accept-entry", .keybinding = "Control+j,Control+m,Return,KP_Enter", .comment = "Accept entry" },
{ .id = ACCEPT_CUSTOM, .name = "kb-accept-custom", .keybinding = "Control+Return", .comment = "Use entered text as command (in ssh/run modi)" },
{ .id = ACCEPT_ALT, .name = "kb-accept-alt", .keybinding = "Shift+Return", .comment = "Use alternate accept command." },

View file

@ -535,6 +535,15 @@ static void textbox_cursor_bkspc_word ( textbox *tb )
}
}
}
static void textbox_cursor_del_eol ( textbox *tb )
{
if ( tb->cursor >= 0 ) {
int length = strlen ( tb->text ) - tb->cursor;
if ( length >= 0 ) {
textbox_delete ( tb, tb->cursor, length );
}
}
}
static void textbox_cursor_del_word ( textbox *tb )
{
if ( tb->cursor >= 0 ) {
@ -587,6 +596,9 @@ int textbox_keybinding ( textbox *tb, KeyBindingAction action )
case REMOVE_WORD_FORWARD:
textbox_cursor_del_word ( tb );
return 1;
case REMOVE_TO_EOL:
textbox_cursor_del_eol ( tb );
return 1;
// Delete or Ctrl-D
case REMOVE_CHAR_FORWARD:
textbox_cursor_del ( tb );

View file

@ -1438,6 +1438,7 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, KeyBindingAction actio
case CLEAR_LINE:
case MOVE_FRONT:
case MOVE_END:
case REMOVE_TO_EOL:
case REMOVE_WORD_BACK:
case REMOVE_WORD_FORWARD:
case REMOVE_CHAR_FORWARD: