mirror of
https://github.com/ilyakooo0/vty.git
synced 2024-10-04 19:27:08 +03:00
docs
This commit is contained in:
parent
0cd14329e5
commit
3a57dac719
@ -83,3 +83,4 @@ rm -rf dist ; cabal configure --enable-tests --disable-library-coverage \
|
||||
* http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
|
||||
* http://ulisse.elettra.trieste.it/services/doc/serial/config.html
|
||||
* http://www.leonerd.org.uk/hacks/hints/xterm-8bit.html
|
||||
* http://www.unixwiz.net/techtips/termios-vmin-vtime.html
|
||||
|
@ -8,19 +8,19 @@
|
||||
--
|
||||
-- Which is better? Well, depends on if you want to enter Unicode as UTF-8 or not.
|
||||
--
|
||||
-- * 7 bit mode: UTF-8 can be input unambiguiously. Requires an escape delay to differentiate ESC
|
||||
-- from extended control characters. EG: F1
|
||||
-- * 7 bit mode: UTF-8 can be input unambiguiously.
|
||||
-- * 8 bit mode: UTF-8 cannot be input. Does not require an escape delay.
|
||||
--
|
||||
-- By default 7 bit mode is used. If 8 bit moe is requested then vty will request 8 bit mode from
|
||||
-- the terminal. However, if the terminal does not report a capability that uses 8 bit encoding the
|
||||
-- mode will fall back to 7 bit.
|
||||
-- vty uses 7 bit mode.
|
||||
--
|
||||
-- To differentiate between ESC and control keys that contain ESC:
|
||||
-- vty using the timing of the input to differentiate.
|
||||
-- This, I best I can figure, is what VMIN and VTIME are supposed to be for.
|
||||
-- For some reason, I don't yet know, vty implements the timing in the library.
|
||||
-- I'm not sure if this is an advantage or not!
|
||||
--
|
||||
-- By default, the escape delay is 10000 microseconds. Which is assumed to be well above the
|
||||
-- sampling rate required to detect a keyup for a person typing 200 wpm.
|
||||
--
|
||||
-- 0. set raw mode with min == 0 and time == 0
|
||||
--
|
||||
module Graphics.Vty.Input ( Key(..)
|
||||
, Modifier(..)
|
||||
, Button(..)
|
||||
@ -42,8 +42,10 @@ import System.Posix.Signals.Exts
|
||||
import System.Posix.Terminal
|
||||
import System.Posix.IO (stdInput)
|
||||
|
||||
-- | By default, the escape delay is 10000 microseconds. Which is assumed to be well above the
|
||||
-- sampling rate required to detect a keyup for a person typing 200 wpm.
|
||||
defaultEscDelay :: Int
|
||||
defaultEscDelay = 4000
|
||||
defaultEscDelay = 10000
|
||||
|
||||
-- | Set up the terminal for input. Returns a function which reads key
|
||||
-- events, and a function for shutting down the terminal access.
|
||||
|
@ -27,15 +27,17 @@ data Event = EvKey Key [Modifier] | EvMouse Int Int Button [Modifier]
|
||||
-- | representation of mapping from input bytes to output event
|
||||
--
|
||||
-- deprecated
|
||||
type ClassifyTable = [(String, (Key, [Modifier]))]
|
||||
type ClassifyTableV1 = [(String, (Key, [Modifier]))]
|
||||
|
||||
map_to_legacy_table :: [(String, Event)] -> ClassifyTable
|
||||
type ClassifyTable = [(String, Event)]
|
||||
|
||||
map_to_legacy_table :: ClassifyTable -> ClassifyTableV1
|
||||
map_to_legacy_table = map f
|
||||
where f (s, EvKey k mods) = (s, (k, mods))
|
||||
f _ = error "no mapping for mouse or resize events"
|
||||
|
||||
-- | classify table directly generated from terminfo cap strings
|
||||
keys_from_caps_table :: [(String, Event)]
|
||||
keys_from_caps_table :: ClassifyTable
|
||||
keys_from_caps_table =
|
||||
[ ("khome", EvKey KHome [])
|
||||
, ("kend", EvKey KEnd [])
|
||||
@ -49,13 +51,13 @@ keys_from_caps_table =
|
||||
] ++ function_key_caps_table
|
||||
|
||||
-- | cap names for function keys
|
||||
function_key_caps_table :: [(String, Event)]
|
||||
function_key_caps_table :: ClassifyTable
|
||||
function_key_caps_table = flip map [0..63] $ \n -> ("kf" ++ show n, EvKey (KFun n) [])
|
||||
|
||||
-- VT 100 encoding for navigation keys.
|
||||
-- | Encoding for navigation keys.
|
||||
--
|
||||
-- TODO: remove those that duplicate entries in caps table.
|
||||
nav_keys_0 :: ClassifyTable
|
||||
-- TODO: This is not the same as the input bytes pulled from teh caps table.
|
||||
nav_keys_0 :: ClassifyTableV1
|
||||
nav_keys_0 =
|
||||
[ k "G" KNP5
|
||||
, k "P" KPause
|
||||
@ -69,8 +71,8 @@ nav_keys_0 =
|
||||
]
|
||||
where k c s = ("\ESC["++c,(s,[]))
|
||||
|
||||
-- | VT 100 (?) encoding for arrows and KHome/KEnd
|
||||
nav_keys_1 :: ClassifyTable
|
||||
-- | VT 100 (?) encoding for shift, meta and ctrl plus arrows/home/end
|
||||
nav_keys_1 :: ClassifyTableV1
|
||||
nav_keys_1 =
|
||||
[("\ESC[" ++ charCnt ++ show mc++c,(s,m))
|
||||
| charCnt <- ["1;", ""], -- we can have a count or not
|
||||
@ -105,9 +107,6 @@ simple_chars = [(x:[],(KASCII x,[])) | x <- [' ' .. toEnum 0xC1]]
|
||||
|
||||
-- | VT 100 (?) encoding for shift plus function keys
|
||||
--
|
||||
-- (corey): yes. This definitely should. On my terminal these keys do not operate as expected.
|
||||
-- function_keys_0 :: ClassifyTable
|
||||
-- function_keys_0 = [ ("\ESC[["++[toEnum(64+i)],(KFun i,[])) | i <- [1..5] ]
|
||||
-- TODO: I suspect this should be generated by interpretting the terminals use of meta mode:
|
||||
-- "If the terminal has a ``meta key'' which acts as a shift key, setting the 8th bit of any
|
||||
-- character transmitted, this fact can be indicated with km. Other- wise, software will
|
||||
|
Loading…
Reference in New Issue
Block a user