[commit: packages/haskeline] master: Properly process Unicode key events on Windows (#55) (18a978c)
git at git.haskell.org
git at git.haskell.org
Wed Mar 8 04:53:51 UTC 2017
Repository : ssh://git@git.haskell.org/haskeline
On branch : master
Link : http://git.haskell.org/packages/haskeline.git/commitdiff/18a978ce7138eec9bbe6d93e5e241f135f76e2e0
>---------------------------------------------------------------
commit 18a978ce7138eec9bbe6d93e5e241f135f76e2e0
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date: Fri Feb 17 18:08:10 2017 -0500
Properly process Unicode key events on Windows (#55)
Fixes #54.
>---------------------------------------------------------------
18a978ce7138eec9bbe6d93e5e241f135f76e2e0
Changelog | 2 ++
System/Console/Haskeline/Backend/Win32.hsc | 6 +++++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/Changelog b/Changelog
index 87dab99..388e339 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,5 @@
+next:
+ * Properly process Unicode key events on Windows.
Changed in version 0.7.3.1:
* Properly disable echoing in getPassword when running in MinTTY.
* Use `cast` from Data.Typeable instead of Data.Dynamic.
diff --git a/System/Console/Haskeline/Backend/Win32.hsc b/System/Console/Haskeline/Backend/Win32.hsc
index 9471354..b15a827 100644
--- a/System/Console/Haskeline/Backend/Win32.hsc
+++ b/System/Console/Haskeline/Backend/Win32.hsc
@@ -73,8 +73,12 @@ consoleHandles = do
processEvent :: InputEvent -> Maybe Event
-processEvent KeyEvent {keyDown = True, unicodeChar = c, virtualKeyCode = vc,
+processEvent KeyEvent {keyDown = kd, unicodeChar = c, virtualKeyCode = vc,
controlKeyState = cstate}
+ | kd || ((testMod (#const LEFT_ALT_PRESSED) || vc == (#const VK_MENU))
+ && c /= '\NUL')
+ -- Make sure not to ignore Unicode key events! The Unicode character might
+ -- only be emitted on a keyup event. See also GH issue #54.
= fmap (\e -> KeyInput [Key modifier' e]) $ keyFromCode vc `mplus` simpleKeyChar
where
simpleKeyChar = guard (c /= '\NUL') >> return (KeyChar c)
More information about the ghc-commits
mailing list