rcurses 3.3 → 3.4.1
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/README.md +2 -0
- data/lib/rcurses/pane.rb +17 -8
- data/lib/string_extensions.rb +10 -0
- 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: b639396f6e9ac9ac7fe77f5fcce3346abcbe6e54f0662a7655a684ff1fd65f54
|
4
|
+
data.tar.gz: 40d11e4c27a34f1e289f1e098e30110b176db829918cecbe310483f9c68b47cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a3e1b37d0067eaff67d6e84f0496f122774246d9a2497bc56d36cd169ea05748757fc7f62ea7e38b3321ad73fca8e7316daa91e4b1f097e3f0fb6f4567ceda8
|
7
|
+
data.tar.gz: b3fc5442eec96aae8eb82840bb751282983c2ef53fac8b814e3f103a8a1dc9dcbc4f1ef5768d8cc23fce686c43f51d47225fe536fb41bdd64bfee86420f49d23
|
data/README.md
CHANGED
@@ -79,6 +79,7 @@ Method | Description
|
|
79
79
|
new/init | Initializes a Pane with optional arguments `x, y, w, h, fg and bg`
|
80
80
|
move(x,y) | Move the pane by `x`and `y` (`mypane.move(-4,5)` will move the pane left four characters and five characters down)
|
81
81
|
refresh | Refreshes/redraws the Pane with content
|
82
|
+
full_refresh | Refreshes/redraws the Pane with content completely (without diff rendering)
|
82
83
|
edit | An editor for the Pane. When this is invoked, all existing font dressing is stripped and the user gets to edit the raw text. The user can add font effects similar to Markdown; Use an asterisk before and after text to be drawn in bold, text between forward-slashes become italic, and underline before and after text means the text will be underlined, a hash-sign before and after text makes the text reverse colored. You can also combine a whole set of dressings in this format: `<23,245,biurl|Hello World!>` - this will make "Hello World!" print in the color 23 with the background color 245 (regardless of the Pane's fg/bg setting) in bold, italic, underlined, reversed colored and blinking. Hitting `ESC` while in edit mode will disregard the edits, while `Ctrl-S` will save the edits
|
83
84
|
editline | Used for one-line Panes. It will print the content of the property `prompt` and then the property `text` that can then be edited by the user. Hitting `ESC` will disregard the edits, while `ENTER` will save the edited text
|
84
85
|
puts(text) | Short form for setting panel.text, then doing a refresh of that panel
|
@@ -105,6 +106,7 @@ l | Set text to be printed blinking (example: `"TEST".l`)
|
|
105
106
|
r | Set text to be printed in reverse colors (example: `"TEST".r`)
|
106
107
|
c(code) | Use coded format like "TEST".c("204,45,bui") to print "TEST" in bold, underline italic, fg=204 and bg=45 (the format is `.c("fg,bg,biulr"))
|
107
108
|
pure | Strip text of any "dressing" (example: with `text = "TEST".b`, you will have bold text in the variable `text`, then with `text.pure` it will show "uncoded" or pure text)
|
109
|
+
ansi_clean | Strip seemingly uncolored strings of ansi code (those that are enclosed in "\e[0m"
|
108
110
|
shorten(n) | Shorten the pure version of the string to 'n' characters, preserving any ANSI coding
|
109
111
|
inject("chars",pos) | Inject "chars" at position 'pos' in the pure version of the string (if 'pos' is '-1', then append at end). Preserves any ANSI code
|
110
112
|
|
data/lib/rcurses/pane.rb
CHANGED
@@ -106,6 +106,12 @@ module Rcurses
|
|
106
106
|
refresh
|
107
107
|
end
|
108
108
|
|
109
|
+
# full_refresh forces a complete repaint.
|
110
|
+
def full_refresh(cont = @text)
|
111
|
+
@prev_frame = nil
|
112
|
+
refresh(cont)
|
113
|
+
end
|
114
|
+
|
109
115
|
# Diff-based refresh that minimizes flicker.
|
110
116
|
# In this updated version we lazily process only the raw lines required to fill the pane.
|
111
117
|
def refresh(cont = @text)
|
@@ -124,7 +130,9 @@ module Rcurses
|
|
124
130
|
end
|
125
131
|
|
126
132
|
o_row, o_col = pos
|
127
|
-
|
133
|
+
|
134
|
+
# Hide cursor and disable auto-wrap (minimal fix)
|
135
|
+
STDOUT.print "\e[?25l\e[?7l"
|
128
136
|
|
129
137
|
fmt = [@fg, @bg].compact.join(',')
|
130
138
|
|
@@ -143,7 +151,7 @@ module Rcurses
|
|
143
151
|
while @lazy_txt.size < required_lines && @lazy_index < @raw_txt.size
|
144
152
|
raw_line = @raw_txt[@lazy_index]
|
145
153
|
# If the raw line is short, no wrapping is needed.
|
146
|
-
if raw_line.respond_to?(:pure) && raw_line.pure
|
154
|
+
if raw_line.respond_to?(:pure) && Rcurses.display_width(raw_line.pure) < @w
|
147
155
|
processed = [raw_line]
|
148
156
|
else
|
149
157
|
processed = split_line_with_ansi(raw_line, @w)
|
@@ -166,7 +174,7 @@ module Rcurses
|
|
166
174
|
line_str = ""
|
167
175
|
l = @ix + i
|
168
176
|
if @txt[l].to_s != ""
|
169
|
-
pl = @w - @txt[l].pure
|
177
|
+
pl = @w - Rcurses.display_width(@txt[l].pure)
|
170
178
|
pl = 0 if pl < 0
|
171
179
|
hl = pl / 2
|
172
180
|
case @align
|
@@ -203,7 +211,8 @@ module Rcurses
|
|
203
211
|
end
|
204
212
|
end
|
205
213
|
|
206
|
-
|
214
|
+
# Re-enable wrap just before printing the final buffer
|
215
|
+
diff_buf << "\e[#{o_row};#{o_col}H\e[?7h"
|
207
216
|
print diff_buf
|
208
217
|
@prev_frame = new_frame
|
209
218
|
|
@@ -505,7 +514,7 @@ module Rcurses
|
|
505
514
|
def calculate_posx
|
506
515
|
total_length = 0
|
507
516
|
(@ix + @line).times do |i|
|
508
|
-
total_length += @txt[i].pure
|
517
|
+
total_length += Rcurses.display_width(@txt[i].pure) + 1 # +1 for newline
|
509
518
|
end
|
510
519
|
total_length += @pos
|
511
520
|
total_length
|
@@ -514,7 +523,7 @@ module Rcurses
|
|
514
523
|
def calculate_line_start_pos
|
515
524
|
total_length = 0
|
516
525
|
(@ix + @line).times do |i|
|
517
|
-
total_length += @txt[i].pure
|
526
|
+
total_length += Rcurses.display_width(@txt[i].pure) + 1
|
518
527
|
end
|
519
528
|
total_length
|
520
529
|
end
|
@@ -550,7 +559,7 @@ module Rcurses
|
|
550
559
|
else
|
551
560
|
words = token.scan(/\s+|\S+/)
|
552
561
|
words.each do |word|
|
553
|
-
word_length = word.gsub(ansi_regex, '')
|
562
|
+
word_length = Rcurses.display_width(word.gsub(ansi_regex, ''))
|
554
563
|
if current_line_length + word_length <= w
|
555
564
|
current_line << word
|
556
565
|
current_line_length += word_length
|
@@ -565,7 +574,7 @@ module Rcurses
|
|
565
574
|
current_line << part
|
566
575
|
result << current_line
|
567
576
|
word = word[w..-1]
|
568
|
-
word_length = word.gsub(ansi_regex, '')
|
577
|
+
word_length = Rcurses.display_width(word.gsub(ansi_regex, ''))
|
569
578
|
current_line = active_sequences.join
|
570
579
|
current_line_length = 0
|
571
580
|
end
|
data/lib/string_extensions.rb
CHANGED
@@ -34,6 +34,16 @@ class String
|
|
34
34
|
prop
|
35
35
|
end
|
36
36
|
|
37
|
+
def clean_ansi
|
38
|
+
# Remove surrounding \e[0m if the string is otherwise unstyled
|
39
|
+
stripped = self.gsub(/\A\e\[0m/, '').gsub(/\e\[0m\z/, '')
|
40
|
+
if stripped.pure == stripped
|
41
|
+
stripped
|
42
|
+
else
|
43
|
+
self
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
37
47
|
def pure
|
38
48
|
self.gsub(/\e\[\d+(?:;\d+)*m/, '')
|
39
49
|
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:
|
4
|
+
version: 3.4.1
|
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-05 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.4.1: Fixed bug on handling
|
33
|
+
utf-8 characters.'
|
34
34
|
email: g@isene.com
|
35
35
|
executables: []
|
36
36
|
extensions: []
|