on master help sign in
fdReadBuf instead of fdRead to input multi byte character
commit37b3a672ef4c9ea591b290b105b6e6c9ac3eba0b authoriocikun.jujon <PAF01143@nifty.ne.jp> dateMon 9 Jul 2012, 10:50 (14 years ago) parentc68f69f
2 files changed+9−3
src/Graphics/Vty/LLInput.hs+8−2 vty.cabal+1−1
src/Graphics/Vty/LLInput.hs+8−2
@@ -28,11 +28,13 @@ import System.Console.Terminfo
2828import System.Posix.Signals.Exts
2929import System.Posix.Terminal
3030import System.Posix.IO ( stdInput
31− ,fdRead
31+ ,fdReadBuf
3232 ,setFdOption
3333 ,FdOption(..)
3434 )
3535
36+import Foreign ( malloc, poke, peek, free )
37+
3638-- |Representations of non-modifier keys.
3739data Key = KEsc | KFun Int | KBackTab | KPrtScr | KPause | KASCII Char | KBS | KIns
3840 | KHome | KPageUp | KDel | KEnd | KPageDown | KBegin | KNP5 | KUp | KMenu
@@ -91,7 +93,11 @@ initTermInput escDelay terminal = do
9193 when (escDelay == 0) finishAtomicInput
9294 loop
9395 readAll = do
94− (bytes, bytes_read) <- fdRead stdInput 1
96+ ptr <- malloc
97+ poke ptr 0
98+ bytes_read <- fdReadBuf stdInput ptr 1
99+ bytes <- fmap ((: "") . chr . fromIntegral) $ peek ptr
100+ free ptr
95101 when (bytes_read > 0) $ do
96102 _ <- tryPutMVar hadInput () -- signal input
97103 writeChan inputChannel (head bytes)
vty.cabal+1−1
@@ -1,5 +1,5 @@
11Name: vty
2−Version: 4.7.0.14
2+Version: 4.7.0.14.10
33License: BSD3
44License-file: LICENSE
55Author: Stefan O'Rear, Corey O'Connor