rcurses 6.2.5 → 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: 4ed97ba200bc51c5599c78550f12429ffe8887c01b25a59b509a015b84be7a72
4
- data.tar.gz: bfac1a426621f248c11adaca91916cdeed07caf2ed1e8a55319b4fff70ef6b32
3
+ metadata.gz: 60c52faf2a2b546871a48dc7a4275b474b5cd30a6c645ed5ec25acb738e59402
4
+ data.tar.gz: '094944dbfc0bdab94c1db6e8acc867e46f777973ee9ab92ae8263f4044c38754'
5
5
  SHA512:
6
- metadata.gz: 2eb5ed84c91747596cd97c0563140502339ef2d92d65de3652e475d5d6b525affa993d6a98ec0a6f07b79db4c935a1d90ad99e401ecf9c8ffc12c065b4c1a8fb
7
- data.tar.gz: de0fba662080514b3cb3db0750a5cd3cfe72b71ef5ec20aa4f303902823f62dd2d370154b16854d4fadaef41f5bcd7e97e5d3e2f71e4eece757f0f3765a3d119
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,12 @@ 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
+
347
341
  # Hard-clip line to pane width to prevent overflow into adjacent panes
348
342
  visible_w = Rcurses.display_width(line_str.respond_to?(:pure) ? line_str.pure : line_str.gsub(/\e\[[0-9;]*m/, ''))
349
343
  if visible_w > @w
@@ -366,10 +360,10 @@ module Rcurses
366
360
  diff_buf << "\e8\e[0m\e[r"
367
361
  begin
368
362
  print diff_buf
369
- rescue => e
363
+ rescue StandardError
370
364
  begin
371
365
  print "\e[0m\e[?25h"
372
- rescue
366
+ rescue StandardError
373
367
  end
374
368
  end
375
369
  @prev_frame = new_frame
@@ -389,20 +383,8 @@ module Rcurses
389
383
  end
390
384
 
391
385
  if @border
392
- # Determine border characters based on environment
393
- if ENV['RCURSES_BORDERS'] == 'ascii'
394
- tl, tr, bl, br, h, v = '+', '+', '+', '+', '-', '|'
395
- else
396
- # Check if locale supports UTF-8
397
- locale = ENV['LANG'] || ENV['LC_ALL'] || ENV['LC_CTYPE'] || ''
398
- if locale.downcase.include?('utf-8') || locale.downcase.include?('utf8')
399
- tl, tr, bl, br, h, v = '┌', '┐', '└', '┘', '─', '│'
400
- else
401
- # Fallback to ASCII for non-UTF-8 locales
402
- tl, tr, bl, br, h, v = '+', '+', '+', '+', '-', '|'
403
- end
404
- end
405
-
386
+ tl, tr, bl, br, h, v = border_chars
387
+
406
388
  # top
407
389
  print "\e[#{@y - 1};#{@x - 1}H" + (tl + h * @w + tr).c(fmt)
408
390
  # sides
@@ -473,10 +455,7 @@ module Rcurses
473
455
  else
474
456
  @line -= 1
475
457
  end
476
- begin
477
- @pos = [@pos, @txt[@ix + @line].length].min
478
- rescue
479
- end
458
+ @pos = [@pos, @txt[@ix + @line]&.length || 0].min
480
459
  end
481
460
 
482
461
  def down
@@ -485,10 +464,7 @@ module Rcurses
485
464
  elsif @line + @ix + 1 < @txt.length
486
465
  @line += 1
487
466
  end
488
- begin
489
- @pos = [@pos, @txt[@ix + @line].length].min
490
- rescue
491
- end
467
+ @pos = [@pos, @txt[@ix + @line]&.length || 0].min
492
468
  end
493
469
 
494
470
  def parse(cont)
@@ -777,6 +753,19 @@ module Rcurses
777
753
 
778
754
  private
779
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
+
780
769
  def flush_stdin
781
770
  while IO.select([$stdin], nil, nil, 0.005)
782
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.5
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-20 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