Module: TTY::Prompt::Reader::Codes Private

Defined in:
lib/tty/prompt/reader/codes.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.ctrl_keysObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/tty/prompt/reader/codes.rb', line 7

def ctrl_keys
  {
    ctrl_a: ?\C-a,
    ctrl_b: ?\C-b,
    ctrl_c: ?\C-c,
    ctrl_d: ?\C-d,
    ctrl_e: ?\C-e,
    ctrl_f: ?\C-f,
    ctrl_g: ?\C-g,
    ctrl_h: ?\C-h,
    ctrl_i: ?\C-i,
    ctrl_j: ?\C-j,
    ctrl_k: ?\C-k,
    ctrl_l: ?\C-l,
    ctrl_m: ?\C-m,
    ctrl_n: ?\C-n,
    ctrl_o: ?\C-o,
    ctrl_p: ?\C-p,
    ctrl_q: ?\C-q,
    ctrl_r: ?\C-r,
    ctrl_s: ?\C-s,
    ctrl_t: ?\C-t,
    ctrl_u: ?\C-u,
    ctrl_v: ?\C-v,
    ctrl_w: ?\C-w,
    ctrl_x: ?\C-x,
    ctrl_y: ?\C-y,
    ctrl_z: ?\C-z
  }
end

.keysObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/tty/prompt/reader/codes.rb', line 39

def keys
  {
    tab:       "\t",
    enter:     "\n",
    return:    "\r",
    escape:    "\e",
    space:     " ",
    backspace: ?\C-?,
    home:      "\e[1~",
    insert:    "\e[2~",
    delete:    "\e[3~",
    end:       "\e[4~",
    page_up:   "\e[5~",
    page_down: "\e[6~",

    up:     "\e[A",
    down:   "\e[B",
    right:  "\e[C",
    left:   "\e[D",
    clear:  "\e[E",

    f1_xterm: "\eOP",
    f2_xterm: "\eOQ",
    f3_xterm: "\eOR",
    f4_xterm: "\eOS",

    f1:  "\e[11~",
    f2:  "\e[12~",
    f3:  "\e[13~",
    f4:  "\e[14~",
    f5:  "\e[15~",
    f6:  "\e[17~",
    f7:  "\e[18~",
    f8:  "\e[19~",
    f9:  "\e[20~",
    f10: "\e[21~",
    f11: "\e[23~",
    f12: "\e[24~"
  }.merge(ctrl_keys)
end

.win_keysObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/tty/prompt/reader/codes.rb', line 81

def win_keys
  {
    tab:       "\t",
    enter:     "\r",
    return:    "\r",
    escape:    "\e",
    space:     " ",
    backspace: "\b",
    home:      [224, 71].pack('U*'),
    end:       [224, 79].pack('U*'),
    insert:    [224, 82].pack('U*'),
    delete:    [224, 83].pack('U*'),
    page_up:   [224, 73].pack('U*'),
    page_down: [224, 81].pack('U*'),

    up:     [224, 72].pack('U*'),
    down:   [224, 80].pack('U*'),
    right:  [224, 77].pack('U*'),
    left:   [224, 75].pack('U*'),
    clear:  [224, 83].pack('U*'),

    f1:  "\x00;",
    f2:  "\x00<",
    f3:  "\x00",
    f4:  "\x00=",
    f5:  "\x00?",
    f6:  "\x00@",
    f7:  "\x00A",
    f8:  "\x00B",
    f9:  "\x00C",
    f10: "\x00D",
    f11: "\x00\x85",
    f12: "\x00\x86"
  }.merge(ctrl_keys)
end