rcurses 5.1.5 → 5.1.6
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.rb +52 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd5e0ec070d80452ce6733eed313a97b78b33db8ec992f329d2153ae3fcb6901
|
4
|
+
data.tar.gz: b9b7a0c97d31385dc2698e18b2e29baa0c95c9d584eaf7b7f0acde11b1c8910b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0e343b3cad38bd4f96b1ba47ca414ba84456c836a9fb1c64c624665101d7e0c214895a34ecaae8dfb87fc3de14c0e2dceb44db36f0c86e72303cb82a20b182f
|
7
|
+
data.tar.gz: 226e33514574213c955582af9eddbe3d45d18c5ecc3b84fd4f78250e2d2fb376261ea28120f4944fbe2c166edd3597006a0f5b13a752767cc93e9a761ce5010a
|
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: 5.1.
|
8
|
+
# Version: 5.1.6: Ruby 3.4+ compatibility - handle potential raw!/cooked! blocking
|
9
9
|
|
10
10
|
require 'io/console' # Basic gem for rcurses
|
11
11
|
require 'io/wait' # stdin handling
|
@@ -26,8 +26,33 @@ module Rcurses
|
|
26
26
|
return unless $stdin.tty?
|
27
27
|
|
28
28
|
# enter raw mode, disable echo
|
29
|
-
|
30
|
-
|
29
|
+
# Ruby 3.4+ compatibility: Handle potential blocking in raw!
|
30
|
+
begin
|
31
|
+
if RUBY_VERSION >= "3.4.0"
|
32
|
+
# Flush outputs before changing terminal mode (Ruby 3.4+ requirement)
|
33
|
+
$stdout.flush if $stdout.respond_to?(:flush)
|
34
|
+
$stderr.flush if $stderr.respond_to?(:flush)
|
35
|
+
|
36
|
+
# Use timeout to detect hanging raw! call
|
37
|
+
begin
|
38
|
+
Timeout::timeout(0.5) do
|
39
|
+
$stdin.raw!
|
40
|
+
$stdin.echo = false
|
41
|
+
end
|
42
|
+
rescue Timeout::Error
|
43
|
+
# Fallback to stty for Ruby 3.4+ if raw! hangs
|
44
|
+
system("stty raw -echo 2>/dev/null")
|
45
|
+
@using_stty = true
|
46
|
+
end
|
47
|
+
else
|
48
|
+
# Original code for Ruby < 3.4
|
49
|
+
$stdin.raw!
|
50
|
+
$stdin.echo = false
|
51
|
+
end
|
52
|
+
rescue Errno::ENOTTY, Errno::ENODEV
|
53
|
+
# Not a real terminal
|
54
|
+
return
|
55
|
+
end
|
31
56
|
|
32
57
|
# ensure cleanup on normal exit
|
33
58
|
at_exit do
|
@@ -52,8 +77,30 @@ module Rcurses
|
|
52
77
|
return if @cleaned_up
|
53
78
|
|
54
79
|
# Restore terminal to normal mode
|
55
|
-
|
56
|
-
|
80
|
+
begin
|
81
|
+
if @using_stty
|
82
|
+
# If we used stty for init, use it for cleanup
|
83
|
+
system("stty sane 2>/dev/null")
|
84
|
+
elsif RUBY_VERSION >= "3.4.0"
|
85
|
+
# Ruby 3.4+ with timeout protection
|
86
|
+
begin
|
87
|
+
Timeout::timeout(0.5) do
|
88
|
+
$stdin.cooked!
|
89
|
+
$stdin.echo = true
|
90
|
+
end
|
91
|
+
rescue Timeout::Error
|
92
|
+
# Fallback if cooked! hangs
|
93
|
+
system("stty sane 2>/dev/null")
|
94
|
+
end
|
95
|
+
else
|
96
|
+
# Original code for Ruby < 3.4
|
97
|
+
$stdin.cooked!
|
98
|
+
$stdin.echo = true
|
99
|
+
end
|
100
|
+
rescue => e
|
101
|
+
# Last resort fallback
|
102
|
+
system("stty sane 2>/dev/null")
|
103
|
+
end
|
57
104
|
|
58
105
|
# Only clear screen if there's no error to display
|
59
106
|
# This preserves the error context on screen
|