rcurses 6.2.1 → 6.2.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 +28 -11
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eb17c84b97853669cbe02b9abaa12f779f724d3c4444fb8e51ec67b390db9344
|
|
4
|
+
data.tar.gz: 8dc9eb91e22ae86060f2291ae2a2474751687ed2cb7b8e3f05d3be280da9f631
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2c1bebbbda8d009e509e5615b0530445dabe5788492fac8315b4813931ff341c2d0640d4fb2dc4187ce60cdec9d7267163cff31da31ed24b82bd17b0b11b997f
|
|
7
|
+
data.tar.gz: 3ad6dea2292e330474caa5a707cde814f1b09189c087c3e1baec01bafc771b343139a34e6585d479b4675a00ac518f577defd3c3a1d13d39de8ec2807ec9a459
|
data/lib/rcurses/input.rb
CHANGED
|
@@ -2,33 +2,51 @@ module Rcurses
|
|
|
2
2
|
module Input
|
|
3
3
|
def getchr(t = nil, flush: true)
|
|
4
4
|
begin
|
|
5
|
+
# Reinforce raw mode on every call. External programs (e.g. hyperlist)
|
|
6
|
+
# can leave the terminal in cooked/echo mode; raw! fixes it without
|
|
7
|
+
# the save/restore cycle of getch's raw{} block.
|
|
8
|
+
$stdin.raw!
|
|
5
9
|
# 1) Read a byte (with optional timeout)
|
|
10
|
+
# Use IO.select for timeout (clean syscall, no background thread).
|
|
6
11
|
if t
|
|
7
12
|
return nil unless IO.select([$stdin], nil, nil, t)
|
|
8
13
|
end
|
|
9
|
-
c = $stdin.
|
|
10
|
-
|
|
14
|
+
c = $stdin.getc
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
|
|
17
|
+
# 2) If it's ESC, read escape sequence byte-by-byte
|
|
18
|
+
# (greedy read_nonblock can swallow the NEXT keypress)
|
|
13
19
|
seq = c
|
|
14
20
|
if c == "\e"
|
|
15
21
|
if IO.select([$stdin], nil, nil, 0.05)
|
|
16
22
|
begin
|
|
17
|
-
|
|
23
|
+
b = $stdin.read_nonblock(1)
|
|
24
|
+
seq << b
|
|
25
|
+
# CSI sequence: \e[ ... (letter or ~)
|
|
26
|
+
# SS3 sequence: \eO (one more byte)
|
|
27
|
+
if b == '[' || b == 'O'
|
|
28
|
+
while IO.select([$stdin], nil, nil, 0.05)
|
|
29
|
+
b = $stdin.read_nonblock(1)
|
|
30
|
+
seq << b
|
|
31
|
+
# CSI terminates on a letter (A-Z, a-z) or ~
|
|
32
|
+
# SS3 terminates after one char
|
|
33
|
+
break if b =~ /[A-Za-z~]/
|
|
34
|
+
end
|
|
35
|
+
end
|
|
18
36
|
rescue IO::WaitReadable, EOFError
|
|
19
37
|
end
|
|
20
38
|
end
|
|
21
39
|
end
|
|
22
|
-
|
|
23
|
-
|
|
40
|
+
|
|
41
|
+
|
|
24
42
|
|
|
25
43
|
# 3) Single ESC alone
|
|
26
44
|
return "ESC" if seq == "\e"
|
|
27
45
|
|
|
28
|
-
# 4) Shift
|
|
46
|
+
# 4) Shift‐TAB
|
|
29
47
|
return "S-TAB" if seq == "\e[Z"
|
|
30
48
|
|
|
31
|
-
# 5) Legacy single
|
|
49
|
+
# 5) Legacy single‐char shift‐arrows (your old working ones)
|
|
32
50
|
case seq
|
|
33
51
|
when "\e[a" then return "S-UP"
|
|
34
52
|
when "\e[b" then return "S-DOWN"
|
|
@@ -36,11 +54,11 @@ module Rcurses
|
|
|
36
54
|
when "\e[d" then return "S-LEFT"
|
|
37
55
|
end
|
|
38
56
|
|
|
39
|
-
# 6) CSI style shift
|
|
57
|
+
# 6) CSI style shift‐arrows (e.g. ESC [1;2A )
|
|
40
58
|
if m = seq.match(/\A\e\[\d+;2([ABCD])\z/)
|
|
41
59
|
return { 'A' => "S-UP", 'B' => "S-DOWN", 'C' => "S-RIGHT", 'D' => "S-LEFT" }[m[1]]
|
|
42
60
|
end
|
|
43
|
-
|
|
61
|
+
|
|
44
62
|
# 6b) CSI style ctrl-arrows (e.g. ESC [1;5A )
|
|
45
63
|
if m = seq.match(/\A\e\[\d+;5([ABCD])\z/)
|
|
46
64
|
return { 'A' => "C-UP", 'B' => "C-DOWN", 'C' => "C-RIGHT", 'D' => "C-LEFT" }[m[1]]
|
|
@@ -137,4 +155,3 @@ module Rcurses
|
|
|
137
155
|
end
|
|
138
156
|
end
|
|
139
157
|
end
|
|
140
|
-
|
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: 6.2.
|
|
4
|
+
version: 6.2.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: 2026-03-
|
|
11
|
+
date: 2026-03-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: clipboard
|