on d64ff96 help sign in
vty/src/Graphics/Vty/Input/Events.hs
65 lines 2.9 kB history raw
1{-# Language DeriveGeneric #-}
2module Graphics.Vty.Input.Events where
4import Data.ByteString
5import GHC.Generics
7-- | Representations of non-modifier keys.
8--
9-- * KFun is indexed from 0 to 63. Range of supported FKeys varies by
10-- terminal and keyboard.
11--
12-- * KUpLeft, KUpRight, KDownLeft, KDownRight, KCenter support varies by
13-- terminal and keyboard.
14--
15-- * Actually, support for most of these but KEsc, KChar, KBS, and
16-- KEnter vary by terminal and keyboard.
17data Key = KEsc | KChar Char | KBS | KEnter
18 | KLeft | KRight | KUp | KDown
19 | KUpLeft | KUpRight | KDownLeft | KDownRight | KCenter
20 | KFun Int | KBackTab | KPrtScr | KPause | KIns
21 | KHome | KPageUp | KDel | KEnd | KPageDown | KBegin | KMenu
22 deriving (Eq,Show,Read,Ord,Generic)
24-- | Modifier keys. Key codes are interpreted such that users are more
25-- likely to have Meta than Alt; for instance on the PC Linux console,
26-- 'MMeta' will generally correspond to the physical Alt key.
27data Modifier = MShift | MCtrl | MMeta | MAlt
28 deriving (Eq,Show,Read,Ord,Generic)
30-- | Mouse buttons.
31data Button = BLeft | BMiddle | BRight | BScrollUp | BScrollDown
32 deriving (Eq,Show,Read,Ord,Generic)
34-- | Events.
35data Event
36 = EvKey Key [Modifier]
37 -- ^ A keyboard key was pressed with the specified modifiers.
38 | EvMouseDown Int Int Button [Modifier]
39 -- ^ A mouse button was pressed at the specified column and row. Any
40 -- modifiers available in the event are also provided.
41 | EvMouseUp Int Int (Maybe Button)
42 -- ^ A mouse button was released at the specified column and
43 -- row. Some terminals report only that a button was released
44 -- without specifying which one; in that case, Nothing is provided.
45 -- Otherwise Just the button released is included in the event.
46 | EvResize Int Int
47 -- ^ If read from 'eventChannel' this is the size at the time of the
48 -- signal. If read from 'nextEvent' this is the size at the time the
49 -- event was processed by Vty. Typically these are the same, but if
50 -- somebody is resizing the terminal quickly they can be different.
51 | EvPaste ByteString
52 -- ^ A paste event occurs when a bracketed paste input sequence is
53 -- received. For terminals that support bracketed paste mode, these
54 -- events will be triggered on a paste event. Terminals that do not
55 -- support bracketed pastes will send the paste contents as ordinary
56 -- input (which is probably bad, so beware!) Note that the data is
57 -- provided in raw form and you'll have to decode (e.g. as UTF-8) if
58 -- that's what your application expects.
59 | EvLostFocus
60 -- ^ The terminal running the application lost input focus.
61 | EvGainedFocus
62 -- ^ The terminal running the application gained input focus.
63 deriving (Eq,Show,Read,Ord,Generic)
65type ClassifyMap = [(String,Event)]