rcurses 6.1.2 → 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.
- checksums.yaml +4 -4
- data/lib/rcurses/pane.rb +20 -2
- 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: 50072ee45a20e250fc0b370d62c25c99fc0a4d66bc014aa61819c5fbeaafde7d
|
4
|
+
data.tar.gz: 382eb72b8698e332b3cf55b36729bb93c2935df5a50fe837684ded7912c4523f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
@@ -618,6 +620,7 @@ 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)
|
@@ -652,7 +655,13 @@ module Rcurses
|
|
652
655
|
cont = ''
|
653
656
|
@pos = 0
|
654
657
|
when 'ENTER'
|
655
|
-
|
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
|
656
665
|
chr = 'ESC'
|
657
666
|
when 'UP'
|
658
667
|
if @history.any? && history_index > 0
|
@@ -680,6 +689,15 @@ module Rcurses
|
|
680
689
|
while IO.select([$stdin], nil, nil, 0)
|
681
690
|
chr = $stdin.read_nonblock(1) rescue nil
|
682
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"
|
683
701
|
if @pos < content_len
|
684
702
|
cont.insert(@pos, chr)
|
685
703
|
@pos += 1
|