From: DeaDDooMER Date: Sun, 6 Oct 2019 22:03:09 +0000 (+0300) Subject: improve text input X-Git-Url: https://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=commitdiff_plain;h=6fc3ad181843ea8ee8c1be9060fda475b8d906b4 improve text input --- diff --git a/src/game/sdl/g_system.pas b/src/game/sdl/g_system.pas index 81b1ca3..25e95ec 100644 --- a/src/game/sdl/g_system.pas +++ b/src/game/sdl/g_system.pas @@ -263,11 +263,8 @@ implementation begin KeyPress(key) end; - if down and (ev.keysym.unicode <= $44F) then - begin - if IsPrintable1251(ch) then - CharPress(ch) - end + if down and IsValid1251(ev.keysym.unicode) and IsPrintable1251(ch) then + CharPress(ch) end; function sys_HandleInput (): Boolean; diff --git a/src/shared/utils.pas b/src/shared/utils.pas index 4c4db7b..20706c6 100644 --- a/src/shared/utils.pas +++ b/src/shared/utils.pas @@ -87,6 +87,7 @@ function int64ToStrComma (i: Int64): AnsiString; function upcase1251 (ch: AnsiChar): AnsiChar; inline; function locase1251 (ch: AnsiChar): AnsiChar; inline; +function IsValid1251 (ch: Word): Boolean; function IsPrintable1251 (ch: AnsiChar): Boolean; function toLowerCase1251 (const s: AnsiString): AnsiString; @@ -962,6 +963,11 @@ begin result := ch; end; +function IsValid1251 (ch: Word): Boolean; +begin + result := (ch = Ord('?')) or (wc2shitmap[ch] <> '?') +end; + function IsPrintable1251 (ch: AnsiChar): Boolean; begin result := (ch >= #32) and (ch <> #127)