~ubuntu-branches/ubuntu/precise/ghc/precise

« back to all changes in this revision

Viewing changes to libraries/terminfo/System/Console/Terminfo/Keys.hs

  • Committer: Bazaar Package Importer
  • Author(s): Joachim Breitner
  • Date: 2011-01-17 12:49:24 UTC
  • Revision ID: james.westby@ubuntu.com-20110117124924-do1pym1jlf5o636m
Tags: upstream-7.0.1
ImportĀ upstreamĀ versionĀ 7.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-- |
 
2
-- Maintainer  : judah.jacobson@gmail.com
 
3
-- Stability   : experimental
 
4
-- Portability : portable (FFI)
 
5
--
 
6
-- The string capabilities in this module are the character sequences
 
7
-- corresponding to user input such as arrow keys and function keys.
 
8
module System.Console.Terminfo.Keys(
 
9
                    -- * The keypad
 
10
                    -- | The following commands
 
11
                    -- turn the keypad on\/off (@smkx@ and @rmkx@).  
 
12
                    -- They have no effect if those capabilities are not defined.  
 
13
                    -- For portability between terminals, the keypad should be
 
14
                    -- explicitly turned on before accepting user key input.
 
15
                    keypadOn,
 
16
                    keypadOff,
 
17
                    -- * Arrow keys
 
18
                    keyUp,
 
19
                    keyDown,
 
20
                    keyLeft,
 
21
                    keyRight,
 
22
                    -- * Miscellaneous
 
23
                    functionKey,
 
24
                    keyBackspace,
 
25
                    keyDeleteChar,
 
26
                    keyHome,
 
27
                    keyEnd,
 
28
                    keyPageUp,
 
29
                    keyPageDown,
 
30
                    keyEnter,
 
31
                    ) where
 
32
 
 
33
import System.Console.Terminfo.Base
 
34
 
 
35
keypadOn :: TermStr s => Capability s
 
36
keypadOn = tiGetOutput1 "smkx"
 
37
 
 
38
keypadOff :: TermStr s => Capability s
 
39
keypadOff = tiGetOutput1 "rmkx"
 
40
 
 
41
keyUp :: Capability String
 
42
keyUp = tiGetOutput1 "kcuu1"
 
43
 
 
44
keyDown :: Capability String
 
45
keyDown = tiGetOutput1 "kcud1"
 
46
 
 
47
keyLeft :: Capability String
 
48
keyLeft = tiGetOutput1 "kcub1"
 
49
 
 
50
keyRight :: Capability String
 
51
keyRight = tiGetOutput1 "kcuf1"
 
52
 
 
53
-- | Look up the control sequence for a given function sequence.  For example, 
 
54
-- @functionKey 12@ retrieves the @kf12@ capability.
 
55
functionKey :: Int -> Capability String
 
56
functionKey n = tiGetOutput1 ("kf" ++ show n)
 
57
 
 
58
keyBackspace :: Capability String
 
59
keyBackspace = tiGetOutput1 "kbs"
 
60
 
 
61
keyDeleteChar :: Capability String
 
62
keyDeleteChar = tiGetOutput1 "kdch1"
 
63
 
 
64
keyHome :: Capability String
 
65
keyHome = tiGetOutput1 "khome"
 
66
 
 
67
keyEnd :: Capability String
 
68
keyEnd = tiGetOutput1 "kend"
 
69
 
 
70
keyPageUp :: Capability String
 
71
keyPageUp = tiGetOutput1 "kpp"
 
72
 
 
73
keyPageDown :: Capability String
 
74
keyPageDown = tiGetOutput1 "knp"
 
75
 
 
76
keyEnter :: Capability String
 
77
keyEnter = tiGetOutput1 "kent"