rcurses 5.1.5 → 6.0.0

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rcurses.rb +55 -7
  3. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3912ae6525494a8bc621fc3a088525b660246778420f311d61778891499d88cf
4
- data.tar.gz: a87bbfb6c23a9eaa8561d7f9606bf0f29b4abac34f674024dc8c7f7ddbc60969
3
+ metadata.gz: a5b3327d242e4e2b4644033802a3acf428683be84817eeaadb6660e81c8ecbc6
4
+ data.tar.gz: b0b8a0b6c96d949bb82c61db5a328294c85b58d16f40039161cdb9c313edc54b
5
5
  SHA512:
6
- metadata.gz: 2c87e2dc82b3efdd78a71a805f6d1e52d15c5c32f03d4882cf3095dbd7efefd3492ffb9ce7609d3477212597b582796c009de7af3ea90c8b8b300b9e8a910f60
7
- data.tar.gz: f6758d24f234f979d3c311ff226afad6d46adcd7e5714fc89389a9a691f386bd6beac30feef438d332a8e1e909045cc75debfa4c7418526f4d530e42518711ca
6
+ metadata.gz: 75ada84fd5db957fb04f494ebc2d9db4ae0bbf3930d70a47edbf8330102e10c45b116d8dc2255908babb8eb0ce5c362801eaff294054c66fb397dd31fbcb34cf
7
+ data.tar.gz: 264a82852322b446424bf9572ba992afe1981bd036b5a80c9341e10efcfd810badbcede9c4703403b6d931c589b507d5df898f2fcf41f6edf6533d550a16c608
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.5: Improved error handling - preserves screen content on crash
8
+ # Version: 6.0.0: Breaking change - no auto-init, apps must call Rcurses.init!
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
- $stdin.raw!
30
- $stdin.echo = false
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
- $stdin.cooked!
56
- $stdin.echo = true
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
@@ -116,8 +163,9 @@ module Rcurses
116
163
  end
117
164
  end
118
165
 
119
- # Kick off initialization as soon as the library is required.
120
- init!
166
+ # BREAKING CHANGE in 6.0.0: No more auto-initialization
167
+ # All apps must now explicitly call Rcurses.init! when ready to use rcurses
168
+ # This ensures compatibility with Ruby 3.4+ and gives apps better control
121
169
  end
122
170
 
123
171
  # vim: set sw=2 sts=2 et filetype=ruby fdn=2 fcs=fold\:\ :
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: 5.1.5
4
+ version: 6.0.0
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-08-14 00:00:00.000000000 Z
11
+ date: 2025-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard
@@ -29,9 +29,9 @@ 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. 5.0.0: Major improvements - memory
33
- leak fixes, terminal state protection, Unicode support, and enhanced error handling
34
- while maintaining full backward compatibility and 4.8.3 performance.'
32
+ in panes. Cursor movement around the terminal. VERSION 6.0.0 BREAKING CHANGE: Apps
33
+ must now explicitly call Rcurses.init! - auto-initialization has been removed for
34
+ Ruby 3.4+ compatibility.'
35
35
  email: g@isene.com
36
36
  executables: []
37
37
  extensions: []