rcurses 6.2.4 → 6.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16222a062a9490a2ad8382125fe23fd935a975eff70d0b9eea64529ca2b537b6
4
- data.tar.gz: 98ed3f36f055cc8219dabf1560101ba1f4b44acd9c4606ddb760a40e84237a2a
3
+ metadata.gz: 60c52faf2a2b546871a48dc7a4275b474b5cd30a6c645ed5ec25acb738e59402
4
+ data.tar.gz: '094944dbfc0bdab94c1db6e8acc867e46f777973ee9ab92ae8263f4044c38754'
5
5
  SHA512:
6
- metadata.gz: 570af805bb2c612fcf116732eeef3721d97dd7b5ea5925890927f34e368c392db088b9e10469de6c181b0947e7427233820bf016d7a1ac912a9f8feca921cfda
7
- data.tar.gz: 23fd4c4d019c983c3edb48d0c1794a9710f650f07e14fd41cea333f13926a56efeb4ee5e13b8f65b81cf8e0fd915959597ad5be5e80ee35558fd77217ffa0100
6
+ metadata.gz: 38fe8fa0c2f06c5247d549d8bb5b955ac09e86a3327da9559694c898ff3a33d1c23ffb8fd5ff3a6b0ed83067bcecd7d68cbc2b97d22b12692988865a9481ff75
7
+ data.tar.gz: 365e95059cc92d724a91d0e394c9b5b2934c1454aff5e112608c6d7c93f2f89a9e0b291a16415be47778e88075018c0c59a6a9ee89b47bc2d3a3859f375bd093
@@ -23,12 +23,12 @@ module Rcurses
23
23
  # Reset terminal
24
24
  print "\e[0m\e[?25h\e[?7h\e[r"
25
25
  STDOUT.flush
26
- rescue
26
+ rescue StandardError
27
27
  # Fallback restoration
28
28
  begin
29
29
  STDIN.cooked! rescue nil
30
30
  STDIN.echo = true rescue nil
31
- rescue
31
+ rescue StandardError
32
32
  end
33
33
  end
34
34
  end
data/lib/rcurses/pane.rb CHANGED
@@ -159,20 +159,8 @@ module Rcurses
159
159
  bottom_row = @y + @h
160
160
 
161
161
  if @border
162
- # Determine border characters based on environment
163
- if ENV['RCURSES_BORDERS'] == 'ascii'
164
- tl, tr, bl, br, h, v = '+', '+', '+', '+', '-', '|'
165
- else
166
- # Check if locale supports UTF-8
167
- locale = ENV['LANG'] || ENV['LC_ALL'] || ENV['LC_CTYPE'] || ''
168
- if locale.downcase.include?('utf-8') || locale.downcase.include?('utf8')
169
- tl, tr, bl, br, h, v = '┌', '┐', '└', '┘', '─', '│'
170
- else
171
- # Fallback to ASCII for non-UTF-8 locales
172
- tl, tr, bl, br, h, v = '+', '+', '+', '+', '-', '|'
173
- end
174
- end
175
-
162
+ tl, tr, bl, br, h, v = border_chars
163
+
176
164
  fmt = [@fg.to_s, @bg.to_s].join(',')
177
165
  top = (tl + h * @w + tr).c(fmt)
178
166
  STDOUT.print "\e[#{top_row};#{left_col}H" + top
@@ -238,7 +226,7 @@ module Rcurses
238
226
  # Lazy evaluation: If the content or pane width has changed, reinitialize the lazy cache.
239
227
  if !defined?(@cached_text) || @cached_text != cont || @cached_w != @w
240
228
  begin
241
- @raw_txt = (cont || "").split("\n").map { |line| line.chomp("\r") }
229
+ @raw_txt = (cont || "").split(/\r?\n|\r/).map { |line| line }
242
230
  @lazy_txt = [] # This will hold the processed (wrapped) lines as needed.
243
231
  @lazy_index = 0 # Pointer to the next raw line to process.
244
232
  @cached_text = (cont || "").dup
@@ -344,6 +332,18 @@ module Rcurses
344
332
  line_str = @skip_colors ? " " * @w : " ".c(fmt) * @w
345
333
  end
346
334
 
335
+ # Strip non-SGR ANSI sequences (cursor movement, clear, etc.)
336
+ # Keep only SGR sequences (ending in 'm') for colors/styles
337
+ line_str = line_str.gsub(/\e\[[0-9;]*[A-HJKSTfhlnr]/, '')
338
+ # Strip any raw control characters (except tab and ANSI ESC sequences)
339
+ line_str = line_str.gsub(/[\x00-\x08\x0b-\x1a\x7f]/, '?')
340
+
341
+ # Hard-clip line to pane width to prevent overflow into adjacent panes
342
+ visible_w = Rcurses.display_width(line_str.respond_to?(:pure) ? line_str.pure : line_str.gsub(/\e\[[0-9;]*m/, ''))
343
+ if visible_w > @w
344
+ line_str = line_str.respond_to?(:shorten) ? line_str.shorten(@w) : line_str[0, @w]
345
+ end
346
+
347
347
  new_frame << line_str
348
348
  end
349
349
 
@@ -356,14 +356,14 @@ module Rcurses
356
356
  end
357
357
  end
358
358
 
359
- # Restore cursor, re-enable wrap, reset SGR and scroll-region
360
- diff_buf << "\e8\e[?7h\e[0m\e[r"
359
+ # Restore cursor, reset SGR and scroll-region (keep auto-wrap disabled)
360
+ diff_buf << "\e8\e[0m\e[r"
361
361
  begin
362
362
  print diff_buf
363
- rescue => e
363
+ rescue StandardError
364
364
  begin
365
- print "\e[0m\e[?25h\e[?7h"
366
- rescue
365
+ print "\e[0m\e[?25h"
366
+ rescue StandardError
367
367
  end
368
368
  end
369
369
  @prev_frame = new_frame
@@ -383,20 +383,8 @@ module Rcurses
383
383
  end
384
384
 
385
385
  if @border
386
- # Determine border characters based on environment
387
- if ENV['RCURSES_BORDERS'] == 'ascii'
388
- tl, tr, bl, br, h, v = '+', '+', '+', '+', '-', '|'
389
- else
390
- # Check if locale supports UTF-8
391
- locale = ENV['LANG'] || ENV['LC_ALL'] || ENV['LC_CTYPE'] || ''
392
- if locale.downcase.include?('utf-8') || locale.downcase.include?('utf8')
393
- tl, tr, bl, br, h, v = '┌', '┐', '└', '┘', '─', '│'
394
- else
395
- # Fallback to ASCII for non-UTF-8 locales
396
- tl, tr, bl, br, h, v = '+', '+', '+', '+', '-', '|'
397
- end
398
- end
399
-
386
+ tl, tr, bl, br, h, v = border_chars
387
+
400
388
  # top
401
389
  print "\e[#{@y - 1};#{@x - 1}H" + (tl + h * @w + tr).c(fmt)
402
390
  # sides
@@ -467,10 +455,7 @@ module Rcurses
467
455
  else
468
456
  @line -= 1
469
457
  end
470
- begin
471
- @pos = [@pos, @txt[@ix + @line].length].min
472
- rescue
473
- end
458
+ @pos = [@pos, @txt[@ix + @line]&.length || 0].min
474
459
  end
475
460
 
476
461
  def down
@@ -479,10 +464,7 @@ module Rcurses
479
464
  elsif @line + @ix + 1 < @txt.length
480
465
  @line += 1
481
466
  end
482
- begin
483
- @pos = [@pos, @txt[@ix + @line].length].min
484
- rescue
485
- end
467
+ @pos = [@pos, @txt[@ix + @line]&.length || 0].min
486
468
  end
487
469
 
488
470
  def parse(cont)
@@ -771,6 +753,19 @@ module Rcurses
771
753
 
772
754
  private
773
755
 
756
+ def border_chars
757
+ if ENV['RCURSES_BORDERS'] == 'ascii'
758
+ ['+', '+', '+', '+', '-', '|']
759
+ else
760
+ locale = ENV['LANG'] || ENV['LC_ALL'] || ENV['LC_CTYPE'] || ''
761
+ if locale.downcase.include?('utf-8') || locale.downcase.include?('utf8')
762
+ ["\u250C", "\u2510", "\u2514", "\u2518", "\u2500", "\u2502"]
763
+ else
764
+ ['+', '+', '+', '+', '-', '|']
765
+ end
766
+ end
767
+ end
768
+
774
769
  def flush_stdin
775
770
  while IO.select([$stdin], nil, nil, 0.005)
776
771
  begin
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
4
+ version: 6.3.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: 2026-03-18 00:00:00.000000000 Z
11
+ date: 2026-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard