rcurses 3.7.1 → 3.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rcurses/input.rb +106 -96
- data/lib/rcurses.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f5f1abba12690ed9ad662a78930994e8a4a8667abafe4508d467f059007951a
|
4
|
+
data.tar.gz: fa3a289bbb5f24f77a3417505a9c860a375efc3498860946b938d392ec36c20d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21fc4e420009b25f19e635ad48cec4124e396ff8a56ae4fc900cf9a1e171f7af9f9126d0a50439632cf0ea4afe6ea5e3a4c531cb66275c8eafef7fd541da69e1
|
7
|
+
data.tar.gz: 3c0bb2893b2b561d842665bbac5543cd1e337f8c9ea6ebdd1d3e1d1d942ed62fc18c7c92a1234c319d1c5732b96a814b28c176c594114889d442057b2ccad84a
|
data/lib/rcurses/input.rb
CHANGED
@@ -1,114 +1,124 @@
|
|
1
1
|
module Rcurses
|
2
2
|
module Input
|
3
3
|
def getchr(t = nil)
|
4
|
-
# 1) Read a byte (with optional timeout)
|
5
4
|
begin
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
# 1) Read a byte (with optional timeout)
|
6
|
+
begin
|
7
|
+
c = t ? Timeout.timeout(t) { $stdin.getch } : $stdin.getch
|
8
|
+
rescue Timeout::Error
|
9
|
+
return nil
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
# 2) If it's ESC, grab any quick trailing bytes
|
13
|
+
seq = c
|
14
|
+
if c == "\e"
|
15
|
+
if IO.select([$stdin], nil, nil, 0.05)
|
16
|
+
begin
|
17
|
+
seq << $stdin.read_nonblock(16)
|
18
|
+
rescue IO::WaitReadable, EOFError
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
|
-
end
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
# 3) Single ESC alone
|
24
|
+
return "ESC" if seq == "\e"
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
# 4) ShiftâTAB
|
27
|
+
return "S-TAB" if seq == "\e[Z"
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
# 5) Legacy singleâchar shiftâarrows (your old working ones)
|
30
|
+
case seq
|
31
|
+
when "\e[a" then return "S-UP"
|
32
|
+
when "\e[b" then return "S-DOWN"
|
33
|
+
when "\e[c" then return "S-RIGHT"
|
34
|
+
when "\e[d" then return "S-LEFT"
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
# 6) CSI style shiftâarrows (e.g. ESC [1;2A )
|
38
|
+
if m = seq.match(/\A\e\[\d+;2([ABCD])\z/)
|
39
|
+
return { 'A' => "S-UP", 'B' => "S-DOWN", 'C' => "S-RIGHT", 'D' => "S-LEFT" }[m[1]]
|
40
|
+
end
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
# 7) Plain arrows
|
43
|
+
if m = seq.match(/\A\e\[([ABCD])\z/)
|
44
|
+
return { 'A' => "UP", 'B' => "DOWN", 'C' => "RIGHT", 'D' => "LEFT" }[m[1]]
|
45
|
+
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
47
|
+
# 8) CSI + '~' sequences (Ins, Del, Home, End, PgUp, PgDn, F5-F12)
|
48
|
+
if seq.start_with?("\e[") && seq.end_with?("~")
|
49
|
+
num = seq[/\d+(?=~)/].to_i
|
50
|
+
return case num
|
51
|
+
when 1, 7 then "HOME"
|
52
|
+
when 2 then "INS"
|
53
|
+
when 3 then "DEL"
|
54
|
+
when 4, 8 then "END"
|
55
|
+
when 5 then "PgUP"
|
56
|
+
when 6 then "PgDOWN"
|
57
|
+
when 15 then "F5"
|
58
|
+
when 17 then "F6"
|
59
|
+
when 18 then "F7"
|
60
|
+
when 19 then "F8"
|
61
|
+
when 20 then "F9"
|
62
|
+
when 21 then "F10"
|
63
|
+
when 23 then "F11"
|
64
|
+
when 24 then "F12"
|
65
|
+
else ""
|
66
|
+
end
|
67
|
+
end
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
69
|
+
# 9) SS3 function keys F1-F4
|
70
|
+
if seq.start_with?("\eO") && seq.length == 3
|
71
|
+
return case seq[2]
|
72
|
+
when 'P' then "F1"
|
73
|
+
when 'Q' then "F2"
|
74
|
+
when 'R' then "F3"
|
75
|
+
when 'S' then "F4"
|
76
|
+
else ""
|
77
|
+
end
|
78
|
+
end
|
78
79
|
|
79
|
-
|
80
|
-
|
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
|
-
|
80
|
+
# 10) Single / Ctrl-char mappings
|
81
|
+
return case seq
|
82
|
+
when "\r", "\n" then "ENTER"
|
83
|
+
when "\t" then "TAB"
|
84
|
+
when "\u007F", "\b" then "BACK"
|
85
|
+
when "\u0000" then "C-SPACE"
|
86
|
+
when "\u0001" then "C-A"
|
87
|
+
when "\u0002" then "C-B"
|
88
|
+
when "\u0003" then "C-C"
|
89
|
+
when "\u0004" then "C-D"
|
90
|
+
when "\u0005" then "C-E"
|
91
|
+
when "\u0006" then "C-F"
|
92
|
+
when "\u0007" then "C-G"
|
93
|
+
when "\u0008" then "C-H"
|
94
|
+
when "\u000B" then "C-K"
|
95
|
+
when "\u000C" then "C-L"
|
96
|
+
when "\u000D" then "C-M"
|
97
|
+
when "\u000E" then "C-N"
|
98
|
+
when "\u000F" then "C-O"
|
99
|
+
when "\u0010" then "C-P"
|
100
|
+
when "\u0011" then "C-Q"
|
101
|
+
when "\u0012" then "C-R"
|
102
|
+
when "\u0013" then "C-S"
|
103
|
+
when "\u0014" then "C-T"
|
104
|
+
when "\u0015" then "C-U"
|
105
|
+
when "\u0016" then "C-V"
|
106
|
+
when "\u0018" then "C-X"
|
107
|
+
when "\u0019" then "C-Y"
|
108
|
+
when "\u001A" then "C-Z"
|
109
|
+
when "\u0017" then "WBACK"
|
110
|
+
when /\A[[:print:]]\z/ then seq
|
111
|
+
else ""
|
112
|
+
end
|
113
|
+
ensure
|
114
|
+
while IO.select([$stdin], nil, nil, 0)
|
115
|
+
begin
|
116
|
+
$stdin.read_nonblock(4096)
|
117
|
+
rescue IO::WaitReadable, EOFError
|
118
|
+
break
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
112
122
|
end
|
113
123
|
end
|
114
124
|
end
|
data/lib/rcurses.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Web_site: http://isene.com/
|
6
6
|
# Github: https://github.com/isene/rcurses
|
7
7
|
# License: Public domain
|
8
|
-
# Version: 3.7.
|
8
|
+
# Version: 3.7.2: Better fix for straggling residue key codes
|
9
9
|
|
10
10
|
require 'io/console' # Basic gem for rcurses
|
11
11
|
require 'io/wait' # stdin handling
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rcurses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.7.
|
4
|
+
version: 3.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geir Isene
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clipboard
|
@@ -29,8 +29,8 @@ description: 'Create curses applications for the terminal easier than ever. Crea
|
|
29
29
|
up text (in panes or anywhere in the terminal) in bold, italic, underline, reverse
|
30
30
|
color, blink and in any 256 terminal colors for foreground and background. Use a
|
31
31
|
simple editor to let users edit text in panes. Left, right or center align text
|
32
|
-
in panes. Cursor movement around the terminal. New in 3.7.
|
33
|
-
key codes
|
32
|
+
in panes. Cursor movement around the terminal. New in 3.7.2: Better fix for straggling
|
33
|
+
residue key codes.'
|
34
34
|
email: g@isene.com
|
35
35
|
executables: []
|
36
36
|
extensions: []
|