diff --git a/include/textbox.h b/include/textbox.h index 103898c6..455904f8 100644 --- a/include/textbox.h +++ b/include/textbox.h @@ -103,7 +103,15 @@ void textbox_text ( textbox *tb, const char *text ); void textbox_draw ( textbox *tb, cairo_t *draw ); int textbox_keybinding ( textbox *tb, KeyBindingAction action ); -gboolean textbox_append ( textbox *tb, char *pad, int pad_len ); +/** + * @param tb Handle to the textbox + * @param pad The text to insert + * @param pad_len the length of the text + * + * The text should be one insert from a keypress.. the first gunichar is validated to be (or not) control + * return TRUE if inserted + */ +gboolean textbox_append_char ( textbox *tb, char *pad, int pad_len ); /** * @param tb Handle to the textbox diff --git a/source/textbox.c b/source/textbox.c index e58230ea..a5f24bed 100644 --- a/source/textbox.c +++ b/source/textbox.c @@ -600,22 +600,19 @@ int textbox_keybinding ( textbox *tb, KeyBindingAction action ) g_return_val_if_reached ( 0 ); } -gboolean textbox_append ( textbox *tb, char *pad, int pad_len ) +gboolean textbox_append_char ( textbox *tb, char *pad, int pad_len ) { if ( !( tb->flags & TB_EDITABLE ) ) { return FALSE; } - int old_blink = tb->blink; - tb->blink = 2; // Filter When alt/ctrl is pressed do not accept the character. - if ( !g_ascii_iscntrl ( *pad ) ) { + if ( !g_unichar_iscntrl(g_utf8_get_char(pad))){ + tb->blink = 2; textbox_insert ( tb, tb->cursor, pad, pad_len ); textbox_cursor ( tb, tb->cursor + pad_len ); return TRUE; } - - tb->blink = old_blink; return FALSE; } diff --git a/source/view.c b/source/view.c index 1114c923..8473d859 100644 --- a/source/view.c +++ b/source/view.c @@ -1535,7 +1535,7 @@ static void rofi_view_handle_keypress ( RofiViewState *state, xkb_stuff *xkb, xc } } - if ( ( len > 0 ) && ( textbox_append ( state->text, pad, len ) ) ) { + if ( ( len > 0 ) && ( textbox_append_char ( state->text, pad, len ) ) ) { state->refilter = TRUE; state->update = TRUE; return;