rcurses 3.2 → 3.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 +34 -13
- data/lib/rcurses.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c115cb970dc679cf90286b3881c0543de420c76930fe25ae63adf224433f6c62
|
4
|
+
data.tar.gz: d837ebda76384152815d687fd614ad41b48e8a7af4c131f125e1b4ad293b02bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9733a2dc05ac13ec49cd8bbd21681da9b0436f845d0a66256e30dc23c5038fb11f25b225174a0b9b008ebb1f0ea5f01a4a8e6571496e4119553ed8f895d2966
|
7
|
+
data.tar.gz: 0fde756777022b0606a041ddecaf3f1e44ef00b2e7f099f09ef25ca1c3fb3b18eaf8f067cccc2debf6c216efcee2c01d875cc2f865a59d36f19845deaec134c6
|
data/lib/rcurses/pane.rb
CHANGED
@@ -107,9 +107,7 @@ module Rcurses
|
|
107
107
|
end
|
108
108
|
|
109
109
|
# Diff-based refresh that minimizes flicker.
|
110
|
-
#
|
111
|
-
# We have removed scroll marker insertion from within the double-buffered frame.
|
112
|
-
# Instead, after printing the frame we reprint the right border column.
|
110
|
+
# In this updated version we lazily process only the raw lines required to fill the pane.
|
113
111
|
def refresh(cont = @text)
|
114
112
|
@max_h, @max_w = IO.console.winsize
|
115
113
|
|
@@ -129,8 +127,32 @@ module Rcurses
|
|
129
127
|
STDOUT.print "\e[?25l" # Hide cursor
|
130
128
|
|
131
129
|
fmt = [@fg, @bg].compact.join(',')
|
132
|
-
|
133
|
-
|
130
|
+
|
131
|
+
# Lazy evaluation: If the content or pane width has changed, reinitialize the lazy cache.
|
132
|
+
if !defined?(@cached_text) || @cached_text != cont || @cached_w != @w
|
133
|
+
@raw_txt = cont.split("\n")
|
134
|
+
@lazy_txt = [] # This will hold the processed (wrapped) lines as needed.
|
135
|
+
@lazy_index = 0 # Pointer to the next raw line to process.
|
136
|
+
@cached_text = cont
|
137
|
+
@cached_w = @w
|
138
|
+
end
|
139
|
+
|
140
|
+
content_rows = @h
|
141
|
+
# Ensure we have processed enough lines for the current scroll position + visible area.
|
142
|
+
required_lines = @ix + content_rows
|
143
|
+
while @lazy_txt.size < required_lines && @lazy_index < @raw_txt.size
|
144
|
+
raw_line = @raw_txt[@lazy_index]
|
145
|
+
# If the raw line is short, no wrapping is needed.
|
146
|
+
if raw_line.respond_to?(:pure) && raw_line.pure.length < @w
|
147
|
+
processed = [raw_line]
|
148
|
+
else
|
149
|
+
processed = split_line_with_ansi(raw_line, @w)
|
150
|
+
end
|
151
|
+
@lazy_txt.concat(processed)
|
152
|
+
@lazy_index += 1
|
153
|
+
end
|
154
|
+
@txt = @lazy_txt
|
155
|
+
|
134
156
|
@ix = @txt.length - 1 if @ix > @txt.length - 1
|
135
157
|
@ix = 0 if @ix < 0
|
136
158
|
|
@@ -140,7 +162,6 @@ module Rcurses
|
|
140
162
|
new_frame << top_border
|
141
163
|
end
|
142
164
|
|
143
|
-
content_rows = @h
|
144
165
|
content_rows.times do |i|
|
145
166
|
line_str = ""
|
146
167
|
l = @ix + i
|
@@ -184,24 +205,21 @@ module Rcurses
|
|
184
205
|
|
185
206
|
diff_buf << "\e[#{o_row};#{o_col}H"
|
186
207
|
print diff_buf
|
187
|
-
#STDOUT.print "\e[?25h" # We leave the cursor hidden unless explicitly shown
|
188
208
|
@prev_frame = new_frame
|
189
209
|
|
190
|
-
#
|
210
|
+
# Draw scroll markers after printing the frame.
|
191
211
|
if @scroll
|
192
|
-
# Use the same marker column as before.
|
193
212
|
marker_col = @border ? (@x + @w - 1) : (@x + @w - 1)
|
194
|
-
# Draw top marker at row = @y + 1 (inside the frame)
|
195
213
|
if @ix > 0
|
196
214
|
print "\e[#{@y};#{marker_col}H" + "∆".c(fmt)
|
197
215
|
end
|
198
|
-
#
|
199
|
-
|
216
|
+
# If there are more processed lines than fit in the pane
|
217
|
+
# OR there remain raw lines to process, show the down marker.
|
218
|
+
if (@txt.length - @ix) > @h || (@lazy_index < @raw_txt.size)
|
200
219
|
print "\e[#{@y + @h - 1};#{marker_col}H" + "∇".c(fmt)
|
201
220
|
end
|
202
221
|
end
|
203
222
|
|
204
|
-
# Now, reprint the right border column for each content line to fill any holes.
|
205
223
|
if @border
|
206
224
|
(0...@h).each do |i|
|
207
225
|
print "\e[#{@y + i};#{@x + @w}H" + "│".c(fmt)
|
@@ -212,6 +230,8 @@ module Rcurses
|
|
212
230
|
end
|
213
231
|
|
214
232
|
def textformat(cont)
|
233
|
+
# This method is no longer used in refresh since we process lazily,
|
234
|
+
# but is kept here if needed elsewhere.
|
215
235
|
lines = cont.split("\n")
|
216
236
|
result = []
|
217
237
|
lines.each do |line|
|
@@ -562,3 +582,4 @@ module Rcurses
|
|
562
582
|
end
|
563
583
|
end
|
564
584
|
end
|
585
|
+
|
data/lib/rcurses.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Web_site: http://isene.com/
|
6
6
|
# Github: https://github.com/isene/rcurses
|
7
7
|
# License: Public domain
|
8
|
-
# Version: 3.
|
8
|
+
# Version: 3.3: Faster rendering of pane content
|
9
9
|
|
10
10
|
require 'io/console' # Basic gem for rcurses
|
11
11
|
require 'io/wait' # stdin handling
|
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: '3.
|
4
|
+
version: '3.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-04-
|
11
|
+
date: 2025-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clipboard
|
@@ -29,8 +29,8 @@ description: 'Create curses applications for the terminal easier than ever. Crea
|
|
29
29
|
up text (in panes or anywhere in the terminal) in bold, italic, underline, reverse
|
30
30
|
color, blink and in any 256 terminal colors for foreground and background. Use a
|
31
31
|
simple editor to let users edit text in panes. Left, right or center align text
|
32
|
-
in panes. Cursor movement around the terminal. New in 3.
|
33
|
-
|
32
|
+
in panes. Cursor movement around the terminal. New in 3.3: Faster rendering of pane
|
33
|
+
content.'
|
34
34
|
email: g@isene.com
|
35
35
|
executables: []
|
36
36
|
extensions: []
|