on master help sign in
add another tests and more docs
4e99fd9Corey O'Connor
CHANGELOG+5
@@ -20,6 +20,11 @@
20 visibility changes in the Picture will have no effect.
20 visibility changes in the Picture will have no effect.
21 * alternate (setf/setb) color maps supported. Though colors beyond the first 8 are just a
21 * alternate (setf/setb) color maps supported. Though colors beyond the first 8 are just a
22 guess.
22 guess.
23+ * input handling changes
24+ * tests exist
25+ * the default amount of time between ESC and a subsequent character that causes VTY to
26+ interpret the input as "ESC" then the character, versus some special key, has been
27+ increased to 4000 microseconds.
23
28
244.7.0.0
294.7.0.0
25 * API changes:
30 * API changes:
src/Graphics/Vty/Input.hs+26−1
@@ -1,5 +1,7 @@
1-- Copyright 2009-2010 Corey O'Connor
1-- Copyright 2009-2010 Corey O'Connor
2--
2--
3+-- Right, I'm mostly guessing on these details. So, as far as I can figure:
4+--
3-- There are two input modes:
5-- There are two input modes:
4-- 1. 7 bit
6-- 1. 7 bit
5-- 2. 8 bit
7-- 2. 8 bit
@@ -45,10 +47,33 @@ defaultEscDelay = 4000
45
47
46-- | Set up the terminal for input. Returns a function which reads key
48-- | Set up the terminal for input. Returns a function which reads key
47-- events, and a function for shutting down the terminal access.
49-- events, and a function for shutting down the terminal access.
50+--
51+-- The terminal is modified as follows:
52+--
53+-- * IXON disabled
54+-- - disables software flow control on outgoing data. This stops the process from being
55+-- suspended if the output terminal cannot keep up. I presume this has little effect these
56+-- days. I hope this means that output will be buffered if the terminal cannot keep up. In the
57+-- ol days the output might of been dropped.
58+--
59+-- "raw" mode is used for input.
60+--
61+-- * ISIG disabled
62+-- - enables keyboard combinations that result in signals. People would probably want this to
63+-- be an option.
64+--
65+-- * ECHO disabled
66+-- - input is not echod to the output.
67+--
68+-- * ICANON disabled
69+-- - canonical mode (line mode) input is not used.
70+--
71+-- * IEXTEN disabled
72+-- - extended functions are disabled. Uh. Whatever these are.
73+--
48initTermInput :: Int -> Terminal -> IO (IO Event, IO ())
74initTermInput :: Int -> Terminal -> IO (IO Event, IO ())
49initTermInput escDelay terminal = do
75initTermInput escDelay terminal = do
50 attr <- getTerminalAttributes stdInput
76 attr <- getTerminalAttributes stdInput
51− -- disable IXON,
52 let attr' = foldl withoutMode attr [ StartStopOutput, KeyboardInterrupts
77 let attr' = foldl withoutMode attr [ StartStopOutput, KeyboardInterrupts
53 , EnableEcho, ProcessInput, ExtendedFunctions
78 , EnableEcho, ProcessInput, ExtendedFunctions
54 ]
79 ]
test/VerifyUsingMockInput.hs+11
@@ -171,6 +171,15 @@ verify_simple_syn_input_to_event = forAll $ \(InputBlocksUsingTable gen) ->
171 input = intersperse (Delay test_key_delay) keydowns
171 input = intersperse (Delay test_key_delay) keydowns
172 assert_events_from_syn_input (map_to_legacy_table table) input events
172 assert_events_from_syn_input (map_to_legacy_table table) input events
173
173
174+verify_fkeys_syn_input_to_event :: Property IO
175+verify_fkeys_syn_input_to_event = forAll $ \(InputBlocksUsingTable gen) -> monadic $ do
176+ let table = function_keys_0
177+ input_seq = gen table
178+ events = [EvKey k ms | (_,(k,ms)) <- input_seq]
179+ keydowns = [Bytes s | (s,_) <- input_seq]
180+ input = intersperse (Delay test_key_delay) keydowns
181+ assert_events_from_syn_input (concat ansi_classify_table) input events
182+
174main :: IO ()
183main :: IO ()
175main = defaultMain
184main = defaultMain
176 [ testProperty "basic block generated from a single ansi chars to event translation"
185 [ testProperty "basic block generated from a single ansi chars to event translation"
@@ -179,5 +188,7 @@ main = defaultMain
179 verify_keys_from_caps_table_block_to_event
188 verify_keys_from_caps_table_block_to_event
180 , testProperty "synthesized typing from basic blocks translates to expected events"
189 , testProperty "synthesized typing from basic blocks translates to expected events"
181 verify_simple_syn_input_to_event
190 verify_simple_syn_input_to_event
191+ , testProperty "synthesized typing from function keys translates to expected events"
192+ verify_fkeys_syn_input_to_event
182 ]
193 ]
183
194