textbox: Fix appending more than one character

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This commit is contained in:
Quentin Glidic 2017-06-01 13:24:44 +02:00
parent 711d97b66d
commit 2b6c084f32
No known key found for this signature in database
GPG Key ID: AC203F96E2C34BB7
3 changed files with 13 additions and 7 deletions

View File

@ -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

View File

@ -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;

View File

@ -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 )