diff options
author | Simon Howard | 2014-10-19 16:52:36 -0400 |
---|---|---|
committer | Simon Howard | 2014-10-19 16:52:36 -0400 |
commit | 16c56ea0c4476f4d908a4f8073cab48cdfe43005 (patch) | |
tree | a90780cde55293238182625dcffdc4addfae1721 /textscreen/txt_gui.c | |
parent | a8a5d2899a73f9830f69fe2c329d2a81e299def8 (diff) | |
download | chocolate-doom-16c56ea0c4476f4d908a4f8073cab48cdfe43005.tar.gz chocolate-doom-16c56ea0c4476f4d908a4f8073cab48cdfe43005.tar.bz2 chocolate-doom-16c56ea0c4476f4d908a4f8073cab48cdfe43005.zip |
textscreen: Don't allow input of unprintable characters.
If a Unicode character is not part of the Extended ASCII set that
we can display on screen, don't allow it to be typed (which would
display a backwards question mark). Thanks Alexandre-Xavier for this
suggestion on #229.
Diffstat (limited to 'textscreen/txt_gui.c')
-rw-r--r-- | textscreen/txt_gui.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/textscreen/txt_gui.c b/textscreen/txt_gui.c index 1a5275b6..74e3ec75 100644 --- a/textscreen/txt_gui.c +++ b/textscreen/txt_gui.c @@ -322,6 +322,29 @@ static void PutUnicodeChar(unsigned int c) TXT_PutChar('\xa8'); } +int TXT_CanDrawCharacter(unsigned int c) +{ + unsigned int i; + + // Standard ASCII range? + if (c < 128) + { + return 1; + } + + // Extended ASCII range? + for (i = 0; i < 128; ++i) + { + if (cp437_unicode[i] == c) + { + return 1; + } + } + + // Nope. + return 0; +} + void TXT_DrawUTF8String(const char *s) { int x, y; |