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.
Files changed (262) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +25 -0
  4. data/README.md +530 -121
  5. data/Rakefile +1 -20
  6. data/bin/easing +33 -0
  7. data/bin/reset_cursor +11 -0
  8. data/bin/screen_test +68 -0
  9. data/examples/components.rb +35 -0
  10. data/examples/graph.rb +54 -0
  11. data/examples/intro.rb +3 -3
  12. data/examples/scrolling.rb +13 -23
  13. data/lib/data/themes.yaml +13 -0
  14. data/lib/whirled_peas.rb +33 -13
  15. data/lib/whirled_peas/animator.rb +5 -0
  16. data/lib/whirled_peas/animator/debug_consumer.rb +17 -0
  17. data/lib/whirled_peas/animator/easing.rb +72 -0
  18. data/lib/whirled_peas/animator/frame.rb +5 -0
  19. data/lib/whirled_peas/animator/frameset.rb +33 -0
  20. data/lib/whirled_peas/animator/producer.rb +35 -0
  21. data/lib/whirled_peas/animator/renderer_consumer.rb +31 -0
  22. data/lib/whirled_peas/command.rb +5 -0
  23. data/lib/whirled_peas/command/base.rb +86 -0
  24. data/lib/whirled_peas/command/config_command.rb +44 -0
  25. data/lib/whirled_peas/command/debug.rb +21 -0
  26. data/lib/whirled_peas/command/fonts.rb +22 -0
  27. data/lib/whirled_peas/command/frame_command.rb +34 -0
  28. data/lib/whirled_peas/command/frames.rb +24 -0
  29. data/lib/whirled_peas/command/help.rb +38 -0
  30. data/lib/whirled_peas/command/play.rb +112 -0
  31. data/lib/whirled_peas/command/record.rb +57 -0
  32. data/lib/whirled_peas/command/still.rb +29 -0
  33. data/lib/whirled_peas/command/themes.rb +77 -0
  34. data/lib/whirled_peas/command_line.rb +24 -212
  35. data/lib/whirled_peas/component.rb +35 -0
  36. data/lib/whirled_peas/component/list_with_active.rb +88 -0
  37. data/lib/whirled_peas/config.rb +56 -6
  38. data/lib/whirled_peas/device.rb +5 -0
  39. data/lib/whirled_peas/device/null_device.rb +8 -0
  40. data/lib/whirled_peas/device/output_file.rb +19 -0
  41. data/lib/whirled_peas/device/screen.rb +26 -0
  42. data/lib/whirled_peas/graphics/box_painter.rb +4 -4
  43. data/lib/whirled_peas/graphics/composer.rb +27 -2
  44. data/lib/whirled_peas/graphics/container_coords.rb +24 -2
  45. data/lib/whirled_peas/graphics/container_painter.rb +63 -82
  46. data/lib/whirled_peas/graphics/content_dimensions.rb +19 -0
  47. data/lib/whirled_peas/graphics/content_painter.rb +20 -0
  48. data/lib/whirled_peas/graphics/debugger.rb +1 -7
  49. data/lib/whirled_peas/graphics/graph_dimensions.rb +12 -0
  50. data/lib/whirled_peas/graphics/graph_painter.rb +97 -0
  51. data/lib/whirled_peas/graphics/grid_painter.rb +0 -3
  52. data/lib/whirled_peas/graphics/painter.rb +10 -0
  53. data/lib/whirled_peas/graphics/renderer.rb +8 -2
  54. data/lib/whirled_peas/graphics/scrollbar_helper.rb +124 -0
  55. data/lib/whirled_peas/graphics/text_painter.rb +7 -11
  56. data/lib/whirled_peas/null_logger.rb +0 -1
  57. data/lib/whirled_peas/settings/border.rb +25 -4
  58. data/lib/whirled_peas/settings/container_settings.rb +14 -9
  59. data/lib/whirled_peas/settings/debugger.rb +1 -1
  60. data/lib/whirled_peas/settings/element_settings.rb +12 -3
  61. data/lib/whirled_peas/settings/graph_settings.rb +21 -0
  62. data/lib/whirled_peas/settings/grid_settings.rb +7 -0
  63. data/lib/whirled_peas/settings/position.rb +17 -5
  64. data/lib/whirled_peas/settings/text_settings.rb +1 -0
  65. data/lib/whirled_peas/settings/theme.rb +40 -0
  66. data/lib/whirled_peas/settings/theme_library.rb +63 -0
  67. data/lib/whirled_peas/utils/ansi.rb +13 -0
  68. data/lib/whirled_peas/utils/file_handler.rb +57 -0
  69. data/lib/whirled_peas/version.rb +1 -1
  70. data/screen_test/components/list_with_active/l2r_active_color.frame +1 -0
  71. data/screen_test/components/list_with_active/l2r_active_color.rb +18 -0
  72. data/screen_test/components/list_with_active/l2r_position_end.frame +1 -0
  73. data/screen_test/components/list_with_active/l2r_position_end.rb +16 -0
  74. data/screen_test/components/list_with_active/l2r_position_middle.frame +1 -0
  75. data/screen_test/components/list_with_active/l2r_position_middle.rb +16 -0
  76. data/screen_test/components/list_with_active/l2r_position_start.frame +1 -0
  77. data/screen_test/components/list_with_active/l2r_position_start.rb +16 -0
  78. data/screen_test/components/list_with_active/l2r_separator.frame +1 -0
  79. data/screen_test/components/list_with_active/l2r_separator.rb +17 -0
  80. data/screen_test/components/list_with_active/t2b_active_color.frame +1 -0
  81. data/screen_test/components/list_with_active/t2b_active_color.rb +19 -0
  82. data/screen_test/components/list_with_active/t2b_position_end.frame +1 -0
  83. data/screen_test/components/list_with_active/t2b_position_end.rb +17 -0
  84. data/screen_test/components/list_with_active/t2b_position_middle.frame +1 -0
  85. data/screen_test/components/list_with_active/t2b_position_middle.rb +17 -0
  86. data/screen_test/components/list_with_active/t2b_position_start.frame +1 -0
  87. data/screen_test/components/list_with_active/t2b_position_start.rb +17 -0
  88. data/screen_test/components/list_with_active/t2b_separator.frame +1 -0
  89. data/screen_test/components/list_with_active/t2b_separator.rb +18 -0
  90. data/screen_test/elements/box.frame +1 -1
  91. data/screen_test/elements/box.rb +1 -1
  92. data/screen_test/elements/graph.frame +1 -0
  93. data/screen_test/elements/graph.rb +12 -0
  94. data/screen_test/elements/grid.frame +1 -1
  95. data/screen_test/elements/grid.rb +1 -1
  96. data/screen_test/elements/screen_overflow_x.frame +1 -1
  97. data/screen_test/elements/screen_overflow_x.rb +1 -1
  98. data/screen_test/elements/screen_overflow_y.frame +1 -1
  99. data/screen_test/elements/screen_overflow_y.rb +1 -1
  100. data/screen_test/elements/text.frame +1 -1
  101. data/screen_test/elements/text.rb +1 -1
  102. data/screen_test/elements/text_multiline.frame +1 -1
  103. data/screen_test/elements/text_multiline.rb +1 -1
  104. data/screen_test/elements/theme.frame +1 -0
  105. data/screen_test/elements/theme.rb +26 -0
  106. data/screen_test/settings/align/box_around.frame +1 -1
  107. data/screen_test/settings/align/box_around.rb +1 -1
  108. data/screen_test/settings/align/box_between.frame +1 -1
  109. data/screen_test/settings/align/box_between.rb +1 -1
  110. data/screen_test/settings/align/box_center.frame +1 -1
  111. data/screen_test/settings/align/box_center.rb +1 -1
  112. data/screen_test/settings/align/box_default.frame +1 -1
  113. data/screen_test/settings/align/box_default.rb +1 -1
  114. data/screen_test/settings/align/box_evenly.frame +1 -1
  115. data/screen_test/settings/align/box_evenly.rb +1 -1
  116. data/screen_test/settings/align/box_left.frame +1 -1
  117. data/screen_test/settings/align/box_left.rb +1 -1
  118. data/screen_test/settings/align/box_right.frame +1 -1
  119. data/screen_test/settings/align/box_right.rb +1 -1
  120. data/screen_test/settings/align/children_center.frame +1 -1
  121. data/screen_test/settings/align/children_center.rb +1 -1
  122. data/screen_test/settings/align/children_left.frame +1 -1
  123. data/screen_test/settings/align/children_left.rb +1 -1
  124. data/screen_test/settings/align/children_right.frame +1 -1
  125. data/screen_test/settings/align/children_right.rb +1 -1
  126. data/screen_test/settings/align/grid_center.frame +1 -1
  127. data/screen_test/settings/align/grid_center.rb +1 -1
  128. data/screen_test/settings/align/grid_default.frame +1 -1
  129. data/screen_test/settings/align/grid_default.rb +1 -1
  130. data/screen_test/settings/align/grid_left.frame +1 -1
  131. data/screen_test/settings/align/grid_left.rb +1 -1
  132. data/screen_test/settings/align/grid_right.frame +1 -1
  133. data/screen_test/settings/align/grid_right.rb +1 -1
  134. data/screen_test/settings/ansi/bold.frame +1 -1
  135. data/screen_test/settings/ansi/bold.rb +1 -1
  136. data/screen_test/settings/ansi/color.frame +1 -1
  137. data/screen_test/settings/ansi/color.rb +1 -1
  138. data/screen_test/settings/ansi/underline.frame +1 -1
  139. data/screen_test/settings/ansi/underline.rb +1 -1
  140. data/screen_test/settings/border.frame +1 -1
  141. data/screen_test/settings/border.rb +1 -1
  142. data/screen_test/settings/content_start/box_bottom.frame +1 -0
  143. data/screen_test/settings/content_start/box_bottom.rb +17 -0
  144. data/screen_test/settings/content_start/box_left.frame +1 -0
  145. data/screen_test/settings/{position → content_start}/box_left.rb +2 -2
  146. data/screen_test/settings/content_start/box_left_negative.frame +1 -0
  147. data/screen_test/settings/{position → content_start}/box_left_negative.rb +2 -2
  148. data/screen_test/settings/content_start/box_right.frame +1 -0
  149. data/screen_test/settings/content_start/box_right.rb +17 -0
  150. data/screen_test/settings/content_start/box_top.frame +1 -0
  151. data/screen_test/settings/{position → content_start}/box_top.rb +2 -2
  152. data/screen_test/settings/content_start/box_top_negative.frame +1 -0
  153. data/screen_test/settings/{position → content_start}/box_top_negative.rb +2 -2
  154. data/screen_test/settings/content_start/grid_left.frame +1 -0
  155. data/screen_test/settings/{position → content_start}/grid_left.rb +2 -2
  156. data/screen_test/settings/content_start/grid_left_negative.frame +1 -0
  157. data/screen_test/settings/{position → content_start}/grid_left_negative.rb +2 -2
  158. data/screen_test/settings/content_start/grid_top.frame +1 -0
  159. data/screen_test/settings/{position → content_start}/grid_top.rb +2 -2
  160. data/screen_test/settings/content_start/grid_top_negative.frame +1 -0
  161. data/screen_test/settings/{position → content_start}/grid_top_negative.rb +2 -2
  162. data/screen_test/settings/flow/box_b2t.frame +1 -1
  163. data/screen_test/settings/flow/box_b2t.rb +1 -1
  164. data/screen_test/settings/flow/box_l2r.frame +1 -1
  165. data/screen_test/settings/flow/box_l2r.rb +1 -1
  166. data/screen_test/settings/flow/box_r2l.frame +1 -1
  167. data/screen_test/settings/flow/box_r2l.rb +1 -1
  168. data/screen_test/settings/flow/box_t2b.frame +1 -1
  169. data/screen_test/settings/flow/box_t2b.rb +1 -1
  170. data/screen_test/settings/flow/grid_b2t.frame +1 -1
  171. data/screen_test/settings/flow/grid_b2t.rb +1 -1
  172. data/screen_test/settings/flow/grid_l2r.frame +1 -1
  173. data/screen_test/settings/flow/grid_l2r.rb +1 -1
  174. data/screen_test/settings/flow/grid_r2l.frame +1 -1
  175. data/screen_test/settings/flow/grid_r2l.rb +1 -1
  176. data/screen_test/settings/flow/grid_t2b.frame +1 -1
  177. data/screen_test/settings/flow/grid_t2b.rb +1 -1
  178. data/screen_test/settings/height/box.frame +1 -1
  179. data/screen_test/settings/height/box.rb +1 -1
  180. data/screen_test/settings/height/box_border_sizing.frame +1 -1
  181. data/screen_test/settings/height/box_border_sizing.rb +1 -1
  182. data/screen_test/settings/height/grid.frame +1 -1
  183. data/screen_test/settings/height/grid.rb +1 -1
  184. data/screen_test/settings/height/overflow_box.frame +1 -1
  185. data/screen_test/settings/height/overflow_box.rb +1 -1
  186. data/screen_test/settings/height/overflow_box_l2r.frame +1 -1
  187. data/screen_test/settings/height/overflow_box_l2r.rb +1 -1
  188. data/screen_test/settings/height/overflow_box_t2b.frame +1 -1
  189. data/screen_test/settings/height/overflow_box_t2b.rb +1 -1
  190. data/screen_test/settings/height/overflow_grid.frame +1 -1
  191. data/screen_test/settings/height/overflow_grid.rb +1 -1
  192. data/screen_test/settings/margin.frame +1 -1
  193. data/screen_test/settings/margin.rb +1 -1
  194. data/screen_test/settings/padding.frame +1 -1
  195. data/screen_test/settings/padding.rb +1 -1
  196. data/screen_test/settings/scroll/horiz_box.frame +1 -1
  197. data/screen_test/settings/scroll/horiz_box.rb +3 -5
  198. data/screen_test/settings/scroll/horiz_box_align_center.rb +3 -5
  199. data/screen_test/settings/scroll/horiz_box_align_right.rb +3 -5
  200. data/screen_test/settings/scroll/vert_box.frame +1 -1
  201. data/screen_test/settings/scroll/vert_box.rb +6 -8
  202. data/screen_test/settings/title_font.frame +1 -1
  203. data/screen_test/settings/title_font.rb +1 -1
  204. data/screen_test/settings/valign/box_around.frame +1 -1
  205. data/screen_test/settings/valign/box_around.rb +1 -1
  206. data/screen_test/settings/valign/box_between.frame +1 -1
  207. data/screen_test/settings/valign/box_between.rb +1 -1
  208. data/screen_test/settings/valign/box_bottom.frame +1 -1
  209. data/screen_test/settings/valign/box_bottom.rb +1 -1
  210. data/screen_test/settings/valign/box_default.frame +1 -1
  211. data/screen_test/settings/valign/box_default.rb +1 -1
  212. data/screen_test/settings/valign/box_evenly.frame +1 -1
  213. data/screen_test/settings/valign/box_evenly.rb +1 -1
  214. data/screen_test/settings/valign/box_middle.frame +1 -1
  215. data/screen_test/settings/valign/box_middle.rb +1 -1
  216. data/screen_test/settings/valign/box_top.frame +1 -1
  217. data/screen_test/settings/valign/box_top.rb +1 -1
  218. data/screen_test/settings/valign/grid_bottom.frame +1 -1
  219. data/screen_test/settings/valign/grid_bottom.rb +1 -1
  220. data/screen_test/settings/valign/grid_default.frame +1 -1
  221. data/screen_test/settings/valign/grid_default.rb +1 -1
  222. data/screen_test/settings/valign/grid_middle.frame +1 -1
  223. data/screen_test/settings/valign/grid_middle.rb +1 -1
  224. data/screen_test/settings/valign/grid_top.frame +1 -1
  225. data/screen_test/settings/valign/grid_top.rb +1 -1
  226. data/screen_test/settings/width/box_border_sizing.frame +1 -1
  227. data/screen_test/settings/width/box_border_sizing.rb +1 -1
  228. data/screen_test/settings/width/box_content.frame +1 -1
  229. data/screen_test/settings/width/box_content.rb +1 -1
  230. data/screen_test/settings/width/box_default.frame +1 -1
  231. data/screen_test/settings/width/box_default.rb +1 -1
  232. data/screen_test/settings/width/grid.frame +1 -1
  233. data/screen_test/settings/width/grid.rb +1 -1
  234. data/screen_test/settings/width/overflow_align_center.frame +1 -1
  235. data/screen_test/settings/width/overflow_align_center.rb +1 -1
  236. data/screen_test/settings/width/overflow_align_right.frame +1 -1
  237. data/screen_test/settings/width/overflow_align_right.rb +1 -1
  238. data/screen_test/settings/width/overflow_box.frame +1 -1
  239. data/screen_test/settings/width/overflow_box.rb +1 -1
  240. data/screen_test/settings/width/overflow_box_l2r.frame +1 -1
  241. data/screen_test/settings/width/overflow_box_l2r.rb +1 -1
  242. data/screen_test/settings/width/overflow_box_t2b.frame +1 -1
  243. data/screen_test/settings/width/overflow_box_t2b.rb +1 -1
  244. data/screen_test/settings/width/overflow_grid.frame +1 -1
  245. data/screen_test/settings/width/overflow_grid.rb +1 -1
  246. data/tools/whirled_peas/tools/screen_tester.rb +131 -65
  247. metadata +86 -25
  248. data/lib/whirled_peas/frame.rb +0 -6
  249. data/lib/whirled_peas/frame/consumer.rb +0 -30
  250. data/lib/whirled_peas/frame/debug_consumer.rb +0 -30
  251. data/lib/whirled_peas/frame/event_loop.rb +0 -90
  252. data/lib/whirled_peas/frame/producer.rb +0 -67
  253. data/lib/whirled_peas/graphics/screen.rb +0 -70
  254. data/lib/whirled_peas/graphics/text_dimensions.rb +0 -15
  255. data/screen_test/settings/position/box_left.frame +0 -1
  256. data/screen_test/settings/position/box_left_negative.frame +0 -1
  257. data/screen_test/settings/position/box_top.frame +0 -1
  258. data/screen_test/settings/position/box_top_negative.frame +0 -1
  259. data/screen_test/settings/position/grid_left.frame +0 -1
  260. data/screen_test/settings/position/grid_left_negative.frame +0 -1
  261. data/screen_test/settings/position/grid_top.frame +0 -1
  262. 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: 55ddf23151c866304cbe5213073c9ac9bd3c7b17139737acf1fe2f6678e6248f
4
- data.tar.gz: 31d26322b45af3d06c2f64c019fde32cebfe87638852c87857fa0113dc3bdc11
3
+ metadata.gz: 7f73ce3a27741b9c790785fe5aad7179c6db66e045ca1c2e43af33887c1fd4d9
4
+ data.tar.gz: bd19233e2d81a2d4e985bc4c8b0ec3ec07b8fe4691f0c70c5a2374add780bc9b
5
5
  SHA512:
6
- metadata.gz: 7be414e153881ff228f8780e11887be61844d1f719c1b19d50888cf7c2caf3d2171dd992c6694604672209f5e7457b35eebba7498dd60bb1d21e717c467f0a6c
7
- data.tar.gz: d27958378cfd0fe6728ef547559f07258ecafb2481df0d1994d3cf13802ae14ad414c212d2186f8e36ecb00be608d8abc3c6ccb918109a0114cc9585ed431735
6
+ metadata.gz: 9c2a41a72c30eb2c96161c23bb4f47a37dd9052ca1206cdec2d714d3266b0a6e3eb58bc8dab0dea0517eaf1fe7c5743323a8a7579319e81fdce80b9d65992504
7
+ data.tar.gz: 1b120aa9b5327880dcdcffbb37cfb77b63a06be55089f77efe7c4da104ce36e65893412178b5efcc31d6f7a3b9aed8353bbe076ea0131f52a142910d251bc61f
data/.gitignore CHANGED
@@ -11,4 +11,5 @@ Gemfile.lock
11
11
 
12
12
  # rspec failure tracking
13
13
  .rspec_status
14
+ *.wpz
14
15
 
@@ -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 visual 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.
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 driver (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 driver into terminal graphics
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 Driver
64
+ class Application
66
65
  def start(producer)
67
- producer.send_frame('starting', args: { name: 'World' })
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.driver = Driver.new
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 start visualize.rb
80
+ $ whirled_peas play visualize.rb
82
81
  ```
83
82
 
84
- The optional loading screen can be configured like
83
+ ### Application
85
84
 
86
- ```ruby
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
- WhirledPeas.configure do |config|
101
- # ...
102
- config.loading_template_factory = LoadingTemplateFactory.new
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
- ### Driver
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
- # Start the application and pass frame events to the producer to be rendered by the UI
100
+ # Add a frame to be displayed
112
101
  #
113
- # @param producer [Producer] frame producer that sends events to the UI
114
- def start(producer)
115
- # application code here
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
- The producer provides a single method
127
+ A frameset instance provides one method
120
128
 
121
129
  ```ruby
122
- # Send frame events to the UI
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 template factory will be provided this name
125
- # @param duration [Number] time in seconds this frame should be displayed for (defaults to 1 frame)
126
- # @param args [Hash<Symbol, Object>] key value pairs to send as arguments to the template factory
127
- def send_frame(name, duration:, args:)
128
- # implementation
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 Driver
148
+ class Application
140
149
  def start(producer)
141
150
  numbers = File.readlines('/path/to/numbers.txt').map(&:to_i)
142
- producer.send_frame('load-numbers', duration: 3, args: { numbers: numbers })
151
+ producer.add_frame('load-numbers', duration: 3, args: { numbers: numbers })
143
152
  numbers.sort!
144
- producer.send_frame('sort-numbers', duration: 3, args: { numbers: numbers })
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.send_frame('found-pair', duration: 5, args: { low: low, high: high, sum: sum })
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.send_frame('too-low', args: { low: low, high: high, sum: sum })
162
+ producer.add_frame('too-low', args: { low: low, high: high, sum: sum })
154
163
  low += 1
155
164
  else
156
- producer.send_frame('too-high', args: { low: low, high: high, sum: sum })
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.send_frame('no-solution', duration: 5)
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 driver, 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 driver. 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.
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
- The available settigs are
246
-
247
- | Setting | Description | Default | Availability | Inherited |
248
- | ------------ | -------------------------------------------------------------------------------- | ---------- | --------------------- | -------------------- |
249
- | `align` | Justifies the content in the horizontal direction | `:left` | `Box`, `Grid` | No |
250
- | `bg_color` | Background color (see [Colors](#colors)) | | `Box`, `Grid`, `Text` | Yes |
251
- | `bold` | `true` makes the font bold | `false` | `Box`, `Grid`, `Text` | Yes |
252
- | `border` | Set the border for the lements | none | `Box`, `Grid`, | Only style and color |
253
- | `color` | Foreground text color (see [Colors](#colors)) | | `Box`, `Grid`, `Text` | Yes |
254
- | `flow` | Flow to display child elements (see [Display Flow](#display-flow)) | `:l2r` | `Box`, `Grid` | No |
255
- | `height` | Override the calculated height of an element's content area | | `Box`, `Grid` | No |
256
- | `margin` | Set the (left, top, right, bottom) margin of the element | `0` | `Box`, `Grid` | No |
257
- | `num_cols` | Number of columns in the grid (must be set!) | | `Grid` | No |
258
- | `padding` | Set the (left, top, right, bottom) padding of the element | `0` | `Box`, `Grid` | No |
259
- | `position` | Set the (left, top) position of the element relative to parent content area | `0` | `Box`, `Grid` | No |
260
- | `scrollbar` | Display a scroll bar for vertical or horizontal scrolling | | `Box` | No |
261
- | `sizing` | Sizing model (`:content` or `:border`) used in conjunction with `width`/`hieght` | `:content` | `Box` | No |
262
- | `title_font` | Font used for "large" text (see [Large Text](#large-text), ignores `underline`) | | `Text` | No |
263
- | `underline` | `true` underlines the font | `false` | `Box`, `Grid`, `Text` | Yes |
264
- | `width` | Override the calculated width of an element's content area | | `Box`, `Grid` | No |
265
- | `valign` | Justifies the content in the vertical direction | `:top` | `Box`, `Grid` | No |
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
- ##### Position
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
- Position settings dictate the relative position from where the painter would have preferred to place the container. Negative numbers move the container left/up and positive numbers move it right/down. To set these values, use
536
+ To set these values, use
456
537
 
457
- - `set_position(left:, top:)`
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
- ### Example
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
- ### Debugging
1094
+ ### Full usage
1095
+
1096
+ ```
1097
+ Usage: whirled_peas <command> [command options]
1098
+
1099
+ Available commands:
750
1100
 
751
- The `whirled_peas` executable provides some commands that are helpful for debugging.
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
- #### list_frames
1111
+ #### `debug`
754
1112
 
755
- List the frames sent by the driver
1113
+ Print the template tree for specified frame.
756
1114
 
757
1115
  ```
758
- $ whirled_peas <config file> list_frames
759
- Frame 'start' displayed for 5 second(s)
760
- Frame 'move' displayed for 1 frame ({:direction=>'N'})
761
- ...
762
- EOF frame detected
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
- #### play_frame
1133
+ #### `fonts`
766
1134
 
767
- Displays a single frame for several seconds
1135
+ List all installed title fonts with sample text.
768
1136
 
769
1137
  ```
770
- $ whirled_peas <config file> play_frame move '{"direction":"N"}'
1138
+ # Usage: whirled_peas fonts
771
1139
  ```
772
1140
 
773
- Adding the `--template` flag will result in printing out debug information for the template, e.g.
1141
+ #### `frames`
1142
+
1143
+ Print out list of frames generated by application.
774
1144
 
775
1145
  ```
776
- $ whirled_peas <config file> play_frame move '{"direction":"N"}' --template
777
- + TEMPLATE [WhirledPeas::Graphics::BoxPainter]
778
- - Settings
779
- WhirledPeas::Settings::BoxSettings
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
- Note: the `list_frames` command will print out frame names and arguments formatted for this command
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
- #### loading
1177
+ #### `record`
789
1178
 
790
- Displays the configured loading screen for several seconds
1179
+ Record animation to a file
791
1180
 
792
1181
  ```
793
- $ whirled_peas <config file> loading
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
- Adding the `--template` flag will result in just printing out the loading template's debug information, e.g.
1187
+ #### `still`
1188
+
1189
+ Show the specified still frame
797
1190
 
798
1191
  ```
799
- $ whirled_peas <config file> loading --template
800
- + TEMPLATE [WhirledPeas::Graphics::BoxPainter]
801
- - Settings
802
- WhirledPeas::Settings::BoxSettings
803
- <default>
804
- - Children
805
- + TitleContainer [WhirledPeas::Graphics::BoxPainter]
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/rendered`. 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.
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
- The following rake tasks are provided to interact with the screen tests
1222
+ ```
1223
+
1224
+ Usage: screen_test [file] [options]
1225
+
1226
+ If not file or options are provide, all tests are run
822
1227
 
823
- - `screen_test` runs all screen tests in the `screen_test/rendered` directory
824
- - `screen_test:debug[path/to/file.rb]` render the screen without printing it, this allows for debug print statments in the code to appear in the terminal
825
- - `screen_test:template[path/to/file.rb]` print the rendered template debug tree
826
- - `screen_test:run[path/to/file.rb]` runs a single screen test
827
- - `screen_test:save[path/to/file.rb]` saves the output generated by the template in the `.frame` file, overwriting any existing file
828
- - `screen_test:view[path/to/file.rb]` views the output generated by the template
829
- - `screen_test:update_all[path/to/file.rb]` interactively step through each pending or failed screen test to compare/set the expected output
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/[USERNAME]/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/[USERNAME]/whirled_peas/blob/master/CODE_OF_CONDUCT.md).
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/[USERNAME]/whirled_peas/blob/master/CODE_OF_CONDUCT.md).
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).