rcurses 6.2.0 → 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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rcurses/input.rb +31 -15
  3. data/lib/rcurses.rb +2 -2
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83520fbe28d15e3132827b2487cf90c386bd94362bcd77561a6361bf34a155fc
4
- data.tar.gz: 22be19a0d1625c0e264372dbfa9fd9031016400a3859119158a783a620e3c412
3
+ metadata.gz: eb17c84b97853669cbe02b9abaa12f779f724d3c4444fb8e51ec67b390db9344
4
+ data.tar.gz: 8dc9eb91e22ae86060f2291ae2a2474751687ed2cb7b8e3f05d3be280da9f631
5
5
  SHA512:
6
- metadata.gz: 523564a95aaf527d1df0f03056d6f2776f66e5d2aacb7bf70f81381d1f7cee5fc2f575cb6196126dcf990d6fde4db11d357f60dfb85112ef3f1e8fee038e9bee
7
- data.tar.gz: 670f44738dab604557da61576ec048634efbef7d3a6adbac84bba5ace294fe2a246c7c25a438798e70012a45ab4263a311ee6abb8026943be9b4e746c068ce4a
6
+ metadata.gz: 2c1bebbbda8d009e509e5615b0530445dabe5788492fac8315b4813931ff341c2d0640d4fb2dc4187ce60cdec9d7267163cff31da31ed24b82bd17b0b11b997f
7
+ data.tar.gz: 3ad6dea2292e330474caa5a707cde814f1b09189c087c3e1baec01bafc771b343139a34e6585d479b4675a00ac518f577defd3c3a1d13d39de8ec2807ec9a459
data/lib/rcurses/input.rb CHANGED
@@ -2,34 +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)
6
- begin
7
- c = t ? Timeout.timeout(t) { $stdin.getch } : $stdin.getch
8
- rescue Timeout::Error
9
- return nil
10
+ # Use IO.select for timeout (clean syscall, no background thread).
11
+ if t
12
+ return nil unless IO.select([$stdin], nil, nil, t)
10
13
  end
11
-
14
+ c = $stdin.getc
12
15
 
13
- # 2) If it's ESC, grab any quick trailing bytes
16
+
17
+ # 2) If it's ESC, read escape sequence byte-by-byte
18
+ # (greedy read_nonblock can swallow the NEXT keypress)
14
19
  seq = c
15
20
  if c == "\e"
16
- if IO.select([$stdin], nil, nil, 0.15)
21
+ if IO.select([$stdin], nil, nil, 0.05)
17
22
  begin
18
- seq << $stdin.read_nonblock(16)
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
19
36
  rescue IO::WaitReadable, EOFError
20
37
  end
21
38
  end
22
39
  end
23
-
24
-
40
+
41
+
25
42
 
26
43
  # 3) Single ESC alone
27
44
  return "ESC" if seq == "\e"
28
45
 
29
- # 4) Shift‑TAB
46
+ # 4) ShiftTAB
30
47
  return "S-TAB" if seq == "\e[Z"
31
48
 
32
- # 5) Legacy single‑char shift‑arrows (your old working ones)
49
+ # 5) Legacy singlechar shiftarrows (your old working ones)
33
50
  case seq
34
51
  when "\e[a" then return "S-UP"
35
52
  when "\e[b" then return "S-DOWN"
@@ -37,11 +54,11 @@ module Rcurses
37
54
  when "\e[d" then return "S-LEFT"
38
55
  end
39
56
 
40
- # 6) CSI style shift‑arrows (e.g. ESC [1;2A )
57
+ # 6) CSI style shiftarrows (e.g. ESC [1;2A )
41
58
  if m = seq.match(/\A\e\[\d+;2([ABCD])\z/)
42
59
  return { 'A' => "S-UP", 'B' => "S-DOWN", 'C' => "S-RIGHT", 'D' => "S-LEFT" }[m[1]]
43
60
  end
44
-
61
+
45
62
  # 6b) CSI style ctrl-arrows (e.g. ESC [1;5A )
46
63
  if m = seq.match(/\A\e\[\d+;5([ABCD])\z/)
47
64
  return { 'A' => "C-UP", 'B' => "C-DOWN", 'C' => "C-RIGHT", 'D' => "C-LEFT" }[m[1]]
@@ -138,4 +155,3 @@ module Rcurses
138
155
  end
139
156
  end
140
157
  end
141
-
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: 6.2.0: Popup widget, emoji picker, pane color cache, stdin flush
8
+ # Version: 6.2.1: Replace Timeout with IO.select in getchr, revert ESC timeout
9
9
 
10
10
  require 'io/console' # Basic gem for rcurses
11
11
  require 'io/wait' # stdin handling
@@ -176,7 +176,7 @@ module Rcurses
176
176
  f.puts "Program: #{$0}"
177
177
  f.puts "Working Directory: #{Dir.pwd}"
178
178
  f.puts "Ruby Version: #{RUBY_VERSION}"
179
- f.puts "Rcurses Version: 6.2.0"
179
+ f.puts "Rcurses Version: 6.2.1"
180
180
  f.puts "=" * 60
181
181
  f.puts "Error Class: #{error.class}"
182
182
  f.puts "Error Message: #{error.message}"
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.0
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-12 00:00:00.000000000 Z
11
+ date: 2026-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard