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_CHAR_FORWARD,
|
||||||
/** Remove previous character */
|
/** Remove previous character */
|
||||||
REMOVE_CHAR_BACK,
|
REMOVE_CHAR_BACK,
|
||||||
|
/** Remove till EOL */
|
||||||
|
REMOVE_TO_EOL,
|
||||||
/** Accept the current selected entry */
|
/** Accept the current selected entry */
|
||||||
ACCEPT_ENTRY,
|
ACCEPT_ENTRY,
|
||||||
ACCEPT_ALT,
|
ACCEPT_ALT,
|
||||||
|
|
|
@ -39,16 +39,16 @@ typedef struct
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
TB_AUTOHEIGHT = 1 << 0,
|
TB_AUTOHEIGHT = 1 << 0,
|
||||||
TB_AUTOWIDTH = 1 << 1,
|
TB_AUTOWIDTH = 1 << 1,
|
||||||
TB_LEFT = 1 << 16,
|
TB_LEFT = 1 << 16,
|
||||||
TB_RIGHT = 1 << 17,
|
TB_RIGHT = 1 << 17,
|
||||||
TB_CENTER = 1 << 18,
|
TB_CENTER = 1 << 18,
|
||||||
TB_EDITABLE = 1 << 19,
|
TB_EDITABLE = 1 << 19,
|
||||||
TB_MARKUP = 1 << 20,
|
TB_MARKUP = 1 << 20,
|
||||||
TB_WRAP = 1 << 21,
|
TB_WRAP = 1 << 21,
|
||||||
TB_PASSWORD = 1 << 22,
|
TB_PASSWORD = 1 << 22,
|
||||||
TB_INDICATOR = 1 << 23,
|
TB_INDICATOR = 1 << 23,
|
||||||
} TextboxFlags;
|
} TextboxFlags;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
|
|
@ -198,7 +198,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length )
|
||||||
// Reading one line per time.
|
// Reading one line per time.
|
||||||
while ( getline ( &buffer, &buffer_length, fd ) > 0 ) {
|
while ( getline ( &buffer, &buffer_length, fd ) > 0 ) {
|
||||||
// Evaluate one line.
|
// Evaluate one line.
|
||||||
unsigned int index = 0, ti = 0;
|
unsigned int index = 0, ti = 0;
|
||||||
char *token = buffer;
|
char *token = buffer;
|
||||||
|
|
||||||
// Tokenize it.
|
// Tokenize it.
|
||||||
|
|
|
@ -197,7 +197,7 @@ GRegex **tokenize ( const char *input, int case_sensitive )
|
||||||
}
|
}
|
||||||
|
|
||||||
char *saveptr = NULL, *token;
|
char *saveptr = NULL, *token;
|
||||||
GRegex **retv = NULL;
|
GRegex **retv = NULL;
|
||||||
if ( !config.tokenize ) {
|
if ( !config.tokenize ) {
|
||||||
retv = g_malloc0 ( sizeof ( GRegex* ) * 2 );
|
retv = g_malloc0 ( sizeof ( GRegex* ) * 2 );
|
||||||
retv[0] = (GRegex *) create_regex ( input, case_sensitive );
|
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_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_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_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_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_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." },
|
{ .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,
|
.keymap = NULL,
|
||||||
.state = NULL,
|
.state = NULL,
|
||||||
.compose = {
|
.compose = {
|
||||||
.table = NULL,
|
.table = NULL,
|
||||||
.state = NULL
|
.state = NULL
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
char *config_path = NULL;
|
char *config_path = NULL;
|
||||||
// Array of modi.
|
// 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 );
|
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id );
|
||||||
break;
|
break;
|
||||||
case XCB_XKB_STATE_NOTIFY:
|
case XCB_XKB_STATE_NOTIFY:
|
||||||
{
|
{
|
||||||
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
|
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
|
||||||
guint modmask;
|
guint modmask;
|
||||||
xkb_state_update_mask ( xkb.state,
|
xkb_state_update_mask ( xkb.state,
|
||||||
ksne->baseMods,
|
ksne->baseMods,
|
||||||
ksne->latchedMods,
|
ksne->latchedMods,
|
||||||
ksne->lockedMods,
|
ksne->lockedMods,
|
||||||
ksne->baseGroup,
|
ksne->baseGroup,
|
||||||
ksne->latchedGroup,
|
ksne->latchedGroup,
|
||||||
ksne->lockedGroup );
|
ksne->lockedGroup );
|
||||||
modmask = x11_get_current_mask ( &xkb );
|
modmask = x11_get_current_mask ( &xkb );
|
||||||
if ( modmask == 0 ) {
|
if ( modmask == 0 ) {
|
||||||
abe_trigger_release ( );
|
abe_trigger_release ( );
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return G_SOURCE_CONTINUE;
|
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 )
|
static void textbox_cursor_del_word ( textbox *tb )
|
||||||
{
|
{
|
||||||
if ( tb->cursor >= 0 ) {
|
if ( tb->cursor >= 0 ) {
|
||||||
|
@ -587,6 +596,9 @@ int textbox_keybinding ( textbox *tb, KeyBindingAction action )
|
||||||
case REMOVE_WORD_FORWARD:
|
case REMOVE_WORD_FORWARD:
|
||||||
textbox_cursor_del_word ( tb );
|
textbox_cursor_del_word ( tb );
|
||||||
return 1;
|
return 1;
|
||||||
|
case REMOVE_TO_EOL:
|
||||||
|
textbox_cursor_del_eol ( tb );
|
||||||
|
return 1;
|
||||||
// Delete or Ctrl-D
|
// Delete or Ctrl-D
|
||||||
case REMOVE_CHAR_FORWARD:
|
case REMOVE_CHAR_FORWARD:
|
||||||
textbox_cursor_del ( tb );
|
textbox_cursor_del ( tb );
|
||||||
|
|
|
@ -1438,6 +1438,7 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, KeyBindingAction actio
|
||||||
case CLEAR_LINE:
|
case CLEAR_LINE:
|
||||||
case MOVE_FRONT:
|
case MOVE_FRONT:
|
||||||
case MOVE_END:
|
case MOVE_END:
|
||||||
|
case REMOVE_TO_EOL:
|
||||||
case REMOVE_WORD_BACK:
|
case REMOVE_WORD_BACK:
|
||||||
case REMOVE_WORD_FORWARD:
|
case REMOVE_WORD_FORWARD:
|
||||||
case REMOVE_CHAR_FORWARD:
|
case REMOVE_CHAR_FORWARD:
|
||||||
|
|
Loading…
Reference in a new issue