whirled_peas 0.7.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +25 -0
- data/README.md +530 -121
- data/Rakefile +1 -20
- data/bin/easing +33 -0
- data/bin/reset_cursor +11 -0
- data/bin/screen_test +68 -0
- data/examples/components.rb +35 -0
- data/examples/graph.rb +54 -0
- data/examples/intro.rb +3 -3
- data/examples/scrolling.rb +13 -23
- data/lib/data/themes.yaml +13 -0
- data/lib/whirled_peas.rb +33 -13
- data/lib/whirled_peas/animator.rb +5 -0
- data/lib/whirled_peas/animator/debug_consumer.rb +17 -0
- data/lib/whirled_peas/animator/easing.rb +72 -0
- data/lib/whirled_peas/animator/frame.rb +5 -0
- data/lib/whirled_peas/animator/frameset.rb +33 -0
- data/lib/whirled_peas/animator/producer.rb +35 -0
- data/lib/whirled_peas/animator/renderer_consumer.rb +31 -0
- data/lib/whirled_peas/command.rb +5 -0
- data/lib/whirled_peas/command/base.rb +86 -0
- data/lib/whirled_peas/command/config_command.rb +44 -0
- data/lib/whirled_peas/command/debug.rb +21 -0
- data/lib/whirled_peas/command/fonts.rb +22 -0
- data/lib/whirled_peas/command/frame_command.rb +34 -0
- data/lib/whirled_peas/command/frames.rb +24 -0
- data/lib/whirled_peas/command/help.rb +38 -0
- data/lib/whirled_peas/command/play.rb +112 -0
- data/lib/whirled_peas/command/record.rb +57 -0
- data/lib/whirled_peas/command/still.rb +29 -0
- data/lib/whirled_peas/command/themes.rb +77 -0
- data/lib/whirled_peas/command_line.rb +24 -212
- data/lib/whirled_peas/component.rb +35 -0
- data/lib/whirled_peas/component/list_with_active.rb +88 -0
- data/lib/whirled_peas/config.rb +56 -6
- data/lib/whirled_peas/device.rb +5 -0
- data/lib/whirled_peas/device/null_device.rb +8 -0
- data/lib/whirled_peas/device/output_file.rb +19 -0
- data/lib/whirled_peas/device/screen.rb +26 -0
- data/lib/whirled_peas/graphics/box_painter.rb +4 -4
- data/lib/whirled_peas/graphics/composer.rb +27 -2
- data/lib/whirled_peas/graphics/container_coords.rb +24 -2
- data/lib/whirled_peas/graphics/container_painter.rb +63 -82
- data/lib/whirled_peas/graphics/content_dimensions.rb +19 -0
- data/lib/whirled_peas/graphics/content_painter.rb +20 -0
- data/lib/whirled_peas/graphics/debugger.rb +1 -7
- data/lib/whirled_peas/graphics/graph_dimensions.rb +12 -0
- data/lib/whirled_peas/graphics/graph_painter.rb +97 -0
- data/lib/whirled_peas/graphics/grid_painter.rb +0 -3
- data/lib/whirled_peas/graphics/painter.rb +10 -0
- data/lib/whirled_peas/graphics/renderer.rb +8 -2
- data/lib/whirled_peas/graphics/scrollbar_helper.rb +124 -0
- data/lib/whirled_peas/graphics/text_painter.rb +7 -11
- data/lib/whirled_peas/null_logger.rb +0 -1
- data/lib/whirled_peas/settings/border.rb +25 -4
- data/lib/whirled_peas/settings/container_settings.rb +14 -9
- data/lib/whirled_peas/settings/debugger.rb +1 -1
- data/lib/whirled_peas/settings/element_settings.rb +12 -3
- data/lib/whirled_peas/settings/graph_settings.rb +21 -0
- data/lib/whirled_peas/settings/grid_settings.rb +7 -0
- data/lib/whirled_peas/settings/position.rb +17 -5
- data/lib/whirled_peas/settings/text_settings.rb +1 -0
- data/lib/whirled_peas/settings/theme.rb +40 -0
- data/lib/whirled_peas/settings/theme_library.rb +63 -0
- data/lib/whirled_peas/utils/ansi.rb +13 -0
- data/lib/whirled_peas/utils/file_handler.rb +57 -0
- data/lib/whirled_peas/version.rb +1 -1
- data/screen_test/components/list_with_active/l2r_active_color.frame +1 -0
- data/screen_test/components/list_with_active/l2r_active_color.rb +18 -0
- data/screen_test/components/list_with_active/l2r_position_end.frame +1 -0
- data/screen_test/components/list_with_active/l2r_position_end.rb +16 -0
- data/screen_test/components/list_with_active/l2r_position_middle.frame +1 -0
- data/screen_test/components/list_with_active/l2r_position_middle.rb +16 -0
- data/screen_test/components/list_with_active/l2r_position_start.frame +1 -0
- data/screen_test/components/list_with_active/l2r_position_start.rb +16 -0
- data/screen_test/components/list_with_active/l2r_separator.frame +1 -0
- data/screen_test/components/list_with_active/l2r_separator.rb +17 -0
- data/screen_test/components/list_with_active/t2b_active_color.frame +1 -0
- data/screen_test/components/list_with_active/t2b_active_color.rb +19 -0
- data/screen_test/components/list_with_active/t2b_position_end.frame +1 -0
- data/screen_test/components/list_with_active/t2b_position_end.rb +17 -0
- data/screen_test/components/list_with_active/t2b_position_middle.frame +1 -0
- data/screen_test/components/list_with_active/t2b_position_middle.rb +17 -0
- data/screen_test/components/list_with_active/t2b_position_start.frame +1 -0
- data/screen_test/components/list_with_active/t2b_position_start.rb +17 -0
- data/screen_test/components/list_with_active/t2b_separator.frame +1 -0
- data/screen_test/components/list_with_active/t2b_separator.rb +18 -0
- data/screen_test/elements/box.frame +1 -1
- data/screen_test/elements/box.rb +1 -1
- data/screen_test/elements/graph.frame +1 -0
- data/screen_test/elements/graph.rb +12 -0
- data/screen_test/elements/grid.frame +1 -1
- data/screen_test/elements/grid.rb +1 -1
- data/screen_test/elements/screen_overflow_x.frame +1 -1
- data/screen_test/elements/screen_overflow_x.rb +1 -1
- data/screen_test/elements/screen_overflow_y.frame +1 -1
- data/screen_test/elements/screen_overflow_y.rb +1 -1
- data/screen_test/elements/text.frame +1 -1
- data/screen_test/elements/text.rb +1 -1
- data/screen_test/elements/text_multiline.frame +1 -1
- data/screen_test/elements/text_multiline.rb +1 -1
- data/screen_test/elements/theme.frame +1 -0
- data/screen_test/elements/theme.rb +26 -0
- data/screen_test/settings/align/box_around.frame +1 -1
- data/screen_test/settings/align/box_around.rb +1 -1
- data/screen_test/settings/align/box_between.frame +1 -1
- data/screen_test/settings/align/box_between.rb +1 -1
- data/screen_test/settings/align/box_center.frame +1 -1
- data/screen_test/settings/align/box_center.rb +1 -1
- data/screen_test/settings/align/box_default.frame +1 -1
- data/screen_test/settings/align/box_default.rb +1 -1
- data/screen_test/settings/align/box_evenly.frame +1 -1
- data/screen_test/settings/align/box_evenly.rb +1 -1
- data/screen_test/settings/align/box_left.frame +1 -1
- data/screen_test/settings/align/box_left.rb +1 -1
- data/screen_test/settings/align/box_right.frame +1 -1
- data/screen_test/settings/align/box_right.rb +1 -1
- data/screen_test/settings/align/children_center.frame +1 -1
- data/screen_test/settings/align/children_center.rb +1 -1
- data/screen_test/settings/align/children_left.frame +1 -1
- data/screen_test/settings/align/children_left.rb +1 -1
- data/screen_test/settings/align/children_right.frame +1 -1
- data/screen_test/settings/align/children_right.rb +1 -1
- data/screen_test/settings/align/grid_center.frame +1 -1
- data/screen_test/settings/align/grid_center.rb +1 -1
- data/screen_test/settings/align/grid_default.frame +1 -1
- data/screen_test/settings/align/grid_default.rb +1 -1
- data/screen_test/settings/align/grid_left.frame +1 -1
- data/screen_test/settings/align/grid_left.rb +1 -1
- data/screen_test/settings/align/grid_right.frame +1 -1
- data/screen_test/settings/align/grid_right.rb +1 -1
- data/screen_test/settings/ansi/bold.frame +1 -1
- data/screen_test/settings/ansi/bold.rb +1 -1
- data/screen_test/settings/ansi/color.frame +1 -1
- data/screen_test/settings/ansi/color.rb +1 -1
- data/screen_test/settings/ansi/underline.frame +1 -1
- data/screen_test/settings/ansi/underline.rb +1 -1
- data/screen_test/settings/border.frame +1 -1
- data/screen_test/settings/border.rb +1 -1
- data/screen_test/settings/content_start/box_bottom.frame +1 -0
- data/screen_test/settings/content_start/box_bottom.rb +17 -0
- data/screen_test/settings/content_start/box_left.frame +1 -0
- data/screen_test/settings/{position → content_start}/box_left.rb +2 -2
- data/screen_test/settings/content_start/box_left_negative.frame +1 -0
- data/screen_test/settings/{position → content_start}/box_left_negative.rb +2 -2
- data/screen_test/settings/content_start/box_right.frame +1 -0
- data/screen_test/settings/content_start/box_right.rb +17 -0
- data/screen_test/settings/content_start/box_top.frame +1 -0
- data/screen_test/settings/{position → content_start}/box_top.rb +2 -2
- data/screen_test/settings/content_start/box_top_negative.frame +1 -0
- data/screen_test/settings/{position → content_start}/box_top_negative.rb +2 -2
- data/screen_test/settings/content_start/grid_left.frame +1 -0
- data/screen_test/settings/{position → content_start}/grid_left.rb +2 -2
- data/screen_test/settings/content_start/grid_left_negative.frame +1 -0
- data/screen_test/settings/{position → content_start}/grid_left_negative.rb +2 -2
- data/screen_test/settings/content_start/grid_top.frame +1 -0
- data/screen_test/settings/{position → content_start}/grid_top.rb +2 -2
- data/screen_test/settings/content_start/grid_top_negative.frame +1 -0
- data/screen_test/settings/{position → content_start}/grid_top_negative.rb +2 -2
- data/screen_test/settings/flow/box_b2t.frame +1 -1
- data/screen_test/settings/flow/box_b2t.rb +1 -1
- data/screen_test/settings/flow/box_l2r.frame +1 -1
- data/screen_test/settings/flow/box_l2r.rb +1 -1
- data/screen_test/settings/flow/box_r2l.frame +1 -1
- data/screen_test/settings/flow/box_r2l.rb +1 -1
- data/screen_test/settings/flow/box_t2b.frame +1 -1
- data/screen_test/settings/flow/box_t2b.rb +1 -1
- data/screen_test/settings/flow/grid_b2t.frame +1 -1
- data/screen_test/settings/flow/grid_b2t.rb +1 -1
- data/screen_test/settings/flow/grid_l2r.frame +1 -1
- data/screen_test/settings/flow/grid_l2r.rb +1 -1
- data/screen_test/settings/flow/grid_r2l.frame +1 -1
- data/screen_test/settings/flow/grid_r2l.rb +1 -1
- data/screen_test/settings/flow/grid_t2b.frame +1 -1
- data/screen_test/settings/flow/grid_t2b.rb +1 -1
- data/screen_test/settings/height/box.frame +1 -1
- data/screen_test/settings/height/box.rb +1 -1
- data/screen_test/settings/height/box_border_sizing.frame +1 -1
- data/screen_test/settings/height/box_border_sizing.rb +1 -1
- data/screen_test/settings/height/grid.frame +1 -1
- data/screen_test/settings/height/grid.rb +1 -1
- data/screen_test/settings/height/overflow_box.frame +1 -1
- data/screen_test/settings/height/overflow_box.rb +1 -1
- data/screen_test/settings/height/overflow_box_l2r.frame +1 -1
- data/screen_test/settings/height/overflow_box_l2r.rb +1 -1
- data/screen_test/settings/height/overflow_box_t2b.frame +1 -1
- data/screen_test/settings/height/overflow_box_t2b.rb +1 -1
- data/screen_test/settings/height/overflow_grid.frame +1 -1
- data/screen_test/settings/height/overflow_grid.rb +1 -1
- data/screen_test/settings/margin.frame +1 -1
- data/screen_test/settings/margin.rb +1 -1
- data/screen_test/settings/padding.frame +1 -1
- data/screen_test/settings/padding.rb +1 -1
- data/screen_test/settings/scroll/horiz_box.frame +1 -1
- data/screen_test/settings/scroll/horiz_box.rb +3 -5
- data/screen_test/settings/scroll/horiz_box_align_center.rb +3 -5
- data/screen_test/settings/scroll/horiz_box_align_right.rb +3 -5
- data/screen_test/settings/scroll/vert_box.frame +1 -1
- data/screen_test/settings/scroll/vert_box.rb +6 -8
- data/screen_test/settings/title_font.frame +1 -1
- data/screen_test/settings/title_font.rb +1 -1
- data/screen_test/settings/valign/box_around.frame +1 -1
- data/screen_test/settings/valign/box_around.rb +1 -1
- data/screen_test/settings/valign/box_between.frame +1 -1
- data/screen_test/settings/valign/box_between.rb +1 -1
- data/screen_test/settings/valign/box_bottom.frame +1 -1
- data/screen_test/settings/valign/box_bottom.rb +1 -1
- data/screen_test/settings/valign/box_default.frame +1 -1
- data/screen_test/settings/valign/box_default.rb +1 -1
- data/screen_test/settings/valign/box_evenly.frame +1 -1
- data/screen_test/settings/valign/box_evenly.rb +1 -1
- data/screen_test/settings/valign/box_middle.frame +1 -1
- data/screen_test/settings/valign/box_middle.rb +1 -1
- data/screen_test/settings/valign/box_top.frame +1 -1
- data/screen_test/settings/valign/box_top.rb +1 -1
- data/screen_test/settings/valign/grid_bottom.frame +1 -1
- data/screen_test/settings/valign/grid_bottom.rb +1 -1
- data/screen_test/settings/valign/grid_default.frame +1 -1
- data/screen_test/settings/valign/grid_default.rb +1 -1
- data/screen_test/settings/valign/grid_middle.frame +1 -1
- data/screen_test/settings/valign/grid_middle.rb +1 -1
- data/screen_test/settings/valign/grid_top.frame +1 -1
- data/screen_test/settings/valign/grid_top.rb +1 -1
- data/screen_test/settings/width/box_border_sizing.frame +1 -1
- data/screen_test/settings/width/box_border_sizing.rb +1 -1
- data/screen_test/settings/width/box_content.frame +1 -1
- data/screen_test/settings/width/box_content.rb +1 -1
- data/screen_test/settings/width/box_default.frame +1 -1
- data/screen_test/settings/width/box_default.rb +1 -1
- data/screen_test/settings/width/grid.frame +1 -1
- data/screen_test/settings/width/grid.rb +1 -1
- data/screen_test/settings/width/overflow_align_center.frame +1 -1
- data/screen_test/settings/width/overflow_align_center.rb +1 -1
- data/screen_test/settings/width/overflow_align_right.frame +1 -1
- data/screen_test/settings/width/overflow_align_right.rb +1 -1
- data/screen_test/settings/width/overflow_box.frame +1 -1
- data/screen_test/settings/width/overflow_box.rb +1 -1
- data/screen_test/settings/width/overflow_box_l2r.frame +1 -1
- data/screen_test/settings/width/overflow_box_l2r.rb +1 -1
- data/screen_test/settings/width/overflow_box_t2b.frame +1 -1
- data/screen_test/settings/width/overflow_box_t2b.rb +1 -1
- data/screen_test/settings/width/overflow_grid.frame +1 -1
- data/screen_test/settings/width/overflow_grid.rb +1 -1
- data/tools/whirled_peas/tools/screen_tester.rb +131 -65
- metadata +86 -25
- data/lib/whirled_peas/frame.rb +0 -6
- data/lib/whirled_peas/frame/consumer.rb +0 -30
- data/lib/whirled_peas/frame/debug_consumer.rb +0 -30
- data/lib/whirled_peas/frame/event_loop.rb +0 -90
- data/lib/whirled_peas/frame/producer.rb +0 -67
- data/lib/whirled_peas/graphics/screen.rb +0 -70
- data/lib/whirled_peas/graphics/text_dimensions.rb +0 -15
- data/screen_test/settings/position/box_left.frame +0 -1
- data/screen_test/settings/position/box_left_negative.frame +0 -1
- data/screen_test/settings/position/box_top.frame +0 -1
- data/screen_test/settings/position/box_top_negative.frame +0 -1
- data/screen_test/settings/position/grid_left.frame +0 -1
- data/screen_test/settings/position/grid_left_negative.frame +0 -1
- data/screen_test/settings/position/grid_top.frame +0 -1
- data/screen_test/settings/position/grid_top_negative.frame +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f73ce3a27741b9c790785fe5aad7179c6db66e045ca1c2e43af33887c1fd4d9
|
4
|
+
data.tar.gz: bd19233e2d81a2d4e985bc4c8b0ec3ec07b8fe4691f0c70c5a2374add780bc9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c2a41a72c30eb2c96161c23bb4f47a37dd9052ca1206cdec2d714d3266b0a6e3eb58bc8dab0dea0517eaf1fe7c5743323a8a7579319e81fdce80b9d65992504
|
7
|
+
data.tar.gz: 1b120aa9b5327880dcdcffbb37cfb77b63a06be55089f77efe7c4da104ce36e65893412178b5efcc31d6f7a3b9aed8353bbe076ea0131f52a142910d251bc61f
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,30 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v0.11.0 - 2021-01-30
|
4
|
+
|
5
|
+
- [c1f3d94](https://github.com/tcollier/whirled_peas/tree/c1f3d944a35305c3032681db13ffd6142a7e19e4): Add component support
|
6
|
+
|
7
|
+
## v0.10.0 - 2021-01-29
|
8
|
+
|
9
|
+
- [3063a2b](https://github.com/tcollier/whirled_peas/tree/3063a2becb7680b5e320a1733b3da933e6c65210): Add built-in and user-defined themes
|
10
|
+
|
11
|
+
## v0.9.1 - 2021-01-29
|
12
|
+
|
13
|
+
- [c35b134](https://github.com/tcollier/whirled_peas/tree/c35b134e1340b8b5f1d1fb0e6e56dc2a99b52e94): Improve graph plots
|
14
|
+
|
15
|
+
## v0.9.0 - 2021-01-29
|
16
|
+
|
17
|
+
BREAKING: `Frameset#add_frame` signature changed
|
18
|
+
|
19
|
+
- [1c28947](https://github.com/tcollier/whirled_peas/tree/1c28947980eedce034d2596732ee4860717904c5): Add graph support
|
20
|
+
|
21
|
+
## v0.8.0 - 2021-01-29
|
22
|
+
|
23
|
+
BREAKING: `Producer` now responds to `#add_frame` instead of `#send_frame`
|
24
|
+
|
25
|
+
- [67fdc17](https://github.com/tcollier/whirled_peas/tree/67fdc172434cb97f31ca20a674f28aefec6babb3): Add easing functions for frame transitions
|
26
|
+
- [b888f2e](https://github.com/tcollier/whirled_peas/tree/b888f2e7a3b7c3341300326b417641cc8cf2e89b): Add record and playback functionality to command line tool
|
27
|
+
|
3
28
|
## v0.7.1 - 2021-01-27
|
4
29
|
|
5
30
|
- [b98781d](https://github.com/tcollier/whirled_peas/tree/b98781de23a24b596955f25cfc48936c0cc1efac): Fix num_cols bug for vertical grid flow
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
╚══╝╚══╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═╝╚══════╝╚══════╝╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚══════╝
|
19
19
|
```
|
20
20
|
|
21
|
-
Easily create terminal-based graphics to
|
21
|
+
Easily create terminal-based graphics to visualize the execution of your code. Whirled Peas offers templating inspired by HTML and CSS and provides a lightweight tie-in for your code to produce visual animations with these templates.
|
22
22
|
|
23
23
|
## Installation
|
24
24
|
|
@@ -40,9 +40,8 @@ Or install it yourself as:
|
|
40
40
|
|
41
41
|
A Whirled Peas application consists of the following pieces
|
42
42
|
|
43
|
-
- The
|
44
|
-
- The main template factory (required) - builds templates to convert frame events from the
|
45
|
-
- A loading screen template factory (optional) - builds templates to display while content is loading
|
43
|
+
- The application (required) - the code that is to be visualized, it emits lightweight frame events through a producer
|
44
|
+
- The main template factory (required) - builds templates to convert frame events from the application into terminal graphics
|
46
45
|
|
47
46
|
These pieces are configured as following
|
48
47
|
|
@@ -62,15 +61,15 @@ class TemplateFactory
|
|
62
61
|
end
|
63
62
|
end
|
64
63
|
|
65
|
-
class
|
64
|
+
class Application
|
66
65
|
def start(producer)
|
67
|
-
producer.
|
66
|
+
producer.add_frame('starting', args: { name: 'World' })
|
68
67
|
# ...
|
69
68
|
end
|
70
69
|
end
|
71
70
|
|
72
71
|
WhirledPeas.configure do |config|
|
73
|
-
config.
|
72
|
+
config.application = Application.new
|
74
73
|
config.template_factory = TemplateFactory.new
|
75
74
|
end
|
76
75
|
```
|
@@ -78,54 +77,64 @@ end
|
|
78
77
|
Then the visualizer is started on the command line with
|
79
78
|
|
80
79
|
```
|
81
|
-
$ whirled_peas
|
80
|
+
$ whirled_peas play visualize.rb
|
82
81
|
```
|
83
82
|
|
84
|
-
|
83
|
+
### Application
|
85
84
|
|
86
|
-
|
87
|
-
class LoadingTemplateFactory
|
88
|
-
def build
|
89
|
-
WhirledPeas.template do |composer|
|
90
|
-
composer.add_box('Loading') do |_, settings|
|
91
|
-
settings.set_margin(top: 15)
|
92
|
-
settings.align = :center
|
93
|
-
settings.full_border(color: :blue, style: :double)
|
94
|
-
"Loading..."
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
85
|
+
The application is code to be visualized that integrates with Whirled Peas by providing the signature below
|
99
86
|
|
100
|
-
|
101
|
-
|
102
|
-
|
87
|
+
```ruby
|
88
|
+
# Start the application and pass frame events to the producer to be rendered
|
89
|
+
# by the UI
|
90
|
+
#
|
91
|
+
# @param producer [Producer] frame producer that sends events to the UI
|
92
|
+
def start(producer)
|
93
|
+
# application code here
|
103
94
|
end
|
104
95
|
```
|
105
96
|
|
106
|
-
|
107
|
-
|
108
|
-
The driver is the application code to be visualized. This is typically a lightweight wrapper around an existing application that conforms to the signature below.
|
97
|
+
The producer provides the following methods
|
109
98
|
|
110
99
|
```ruby
|
111
|
-
#
|
100
|
+
# Add a frame to be displayed
|
112
101
|
#
|
113
|
-
# @param
|
114
|
-
|
115
|
-
|
102
|
+
# @param name [String] (required) application defined name for the frame. The
|
103
|
+
# template factory will be provided this name
|
104
|
+
# @param duration [Number] (optional) time in seconds this frame should be
|
105
|
+
# displayed for (defaults to 1 frame)
|
106
|
+
# @param args [Hash<Symbol, Object>] (optional) key/value pairs to send as
|
107
|
+
# arguments to the template factory
|
108
|
+
def add_frame(name, duration:, args:)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Create and yield a frameset instance that allows applications to add multiple
|
112
|
+
# frames to play over the given duration. Adding frames to the yielded frameset
|
113
|
+
# will result in playback that is eased by the given `easing` and `effect`
|
114
|
+
# arguments (default is `:linear` easing)
|
115
|
+
#
|
116
|
+
# @param duration [Number] (required) total duration for which all frames in
|
117
|
+
# frameset will be displayed
|
118
|
+
# @param easing [Symbol] (optional) easing function to be used to transition
|
119
|
+
# through all frames (defaults to `:linear`)
|
120
|
+
# @param effect [Symbol] (optional) how to apply the easing function (defaults
|
121
|
+
# to `:in_out`, also available are `:in` and `:out`)
|
122
|
+
# @yield [Frameset] instance that provides `#add_frame(name, args:)`
|
123
|
+
def frameset(duration, easing:, effect:, &block)
|
116
124
|
end
|
117
125
|
```
|
118
126
|
|
119
|
-
|
127
|
+
A frameset instance provides one method
|
120
128
|
|
121
129
|
```ruby
|
122
|
-
#
|
130
|
+
# Add a frame to be displayed, the duration will be determine by the number of
|
131
|
+
# frames in the frameset along with the duration and easing of the frameset
|
123
132
|
#
|
124
|
-
# @param name [String] application defined name for the frame. The
|
125
|
-
#
|
126
|
-
# @param args [Hash<Symbol, Object>] key
|
127
|
-
|
128
|
-
|
133
|
+
# @param name [String] (required) application defined name for the frame. The
|
134
|
+
# template factory will be provided this name
|
135
|
+
# @param args [Hash<Symbol, Object>] (optional) key/value pairs to send as
|
136
|
+
# arguments to the template factory
|
137
|
+
def add_frame(name, args:)
|
129
138
|
end
|
130
139
|
```
|
131
140
|
|
@@ -136,39 +145,35 @@ end
|
|
136
145
|
Simple application that loads a set of numbers and looks for a pair that adds up to 1,000
|
137
146
|
|
138
147
|
```ruby
|
139
|
-
class
|
148
|
+
class Application
|
140
149
|
def start(producer)
|
141
150
|
numbers = File.readlines('/path/to/numbers.txt').map(&:to_i)
|
142
|
-
producer.
|
151
|
+
producer.add_frame('load-numbers', duration: 3, args: { numbers: numbers })
|
143
152
|
numbers.sort!
|
144
|
-
producer.
|
153
|
+
producer.add_frame('sort-numbers', duration: 3, args: { numbers: numbers })
|
145
154
|
low = 0
|
146
155
|
high = numbers.length - 1
|
147
156
|
while low < high
|
148
157
|
sum = numbers[low] + numbers[high]
|
149
158
|
if sum == 1000
|
150
|
-
producer.
|
159
|
+
producer.add_frame('found-pair', duration: 5, args: { low: low, high: high, sum: sum })
|
151
160
|
return
|
152
161
|
elsif sum < 1000
|
153
|
-
producer.
|
162
|
+
producer.add_frame('too-low', args: { low: low, high: high, sum: sum })
|
154
163
|
low += 1
|
155
164
|
else
|
156
|
-
producer.
|
165
|
+
producer.add_frame('too-high', args: { low: low, high: high, sum: sum })
|
157
166
|
high -= 1
|
158
167
|
end
|
159
168
|
end
|
160
|
-
producer.
|
169
|
+
producer.add_frame('no-solution', duration: 5)
|
161
170
|
end
|
162
171
|
end
|
163
172
|
```
|
164
173
|
|
165
174
|
### Template Factory
|
166
175
|
|
167
|
-
To render the frame events sent by the
|
168
|
-
|
169
|
-
#### Loading Template Factory
|
170
|
-
|
171
|
-
`WhirledPeas.configure` takes an optional template factory to build a loading screen. This instance must implement `#build` (taking no arguments). The template returned by that method will be painted while the event loop is waiting for frames. The factory method will be called once per refresh cycle, so it's possible to implement animation.
|
176
|
+
To render the frame events sent by the application, the application requires a template factory. This factory will be called for each frame event, with the frame name and the arguments supplied by the application. A template factory can be an instance of ruby class and thus can maintain state. Whirled Peas provides a few basic building blocks to make simple, yet elegant terminal-based UIs.
|
172
177
|
|
173
178
|
#### Building Blocks
|
174
179
|
|
@@ -182,6 +187,7 @@ A template is created with `WhirledPeas.template`, which yields a `Composer` obj
|
|
182
187
|
A `Composer` provides the following methods to add child elements, each of these takes an optional string argument that is set as the name of the element (which can be useful when debugging).
|
183
188
|
|
184
189
|
- `add_box` - yields a `Composer` for a `Box` and a `BoxSettings`, which will be added to the parent's children
|
190
|
+
- `add_graph` - yields a `nil` and a `GraphSettings`, which will be added to the parent's children, the block should return an array of numbers
|
185
191
|
- `add_grid` - yields a `Composer` for a `Grid` and a `GridSettings`, which will be added to the parent's children
|
186
192
|
- `add_text` - yields `nil` and a `TextSettings`, which will be added to the parent's children
|
187
193
|
|
@@ -239,30 +245,103 @@ template.add_box do
|
|
239
245
|
end
|
240
246
|
```
|
241
247
|
|
248
|
+
#### Components
|
249
|
+
|
250
|
+
A component is a composition of the core building blocks. This gem includes a handful of components and third parties can also add components using `WhirledPeas.register_component(name, component_class)` (the convention for `name` is a snake cased symbol). A component class must be constructed with no arguments, though can supply basic setters to allow for customizations. A component must also implement `#compose(composer, settings)`, which should attach elements to the composer. Thus a template can integrate with the component like
|
251
|
+
|
252
|
+
```ruby
|
253
|
+
WhirledPeas.template do |composer, settings|
|
254
|
+
# Attach the component registered with the name `:my_component` to the template
|
255
|
+
WhirledPeas.component(composer, settings, :my_component) do |component|
|
256
|
+
# Configure the component
|
257
|
+
end
|
258
|
+
end
|
259
|
+
```
|
260
|
+
|
261
|
+
##### `:list_with_active`
|
262
|
+
|
263
|
+
This component presents a list of content (either horizontally of vertically) and places the item specified by `active_index` in the preferred position.
|
264
|
+
|
265
|
+
```
|
266
|
+
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
267
|
+
┃ green, blue, *indigo*, viole┃
|
268
|
+
┃ ▗▄▄▄▄▄▄▄▄▄▄▄▄▄▄▖ ┃
|
269
|
+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
270
|
+
```
|
271
|
+
|
272
|
+
Note: in the diagram above, the item specified by the active index is highlighted with `*`s, these are for illustration onlhy. The component can highlight the item with a color and/or background color, but will _not_ add the `*`s.
|
273
|
+
|
274
|
+
This component takes the following options
|
275
|
+
|
276
|
+
**Required**
|
277
|
+
|
278
|
+
- `active_index` - the index of the active item
|
279
|
+
- `items` - the array of items to be displayed in the box
|
280
|
+
|
281
|
+
**Optional**
|
282
|
+
|
283
|
+
- `active_bg_color` - background color of the active item
|
284
|
+
- `active_color` - text color of the active item
|
285
|
+
- `flow` - `:l2r` or `:t2b`
|
286
|
+
- `separator` - string used to separate items in the list, e.g. `", "` for a horizontal list or `"----"` for a vertical list
|
287
|
+
- `viewport_size` - number of characters of the viewport in the flow direction
|
288
|
+
|
289
|
+
**Example**
|
290
|
+
|
291
|
+
```ruby
|
292
|
+
WhirledPeas.template do |composer, settings|
|
293
|
+
WhirledPeas.component(composer, settings, :list_with_active) do |component|
|
294
|
+
component.items = %w[red orange yellow green blue indigo violet]
|
295
|
+
component.separator = ', '
|
296
|
+
component.active_index = active
|
297
|
+
component.viewport_size = 27
|
298
|
+
component.active_color = :blue
|
299
|
+
component.active_bg_color = :bright_yellow
|
300
|
+
end
|
301
|
+
end
|
302
|
+
```
|
303
|
+
|
242
304
|
#### Settings
|
243
305
|
|
244
|
-
Each element type has an associated settings type, which provide a custom set of options to format the output. Child settings will inherit from the parent, where applicable
|
245
|
-
|
246
|
-
|
247
|
-
|
|
248
|
-
|
|
249
|
-
| `
|
250
|
-
| `bg_color`
|
251
|
-
| `bold`
|
252
|
-
| `border`
|
253
|
-
| `color`
|
254
|
-
| `flow`
|
255
|
-
| `height`
|
256
|
-
| `margin`
|
257
|
-
| `num_cols`
|
258
|
-
| `padding`
|
259
|
-
| `
|
260
|
-
| `scrollbar`
|
261
|
-
| `sizing`
|
262
|
-
| `title_font`
|
263
|
-
| `underline`
|
264
|
-
| `width`
|
265
|
-
| `valign`
|
306
|
+
Each element type has an associated settings type, which provide a custom set of options to format the output. Child settings will inherit from the parent, where applicable. The table below lists all settings along with which element types the settings can be applied to (`Grid` and `Box` are containers)
|
307
|
+
|
308
|
+
| Setting | Description | Default | Availability | Inherited |
|
309
|
+
| --------------- | -------------------------------------------------------------------------------- | ---------- | ------------ | -------------------- |
|
310
|
+
| `align` | Justifies the content in the horizontal direction | `:left` | containers | No |
|
311
|
+
| `axis_color` | Color used to paint the axes of the graph (see [Colors](#colors)) | | `Graph` | No |
|
312
|
+
| `bg_color` | Background color (see [Colors](#colors)) | | all | Yes |
|
313
|
+
| `bold` | `true` makes the font bold | `false` | all | Yes |
|
314
|
+
| `border` | Set the border for the lements | none | containers, | Only style and color |
|
315
|
+
| `color` | Foreground text color (see [Colors](#colors)) | | all | Yes |
|
316
|
+
| `flow` | Flow to display child elements (see [Display Flow](#display-flow)) | `:l2r` | containers | No |
|
317
|
+
| `height` | Override the calculated height of an element's content area | | all | No |
|
318
|
+
| `margin` | Set the (left, top, right, bottom) margin of the element | `0` | containers | No |
|
319
|
+
| `num_cols` | Number of columns in the grid (must be set!) | | `Grid` | No |
|
320
|
+
| `padding` | Set the (left, top, right, bottom) padding of the element | `0` | containers | No |
|
321
|
+
| `content_start` | Set the (left, top, right, bottom) position of children | `0` | containers | No |
|
322
|
+
| `scrollbar` | Display a scroll bar for vertical or horizontal scrolling | | `Box` | No |
|
323
|
+
| `sizing` | Sizing model (`:content` or `:border`) used in conjunction with `width`/`height` | `:content` | `Box` | No |
|
324
|
+
| `title_font` | Font used for "large" text (see [Large Text](#large-text), ignores `underline`) | | `Text` | No |
|
325
|
+
| `underline` | `true` underlines the font | `false` | all | Yes |
|
326
|
+
| `width` | Override the calculated width of an element's content area | | all | No |
|
327
|
+
| `valign` | Justifies the content in the vertical direction | `:top` | containers | No |
|
328
|
+
|
329
|
+
##### Themes
|
330
|
+
|
331
|
+
The template builder (`WhirledPeas.template`) takes an optional `theme` argument. You can provide the name of a predefined theme (run `whirled_peas themes` to see a list with samples) or define you own with the following
|
332
|
+
You can define your own theme
|
333
|
+
|
334
|
+
```ruby
|
335
|
+
WhirledPeas.register_theme(:my_theme) do |theme|
|
336
|
+
theme.bg_color = :bright_white
|
337
|
+
theme.color = :blue
|
338
|
+
theme.border_color = :bright_green
|
339
|
+
theme.axis_color = :bright_red
|
340
|
+
theme.title_font = :default
|
341
|
+
end
|
342
|
+
```
|
343
|
+
|
344
|
+
Theme settings will be used as default settings throughout the template, however theme settings can be overridden on any element.
|
266
345
|
|
267
346
|
##### Alignment
|
268
347
|
|
@@ -450,11 +529,19 @@ The `valign` setting takes one of several values
|
|
450
529
|
┗━━━━━━━━━┛
|
451
530
|
```
|
452
531
|
|
453
|
-
#####
|
532
|
+
##### Content Start
|
533
|
+
|
534
|
+
Content start settings dictate the relative position from the content area where the children will get painted. Positive values for `left`/`top` result in moving the children leftward/downward, negative values shift children rightward/upward. Setting `right` or `bototm` will result in the end of the children to be painted relative to the right/bottom of the content area.
|
454
535
|
|
455
|
-
|
536
|
+
To set these values, use
|
456
537
|
|
457
|
-
- `
|
538
|
+
- `set_content_start(left:, top:, right:, bottom:)`
|
539
|
+
- `content_start.left=`
|
540
|
+
- `content_start.top=`
|
541
|
+
- `content_start.right=`
|
542
|
+
- `content_start.bottom=`
|
543
|
+
|
544
|
+
Note: setting `left` and `right` or `top` and `bottom` is not supported
|
458
545
|
|
459
546
|
##### Sizing Model
|
460
547
|
|
@@ -698,7 +785,265 @@ $ whirled_peas title_fonts
|
|
698
785
|
|
699
786
|
Note: when using a title font with WhirledPeas for the first time on a system, the gem loads all fonts to check which ones are available. This can be a slow process and may cause a noticeable delay when running a visualization. Running the command above will cache the results and thus when a WhirledPeas visualization is run, there will be no lag from loading fonts.
|
700
787
|
|
701
|
-
|
788
|
+
#### Easing
|
789
|
+
|
790
|
+
The play duration of a frame within a frameset is determined by the easing function and effect along with the frames relative position within the frameset. The three effects are
|
791
|
+
|
792
|
+
- `:in` - apply easing only to the start of the frameset
|
793
|
+
- `:out` - apply easing only to the end of the frameset
|
794
|
+
- `:in_out` - apply easing to the start and end of the frameset
|
795
|
+
|
796
|
+
The available easing functions are
|
797
|
+
|
798
|
+
- `:bezier`
|
799
|
+
|
800
|
+
```
|
801
|
+
# bezier (in)
|
802
|
+
┃ ▄▀
|
803
|
+
┃ ▄▄▀
|
804
|
+
┃ ▄▀
|
805
|
+
┃ ▄▀▀
|
806
|
+
┃ ▄▄▀
|
807
|
+
┃ ▄▄▀
|
808
|
+
┃ ▄▄▀
|
809
|
+
┃ ▄▀
|
810
|
+
┃ ▄▄▀▀
|
811
|
+
┃ ▄▄▀
|
812
|
+
┃ ▄▀▀
|
813
|
+
┃ ▄▄▀▀
|
814
|
+
┃ ▄▄▀▀▀
|
815
|
+
┃ ▄▄▄▀▀▀
|
816
|
+
┃▄▄▄▄▄▄▄▄▄▄▀▀▀
|
817
|
+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
818
|
+
```
|
819
|
+
|
820
|
+
```
|
821
|
+
# bezier (out)
|
822
|
+
┃ ▄▄▄▀▀▀▀▀▀▀▀▀
|
823
|
+
┃ ▄▄▄▀▀▀
|
824
|
+
┃ ▄▄▄▀▀
|
825
|
+
┃ ▄▄▀▀
|
826
|
+
┃ ▄▄▀
|
827
|
+
┃ ▄▀▀
|
828
|
+
┃ ▄▄▀▀
|
829
|
+
┃ ▄▀
|
830
|
+
┃ ▄▀▀
|
831
|
+
┃ ▄▀▀
|
832
|
+
┃ ▄▀▀
|
833
|
+
┃ ▄▄▀
|
834
|
+
┃ ▄▀
|
835
|
+
┃ ▄▀▀
|
836
|
+
┃▄▄▀
|
837
|
+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
838
|
+
```
|
839
|
+
|
840
|
+
```
|
841
|
+
# bezier (in_out)
|
842
|
+
┃ ▄▄▄▀▀▀▀▀▀
|
843
|
+
┃ ▄▄▀▀
|
844
|
+
┃ ▄▀▀
|
845
|
+
┃ ▄▀▀
|
846
|
+
┃ ▄▀▀
|
847
|
+
┃ ▄▀▀
|
848
|
+
┃ ▄▄▀
|
849
|
+
┃ ▄▀
|
850
|
+
┃ ▄▀▀
|
851
|
+
┃ ▄▄▀
|
852
|
+
┃ ▄▄▀
|
853
|
+
┃ ▄▄▀
|
854
|
+
┃ ▄▄▀
|
855
|
+
┃ ▄▄▀▀
|
856
|
+
┃▄▄▄▄▄▄▄▀▀▀
|
857
|
+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
858
|
+
```
|
859
|
+
|
860
|
+
`:linear`
|
861
|
+
|
862
|
+
```
|
863
|
+
# linear (in)
|
864
|
+
┃ ▄▄▀
|
865
|
+
┃ ▄▄▀▀
|
866
|
+
┃ ▄▄▀▀
|
867
|
+
┃ ▄▄▀▀
|
868
|
+
┃ ▄▄▀▀
|
869
|
+
┃ ▄▄▀▀
|
870
|
+
┃ ▄▄▀▀
|
871
|
+
┃ ▄▄▀▀
|
872
|
+
┃ ▄▄▀▀
|
873
|
+
┃ ▄▄▀▀
|
874
|
+
┃ ▄▄▀▀
|
875
|
+
┃ ▄▄▀▀
|
876
|
+
┃ ▄▄▀▀
|
877
|
+
┃ ▄▄▀▀
|
878
|
+
┃▄▄▀▀
|
879
|
+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
880
|
+
```
|
881
|
+
|
882
|
+
```
|
883
|
+
# linear (out)
|
884
|
+
┃ ▄▄▀
|
885
|
+
┃ ▄▄▀▀
|
886
|
+
┃ ▄▄▀▀
|
887
|
+
┃ ▄▄▀▀
|
888
|
+
┃ ▄▄▀▀
|
889
|
+
┃ ▄▄▀▀
|
890
|
+
┃ ▄▄▀▀
|
891
|
+
┃ ▄▄▀▀
|
892
|
+
┃ ▄▄▀▀
|
893
|
+
┃ ▄▄▀▀
|
894
|
+
┃ ▄▄▀▀
|
895
|
+
┃ ▄▄▀▀
|
896
|
+
┃ ▄▄▀▀
|
897
|
+
┃ ▄▄▀▀
|
898
|
+
┃▄▄▀▀
|
899
|
+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
900
|
+
```
|
901
|
+
|
902
|
+
```
|
903
|
+
# linear (in_out)
|
904
|
+
┃ ▄▄▀
|
905
|
+
┃ ▄▄▀▀
|
906
|
+
┃ ▄▄▀▀
|
907
|
+
┃ ▄▄▀▀
|
908
|
+
┃ ▄▄▀▀
|
909
|
+
┃ ▄▄▀▀
|
910
|
+
┃ ▄▄▀▀
|
911
|
+
┃ ▄▄▀▀
|
912
|
+
┃ ▄▄▀▀
|
913
|
+
┃ ▄▄▀▀
|
914
|
+
┃ ▄▄▀▀
|
915
|
+
┃ ▄▄▀▀
|
916
|
+
┃ ▄▄▀▀
|
917
|
+
┃ ▄▄▀▀
|
918
|
+
┃▄▄▀▀
|
919
|
+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
920
|
+
```
|
921
|
+
|
922
|
+
`:parametric`
|
923
|
+
|
924
|
+
```
|
925
|
+
# parametric (in)
|
926
|
+
┃ ▄
|
927
|
+
┃ ▄▀
|
928
|
+
┃ ▄▀
|
929
|
+
┃ ▄▄▀
|
930
|
+
┃ ▄▀
|
931
|
+
┃ ▄▀
|
932
|
+
┃ ▄▀
|
933
|
+
┃ ▄▄▀
|
934
|
+
┃ ▄▀
|
935
|
+
┃ ▄▀▀
|
936
|
+
┃ ▄▀▀
|
937
|
+
┃ ▄▄▀▀
|
938
|
+
┃ ▄▄▄▀▀
|
939
|
+
┃ ▄▄▄▄▀▀
|
940
|
+
┃▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀▀▀▀▀
|
941
|
+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
942
|
+
```
|
943
|
+
|
944
|
+
```
|
945
|
+
# parametric (out)
|
946
|
+
┃ ▄▄▄▄▄▀▀▀▀▀▀▀▀▀▀▀▀▀
|
947
|
+
┃ ▄▄▀▀▀▀
|
948
|
+
┃ ▄▄▀▀▀
|
949
|
+
┃ ▄▄▀▀
|
950
|
+
┃ ▄▄▀
|
951
|
+
┃ ▄▄▀
|
952
|
+
┃ ▄▀
|
953
|
+
┃ ▄▀▀
|
954
|
+
┃ ▄▀
|
955
|
+
┃ ▄▀
|
956
|
+
┃ ▄▀
|
957
|
+
┃ ▄▀▀
|
958
|
+
┃ ▄▀
|
959
|
+
┃ ▄▀
|
960
|
+
┃▄▀
|
961
|
+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
962
|
+
```
|
963
|
+
|
964
|
+
```
|
965
|
+
# parametric (in_out)
|
966
|
+
┃ ▄▄▄▀▀▀▀▀▀▀▀▀
|
967
|
+
┃ ▄▄▀▀
|
968
|
+
┃ ▄▀▀
|
969
|
+
┃ ▄▄▀
|
970
|
+
┃ ▄▀
|
971
|
+
┃ ▄▀
|
972
|
+
┃ ▄▀
|
973
|
+
┃ ▄▀
|
974
|
+
┃ ▄▀
|
975
|
+
┃ ▄▀
|
976
|
+
┃ ▄▀
|
977
|
+
┃ ▄▀▀
|
978
|
+
┃ ▄▄▀
|
979
|
+
┃ ▄▄▀▀
|
980
|
+
┃▄▄▄▄▄▄▄▄▄▄▀▀▀
|
981
|
+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
982
|
+
```
|
983
|
+
|
984
|
+
`:quadratic`
|
985
|
+
|
986
|
+
```
|
987
|
+
# quadratic (in)
|
988
|
+
┃ ▄▄
|
989
|
+
┃ ▄▀
|
990
|
+
┃ ▄▀
|
991
|
+
┃ ▄▀
|
992
|
+
┃ ▄▀
|
993
|
+
┃ ▄▀▀
|
994
|
+
┃ ▄▀
|
995
|
+
┃ ▄▀▀
|
996
|
+
┃ ▄▀▀
|
997
|
+
┃ ▄▀▀
|
998
|
+
┃ ▄▄▀▀
|
999
|
+
┃ ▄▄▀▀
|
1000
|
+
┃ ▄▄▄▀▀
|
1001
|
+
┃ ▄▄▄▀▀▀
|
1002
|
+
┃▄▄▄▄▄▄▄▄▄▄▄▀▀▀▀▀
|
1003
|
+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
1004
|
+
```
|
1005
|
+
|
1006
|
+
```
|
1007
|
+
# quadratic (out)
|
1008
|
+
┃ ▄▄▄▄▄▀▀▀▀▀▀▀▀▀▀
|
1009
|
+
┃ ▄▄▄▀▀▀
|
1010
|
+
┃ ▄▄▀▀▀
|
1011
|
+
┃ ▄▄▀▀
|
1012
|
+
┃ ▄▄▀▀
|
1013
|
+
┃ ▄▄▀
|
1014
|
+
┃ ▄▄▀
|
1015
|
+
┃ ▄▄▀
|
1016
|
+
┃ ▄▀
|
1017
|
+
┃ ▄▄▀
|
1018
|
+
┃ ▄▀
|
1019
|
+
┃ ▄▀
|
1020
|
+
┃ ▄▀
|
1021
|
+
┃ ▄▀
|
1022
|
+
┃▄▀▀
|
1023
|
+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
1024
|
+
```
|
1025
|
+
|
1026
|
+
```
|
1027
|
+
# quadratic (in_out)
|
1028
|
+
┃ ▄▄▄▀▀▀▀▀▀▀
|
1029
|
+
┃ ▄▄▀▀▀
|
1030
|
+
┃ ▄▀▀
|
1031
|
+
┃ ▄▀▀
|
1032
|
+
┃ ▄▄▀
|
1033
|
+
┃ ▄▀
|
1034
|
+
┃ ▄▀
|
1035
|
+
┃ ▄▀
|
1036
|
+
┃ ▄▀
|
1037
|
+
┃ ▄▀
|
1038
|
+
┃ ▄▀▀
|
1039
|
+
┃ ▄▄▀
|
1040
|
+
┃ ▄▄▀
|
1041
|
+
┃ ▄▄▄▀▀
|
1042
|
+
┃▄▄▄▄▄▄▄▄▀▀▀
|
1043
|
+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
1044
|
+
```
|
1045
|
+
|
1046
|
+
### Full template example
|
702
1047
|
|
703
1048
|
```ruby
|
704
1049
|
class TemplateFactory
|
@@ -746,64 +1091,120 @@ class TemplateFactory
|
|
746
1091
|
end
|
747
1092
|
```
|
748
1093
|
|
749
|
-
###
|
1094
|
+
### Full usage
|
1095
|
+
|
1096
|
+
```
|
1097
|
+
Usage: whirled_peas <command> [command options]
|
1098
|
+
|
1099
|
+
Available commands:
|
750
1100
|
|
751
|
-
|
1101
|
+
debug Print template tree for specified frame
|
1102
|
+
fonts List installed title fonts with sample text
|
1103
|
+
frames Print out list of frames generated by application
|
1104
|
+
help Show detailed help for a command
|
1105
|
+
play Play an animation from an application or prerecorded file
|
1106
|
+
record Record animation to a file
|
1107
|
+
still Show the specified still frame
|
1108
|
+
themes List all themes with sample template rendered in the theme
|
1109
|
+
```
|
752
1110
|
|
753
|
-
####
|
1111
|
+
#### `debug`
|
754
1112
|
|
755
|
-
|
1113
|
+
Print the template tree for specified frame.
|
756
1114
|
|
757
1115
|
```
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
1116
|
+
# Usage: whirled_peas debug <config file> <frame> [args as a JSON string]
|
1117
|
+
% whirled_peas debug my_app.rb greeting '{"name":"World"}'
|
1118
|
+
* WhirledPeas::Graphics::BoxPainter(TEMPLATE)
|
1119
|
+
- Dimensions(outer=140x27, content=120x15, grid=1x1)
|
1120
|
+
- Settings
|
1121
|
+
WhirledPeas::Settings::BoxSettings
|
1122
|
+
padding: Padding(left: 10, top: 6, right: 10, bottom: 6)
|
1123
|
+
align: :center
|
1124
|
+
width: 120
|
1125
|
+
flow: :t2b
|
1126
|
+
bold: true
|
1127
|
+
bg_color: BgColor(code=107, bright=true)
|
1128
|
+
- Children
|
1129
|
+
* WhirledPeas::Graphics::BoxPainter(Element-1)
|
1130
|
+
- Dimensions(outer=64x6, content=64x6, grid=1x1)
|
763
1131
|
```
|
764
1132
|
|
765
|
-
####
|
1133
|
+
#### `fonts`
|
766
1134
|
|
767
|
-
|
1135
|
+
List all installed title fonts with sample text.
|
768
1136
|
|
769
1137
|
```
|
770
|
-
|
1138
|
+
# Usage: whirled_peas fonts
|
771
1139
|
```
|
772
1140
|
|
773
|
-
|
1141
|
+
#### `frames`
|
1142
|
+
|
1143
|
+
Print out list of frames generated by application.
|
774
1144
|
|
775
1145
|
```
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
<default>
|
781
|
-
- Children
|
782
|
-
+ TitleContainer [WhirledPeas::Graphics::BoxPainter]
|
1146
|
+
# Usage: whirled_peas frames <config file>
|
1147
|
+
% whirled_peas frames my_app.rb
|
1148
|
+
Frame 'intro' displayed for 3 second(s) '{"title":"Foo"}'
|
1149
|
+
Frame 'greet' displayed for 0.3 second(s)
|
783
1150
|
...
|
784
1151
|
```
|
785
1152
|
|
786
|
-
|
1153
|
+
#### `help`
|
1154
|
+
|
1155
|
+
Print out command-specific help message
|
1156
|
+
|
1157
|
+
```
|
1158
|
+
Usage: whirled_peas help <command>
|
1159
|
+
```
|
1160
|
+
|
1161
|
+
#### `play`
|
1162
|
+
|
1163
|
+
Play an animation from an application or prerecorded file
|
1164
|
+
|
1165
|
+
```
|
1166
|
+
# Usage: whirled_peas play <config/wpz file>
|
1167
|
+
|
1168
|
+
# Play animation directly from app
|
1169
|
+
% whirled_peas play my_app.rb
|
1170
|
+
# Animation plays
|
1171
|
+
|
1172
|
+
# Play animation from previously recorded file
|
1173
|
+
% whirled_peas play my_animation.wpz
|
1174
|
+
# Animation plays
|
1175
|
+
```
|
787
1176
|
|
788
|
-
####
|
1177
|
+
#### `record`
|
789
1178
|
|
790
|
-
|
1179
|
+
Record animation to a file
|
791
1180
|
|
792
1181
|
```
|
793
|
-
|
1182
|
+
# Usage: whirled_peas record <config file> <output file>
|
1183
|
+
% whirled_peas record my_app.rb my_animation.wpz
|
1184
|
+
# Record animation to my_animation.wpz
|
794
1185
|
```
|
795
1186
|
|
796
|
-
|
1187
|
+
#### `still`
|
1188
|
+
|
1189
|
+
Show the specified still frame
|
797
1190
|
|
798
1191
|
```
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
1192
|
+
# Usage: whirled_peas still <config file> <frame> [args as a JSON string]
|
1193
|
+
% whirled_peas still my_app.rb greeting '{"name":"World"}'
|
1194
|
+
# Still frame is displayed
|
1195
|
+
```
|
1196
|
+
|
1197
|
+
#### `themes`
|
1198
|
+
|
1199
|
+
List all themes and display a small sample screen in each. Running this with no extra command line arguments will display all the built-in themes. Adding the path to a Whirled Peas configuration file will inlcude any themes defined in that configuration.
|
1200
|
+
|
1201
|
+
```
|
1202
|
+
# Usage: whirled_peas themes [config file]
|
1203
|
+
% whirled_peas themes
|
1204
|
+
# Display all system themes
|
1205
|
+
|
1206
|
+
% whirled_peas themes my_app.rb
|
1207
|
+
# Display app-defined themes and all system themes
|
807
1208
|
```
|
808
1209
|
|
809
1210
|
## Development
|
@@ -814,23 +1215,31 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
814
1215
|
|
815
1216
|
### Testing
|
816
1217
|
|
817
|
-
In addition to standard RSpec tests, WhirledPeas has custom tests for rendered templates. These files live in `screen_test
|
1218
|
+
In addition to standard RSpec tests, WhirledPeas has custom tests for rendered templates. These files live in `screen_test/`. Each ruby file is expected to define a class named `TemplateFactory` that responds to `#build(name, args)` returning a template (the standard template factory role). Each file should also be accompanied by a `.frame` file with the same base name. This file will contain the output of the rendered screen and is considered the correct output when running tests.
|
818
1219
|
|
819
1220
|
Note: viewing `.frame` files with `cat` works better than most other text editors.
|
820
1221
|
|
821
|
-
|
1222
|
+
```
|
1223
|
+
|
1224
|
+
Usage: screen_test [file] [options]
|
1225
|
+
|
1226
|
+
If not file or options are provide, all tests are run
|
822
1227
|
|
823
|
-
|
824
|
-
|
825
|
-
-
|
826
|
-
-
|
827
|
-
|
828
|
-
|
829
|
-
|
1228
|
+
If no file is provided, the supported options are
|
1229
|
+
--help print this usage statement and exit
|
1230
|
+
--view-pending interactively display and optionally save rendered output for each pending test
|
1231
|
+
--view-failed interactively display and optionally save rendered output for each faiing test
|
1232
|
+
|
1233
|
+
If a screen test file is provided as the first argument, the supported options are
|
1234
|
+
--run run screen test for given file
|
1235
|
+
--view interactively display and optionally save the file's test output
|
1236
|
+
--template print out template tree for the test template
|
1237
|
+
--debug render the test template without displying it, printing out debug information
|
1238
|
+
```
|
830
1239
|
|
831
1240
|
## Contributing
|
832
1241
|
|
833
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
1242
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tcollier/whirled_peas. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/tcollier/whirled_peas/blob/master/CODE_OF_CONDUCT.md).
|
834
1243
|
|
835
1244
|
## License
|
836
1245
|
|
@@ -838,4 +1247,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
838
1247
|
|
839
1248
|
## Code of Conduct
|
840
1249
|
|
841
|
-
Everyone interacting in the WhirledPeas project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
1250
|
+
Everyone interacting in the WhirledPeas project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/tcollier/whirled_peas/blob/master/CODE_OF_CONDUCT.md).
|