diff --git a/include/widgets/textbox.h b/include/widgets/textbox.h index c93da6eb..f63c7d74 100644 --- a/include/widgets/textbox.h +++ b/include/widgets/textbox.h @@ -170,7 +170,7 @@ int textbox_keybinding ( textbox *tb, KeyBindingAction action ); * 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, const char *pad, const int pad_len ); +gboolean textbox_append_text ( textbox *tb, const char *pad, const int pad_len ); /** * @param tb Handle to the textbox diff --git a/source/view.c b/source/view.c index 8d09575d..dd536639 100644 --- a/source/view.c +++ b/source/view.c @@ -1477,7 +1477,7 @@ void rofi_view_itterrate ( RofiViewState *state, xcb_generic_event_t *event, NkB gchar *text; text = nk_bindings_seat_handle_key ( seat, xkpe->detail, NK_BINDINGS_KEY_STATE_PRESS ); - if ( ( text != NULL ) && ( textbox_append_char ( state->text, text, strlen ( text ) ) ) ) { + if ( ( text != NULL ) && ( textbox_append_text ( state->text, text, strlen ( text ) ) ) ) { state->refilter = TRUE; } break; diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c index 7bac65f5..ea6c4824 100644 --- a/source/widgets/textbox.c +++ b/source/widgets/textbox.c @@ -729,19 +729,25 @@ int textbox_keybinding ( textbox *tb, KeyBindingAction action ) } } -gboolean textbox_append_char ( textbox *tb, const char *pad, const int pad_len ) +gboolean textbox_append_text ( textbox *tb, const char *pad, const int pad_len ) { if ( !( tb->flags & TB_EDITABLE ) ) { return FALSE; } // Filter When alt/ctrl is pressed do not accept the character. - if ( !g_unichar_iscntrl ( g_utf8_get_char ( pad ) ) ) { - textbox_insert ( tb, tb->cursor, pad, pad_len ); + + gboolean used_something = FALSE; + const gchar *w, *n, *e; + for ( w = pad, n = g_utf8_next_char(w), e = w + pad_len ; w < e ; w = n, n = g_utf8_next_char(n) ) { + if ( g_unichar_iscntrl ( g_utf8_get_char ( w ) ) ) { + continue; + } + textbox_insert ( tb, tb->cursor, w, n - w ); textbox_cursor ( tb, tb->cursor + 1 ); - return TRUE; + used_something = TRUE; } - return FALSE; + return used_something; } static void tbfc_entry_free ( TBFontConfig *tbfc )