From 524988feaa43a6bb8e1fdb2895692a87e843e7a4 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Sun, 25 Jun 2017 18:17:46 +0200 Subject: [PATCH] filter unrenderable chars from console input filter all chars that have no entry in the current font --- source/src/console.h | 4 +++- source/src/protos.h | 1 + source/src/rendertext.cpp | 13 +++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/source/src/console.h b/source/src/console.h index eda109ad..7a7fb101 100644 --- a/source/src/console.h +++ b/source/src/console.h @@ -96,7 +96,9 @@ struct textinputbuffer default: { - if(unicode) + extern bool filterunrenderables(char *s); + char tmp[2] = { (char)unicode, 0 }; + if(unicode && !filterunrenderables(tmp)) { size_t len = strlen(buf); if(max && (int)len>=max) break; diff --git a/source/src/protos.h b/source/src/protos.h index 04730379..f5336758 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -724,6 +724,7 @@ extern void text_pos(const char *str, int cursor, int &cx, int &cy, int maxwidth extern void text_startcolumns(); extern void text_endcolumns(); extern void cutcolorstring(char *text, int len); +extern bool filterunrenderables(char *s); // editing #define EDITSEL(x) if(noteditmode(x) || noselection()) return diff --git a/source/src/rendertext.cpp b/source/src/rendertext.cpp index a672e69a..d131d7ea 100644 --- a/source/src/rendertext.cpp +++ b/source/src/rendertext.cpp @@ -445,6 +445,19 @@ void cutcolorstring(char *text, int maxlen) } } +bool filterunrenderables(char *s) +{ + bool res = false; + char *d = s; + while(*s) + { + if(!curfont->chars.inrange(*s - curfont->skip) && *s != ' ') res = true; + else *d++ = *s; + s++; + } + return res; +} + // animated inlined graphics VAR(igraphdefaultframetime, 5, 200, 2000);