on master help sign in
fdReadBuf instead of fdRead to input multi byte character
37b3a67iocikun.jujon
src/Graphics/Vty/LLInput.hs+8−2
@@ -28,11 +28,13 @@ import System.Console.Terminfo
28import System.Posix.Signals.Exts
28import System.Posix.Signals.Exts
29import System.Posix.Terminal
29import System.Posix.Terminal
30import System.Posix.IO ( stdInput
30import System.Posix.IO ( stdInput
31− ,fdRead
31+ ,fdReadBuf
32 ,setFdOption
32 ,setFdOption
33 ,FdOption(..)
33 ,FdOption(..)
34 )
34 )
35
35
36+import Foreign ( malloc, poke, peek, free )
37+
36-- |Representations of non-modifier keys.
38-- |Representations of non-modifier keys.
37data Key = KEsc | KFun Int | KBackTab | KPrtScr | KPause | KASCII Char | KBS | KIns
39data Key = KEsc | KFun Int | KBackTab | KPrtScr | KPause | KASCII Char | KBS | KIns
38 | KHome | KPageUp | KDel | KEnd | KPageDown | KBegin | KNP5 | KUp | KMenu
40 | KHome | KPageUp | KDel | KEnd | KPageDown | KBegin | KNP5 | KUp | KMenu
@@ -91,7 +93,11 @@ initTermInput escDelay terminal = do
91 when (escDelay == 0) finishAtomicInput
93 when (escDelay == 0) finishAtomicInput
92 loop
94 loop
93 readAll = do
95 readAll = do
96+ ptr <- malloc
97+ poke ptr 0
94− (bytes, bytes_read) <- fdRead stdInput 1
98+ bytes_read <- fdReadBuf stdInput ptr 1
99+ bytes <- fmap ((: "") . chr . fromIntegral) $ peek ptr
100+ free ptr
95 when (bytes_read > 0) $ do
101 when (bytes_read > 0) $ do
96 _ <- tryPutMVar hadInput () -- signal input
102 _ <- tryPutMVar hadInput () -- signal input
97 writeChan inputChannel (head bytes)
103 writeChan inputChannel (head bytes)
vty.cabal+1−1
@@ -1,5 +1,5 @@
1Name: vty
1Name: vty
2−Version: 4.7.0.14
2+Version: 4.7.0.14.10
3License: BSD3
3License: BSD3
4License-file: LICENSE
4License-file: LICENSE
5Author: Stefan O'Rear, Corey O'Connor
5Author: Stefan O'Rear, Corey O'Connor