mirror of
https://github.com/davatorium/rofi.git
synced 2025-03-10 17:06:37 -04:00
textbox: Fix appending more than one character
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This commit is contained in:
parent
711d97b66d
commit
2b6c084f32
3 changed files with 13 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 )
|
||||
|
|
Loading…
Add table
Reference in a new issue