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.
@@ -11,7 +11,7 @@ module NattyUI
11
11
  end
12
12
 
13
13
  def print(line)
14
- line = plain(line)
14
+ line = Text.plain(line)
15
15
  time = 0.5 / line.size
16
16
  @stream << @color
17
17
  if (@num += 1).odd?
@@ -9,7 +9,7 @@ module NattyUI
9
9
  end
10
10
 
11
11
  def print(line)
12
- line = plain(line)
12
+ line = Text.plain(line)
13
13
  str = Array.new(line.size) { CHARS.sample }.join
14
14
  pos = Array.new(line.size, &:itself).shuffle
15
15
  until pos.size < 4
@@ -9,7 +9,7 @@ module NattyUI
9
9
  end
10
10
 
11
11
  def print(line)
12
- line = plain(line)
12
+ line = Text.plain(line)
13
13
  11.upto(200) do |spread|
14
14
  (
15
15
  @stream << @prefix <<
@@ -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 do |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
- end
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) = nil
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
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../natty-ui'
4
+
5
+ module NattyUI
6
+ LineAnimation.defined?(:matrix)
7
+ Text::EastAsianWidth[0]
8
+ KEY_MAP[0]
9
+ end