summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Glidic <sardemff7+git@sardemff7.net>2017-06-01 13:24:44 +0200
committerQuentin Glidic <sardemff7+git@sardemff7.net>2017-06-01 13:26:19 +0200
commit2b6c084f324373e118147fc9ee20cd78f0b8bf9e (patch)
tree047c34cd74906d9fa4f380c6a75a2dd151592087
parent711d97b66d451a173482c83bd73ecaae63904221 (diff)
textbox: Fix appending more than one character
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
-rw-r--r--include/widgets/textbox.h2
-rw-r--r--source/view.c2
-rw-r--r--source/widgets/textbox.c16
3 files changed, 13 insertions, 7 deletions
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 )