textbox/key: Cleanup

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This commit is contained in:
Quentin Glidic 2016-04-07 15:11:42 +02:00
parent 67c9fe158a
commit aa350a1583
3 changed files with 24 additions and 24 deletions

View File

@ -110,7 +110,7 @@ void textbox_draw ( textbox *tb, cairo_t *draw );
* @returns if the key was handled (1), unhandled(0) or handled and return was pressed (-1)
*/
int textbox_keybinding ( textbox *tb, unsigned int modstate, xkb_keysym_t key );
int textbox_keypress ( textbox *tb, char *pad, int pad_len );
gboolean textbox_append ( textbox *tb, char *pad, int pad_len );
/**
* @param tb Handle to the textbox

View File

@ -539,59 +539,59 @@ int textbox_keybinding ( textbox *tb, unsigned int modstate, xkb_keysym_t key )
return 2;
}
// Right or Ctrl-F
else if ( abe_test_action ( MOVE_CHAR_FORWARD, modstate, key ) ) {
if ( abe_test_action ( MOVE_CHAR_FORWARD, modstate, key ) ) {
textbox_cursor_inc ( tb );
return 2;
}
// Ctrl-U: Kill from the beginning to the end of the line.
else if ( abe_test_action ( CLEAR_LINE, modstate, key ) ) {
if ( abe_test_action ( CLEAR_LINE, modstate, key ) ) {
textbox_text ( tb, "" );
return 1;
}
// Ctrl-A
else if ( abe_test_action ( MOVE_FRONT, modstate, key ) ) {
if ( abe_test_action ( MOVE_FRONT, modstate, key ) ) {
textbox_cursor ( tb, 0 );
return 2;
}
// Ctrl-E
else if ( abe_test_action ( MOVE_END, modstate, key ) ) {
if ( abe_test_action ( MOVE_END, modstate, key ) ) {
textbox_cursor_end ( tb );
return 2;
}
// Ctrl-Alt-h
else if ( abe_test_action ( REMOVE_WORD_BACK, modstate, key ) ) {
if ( abe_test_action ( REMOVE_WORD_BACK, modstate, key ) ) {
textbox_cursor_bkspc_word ( tb );
return 1;
}
// Ctrl-Alt-d
else if ( abe_test_action ( REMOVE_WORD_FORWARD, modstate, key ) ) {
if ( abe_test_action ( REMOVE_WORD_FORWARD, modstate, key ) ) {
textbox_cursor_del_word ( tb );
return 1;
} // Delete or Ctrl-D
else if ( abe_test_action ( REMOVE_CHAR_FORWARD, modstate, key ) ) {
if ( abe_test_action ( REMOVE_CHAR_FORWARD, modstate, key ) ) {
textbox_cursor_del ( tb );
return 1;
}
// Alt-B
else if ( abe_test_action ( MOVE_WORD_BACK, modstate, key ) ) {
if ( abe_test_action ( MOVE_WORD_BACK, modstate, key ) ) {
textbox_cursor_dec_word ( tb );
return 2;
}
// Alt-F
else if ( abe_test_action ( MOVE_WORD_FORWARD, modstate, key ) ) {
if ( abe_test_action ( MOVE_WORD_FORWARD, modstate, key ) ) {
textbox_cursor_inc_word ( tb );
return 2;
}
// BackSpace, Ctrl-h
else if ( abe_test_action ( REMOVE_CHAR_BACK, modstate, key ) ) {
if ( abe_test_action ( REMOVE_CHAR_BACK, modstate, key ) ) {
textbox_cursor_bkspc ( tb );
return 1;
}
else if ( abe_test_action ( ACCEPT_CUSTOM, modstate, key ) ) {
if ( abe_test_action ( ACCEPT_CUSTOM, modstate, key ) ) {
return -2;
}
else if ( abe_test_action ( ACCEPT_ENTRY, modstate, key ) ) {
if ( abe_test_action ( ACCEPT_ENTRY, modstate, key ) ) {
return -1;
}
@ -599,23 +599,23 @@ int textbox_keybinding ( textbox *tb, unsigned int modstate, xkb_keysym_t key )
return 0;
}
int textbox_keypress ( textbox *tb, char *pad, int pad_len )
gboolean textbox_append ( textbox *tb, char *pad, int pad_len )
{
if ( !( tb->flags & TB_EDITABLE ) ) {
return 0;
return FALSE;
}
int old_blink = tb->blink;
tb->blink = 2;
if ( pad_len > 0 ) {
// Filter When alt/ctrl is pressed do not accept the character.
if ( !g_ascii_iscntrl ( *pad ) ) {
textbox_insert ( tb, tb->cursor, pad, pad_len );
textbox_cursor ( tb, tb->cursor + pad_len );
return 1;
}
// Filter When alt/ctrl is pressed do not accept the character.
if ( !g_ascii_iscntrl ( *pad ) ) {
textbox_insert ( tb, tb->cursor, pad, pad_len );
textbox_cursor ( tb, tb->cursor + pad_len );
return TRUE;
}
tb->blink = old_blink;
return 0;
return FALSE;
}
/***

View File

@ -1459,7 +1459,7 @@ static void rofi_view_handle_keypress ( RofiViewState *state, xkb_stuff *xkb, xc
}
}
if ( ( len > 0 ) && ( textbox_keypress ( state->text, pad, len ) ) ) {
if ( ( len > 0 ) && ( textbox_append ( state->text, pad, len ) ) ) {
state->refilter = TRUE;
state->update = TRUE;
return;