fancy_buff 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fancy_buff.rb +16 -4
- 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: 892b50af936bb97a23a873b029d23410320cde8ecfbee5952ca6693f1b2f6e5c
|
4
|
+
data.tar.gz: cd5c61bd3f0be2e4463686d0e72fd6594aa362048dfea27423bef03c7a6c46a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68953497b15fc893d68b270dde92799394fbeff68b2f39ce500e90a1a212fcafa0c29c69250bd7242a771901b5467a97535c0339f8e5fb9005688791892d0a30
|
7
|
+
data.tar.gz: 0d2b82addc499d165882758b688868495003572975227d3f8a8a9602ea51ff9c5722ef3e5a33714ff629305b8b6efbd7a1bcc87edefcb703ff9ed53a0c8eb7c4
|
data/lib/fancy_buff.rb
CHANGED
@@ -24,6 +24,8 @@ class FancyBuff
|
|
24
24
|
@chars = 0 # the number of characters in the buffer (not the same as the number of bytes)
|
25
25
|
@bytes = 0 # the number of bytes in the buffer (not the same as the number of characters)
|
26
26
|
@lines = []
|
27
|
+
@rendered_lines = [] # fully formatted, syntax highlighted, and transformed
|
28
|
+
@edited_since_last_render = true
|
27
29
|
@max_char_width = 0
|
28
30
|
@all_buff = @lines.join("\n")
|
29
31
|
|
@@ -60,11 +62,20 @@ class FancyBuff
|
|
60
62
|
return [] if h == 0 || w == 0
|
61
63
|
|
62
64
|
line_no_width = @lines.length.to_s.length
|
63
|
-
|
64
|
-
|
65
|
-
|
65
|
+
if @edited_since_last_render
|
66
|
+
@rendered_lines = @formatter
|
67
|
+
.format(@lexer.lex(@lines.join("\n")))
|
68
|
+
.lines
|
69
|
+
.map(&:chomp)
|
70
|
+
|
71
|
+
@edited_since_last_render = false
|
72
|
+
else
|
73
|
+
@rendered_lines[r..(r + visible_lines - 1)]
|
74
|
+
end
|
75
|
+
|
76
|
+
@rendered_lines[r..(r + visible_lines - 1)]
|
66
77
|
.map.with_index{|row, i| "#{(i + r + 1).to_s.rjust(line_no_width)} #{substr_with_color(row, c, c + w - line_no_width - 2)}" }
|
67
|
-
.map{|l| l
|
78
|
+
.map{|l| "#{l}\e[0K" } +
|
68
79
|
Array.new(blank_lines) { "\e[0K" }
|
69
80
|
end
|
70
81
|
|
@@ -178,6 +189,7 @@ class FancyBuff
|
|
178
189
|
@chars += line.chars.length
|
179
190
|
@max_char_width = line.chars.length if line.chars.length > @max_char_width
|
180
191
|
|
192
|
+
@edited_since_last_render = true
|
181
193
|
nil
|
182
194
|
end
|
183
195
|
#
|