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:
parent
dd8f09dab8
commit
fe230eb95c
8 changed files with 46 additions and 30 deletions
|
@ -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,
|
||||
|
|
|
@ -39,16 +39,16 @@ typedef struct
|
|||
|
||||
typedef enum
|
||||
{
|
||||
TB_AUTOHEIGHT = 1 << 0,
|
||||
TB_AUTOWIDTH = 1 << 1,
|
||||
TB_LEFT = 1 << 16,
|
||||
TB_RIGHT = 1 << 17,
|
||||
TB_CENTER = 1 << 18,
|
||||
TB_EDITABLE = 1 << 19,
|
||||
TB_MARKUP = 1 << 20,
|
||||
TB_WRAP = 1 << 21,
|
||||
TB_PASSWORD = 1 << 22,
|
||||
TB_INDICATOR = 1 << 23,
|
||||
TB_AUTOHEIGHT = 1 << 0,
|
||||
TB_AUTOWIDTH = 1 << 1,
|
||||
TB_LEFT = 1 << 16,
|
||||
TB_RIGHT = 1 << 17,
|
||||
TB_CENTER = 1 << 18,
|
||||
TB_EDITABLE = 1 << 19,
|
||||
TB_MARKUP = 1 << 20,
|
||||
TB_WRAP = 1 << 21,
|
||||
TB_PASSWORD = 1 << 22,
|
||||
TB_INDICATOR = 1 << 23,
|
||||
} TextboxFlags;
|
||||
|
||||
typedef enum
|
||||
|
|
|
@ -198,7 +198,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length )
|
|||
// Reading one line per time.
|
||||
while ( getline ( &buffer, &buffer_length, fd ) > 0 ) {
|
||||
// Evaluate one line.
|
||||
unsigned int index = 0, ti = 0;
|
||||
unsigned int index = 0, ti = 0;
|
||||
char *token = buffer;
|
||||
|
||||
// Tokenize it.
|
||||
|
|
|
@ -197,7 +197,7 @@ GRegex **tokenize ( const char *input, int case_sensitive )
|
|||
}
|
||||
|
||||
char *saveptr = NULL, *token;
|
||||
GRegex **retv = NULL;
|
||||
GRegex **retv = NULL;
|
||||
if ( !config.tokenize ) {
|
||||
retv = g_malloc0 ( sizeof ( GRegex* ) * 2 );
|
||||
retv[0] = (GRegex *) create_regex ( input, case_sensitive );
|
||||
|
|
|
@ -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." },
|
||||
|
|
|
@ -74,9 +74,9 @@ struct xkb_stuff xkb = {
|
|||
.keymap = NULL,
|
||||
.state = NULL,
|
||||
.compose = {
|
||||
.table = NULL,
|
||||
.state = NULL
|
||||
}
|
||||
.table = NULL,
|
||||
.state = NULL
|
||||
}
|
||||
};
|
||||
char *config_path = NULL;
|
||||
// Array of modi.
|
||||
|
@ -441,22 +441,22 @@ static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UN
|
|||
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id );
|
||||
break;
|
||||
case XCB_XKB_STATE_NOTIFY:
|
||||
{
|
||||
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
|
||||
guint modmask;
|
||||
xkb_state_update_mask ( xkb.state,
|
||||
ksne->baseMods,
|
||||
ksne->latchedMods,
|
||||
ksne->lockedMods,
|
||||
ksne->baseGroup,
|
||||
ksne->latchedGroup,
|
||||
ksne->lockedGroup );
|
||||
modmask = x11_get_current_mask ( &xkb );
|
||||
if ( modmask == 0 ) {
|
||||
abe_trigger_release ( );
|
||||
}
|
||||
break;
|
||||
{
|
||||
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
|
||||
guint modmask;
|
||||
xkb_state_update_mask ( xkb.state,
|
||||
ksne->baseMods,
|
||||
ksne->latchedMods,
|
||||
ksne->lockedMods,
|
||||
ksne->baseGroup,
|
||||
ksne->latchedGroup,
|
||||
ksne->lockedGroup );
|
||||
modmask = x11_get_current_mask ( &xkb );
|
||||
if ( modmask == 0 ) {
|
||||
abe_trigger_release ( );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue