summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@blame.services>2023-01-18 09:22:19 +0100
committerDave Davenport <qball@blame.services>2023-01-18 09:25:39 +0100
commita20f8280a78f5fbfc9d0559e9607788ec2fca94b (patch)
treec72fda63c7f3b15ef69e0a642bdbdc38bb14083d
parent8155b2c476694e55452b14cbd15058d85df095db (diff)
[Textbox] Replace 'space' with a space
Issue: #1784
-rw-r--r--source/widgets/textbox.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c
index 4a58d912..6b7030db 100644
--- a/source/widgets/textbox.c
+++ b/source/widgets/textbox.c
@@ -887,12 +887,21 @@ gboolean textbox_append_text(textbox *tb, const char *pad, const int pad_len) {
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;
+ gunichar c = g_utf8_get_char(w);
+ if ( g_unichar_isspace(c)){
+ /** Replace tabs, newlines and others with a normal space. */
+ textbox_insert(tb, tb->cursor, " ", 1);
+ textbox_cursor(tb, tb->cursor + 1);
+ used_something = TRUE;
+ } else if ( g_unichar_iscntrl(c) ){
+ /* skip control characters. */
+ g_info("Got an invalid character: %08X",c);
+ } else {
+ /** Insert the text */
+ textbox_insert(tb, tb->cursor, w, n - w);
+ textbox_cursor(tb, tb->cursor + 1);
+ used_something = TRUE;
}
- textbox_insert(tb, tb->cursor, w, n - w);
- textbox_cursor(tb, tb->cursor + 1);
- used_something = TRUE;
}
return used_something;
}