rcurses 6.1.1 → 6.1.3

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/pane.rb +30 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce484ba636e927e6344a8bb0552c49aec18df5cf3d2ebcb1c80c1d3927da3005
4
- data.tar.gz: 9565880d7a799a27f364e3ec543f69c5061db9e9951684b3747cad5380b5ce85
3
+ metadata.gz: 50072ee45a20e250fc0b370d62c25c99fc0a4d66bc014aa61819c5fbeaafde7d
4
+ data.tar.gz: 382eb72b8698e332b3cf55b36729bb93c2935df5a50fe837684ded7912c4523f
5
5
  SHA512:
6
- metadata.gz: b6406ba055a63fcd8b187920f4280931b046d651919b08e3792db6a09de8ef5d5383de853847cd44cebf579ccb71c8a7a19b2d147cf825579dca6c96113130b1
7
- data.tar.gz: 5522b3932739d6b726bed53a9b349006f0c7ab44bd79038008ed1f4db2cde530d0fe95e6f38d25bbf627b03a2dea4e8dd10f89991761ea048c65eec79f5dd92c
6
+ metadata.gz: 6036a1f6668ff70d3ff7a6858fcaf68904c96744ebd325c1db147f01f05c6c7953535159a65908f1c7b0fb8c04c42fac104ca9bc97322ff9576065c164d155d0
7
+ data.tar.gz: 3eb3944035a86b1894e8e9358b8ccd39a2e572019c23e07e8b5b845a007478b14ba2e12be2728417c4813a8dd95470651e907dad51e7679878d4789849c06cb4
data/lib/rcurses/pane.rb CHANGED
@@ -7,6 +7,7 @@ module Rcurses
7
7
  attr_accessor :border, :scroll, :text, :ix, :index, :align, :prompt
8
8
  attr_accessor :moreup, :moredown
9
9
  attr_accessor :record, :history
10
+ attr_accessor :multiline_buffer
10
11
 
11
12
  def initialize(x = 1, y = 1, w = 1, h = 1, fg = nil, bg = nil)
12
13
  @max_h, @max_w = IO.console ? IO.console.winsize : [24, 80]
@@ -26,7 +27,8 @@ module Rcurses
26
27
  @record = false # Don't record history unless explicitly set to true
27
28
  @history = [] # History array
28
29
  @max_history_size = 100 # Limit history to prevent memory leaks
29
-
30
+ @multiline_buffer = [] # Buffer to store lines from multi-line paste
31
+
30
32
  ObjectSpace.define_finalizer(self, self.class.finalizer_proc)
31
33
  end
32
34
 
@@ -507,7 +509,10 @@ module Rcurses
507
509
  while input_char != 'ESC'
508
510
  # Move the terminal cursor to the logical text cursor
509
511
  row(@y + @line)
510
- col(@x + @pos)
512
+ # Calculate display width up to cursor position on current line
513
+ current_line_text = @txt[@ix + @line] || ""
514
+ display_pos = @pos > 0 ? Rcurses.display_width(current_line_text.pure[0...@pos]) : 0
515
+ col(@x + display_pos)
511
516
  input_char = getchr(flush: false)
512
517
  case input_char
513
518
  when 'C-L'
@@ -615,12 +620,15 @@ module Rcurses
615
620
  @pos = cont.length
616
621
  chr = ''
617
622
  history_index = @history.size
623
+ @multiline_buffer = [] # Clear buffer at start of input
618
624
 
619
625
  while chr != 'ESC'
620
626
  col(@x + prompt_len)
621
627
  cont = cont.slice(0, content_len)
622
628
  print cont.ljust(content_len).c(fmt)
623
- col(@x + prompt_len + @pos)
629
+ # Calculate display width up to cursor position
630
+ display_pos = @pos > 0 ? Rcurses.display_width(cont[0...@pos]) : 0
631
+ col(@x + prompt_len + display_pos)
624
632
  chr = getchr(flush: false)
625
633
  case chr
626
634
  when 'LEFT'
@@ -647,7 +655,13 @@ module Rcurses
647
655
  cont = ''
648
656
  @pos = 0
649
657
  when 'ENTER'
650
- @text = cont
658
+ # If there are lines in multiline_buffer, add current line too
659
+ if @multiline_buffer && !@multiline_buffer.empty? && !cont.empty?
660
+ @multiline_buffer << cont.dup
661
+ @text = @multiline_buffer.shift # Return first line as @text
662
+ else
663
+ @text = cont
664
+ end
651
665
  chr = 'ESC'
652
666
  when 'UP'
653
667
  if @history.any? && history_index > 0
@@ -675,6 +689,15 @@ module Rcurses
675
689
  while IO.select([$stdin], nil, nil, 0)
676
690
  chr = $stdin.read_nonblock(1) rescue nil
677
691
  break unless chr
692
+ # Handle newlines in multi-line paste
693
+ if chr == "\n"
694
+ @multiline_buffer << cont.dup
695
+ cont = ""
696
+ @pos = 0
697
+ next
698
+ end
699
+ # Skip carriage returns
700
+ next if chr == "\r"
678
701
  if @pos < content_len
679
702
  cont.insert(@pos, chr)
680
703
  @pos += 1
@@ -689,7 +712,9 @@ module Rcurses
689
712
  end
690
713
  end
691
714
  prompt_len = @prompt.pure.length
692
- new_col = @x + prompt_len + (@pos > 0 ? @pos - 1 : 0)
715
+ # Calculate display width for final cursor position
716
+ final_display_pos = @pos > 0 ? Rcurses.display_width(cont[0...(@pos - 1).clamp(0, cont.length)]) : 0
717
+ new_col = @x + prompt_len + final_display_pos
693
718
  col(new_col)
694
719
  Rcurses::Cursor.hide
695
720
  end
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.1.1
4
+ version: 6.1.3
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-09-17 00:00:00.000000000 Z
11
+ date: 2025-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard