@@ -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(..)
36+import Foreign ( malloc, poke, peek, free )
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
93 readAll = do
95 readAll = do
94− (bytes, bytes_read) <- fdRead stdInput 1
98+ bytes_read <- fdReadBuf stdInput ptr 1
99+ bytes <- fmap ((: "") . chr . fromIntegral) $ peek 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)