on master help sign in
add another tests and more docs
commit4e99fd9719fc399f058b46848330b87887222b97 authorCorey O'Connor <corey@ooyala.com> dateMon 11 Nov 2013, 22:05 (13 years ago) parent849fc71
3 files changed+42−1
CHANGELOG+5 src/Graphics/Vty/Input.hs+26−1 test/VerifyUsingMockInput.hs+11
CHANGELOG+5
@@ -20,6 +20,11 @@
2020 visibility changes in the Picture will have no effect.
2121 * alternate (setf/setb) color maps supported. Though colors beyond the first 8 are just a
2222 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.
2328
24294.7.0.0
2530 * API changes:
src/Graphics/Vty/Input.hs+26−1
@@ -1,5 +1,7 @@
11-- Copyright 2009-2010 Corey O'Connor
22--
3+-- Right, I'm mostly guessing on these details. So, as far as I can figure:
4+--
35-- There are two input modes:
46-- 1. 7 bit
57-- 2. 8 bit
@@ -45,10 +47,33 @@ defaultEscDelay = 4000
4547
4648-- | Set up the terminal for input. Returns a function which reads key
4749-- 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+--
4874initTermInput :: Int -> Terminal -> IO (IO Event, IO ())
4975initTermInput escDelay terminal = do
5076 attr <- getTerminalAttributes stdInput
51− -- disable IXON,
5277 let attr' = foldl withoutMode attr [ StartStopOutput, KeyboardInterrupts
5378 , EnableEcho, ProcessInput, ExtendedFunctions
5479 ]
test/VerifyUsingMockInput.hs+11
@@ -171,6 +171,15 @@ verify_simple_syn_input_to_event = forAll $ \(InputBlocksUsingTable gen) ->
171171 input = intersperse (Delay test_key_delay) keydowns
172172 assert_events_from_syn_input (map_to_legacy_table table) input events
173173
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+
174183main :: IO ()
175184main = defaultMain
176185 [ testProperty "basic block generated from a single ansi chars to event translation"
@@ -179,5 +188,7 @@ main = defaultMain
179188 verify_keys_from_caps_table_block_to_event
180189 , testProperty "synthesized typing from basic blocks translates to expected events"
181190 verify_simple_syn_input_to_event
191+ , testProperty "synthesized typing from function keys translates to expected events"
192+ verify_fkeys_syn_input_to_event
182193 ]
183194