rcurses 6.1.2 → 6.1.4

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 +28 -3
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc7f1658f29a2aa3cb9f753cb645ccb1ae1ca20ee7bec57bee0897c073322c0e
4
- data.tar.gz: 395e451cfa66f11f2c955c56ab8d6d5408b7af737939c79dd1679f45c55bc231
3
+ metadata.gz: a78252386307963f8ee559bc6f127707a8ba2e58fd03d47c53bdec7ec0a0ea1c
4
+ data.tar.gz: 195a79a814de7653f6f7940807ba72f4a41e1cabe6d86a48913e773940a95281
5
5
  SHA512:
6
- metadata.gz: 6c71b9bed8d75a9eaf9f8754d509149582df834c52137df170885e4cb29198bd3db19524ad7b98084163804bd837a21793b74b5e3c90cb419af9ee2de14bd3dc
7
- data.tar.gz: e0e2c26f75407a1c0de69c87079cf8d010f37723fc49174421eb1e90a5251c7e53f9e83cf0c06f8b856e684866d8d7cf8d3a993facc0ac3c189c66e93648c448
6
+ metadata.gz: 0c122a74e7d389b060e2e6877617bf129413a586dd898e6c558c1799f953fde3315bed72ab6328e0842b9853a99c2ea0c2758a92e33c6d2cd4e899ac8593dd61
7
+ data.tar.gz: c3490dc89c26e0269011a65bcc70bc79dd19caa3a303fc7ca566fc7ed5e6a62fe159ec9f16fba1dec561763a630e1fe12bd60fd22f67c40177397f75f23ee922
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
 
@@ -618,11 +620,19 @@ module Rcurses
618
620
  @pos = cont.length
619
621
  chr = ''
620
622
  history_index = @history.size
623
+ @multiline_buffer = [] # Clear buffer at start of input
621
624
 
622
625
  while chr != 'ESC'
623
626
  col(@x + prompt_len)
624
627
  cont = cont.slice(0, content_len)
625
- print cont.ljust(content_len).c(fmt)
628
+ # Show indicator if multiline content detected
629
+ display_cont = cont
630
+ if @multiline_buffer && !@multiline_buffer.empty?
631
+ lines_indicator = " [+#{@multiline_buffer.size} lines]"
632
+ available = content_len - lines_indicator.length
633
+ display_cont = cont.slice(0, [available, 0].max) + lines_indicator if available > 0
634
+ end
635
+ print display_cont.ljust(content_len).c(fmt)
626
636
  # Calculate display width up to cursor position
627
637
  display_pos = @pos > 0 ? Rcurses.display_width(cont[0...@pos]) : 0
628
638
  col(@x + prompt_len + display_pos)
@@ -652,7 +662,13 @@ module Rcurses
652
662
  cont = ''
653
663
  @pos = 0
654
664
  when 'ENTER'
655
- @text = cont
665
+ # If there are lines in multiline_buffer, add current line too
666
+ if @multiline_buffer && !@multiline_buffer.empty? && !cont.empty?
667
+ @multiline_buffer << cont.dup
668
+ @text = @multiline_buffer.shift # Return first line as @text
669
+ else
670
+ @text = cont
671
+ end
656
672
  chr = 'ESC'
657
673
  when 'UP'
658
674
  if @history.any? && history_index > 0
@@ -680,6 +696,15 @@ module Rcurses
680
696
  while IO.select([$stdin], nil, nil, 0)
681
697
  chr = $stdin.read_nonblock(1) rescue nil
682
698
  break unless chr
699
+ # Handle newlines in multi-line paste
700
+ if chr == "\n"
701
+ @multiline_buffer << cont.dup
702
+ cont = ""
703
+ @pos = 0
704
+ next
705
+ end
706
+ # Skip carriage returns
707
+ next if chr == "\r"
683
708
  if @pos < content_len
684
709
  cont.insert(@pos, chr)
685
710
  @pos += 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcurses
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.2
4
+ version: 6.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene