natty-ui 0.9.2 → 0.9.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/examples/3bit-colors.rb +2 -2
- data/examples/demo.rb +1 -1
- data/examples/illustration.rb +4 -2
- data/examples/table.rb +17 -12
- data/lib/natty-ui/ansi/constants.rb +75 -0
- data/lib/natty-ui/ansi.rb +6 -7
- data/lib/natty-ui/ansi_wrapper.rb +23 -33
- data/lib/natty-ui/east_asian_width.rb +1271 -0
- data/lib/natty-ui/line_animation/default.rb +1 -1
- data/lib/natty-ui/line_animation/matrix.rb +1 -1
- data/lib/natty-ui/line_animation/rainbow.rb +1 -1
- data/lib/natty-ui/line_animation/type_writer.rb +5 -25
- data/lib/natty-ui/line_animation.rb +2 -8
- data/lib/natty-ui/preload.rb +9 -0
- data/lib/natty-ui/text/east_asian_width.rb +1275 -0
- data/lib/natty-ui/text.rb +213 -0
- data/lib/natty-ui/version.rb +1 -1
- data/lib/natty-ui/wrapper/ask.rb +1 -1
- data/lib/natty-ui/wrapper/element.rb +1 -1
- data/lib/natty-ui/wrapper/horizontal_rule.rb +1 -1
- data/lib/natty-ui/wrapper/list_in_columns.rb +6 -8
- data/lib/natty-ui/wrapper/message.rb +1 -1
- data/lib/natty-ui/wrapper/query.rb +0 -1
- data/lib/natty-ui/wrapper/request.rb +1 -1
- data/lib/natty-ui/wrapper/section.rb +2 -2
- data/lib/natty-ui/wrapper/table.rb +10 -18
- data/lib/natty-ui/wrapper.rb +3 -22
- data/lib/natty-ui.rb +22 -80
- metadata +9 -6
- data/lib/natty-ui/ansi_constants.rb +0 -77
- data/lib/natty-ui/line_animation/test.rb +0 -29
- /data/lib/natty-ui/{features.rb → wrapper/features.rb} +0 -0
@@ -12,48 +12,28 @@ module NattyUI
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def print(line)
|
15
|
-
line = plain(line)
|
15
|
+
line = Text.plain(line)
|
16
16
|
if (@num += 1).odd?
|
17
|
-
line.each_char
|
18
|
-
cursor(char)
|
19
|
-
(@stream << char).flush
|
20
|
-
end
|
17
|
+
line.each_char { (@stream << cursor(_1)).flush }
|
21
18
|
else
|
22
19
|
pos = @column + line.size
|
23
20
|
line.reverse!
|
24
21
|
line.each_char do |char|
|
25
22
|
@stream << Ansi.cursor_column(pos -= 1)
|
26
|
-
cursor(char)
|
27
|
-
(@stream << char).flush
|
23
|
+
(@stream << cursor(char)).flush
|
28
24
|
end
|
29
25
|
end
|
30
26
|
end
|
31
27
|
|
32
28
|
def cursor(char)
|
33
|
-
return sleep(0.016) if SPACE.match?(char)
|
34
29
|
@stream << @cursor_color
|
35
|
-
'▁▂▃▄▅▆▇█'.each_char do |cursor|
|
30
|
+
(SPACE.match?(char) ? '▁' : '▁▂▃▄▅▆▇█').each_char do |cursor|
|
36
31
|
(@stream << cursor).flush
|
37
32
|
sleep(0.002)
|
38
33
|
@stream << CURSOR_BACK
|
39
34
|
end
|
40
35
|
@stream << @color
|
41
|
-
|
42
|
-
|
43
|
-
def print_org(line)
|
44
|
-
plain(line).each_char do |char|
|
45
|
-
if SPACE.match?(char)
|
46
|
-
sleep(0.016)
|
47
|
-
else
|
48
|
-
@stream << @cursor_color
|
49
|
-
'▁▂▃▄▅▆▇█'.each_char do |cursor|
|
50
|
-
(@stream << cursor).flush
|
51
|
-
sleep(0.002)
|
52
|
-
@stream << CURSOR_BACK
|
53
|
-
end
|
54
|
-
end
|
55
|
-
(@stream << @color << char).flush
|
56
|
-
end
|
36
|
+
char
|
57
37
|
end
|
58
38
|
|
59
39
|
CURSOR_BACK = Ansi.cursor_back(1)
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'ansi'
|
4
|
-
|
5
3
|
module NattyUI
|
6
4
|
module LineAnimation
|
7
5
|
def self.defined = @defined.keys
|
@@ -23,13 +21,12 @@ module NattyUI
|
|
23
21
|
@options = options
|
24
22
|
end
|
25
23
|
|
26
|
-
def print(_line) =
|
24
|
+
def print(_line) = raise(NotImplementedError)
|
27
25
|
|
28
26
|
protected
|
29
27
|
|
30
28
|
def to_column = Ansi.cursor_column(@options[:prefix_width] + 1)
|
31
29
|
def color = attribute(:color, :default)
|
32
|
-
def plain(str) = NattyUI.plain(str, ansi: false)
|
33
30
|
|
34
31
|
def attribute(name, *default)
|
35
32
|
att = @options[name] or return Ansi[*default]
|
@@ -45,10 +42,7 @@ module NattyUI
|
|
45
42
|
default: "#{dir}/line_animation/default",
|
46
43
|
matrix: "#{dir}/line_animation/matrix",
|
47
44
|
rainbow: "#{dir}/line_animation/rainbow",
|
48
|
-
type_writer: "#{dir}/line_animation/type_writer"
|
49
|
-
test: "#{dir}/line_animation/test"
|
45
|
+
type_writer: "#{dir}/line_animation/type_writer"
|
50
46
|
}.compare_by_identity
|
51
47
|
end
|
52
|
-
|
53
|
-
private_constant :LineAnimation
|
54
48
|
end
|