rcurses 5.1.4 → 5.1.5
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 +24 -8
- 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: 3912ae6525494a8bc621fc3a088525b660246778420f311d61778891499d88cf
|
4
|
+
data.tar.gz: a87bbfb6c23a9eaa8561d7f9606bf0f29b4abac34f674024dc8c7f7ddbc60969
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c87e2dc82b3efdd78a71a805f6d1e52d15c5c32f03d4882cf3095dbd7efefd3492ffb9ce7609d3477212597b582796c009de7af3ea90c8b8b300b9e8a910f60
|
7
|
+
data.tar.gz: f6758d24f234f979d3c311ff226afad6d46adcd7e5714fc89389a9a691f386bd6beac30feef438d332a8e1e909045cc75debfa4c7418526f4d530e42518711ca
|
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.5: Improved error handling - preserves screen content on crash
|
9
9
|
|
10
10
|
require 'io/console' # Basic gem for rcurses
|
11
11
|
require 'io/wait' # stdin handling
|
@@ -51,9 +51,20 @@ module Rcurses
|
|
51
51
|
def cleanup!
|
52
52
|
return if @cleaned_up
|
53
53
|
|
54
|
+
# Restore terminal to normal mode
|
54
55
|
$stdin.cooked!
|
55
56
|
$stdin.echo = true
|
56
|
-
|
57
|
+
|
58
|
+
# Only clear screen if there's no error to display
|
59
|
+
# This preserves the error context on screen
|
60
|
+
if @error_to_display.nil?
|
61
|
+
Rcurses.clear_screen
|
62
|
+
else
|
63
|
+
# Just move cursor to bottom of screen without clearing
|
64
|
+
print "\e[999;1H" # Move to bottom-left
|
65
|
+
print "\e[K" # Clear current line
|
66
|
+
end
|
67
|
+
|
57
68
|
Cursor.show
|
58
69
|
|
59
70
|
@cleaned_up = true
|
@@ -69,20 +80,25 @@ module Rcurses
|
|
69
80
|
# Only display if we're in a TTY and not in a test environment
|
70
81
|
return unless $stdout.tty?
|
71
82
|
|
72
|
-
|
73
|
-
puts "\e[
|
83
|
+
# Add some spacing and make the error very visible
|
84
|
+
puts "\n\n\e[41;37m APPLICATION CRASHED \e[0m"
|
85
|
+
puts "\e[31m═══════════════════════════════════════════════════════════\e[0m"
|
86
|
+
puts "\e[33mError Type:\e[0m #{error.class}"
|
87
|
+
puts "\e[33mMessage:\e[0m #{error.message}"
|
74
88
|
|
75
89
|
# Show backtrace if debug mode is enabled
|
76
90
|
if ENV['DEBUG'] || ENV['RCURSES_DEBUG']
|
77
|
-
puts "\n\e[
|
78
|
-
error.backtrace.first(
|
91
|
+
puts "\n\e[33mBacktrace:\e[0m"
|
92
|
+
error.backtrace.first(15).each do |line|
|
79
93
|
puts " \e[90m#{line}\e[0m"
|
80
94
|
end
|
81
95
|
else
|
82
|
-
puts "\e[
|
96
|
+
puts "\n\e[90mTip: Set DEBUG=1 or RCURSES_DEBUG=1 to see the full backtrace\e[0m"
|
83
97
|
end
|
84
98
|
|
85
|
-
puts "\e[31m
|
99
|
+
puts "\e[31m═══════════════════════════════════════════════════════════\e[0m"
|
100
|
+
puts "\e[33mNote:\e[0m The application state above shows where the error occurred."
|
101
|
+
puts ""
|
86
102
|
end
|
87
103
|
|
88
104
|
# Public: Run a block with proper error handling and terminal cleanup
|