1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-11 13:50:48 -05:00

Don't use g_ascii on utf8 string.

This commit is contained in:
Dave Davenport 2016-05-22 19:41:52 +02:00
parent 498fadc735
commit 99a79f7eb4
3 changed files with 13 additions and 8 deletions

View file

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

View file

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

View file

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