whirled_peas 0.11.0 → 0.11.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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -2
  3. data/CHANGELOG.md +5 -0
  4. data/README.md +7 -1156
  5. data/doc/application.md +92 -0
  6. data/doc/cli.md +115 -0
  7. data/doc/components.md +55 -0
  8. data/doc/easing.md +257 -0
  9. data/doc/elements.md +69 -0
  10. data/doc/screen_test.md +23 -0
  11. data/doc/settings.md +466 -0
  12. data/doc/template_factory.md +53 -0
  13. data/doc/themes.md +15 -0
  14. data/lib/data/themes.yaml +8 -4
  15. data/lib/whirled_peas/component/list_with_active.rb +3 -3
  16. data/lib/whirled_peas/graphics/container_coords.rb +2 -26
  17. data/lib/whirled_peas/graphics/container_dimensions.rb +24 -0
  18. data/lib/whirled_peas/graphics/container_painter.rb +26 -28
  19. data/lib/whirled_peas/graphics/debugger.rb +1 -0
  20. data/lib/whirled_peas/graphics/graph_painter.rb +31 -24
  21. data/lib/whirled_peas/graphics/scrollbar_helper.rb +31 -29
  22. data/lib/whirled_peas/settings/bg_color.rb +5 -1
  23. data/lib/whirled_peas/settings/border.rb +1 -1
  24. data/lib/whirled_peas/settings/color.rb +8 -4
  25. data/lib/whirled_peas/settings/debugger.rb +2 -0
  26. data/lib/whirled_peas/settings/element_settings.rb +10 -2
  27. data/lib/whirled_peas/settings/text_color.rb +5 -0
  28. data/lib/whirled_peas/settings/theme.rb +28 -7
  29. data/lib/whirled_peas/settings/theme_library.rb +10 -4
  30. data/lib/whirled_peas/version.rb +1 -1
  31. data/screen_test/components/list_with_active/l2r_position_start.frame +1 -1
  32. data/screen_test/components/list_with_active/l2r_separator.frame +1 -1
  33. data/screen_test/components/list_with_active/t2b_position_start.frame +1 -1
  34. data/screen_test/components/list_with_active/t2b_separator.frame +1 -1
  35. data/screen_test/elements/{graph.frame → graph_asc.frame} +1 -1
  36. data/screen_test/elements/{graph.rb → graph_asc.rb} +0 -0
  37. data/screen_test/elements/graph_desc.frame +1 -0
  38. data/screen_test/elements/graph_desc.rb +12 -0
  39. data/screen_test/elements/graph_horiz.frame +1 -0
  40. data/screen_test/elements/graph_horiz.rb +12 -0
  41. data/screen_test/elements/graph_sin.frame +1 -0
  42. data/screen_test/elements/graph_sin.rb +12 -0
  43. data/screen_test/elements/theme.frame +1 -1
  44. data/screen_test/settings/scroll/horiz_box.frame +1 -1
  45. data/screen_test/settings/scroll/vert_box.frame +1 -1
  46. metadata +19 -6
  47. data/bin/easing +0 -33
  48. data/lib/whirled_peas/graphics/mock_screen.rb +0 -26
@@ -1,12 +1,12 @@
1
1
  require 'whirled_peas/utils/ansi'
2
2
 
3
3
  require_relative 'color'
4
+ require_relative 'text_color'
4
5
 
5
6
  module WhirledPeas
6
7
  module Settings
7
8
  class BgColor < Color
8
9
  BG_OFFSET = 10
9
- private_constant :BG_OFFSET
10
10
 
11
11
  BLACK = new(Utils::Ansi::BLACK + BG_OFFSET)
12
12
  RED = new(Utils::Ansi::RED + BG_OFFSET)
@@ -19,6 +19,10 @@ module WhirledPeas
19
19
  GRAY = BLACK.bright
20
20
 
21
21
  DEFAULT = nil # Use system defined default
22
+
23
+ def as_text_color
24
+ TextColor.new(code - BG_OFFSET, bright?)
25
+ end
22
26
  end
23
27
  end
24
28
  end
@@ -94,7 +94,7 @@ module WhirledPeas
94
94
  end
95
95
 
96
96
  def style
97
- @_style || Styles::DEFAULT
97
+ @_style || theme.border_style
98
98
  end
99
99
 
100
100
  def style=(val)
@@ -43,11 +43,11 @@ module WhirledPeas
43
43
  end
44
44
 
45
45
  def bright
46
- bright? ? self : self.class.new(@code + Utils::Ansi::BRIGHT_OFFSET, true)
46
+ bright? ? self : self.class.new(code + Utils::Ansi::BRIGHT_OFFSET, true)
47
47
  end
48
48
 
49
49
  def hash
50
- [@code, @bright].hash
50
+ [code, bright].hash
51
51
  end
52
52
 
53
53
  def ==(other)
@@ -56,12 +56,16 @@ module WhirledPeas
56
56
  alias_method :eq?, :==
57
57
 
58
58
  def to_s
59
- @code.to_s
59
+ code.to_s
60
60
  end
61
61
 
62
62
  def inspect
63
- "#{self.class.name.split('::').last}(code=#{@code}, bright=#{@bright})"
63
+ "#{self.class.name.split('::').last}(code=#{code}, bright=#{bright?})"
64
64
  end
65
+
66
+ private
67
+
68
+ attr_reader :code
65
69
  end
66
70
  private_constant :Color
67
71
  end
@@ -34,6 +34,8 @@ module WhirledPeas
34
34
  def debug_value(value)
35
35
  return if value.nil?
36
36
  case value
37
+ when Theme
38
+ nil
37
39
  when Position
38
40
  position_value(value)
39
41
  when Margin
@@ -27,7 +27,11 @@ module WhirledPeas
27
27
  end
28
28
 
29
29
  def bg_color=(color)
30
- @_bg_color = BgColor.validate!(color)
30
+ if color == :highlight
31
+ @_bg_color = theme.highlight_bg_color
32
+ else
33
+ @_bg_color = BgColor.validate!(color)
34
+ end
31
35
  end
32
36
 
33
37
  def bold?
@@ -43,7 +47,11 @@ module WhirledPeas
43
47
  end
44
48
 
45
49
  def color=(color)
46
- @_color = TextColor.validate!(color)
50
+ if color == :highlight
51
+ @_color = theme.highlight_color
52
+ else
53
+ @_color = TextColor.validate!(color)
54
+ end
47
55
  end
48
56
 
49
57
  def underline?
@@ -1,5 +1,6 @@
1
1
  require 'whirled_peas/utils/ansi'
2
2
 
3
+ require_relative 'bg_color'
3
4
  require_relative 'color'
4
5
 
5
6
  module WhirledPeas
@@ -16,6 +17,10 @@ module WhirledPeas
16
17
  GRAY = BLACK.bright
17
18
 
18
19
  DEFAULT = nil # Use system defined default
20
+
21
+ def as_bg_color
22
+ BgColor.new(code + BgColor::BG_OFFSET, bright?)
23
+ end
19
24
  end
20
25
  end
21
26
  end
@@ -1,15 +1,20 @@
1
1
  require 'whirled_peas/utils/title_font'
2
2
 
3
3
  require_relative 'bg_color'
4
+ require_relative 'border'
4
5
  require_relative 'text_color'
5
6
 
6
7
  module WhirledPeas
7
8
  module Settings
8
9
  class Theme
9
- attr_reader :color, :bg_color, :title_font
10
+ attr_reader :bg_color, :border_style, :color, :title_font
10
11
 
11
- def color=(value)
12
- @color = TextColor.validate!(value)
12
+ def axis_color=(value)
13
+ @axis_color = TextColor.validate!(value)
14
+ end
15
+
16
+ def axis_color
17
+ @axis_color || border_color
13
18
  end
14
19
 
15
20
  def bg_color=(value)
@@ -24,12 +29,28 @@ module WhirledPeas
24
29
  @border_color || color
25
30
  end
26
31
 
27
- def axis_color=(value)
28
- @axis_color = TextColor.validate!(value)
32
+ def border_style=(value)
33
+ @border_style = Border::Styles.validate!(value)
29
34
  end
30
35
 
31
- def axis_color
32
- @axis_color || border_color
36
+ def color=(value)
37
+ @color = TextColor.validate!(value)
38
+ end
39
+
40
+ def highlight_bg_color=(value)
41
+ @highlight_bg_color = BgColor.validate!(value)
42
+ end
43
+
44
+ def highlight_bg_color
45
+ @highlight_bg_color || color.as_bg_color
46
+ end
47
+
48
+ def highlight_color=(value)
49
+ @highlight_color = TextColor.validate!(value)
50
+ end
51
+
52
+ def highlight_color
53
+ @highlight_color || bg_color.as_text_color
33
54
  end
34
55
 
35
56
  def title_font=(value)
@@ -39,14 +39,20 @@ module WhirledPeas
39
39
  theme = Theme.new
40
40
  settings.each do |key, value|
41
41
  case key
42
- when 'color'
43
- theme.color = value
42
+ when 'axis_color'
43
+ theme.axis_color = value
44
44
  when 'bg_color'
45
45
  theme.bg_color = value
46
46
  when 'border_color'
47
47
  theme.border_color = value
48
- when 'axis_color'
49
- theme.axis_color = value
48
+ when 'border_style'
49
+ theme.border_style = value
50
+ when 'color'
51
+ theme.color = value
52
+ when 'highlight_bg_color'
53
+ theme.highlight_bg_color = value
54
+ when 'highlight_color'
55
+ theme.highlight_color = value
50
56
  when 'title_font'
51
57
  theme.title_font = value
52
58
  else
@@ -1,3 +1,3 @@
1
1
  module WhirledPeas
2
- VERSION = '0.11.0'
2
+ VERSION = '0.11.1'
3
3
  end
@@ -1 +1 @@
1
- [?25l                        ┏━━━━━━━━━━┓┃ ┃┃▄▄▄▖ ┃┗━━━━━━━━━━┛ABCDEFGHIJ[?25h
1
+ [?25l                        ┏━━━━━━━━━━┓┃ ┃┃▄▄▄▄ ┃┗━━━━━━━━━━┛ABCDEFGHIJ[?25h
@@ -1 +1 @@
1
- [?25l                        ┏━━━━━━━━━━┓┃ ┃┃ ▄▖ ┃┗━━━━━━━━━━┛L, M, N, O[?25h
1
+ [?25l                        ┏━━━━━━━━━━┓┃ ┃┃ ▗▄ ┃┗━━━━━━━━━━┛L, M, N, O[?25h
@@ -1 +1 @@
1
- [?25l                        ┏━━┓┃ ▐┃┃ ▐┃┃ ▐┃┃ ▝┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┗━━┛ABCDEFGHIJ[?25h
1
+ [?25l                        ┏━━┓┃ ▐┃┃ ▐┃┃ ▐┃┃ ▐┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┗━━┛ABCDEFGHIJ[?25h
@@ -1 +1 @@
1
- [?25l                        ┏━━┓┃ ┃┃ ┃┃ ┃┃ ▗┃┃ ▐┃┃ ▝┃┃ ┃┃ ┃┃ ┃┃ ┃┗━━┛K-L-M-N-O-[?25h
1
+ [?25l                        ┏━━┓┃ ┃┃ ┃┃ ┃┃ ┃┃ ▐┃┃ ▐┃┃ ┃┃ ┃┃ ┃┃ ┃┗━━┛K-L-M-N-O-[?25h
@@ -1 +1 @@
1
- [?25l                        ┃ █ ┃ █ ┃ ▄▀ ┃ █ ┃ ▄▀ ┃ █ ┃ ▄▀ ┃ █ ┃ █ ┃ ┃▄▄▀ ┗━━━━━━━━━━[?25h
1
+ [?25l                        ┃ █┃ █┃ █┃ ▄▀┃┃ █ ┃┃ █ ┃ █ ┃ ▄▀ ┃▄▄▀ ┗━━━━━━━━━[?25h
@@ -0,0 +1 @@
1
+ [?25l                        ┃ ▀▄ ┃ ▀▄ ┃ █ ┃ █ ┃ █ ┃ █ ┃ █ ┃ ▀▄┃ █┃ █┃ █┗━━━━━━━━━[?25h
@@ -0,0 +1,12 @@
1
+ require 'whirled_peas'
2
+
3
+ class TemplateFactory
4
+ def build(*)
5
+ WhirledPeas.template(:test) do |composer|
6
+ composer.add_graph('Graph') do |_, settings|
7
+ settings.height = 12
8
+ 10.times.map { |i| 100 - i ** 2 }
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1 @@
1
+ [?25l                        ┃ ┃ ┃ ┃ ┃ ┃▀▀▀▀▀▀▀▀▀┃ ┃ ┃ ┃ ┃ ┗━━━━━━━━━[?25h
@@ -0,0 +1,12 @@
1
+ require 'whirled_peas'
2
+
3
+ class TemplateFactory
4
+ def build(*)
5
+ WhirledPeas.template(:test) do |composer|
6
+ composer.add_graph('Graph') do |_, settings|
7
+ settings.height = 12
8
+ [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1 @@
1
+ [?25l                        ┃ ▄▀▄ ┃ █ █ ┃ █ █ ┃ █ █ ┃█ █ ┃▀ █ ▄┃ █ █┃ █ █┃ █ █┃ █ █ ┃ ▀▄▀ ┗━━━━━━━━━━━━[?25h
@@ -0,0 +1,12 @@
1
+ require 'whirled_peas'
2
+
3
+ class TemplateFactory
4
+ def build(*)
5
+ WhirledPeas.template(:test) do |composer|
6
+ composer.add_graph('Graph') do |_, settings|
7
+ settings.height = 12
8
+ [6, 9, 11, 12, 11, 9, 6, 3, 1, 0, 1, 3, 6]
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1 +1 @@
1
- [?25l┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ██████╗ ██████╗ ██╗ ██╗██╔═══██╗██╔═══██╗██║ ██║██║ ██║██║ ██║███████║██║ ██║██║ ██║██╔══██║╚██████╔╝╚██████╔╝██║ ██║ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝┃ ▄▄▀ ┃ ▄▄▀ ┃ ▄▀ ┃ ▄▀▀ ┃ ▄▀ ┃ ▄▀ ┃ ┃ ▄▀ ┃▄▀ ┃┃█ ┗━━━━━━━━━━━━━━━━━━━━[?25h
1
+ [?25l┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ██████╗ ██████╗ ██╗ ██╗██╔═══██╗██╔═══██╗██║ ██║██║ ██║██║ ██║███████║██║ ██║██║ ██║██╔══██║╚██████╔╝╚██████╔╝██║ ██║ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝┃ ▄▄▀┃ ▄▀▀ ┃ ▄▄▀ ┃ ▄▀ ┃ ▄▀ ┃ ▄▀ ┃ ▄▀ ┃┃┃▄▀ ┃█ ┗━━━━━━━━━━━━━━━━━━━[?25h
@@ -1 +1 @@
1
- [?25l                        ┏━━━━━┓┃ ┃┃▗▖ ┃┗━━━━━┛EFGHI[?25h
1
+ [?25l                        ┏━━━━━┓┃ ┃┃ ▄ ┃┗━━━━━┛EFGHI[?25h
@@ -1 +1 @@
1
- [?25l                        ┏━━┓┃ ▗┃┃ ▝┃┃ ┃┃ ┃┃ ┃┗━━┛EFGHI[?25h
1
+ [?25l                        ┏━━┓┃ ┃┃ ▐┃┃ ┃┃ ┃┃ ┃┗━━┛EFGHI[?25h
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whirled_peas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Collier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-31 00:00:00.000000000 Z
11
+ date: 2021-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -70,10 +70,18 @@ files:
70
70
  - README.md
71
71
  - Rakefile
72
72
  - bin/console
73
- - bin/easing
74
73
  - bin/reset_cursor
75
74
  - bin/screen_test
76
75
  - bin/setup
76
+ - doc/application.md
77
+ - doc/cli.md
78
+ - doc/components.md
79
+ - doc/easing.md
80
+ - doc/elements.md
81
+ - doc/screen_test.md
82
+ - doc/settings.md
83
+ - doc/template_factory.md
84
+ - doc/themes.md
77
85
  - examples/components.rb
78
86
  - examples/graph.rb
79
87
  - examples/intro.rb
@@ -122,7 +130,6 @@ files:
122
130
  - lib/whirled_peas/graphics/graph_dimensions.rb
123
131
  - lib/whirled_peas/graphics/graph_painter.rb
124
132
  - lib/whirled_peas/graphics/grid_painter.rb
125
- - lib/whirled_peas/graphics/mock_screen.rb
126
133
  - lib/whirled_peas/graphics/painter.rb
127
134
  - lib/whirled_peas/graphics/renderer.rb
128
135
  - lib/whirled_peas/graphics/scrollbar_helper.rb
@@ -179,8 +186,14 @@ files:
179
186
  - screen_test/components/list_with_active/t2b_separator.rb
180
187
  - screen_test/elements/box.frame
181
188
  - screen_test/elements/box.rb
182
- - screen_test/elements/graph.frame
183
- - screen_test/elements/graph.rb
189
+ - screen_test/elements/graph_asc.frame
190
+ - screen_test/elements/graph_asc.rb
191
+ - screen_test/elements/graph_desc.frame
192
+ - screen_test/elements/graph_desc.rb
193
+ - screen_test/elements/graph_horiz.frame
194
+ - screen_test/elements/graph_horiz.rb
195
+ - screen_test/elements/graph_sin.frame
196
+ - screen_test/elements/graph_sin.rb
184
197
  - screen_test/elements/grid.frame
185
198
  - screen_test/elements/grid.rb
186
199
  - screen_test/elements/screen_overflow_x.frame
data/bin/easing DELETED
@@ -1,33 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'whirled_peas'
5
- require 'whirled_peas/animator/easing'
6
-
7
- module WhirledPeas
8
- NUM_POINTS = 60
9
-
10
- Animator::Easing::EASING.keys.each do |func|
11
- Animator::Easing::EFFECTS.each do |effect|
12
- easing = Animator::Easing.new(func, effect)
13
- graph = Array.new(NUM_POINTS / ASPECT_RATIO) { '┃' }
14
- NUM_POINTS.times.each do |i|
15
- input = i.to_f / (NUM_POINTS - 1)
16
- eased_value = ((easing.ease(input) * NUM_POINTS * 2) / ASPECT_RATIO).floor
17
- graph.each.with_index do |row, row_num|
18
- y_value = NUM_POINTS.to_f / ASPECT_RATIO - row_num - 1
19
- row << if eased_value == 2 * y_value
20
- '▄'
21
- elsif eased_value == 2 * y_value + 1
22
- '▀'
23
- else
24
- ' '
25
- end
26
- end
27
- end
28
- graph << '┗' + '━' * NUM_POINTS
29
- puts "#{func} (#{effect})"
30
- puts graph.join("\n")
31
- end
32
- end
33
- end
@@ -1,26 +0,0 @@
1
- require_relative 'renderer'
2
-
3
- module WhirledPeas
4
- module Graphics
5
- class MockScreen
6
- def initialize(width:, height:)
7
- @width = width
8
- @height = height
9
- end
10
-
11
- def paint(template)
12
- Renderer.new(template, width, height).paint { }
13
- end
14
-
15
- def refresh
16
- end
17
-
18
- def finalize
19
- end
20
-
21
- private
22
-
23
- attr_reader :width, :height
24
- end
25
- end
26
- end