on master help sign in
resolve the failure to parse reads from the terminal that contained 2 or more ESC prefixed keys.
a20928dCorey O'Connor
src/Graphics/Vty/Input/Internal.hs+7−4
@@ -20,7 +20,7 @@ import Control.Monad.Trans.Reader (ReaderT(..))
20import Data.Char
20import Data.Char
21import Data.Default
21import Data.Default
22import Data.IORef
22import Data.IORef
23−import Data.List( inits )
23+import Data.List(tails,inits)
24import qualified Data.Map as M( fromList, lookup )
24import qualified Data.Map as M( fromList, lookup )
25import Data.Maybe ( mapMaybe )
25import Data.Maybe ( mapMaybe )
26import qualified Data.Set as S( fromList, member )
26import qualified Data.Set as S( fromList, member )
@@ -160,12 +160,15 @@ compile table = cl' where
160 True -> Prefix
160 True -> Prefix
161 -- if the input_block is exactly what is expected for an event then consume the whole
161 -- if the input_block is exactly what is expected for an event then consume the whole
162 -- block and return the event
162 -- block and return the event
163− -- look up progressively large prefixes of the input block until an event is found
163+ -- look up progressively smaller tails of the input block until an event is found
164+ -- The assumption is that the event that consumes the most input bytes should be
165+ -- produced.
166+ -- The test verify_full_syn_input_to_event_2x verifies this.
164 -- H: There will always be one match. The prefix_set contains, by definition, all
167 -- H: There will always be one match. The prefix_set contains, by definition, all
165 -- prefixes of an event.
168 -- prefixes of an event.
166 False ->
169 False ->
167− let input_prefixes = init $ inits input_block
170+ let input_tails = init $ tail $ tails input_block
168− in case mapMaybe (\s -> (,) s `fmap` M.lookup s event_for_input) input_prefixes of
171+ in case mapMaybe (\s -> (,) s `fmap` M.lookup s event_for_input) input_tails of
169 (s,e) : _ -> Valid e (drop (length s) input_block)
172 (s,e) : _ -> Valid e (drop (length s) input_block)
170 -- neither a prefix or a full event. Might be interesting to log.
173 -- neither a prefix or a full event. Might be interesting to log.
171 [] -> Invalid
174 [] -> Invalid
test/VerifyUsingMockInput.hs+2−3
@@ -1,8 +1,7 @@
1{-# LANGUAGE MultiParamTypeClasses #-}
1{-# LANGUAGE MultiParamTypeClasses #-}
2{-# LANGUAGE FlexibleInstances #-}
2{-# LANGUAGE FlexibleInstances #-}
3−{- We setup the environment to envoke certain terminals of interest.
3+{- Generate some input bytes and delays between blocks of input bytes. Verify the events produced
4− - This assumes appropriate definitions exist in the current environment for the terminals of
4+ - are as expected.
5− - interest.
6 -}
5 -}
7module Main where
6module Main where
8
7