ratatui_ruby 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (350) hide show
  1. checksums.yaml +4 -4
  2. data/.builds/ruby-3.2.yml +14 -12
  3. data/.builds/ruby-3.3.yml +14 -12
  4. data/.builds/ruby-3.4.yml +14 -12
  5. data/.builds/ruby-4.0.0.yml +14 -12
  6. data/AGENTS.md +89 -132
  7. data/CHANGELOG.md +223 -1
  8. data/README.md +23 -16
  9. data/REUSE.toml +20 -0
  10. data/doc/application_architecture.md +176 -0
  11. data/doc/application_testing.md +17 -10
  12. data/doc/contributors/design/ruby_frontend.md +11 -7
  13. data/doc/contributors/developing_examples.md +261 -0
  14. data/doc/contributors/documentation_style.md +104 -0
  15. data/doc/contributors/dwim_dx.md +366 -0
  16. data/doc/contributors/index.md +2 -0
  17. data/doc/custom.css +14 -0
  18. data/doc/event_handling.md +125 -0
  19. data/doc/images/app_all_events.png +0 -0
  20. data/doc/images/app_analytics.png +0 -0
  21. data/doc/images/app_color_picker.png +0 -0
  22. data/doc/images/app_custom_widget.png +0 -0
  23. data/doc/images/app_login_form.png +0 -0
  24. data/doc/images/app_map_demo.png +0 -0
  25. data/doc/images/app_mouse_events.png +0 -0
  26. data/doc/images/app_table_select.png +0 -0
  27. data/doc/images/verify_quickstart_dsl.png +0 -0
  28. data/doc/images/verify_quickstart_layout.png +0 -0
  29. data/doc/images/verify_quickstart_lifecycle.png +0 -0
  30. data/doc/images/verify_readme_usage.png +0 -0
  31. data/doc/images/widget_barchart_demo.png +0 -0
  32. data/doc/images/widget_block_padding.png +0 -0
  33. data/doc/images/widget_block_titles.png +0 -0
  34. data/doc/images/widget_box_demo.png +0 -0
  35. data/doc/images/widget_calendar_demo.png +0 -0
  36. data/doc/images/widget_cell_demo.png +0 -0
  37. data/doc/images/widget_chart_demo.png +0 -0
  38. data/doc/images/widget_gauge_demo.png +0 -0
  39. data/doc/images/widget_layout_split.png +0 -0
  40. data/doc/images/widget_line_gauge_demo.png +0 -0
  41. data/doc/images/widget_list_demo.png +0 -0
  42. data/doc/images/widget_list_styles.png +0 -0
  43. data/doc/images/widget_popup_demo.png +0 -0
  44. data/doc/images/widget_ratatui_logo_demo.png +0 -0
  45. data/doc/images/widget_ratatui_mascot_demo.png +0 -0
  46. data/doc/images/widget_rect.png +0 -0
  47. data/doc/images/widget_render.png +0 -0
  48. data/doc/images/widget_rich_text.png +0 -0
  49. data/doc/images/widget_scroll_text.png +0 -0
  50. data/doc/images/widget_scrollbar_demo.png +0 -0
  51. data/doc/images/widget_sparkline_demo.png +0 -0
  52. data/doc/images/widget_style_colors.png +0 -0
  53. data/doc/images/widget_table_flex.png +0 -0
  54. data/doc/images/widget_tabs_demo.png +0 -0
  55. data/doc/index.md +1 -0
  56. data/doc/interactive_design.md +116 -0
  57. data/doc/quickstart.md +186 -84
  58. data/examples/app_all_events/README.md +81 -0
  59. data/examples/app_all_events/app.rb +93 -0
  60. data/examples/app_all_events/model/event_color_cycle.rb +41 -0
  61. data/examples/app_all_events/model/event_entry.rb +75 -0
  62. data/examples/app_all_events/model/events.rb +180 -0
  63. data/examples/app_all_events/model/highlight.rb +57 -0
  64. data/examples/app_all_events/model/timestamp.rb +54 -0
  65. data/examples/app_all_events/test/snapshots/after_focus_lost.txt +24 -0
  66. data/examples/app_all_events/test/snapshots/after_focus_regained.txt +24 -0
  67. data/examples/app_all_events/test/snapshots/after_horizontal_resize.txt +24 -0
  68. data/examples/app_all_events/test/snapshots/after_key_a.txt +24 -0
  69. data/examples/app_all_events/test/snapshots/after_key_ctrl_x.txt +24 -0
  70. data/examples/app_all_events/test/snapshots/after_mouse_click.txt +24 -0
  71. data/examples/app_all_events/test/snapshots/after_mouse_drag.txt +24 -0
  72. data/examples/app_all_events/test/snapshots/after_multiple_events.txt +24 -0
  73. data/examples/app_all_events/test/snapshots/after_paste.txt +24 -0
  74. data/examples/app_all_events/test/snapshots/after_resize.txt +24 -0
  75. data/examples/app_all_events/test/snapshots/after_right_click.txt +24 -0
  76. data/examples/app_all_events/test/snapshots/after_vertical_resize.txt +24 -0
  77. data/examples/app_all_events/test/snapshots/initial_state.txt +24 -0
  78. data/examples/app_all_events/view/app_view.rb +78 -0
  79. data/examples/app_all_events/view/controls_view.rb +50 -0
  80. data/examples/app_all_events/view/counts_view.rb +55 -0
  81. data/examples/app_all_events/view/live_view.rb +69 -0
  82. data/examples/app_all_events/view/log_view.rb +60 -0
  83. data/{lib/ratatui_ruby/output.rb → examples/app_all_events/view.rb} +1 -1
  84. data/examples/app_all_events/view_state.rb +42 -0
  85. data/examples/app_color_picker/README.md +94 -0
  86. data/examples/app_color_picker/app.rb +112 -0
  87. data/examples/app_color_picker/clipboard.rb +84 -0
  88. data/examples/app_color_picker/color.rb +191 -0
  89. data/examples/app_color_picker/copy_dialog.rb +170 -0
  90. data/examples/app_color_picker/harmony.rb +56 -0
  91. data/examples/app_color_picker/input.rb +142 -0
  92. data/examples/app_color_picker/palette.rb +80 -0
  93. data/examples/app_color_picker/scene.rb +201 -0
  94. data/examples/app_login_form/app.rb +108 -0
  95. data/examples/app_map_demo/app.rb +93 -0
  96. data/examples/app_table_select/app.rb +201 -0
  97. data/examples/verify_quickstart_dsl/app.rb +45 -0
  98. data/examples/verify_quickstart_layout/app.rb +69 -0
  99. data/examples/verify_quickstart_lifecycle/app.rb +48 -0
  100. data/examples/verify_readme_usage/app.rb +34 -0
  101. data/examples/widget_barchart_demo/app.rb +238 -0
  102. data/examples/widget_block_padding/app.rb +67 -0
  103. data/examples/widget_block_titles/app.rb +69 -0
  104. data/examples/widget_box_demo/app.rb +250 -0
  105. data/examples/widget_calendar_demo/app.rb +109 -0
  106. data/examples/widget_cell_demo/app.rb +104 -0
  107. data/examples/widget_chart_demo/app.rb +213 -0
  108. data/examples/widget_gauge_demo/app.rb +212 -0
  109. data/examples/widget_layout_split/app.rb +246 -0
  110. data/examples/widget_line_gauge_demo/app.rb +217 -0
  111. data/examples/widget_list_demo/app.rb +382 -0
  112. data/examples/widget_list_styles/app.rb +141 -0
  113. data/examples/widget_popup_demo/app.rb +104 -0
  114. data/examples/widget_ratatui_logo_demo/app.rb +103 -0
  115. data/examples/widget_ratatui_mascot_demo/app.rb +93 -0
  116. data/examples/widget_rect/app.rb +205 -0
  117. data/examples/widget_render/app.rb +184 -0
  118. data/examples/widget_rich_text/app.rb +137 -0
  119. data/examples/widget_scroll_text/app.rb +108 -0
  120. data/examples/widget_scrollbar_demo/app.rb +153 -0
  121. data/examples/widget_sparkline_demo/app.rb +274 -0
  122. data/examples/widget_style_colors/app.rb +102 -0
  123. data/examples/widget_table_flex/app.rb +95 -0
  124. data/examples/widget_tabs_demo/app.rb +167 -0
  125. data/ext/ratatui_ruby/Cargo.lock +889 -115
  126. data/ext/ratatui_ruby/Cargo.toml +4 -3
  127. data/ext/ratatui_ruby/clippy.toml +7 -0
  128. data/ext/ratatui_ruby/extconf.rb +7 -0
  129. data/ext/ratatui_ruby/src/events.rs +293 -219
  130. data/ext/ratatui_ruby/src/frame.rs +115 -0
  131. data/ext/ratatui_ruby/src/lib.rs +105 -24
  132. data/ext/ratatui_ruby/src/rendering.rs +94 -10
  133. data/ext/ratatui_ruby/src/style.rs +357 -93
  134. data/ext/ratatui_ruby/src/terminal.rs +121 -31
  135. data/ext/ratatui_ruby/src/text.rs +178 -0
  136. data/ext/ratatui_ruby/src/widgets/barchart.rs +99 -24
  137. data/ext/ratatui_ruby/src/widgets/block.rs +32 -3
  138. data/ext/ratatui_ruby/src/widgets/calendar.rs +45 -44
  139. data/ext/ratatui_ruby/src/widgets/canvas.rs +44 -9
  140. data/ext/ratatui_ruby/src/widgets/chart.rs +79 -27
  141. data/ext/ratatui_ruby/src/widgets/clear.rs +3 -1
  142. data/ext/ratatui_ruby/src/widgets/gauge.rs +11 -4
  143. data/ext/ratatui_ruby/src/widgets/layout.rs +223 -15
  144. data/ext/ratatui_ruby/src/widgets/line_gauge.rs +92 -0
  145. data/ext/ratatui_ruby/src/widgets/list.rs +114 -11
  146. data/ext/ratatui_ruby/src/widgets/mod.rs +3 -0
  147. data/ext/ratatui_ruby/src/widgets/overlay.rs +4 -2
  148. data/ext/ratatui_ruby/src/widgets/paragraph.rs +35 -13
  149. data/ext/ratatui_ruby/src/widgets/ratatui_logo.rs +40 -0
  150. data/ext/ratatui_ruby/src/widgets/ratatui_mascot.rs +51 -0
  151. data/ext/ratatui_ruby/src/widgets/scrollbar.rs +61 -7
  152. data/ext/ratatui_ruby/src/widgets/sparkline.rs +73 -6
  153. data/ext/ratatui_ruby/src/widgets/table.rs +177 -64
  154. data/ext/ratatui_ruby/src/widgets/tabs.rs +105 -5
  155. data/lib/ratatui_ruby/cell.rb +166 -0
  156. data/lib/ratatui_ruby/event/focus_gained.rb +49 -0
  157. data/lib/ratatui_ruby/event/focus_lost.rb +50 -0
  158. data/lib/ratatui_ruby/event/key.rb +211 -0
  159. data/lib/ratatui_ruby/event/mouse.rb +124 -0
  160. data/lib/ratatui_ruby/event/none.rb +43 -0
  161. data/lib/ratatui_ruby/event/paste.rb +71 -0
  162. data/lib/ratatui_ruby/event/resize.rb +80 -0
  163. data/lib/ratatui_ruby/event.rb +131 -0
  164. data/lib/ratatui_ruby/frame.rb +87 -0
  165. data/lib/ratatui_ruby/schema/bar_chart/bar.rb +45 -0
  166. data/lib/ratatui_ruby/schema/bar_chart/bar_group.rb +23 -0
  167. data/lib/ratatui_ruby/schema/bar_chart.rb +226 -17
  168. data/lib/ratatui_ruby/schema/block.rb +178 -11
  169. data/lib/ratatui_ruby/schema/calendar.rb +70 -14
  170. data/lib/ratatui_ruby/schema/canvas.rb +213 -46
  171. data/lib/ratatui_ruby/schema/center.rb +46 -8
  172. data/lib/ratatui_ruby/schema/chart.rb +134 -32
  173. data/lib/ratatui_ruby/schema/clear.rb +22 -53
  174. data/lib/ratatui_ruby/schema/constraint.rb +72 -12
  175. data/lib/ratatui_ruby/schema/cursor.rb +23 -5
  176. data/lib/ratatui_ruby/schema/draw.rb +53 -0
  177. data/lib/ratatui_ruby/schema/gauge.rb +56 -12
  178. data/lib/ratatui_ruby/schema/layout.rb +91 -9
  179. data/lib/ratatui_ruby/schema/line_gauge.rb +78 -0
  180. data/lib/ratatui_ruby/schema/list.rb +92 -16
  181. data/lib/ratatui_ruby/schema/overlay.rb +29 -3
  182. data/lib/ratatui_ruby/schema/paragraph.rb +82 -25
  183. data/lib/ratatui_ruby/schema/ratatui_logo.rb +29 -0
  184. data/lib/ratatui_ruby/schema/ratatui_mascot.rb +34 -0
  185. data/lib/ratatui_ruby/schema/rect.rb +59 -10
  186. data/lib/ratatui_ruby/schema/scrollbar.rb +127 -19
  187. data/lib/ratatui_ruby/schema/shape/label.rb +66 -0
  188. data/lib/ratatui_ruby/schema/sparkline.rb +120 -12
  189. data/lib/ratatui_ruby/schema/style.rb +39 -11
  190. data/lib/ratatui_ruby/schema/table.rb +109 -18
  191. data/lib/ratatui_ruby/schema/tabs.rb +71 -10
  192. data/lib/ratatui_ruby/schema/text.rb +90 -0
  193. data/lib/ratatui_ruby/session/autodoc.rb +417 -0
  194. data/lib/ratatui_ruby/session.rb +163 -0
  195. data/lib/ratatui_ruby/test_helper.rb +322 -13
  196. data/lib/ratatui_ruby/version.rb +1 -1
  197. data/lib/ratatui_ruby.rb +184 -38
  198. data/sig/examples/app_all_events/app.rbs +11 -0
  199. data/sig/examples/app_all_events/model/event_entry.rbs +16 -0
  200. data/sig/examples/app_all_events/model/events.rbs +15 -0
  201. data/sig/examples/app_all_events/model/timestamp.rbs +11 -0
  202. data/sig/examples/app_all_events/view/app_view.rbs +8 -0
  203. data/sig/examples/app_all_events/view/controls_view.rbs +6 -0
  204. data/sig/examples/app_all_events/view/counts_view.rbs +6 -0
  205. data/sig/examples/app_all_events/view/live_view.rbs +6 -0
  206. data/sig/examples/app_all_events/view/log_view.rbs +6 -0
  207. data/sig/examples/app_all_events/view.rbs +8 -0
  208. data/sig/examples/app_all_events/view_state.rbs +15 -0
  209. data/sig/examples/app_color_picker/app.rbs +12 -0
  210. data/sig/examples/app_login_form/app.rbs +11 -0
  211. data/sig/examples/app_map_demo/app.rbs +11 -0
  212. data/sig/examples/app_table_select/app.rbs +11 -0
  213. data/sig/examples/verify_quickstart_dsl/app.rbs +11 -0
  214. data/sig/examples/verify_quickstart_lifecycle/app.rbs +11 -0
  215. data/sig/examples/verify_readme_usage/app.rbs +11 -0
  216. data/sig/examples/widget_block_padding/app.rbs +11 -0
  217. data/sig/examples/widget_block_titles/app.rbs +11 -0
  218. data/sig/examples/widget_box_demo/app.rbs +11 -0
  219. data/sig/examples/widget_calendar_demo/app.rbs +11 -0
  220. data/sig/examples/widget_cell_demo/app.rbs +11 -0
  221. data/sig/examples/widget_chart_demo/app.rbs +11 -0
  222. data/sig/examples/widget_gauge_demo/app.rbs +11 -0
  223. data/sig/examples/widget_layout_split/app.rbs +10 -0
  224. data/sig/examples/widget_line_gauge_demo/app.rbs +11 -0
  225. data/sig/examples/widget_list_demo/app.rbs +12 -0
  226. data/sig/examples/widget_list_styles/app.rbs +11 -0
  227. data/sig/examples/widget_popup_demo/app.rbs +11 -0
  228. data/sig/examples/widget_ratatui_logo_demo/app.rbs +11 -0
  229. data/sig/examples/widget_ratatui_mascot_demo/app.rbs +11 -0
  230. data/sig/examples/widget_rect/app.rbs +12 -0
  231. data/sig/examples/widget_render/app.rbs +10 -0
  232. data/sig/examples/widget_rich_text/app.rbs +11 -0
  233. data/sig/examples/widget_scroll_text/app.rbs +11 -0
  234. data/sig/examples/widget_scrollbar_demo/app.rbs +11 -0
  235. data/sig/examples/widget_sparkline_demo/app.rbs +10 -0
  236. data/sig/examples/widget_style_colors/app.rbs +14 -0
  237. data/sig/examples/widget_table_flex/app.rbs +11 -0
  238. data/sig/ratatui_ruby/event.rbs +69 -0
  239. data/sig/ratatui_ruby/frame.rbs +9 -0
  240. data/sig/ratatui_ruby/ratatui_ruby.rbs +5 -3
  241. data/sig/ratatui_ruby/schema/bar_chart/bar.rbs +16 -0
  242. data/sig/ratatui_ruby/schema/bar_chart/bar_group.rbs +13 -0
  243. data/sig/ratatui_ruby/schema/bar_chart.rbs +20 -2
  244. data/sig/ratatui_ruby/schema/block.rbs +5 -4
  245. data/sig/ratatui_ruby/schema/calendar.rbs +6 -2
  246. data/sig/ratatui_ruby/schema/canvas.rbs +52 -39
  247. data/sig/ratatui_ruby/schema/center.rbs +3 -3
  248. data/sig/ratatui_ruby/schema/chart.rbs +8 -5
  249. data/sig/ratatui_ruby/schema/constraint.rbs +8 -5
  250. data/sig/ratatui_ruby/schema/cursor.rbs +1 -1
  251. data/sig/ratatui_ruby/schema/draw.rbs +27 -0
  252. data/sig/ratatui_ruby/schema/gauge.rbs +4 -2
  253. data/sig/ratatui_ruby/schema/layout.rbs +11 -1
  254. data/sig/ratatui_ruby/schema/line_gauge.rbs +16 -0
  255. data/sig/ratatui_ruby/schema/list.rbs +5 -1
  256. data/sig/ratatui_ruby/schema/paragraph.rbs +4 -1
  257. data/sig/ratatui_ruby/schema/ratatui_logo.rbs +8 -0
  258. data/sig/ratatui_ruby/{buffer.rbs → schema/ratatui_mascot.rbs} +4 -3
  259. data/sig/ratatui_ruby/schema/rect.rbs +2 -1
  260. data/sig/ratatui_ruby/schema/scrollbar.rbs +18 -2
  261. data/sig/ratatui_ruby/schema/sparkline.rbs +6 -2
  262. data/sig/ratatui_ruby/schema/table.rbs +8 -1
  263. data/sig/ratatui_ruby/schema/tabs.rbs +5 -1
  264. data/sig/ratatui_ruby/schema/text.rbs +22 -0
  265. data/sig/ratatui_ruby/session.rbs +94 -0
  266. data/tasks/autodoc/inventory.rb +61 -0
  267. data/tasks/autodoc/member.rb +56 -0
  268. data/tasks/autodoc/name.rb +19 -0
  269. data/tasks/autodoc/notice.rb +26 -0
  270. data/tasks/autodoc/rbs.rb +38 -0
  271. data/tasks/autodoc/rdoc.rb +45 -0
  272. data/tasks/autodoc.rake +47 -0
  273. data/tasks/bump/history.rb +2 -2
  274. data/tasks/doc.rake +600 -6
  275. data/tasks/example_viewer.html.erb +172 -0
  276. data/tasks/lint.rake +8 -4
  277. data/tasks/resources/build.yml.erb +13 -11
  278. data/tasks/resources/index.html.erb +6 -0
  279. data/tasks/sourcehut.rake +4 -4
  280. data/tasks/terminal_preview/app_screenshot.rb +33 -0
  281. data/tasks/terminal_preview/crash_report.rb +52 -0
  282. data/tasks/terminal_preview/example_app.rb +25 -0
  283. data/tasks/terminal_preview/launcher_script.rb +46 -0
  284. data/tasks/terminal_preview/preview_collection.rb +58 -0
  285. data/tasks/terminal_preview/preview_timing.rb +22 -0
  286. data/tasks/terminal_preview/safety_confirmation.rb +56 -0
  287. data/tasks/terminal_preview/saved_screenshot.rb +53 -0
  288. data/tasks/terminal_preview/system_appearance.rb +11 -0
  289. data/tasks/terminal_preview/terminal_window.rb +136 -0
  290. data/tasks/terminal_preview/window_id.rb +14 -0
  291. data/tasks/terminal_preview.rake +28 -0
  292. data/tasks/test.rake +2 -2
  293. data/tasks/website/index_page.rb +3 -3
  294. data/tasks/website/version.rb +10 -10
  295. data/tasks/website/version_menu.rb +10 -12
  296. data/tasks/website/versioned_documentation.rb +49 -17
  297. data/tasks/website/website.rb +6 -8
  298. data/tasks/website.rake +4 -4
  299. metadata +206 -54
  300. data/LICENSES/BSD-2-Clause.txt +0 -9
  301. data/doc/images/examples-analytics.rb.png +0 -0
  302. data/doc/images/examples-box_demo.rb.png +0 -0
  303. data/doc/images/examples-calendar_demo.rb.png +0 -0
  304. data/doc/images/examples-chart_demo.rb.png +0 -0
  305. data/doc/images/examples-custom_widget.rb.png +0 -0
  306. data/doc/images/examples-dashboard.rb.png +0 -0
  307. data/doc/images/examples-list_styles.rb.png +0 -0
  308. data/doc/images/examples-login_form.rb.png +0 -0
  309. data/doc/images/examples-map_demo.rb.png +0 -0
  310. data/doc/images/examples-mouse_events.rb.png +0 -0
  311. data/doc/images/examples-popup_demo.rb.gif +0 -0
  312. data/doc/images/examples-quickstart_lifecycle.rb.png +0 -0
  313. data/doc/images/examples-scroll_text.rb.png +0 -0
  314. data/doc/images/examples-scrollbar_demo.rb.png +0 -0
  315. data/doc/images/examples-stock_ticker.rb.png +0 -0
  316. data/doc/images/examples-system_monitor.rb.png +0 -0
  317. data/doc/images/examples-table_select.rb.png +0 -0
  318. data/examples/analytics.rb +0 -88
  319. data/examples/box_demo.rb +0 -71
  320. data/examples/calendar_demo.rb +0 -55
  321. data/examples/chart_demo.rb +0 -84
  322. data/examples/custom_widget.rb +0 -43
  323. data/examples/dashboard.rb +0 -72
  324. data/examples/list_styles.rb +0 -66
  325. data/examples/login_form.rb +0 -115
  326. data/examples/map_demo.rb +0 -58
  327. data/examples/mouse_events.rb +0 -95
  328. data/examples/popup_demo.rb +0 -105
  329. data/examples/quickstart_dsl.rb +0 -30
  330. data/examples/quickstart_lifecycle.rb +0 -40
  331. data/examples/readme_usage.rb +0 -21
  332. data/examples/scroll_text.rb +0 -74
  333. data/examples/scrollbar_demo.rb +0 -75
  334. data/examples/stock_ticker.rb +0 -93
  335. data/examples/system_monitor.rb +0 -94
  336. data/examples/table_select.rb +0 -70
  337. data/examples/test_analytics.rb +0 -65
  338. data/examples/test_box_demo.rb +0 -38
  339. data/examples/test_calendar_demo.rb +0 -66
  340. data/examples/test_dashboard.rb +0 -38
  341. data/examples/test_list_styles.rb +0 -61
  342. data/examples/test_login_form.rb +0 -63
  343. data/examples/test_map_demo.rb +0 -100
  344. data/examples/test_popup_demo.rb +0 -62
  345. data/examples/test_scroll_text.rb +0 -130
  346. data/examples/test_stock_ticker.rb +0 -39
  347. data/examples/test_system_monitor.rb +0 -40
  348. data/examples/test_table_select.rb +0 -37
  349. data/ext/ratatui_ruby/src/buffer.rs +0 -54
  350. data/lib/ratatui_ruby/dsl.rb +0 -64
@@ -4,59 +4,226 @@
4
4
  # SPDX-License-Identifier: AGPL-3.0-or-later
5
5
 
6
6
  module RatatuiRuby
7
- # A point in the canvas coordinate system.
8
- # @param x [Float] The x-coordinate.
9
- # @param y [Float] The y-coordinate.
10
- class Point < Data.define(:x, :y)
11
- end
7
+ # Namespace for canvas shape primitives (Point, Line, Rectangle, Circle, Map, Label).
8
+ # Distinct from text components and other Line usages.
9
+ module Shape
10
+ # A point in the canvas coordinate system.
11
+ #
12
+ # [x] The x-coordinate.
13
+ # [y] The y-coordinate.
14
+ class Point < Data.define(:x, :y)
15
+ ##
16
+ # :attr_reader: x
17
+ # X coordinate (Float, duck-typed via +to_f+).
12
18
 
13
- # A line shape on a canvas.
14
- # @param x1 [Float] The starting x-coordinate.
15
- # @param y1 [Float] The starting y-coordinate.
16
- # @param x2 [Float] The ending x-coordinate.
17
- # @param y2 [Float] The ending y-coordinate.
18
- # @param color [String, Symbol] The color of the line.
19
- class Line < Data.define(:x1, :y1, :x2, :y2, :color)
20
- end
19
+ ##
20
+ # :attr_reader: y
21
+ # Y coordinate (Float, duck-typed via +to_f+).
21
22
 
22
- # A rectangle shape on a canvas.
23
- # @param x [Float] The x-coordinate of the bottom-left corner.
24
- # @param y [Float] The y-coordinate of the bottom-left corner.
25
- # @param width [Float] The width of the rectangle.
26
- # @param height [Float] The height of the rectangle.
27
- # @param color [String, Symbol] The color of the rectangle.
28
- class Rectangle < Data.define(:x, :y, :width, :height, :color)
29
- end
23
+ # Creates a new Point.
24
+ #
25
+ # [x] X coordinate (Numeric).
26
+ # [y] Y coordinate (Numeric).
27
+ def initialize(x:, y:)
28
+ super(x: Float(x), y: Float(y))
29
+ end
30
+ end
30
31
 
31
- # A circle shape on a canvas.
32
- # @param x [Float] The x-coordinate of the center.
33
- # @param y [Float] The y-coordinate of the center.
34
- # @param radius [Float] The radius of the circle.
35
- # @param color [String, Symbol] The color of the circle.
36
- class Circle < Data.define(:x, :y, :radius, :color)
37
- end
32
+ # A line shape on a canvas.
33
+ #
34
+ # [x1] The starting x-coordinate.
35
+ # [y1] The starting y-coordinate.
36
+ # [x2] The ending x-coordinate.
37
+ # [y2] The ending y-coordinate.
38
+ # [color] The color of the line.
39
+ class Line < Data.define(:x1, :y1, :x2, :y2, :color)
40
+ ##
41
+ # :attr_reader: x1
42
+ # Start X (Float, duck-typed via +to_f+).
43
+
44
+ ##
45
+ # :attr_reader: y1
46
+ # Start Y (Float, duck-typed via +to_f+).
47
+
48
+ ##
49
+ # :attr_reader: x2
50
+ # End X (Float, duck-typed via +to_f+).
51
+
52
+ ##
53
+ # :attr_reader: y2
54
+ # End Y (Float, duck-typed via +to_f+).
55
+
56
+ ##
57
+ # :attr_reader: color
58
+ # Line color.
59
+
60
+ # Creates a new Line.
61
+ #
62
+ # [x1] Start X (Numeric).
63
+ # [y1] Start Y (Numeric).
64
+ # [x2] End X (Numeric).
65
+ # [y2] End Y (Numeric).
66
+ # [color] Line color (Symbol).
67
+ def initialize(x1:, y1:, x2:, y2:, color:)
68
+ super(x1: Float(x1), y1: Float(y1), x2: Float(x2), y2: Float(y2), color:)
69
+ end
70
+ end
71
+
72
+ # A rectangle shape on a canvas.
73
+ #
74
+ # [x] The x-coordinate of the bottom-left corner.
75
+ # [y] The y-coordinate of the bottom-left corner.
76
+ # [width] The width of the rectangle.
77
+ # [height] The height of the rectangle.
78
+ # [color] The color of the rectangle.
79
+ class Rectangle < Data.define(:x, :y, :width, :height, :color)
80
+ ##
81
+ # :attr_reader: x
82
+ # Bottom-left X (Float, duck-typed via +to_f+).
83
+
84
+ ##
85
+ # :attr_reader: y
86
+ # Bottom-left Y (Float, duck-typed via +to_f+).
87
+
88
+ ##
89
+ # :attr_reader: width
90
+ # Width (Float, duck-typed via +to_f+).
91
+
92
+ ##
93
+ # :attr_reader: height
94
+ # Height (Float, duck-typed via +to_f+).
95
+
96
+ ##
97
+ # :attr_reader: color
98
+ # Color.
38
99
 
39
- # A world map shape on a canvas.
40
- # @param color [String, Symbol] The color of the map.
41
- # @param resolution [Symbol] The resolution of the map (:low, :high).
42
- class Map < Data.define(:color, :resolution)
100
+ # Creates a new Rectangle.
101
+ #
102
+ # [x] Bottom-left X (Numeric).
103
+ # [y] Bottom-left Y (Numeric).
104
+ # [width] Width (Numeric).
105
+ # [height] Height (Numeric).
106
+ # [color] Color (Symbol).
107
+ def initialize(x:, y:, width:, height:, color:)
108
+ super(x: Float(x), y: Float(y), width: Float(width), height: Float(height), color:)
109
+ end
110
+ end
111
+
112
+ # A circle shape on a canvas.
113
+ #
114
+ # [x] The x-coordinate of the center.
115
+ # [y] The y-coordinate of the center.
116
+ # [radius] The radius of the circle.
117
+ # [color] The color of the circle.
118
+ class Circle < Data.define(:x, :y, :radius, :color)
119
+ ##
120
+ # :attr_reader: x
121
+ # Center X (Float, duck-typed via +to_f+).
122
+
123
+ ##
124
+ # :attr_reader: y
125
+ # Center Y (Float, duck-typed via +to_f+).
126
+
127
+ ##
128
+ # :attr_reader: radius
129
+ # Radius (Float, duck-typed via +to_f+).
130
+
131
+ ##
132
+ # :attr_reader: color
133
+ # Color.
134
+
135
+ # Creates a new Circle.
136
+ #
137
+ # [x] Center X (Numeric).
138
+ # [y] Center Y (Numeric).
139
+ # [radius] Radius (Numeric).
140
+ # [color] Color (Symbol).
141
+ def initialize(x:, y:, radius:, color:)
142
+ super(x: Float(x), y: Float(y), radius: Float(radius), color:)
143
+ end
144
+ end
145
+
146
+ # A world map shape on a canvas.
147
+ #
148
+ # [color] The color of the map.
149
+ # [resolution] The resolution of the map (<tt>:low</tt>, <tt>:high</tt>).
150
+ class Map < Data.define(:color, :resolution)
151
+ ##
152
+ # :attr_reader: color
153
+ # Map color.
154
+
155
+ ##
156
+ # :attr_reader: resolution
157
+ # Resolution (<tt>:low</tt> or <tt>:high</tt>).
158
+ end
43
159
  end
44
160
 
45
- # The Canvas Widget.
46
- # @param shapes [Array] Array of shape objects (Line, Rectangle, Circle, Map).
47
- # @param x_bounds [Array<Float>] [min, max] range for the x-axis.
48
- # @param y_bounds [Array<Float>] [min, max] range for the y-axis.
49
- # @param marker [Symbol] The marker to use for drawing (:braille, :dot, :block, :bar).
50
- # @param block [Block, nil] Optional Block widget to wrap the canvas.
51
- class Canvas < Data.define(:shapes, :x_bounds, :y_bounds, :marker, :block)
161
+ # Provides a drawing surface for custom shapes.
162
+ #
163
+ # Standard widgets cover standard cases. Sometimes you need to draw a map, a custom diagram, or a game.
164
+ # Character grids are too coarse for fine detail.
165
+ #
166
+ # This widget increases the resolution. It uses Braille patterns or block characters to create a "sub-pixel" drawing surface.
167
+ #
168
+ # Use it to implement free-form graphics, high-resolution plots, or geographic maps.
169
+ #
170
+ # === Examples
171
+ #
172
+ # Canvas.new(
173
+ # x_bounds: [-180, 180],
174
+ # y_bounds: [-90, 90],
175
+ # shapes: [
176
+ # Shape::Map.new(color: :green, resolution: :high),
177
+ # Shape::Circle.new(x: 0, y: 0, radius: 10, color: :red),
178
+ # Shape::Label.new(x: -122.4, y: 37.8, text: "San Francisco")
179
+ # ]
180
+ # )
181
+ class Canvas < Data.define(:shapes, :x_bounds, :y_bounds, :marker, :block, :background_color)
182
+ ##
183
+ # :attr_reader: shapes
184
+ # Array of shapes to render.
185
+ #
186
+ # Includes {Shape::Line}, {Shape::Circle}, {Shape::Map}, etc.
187
+
188
+ ##
189
+ # :attr_reader: x_bounds
190
+ # [min, max] range for the x-axis.
191
+
192
+ ##
193
+ # :attr_reader: y_bounds
194
+ # [min, max] range for the y-axis.
195
+
196
+ ##
197
+ # :attr_reader: marker
198
+ # The marker type used for drawing.
199
+ #
200
+ # <tt>:braille</tt> (high res), <tt>:half_block</tt>, <tt>:dot</tt>, <tt>:block</tt>, <tt>:bar</tt>.
201
+
202
+ ##
203
+ # :attr_reader: block
204
+ # Optional wrapping block.
205
+
206
+ ##
207
+ # :attr_reader: background_color
208
+ # The background color of the canvas.
209
+
52
210
  # Creates a new Canvas.
53
- # @param shapes [Array] Array of shape objects (Line, Rectangle, Circle, Map).
54
- # @param x_bounds [Array<Float>] [min, max] range for the x-axis.
55
- # @param y_bounds [Array<Float>] [min, max] range for the y-axis.
56
- # @param marker [Symbol] The marker to use for drawing (:braille, :dot, :block, :bar).
57
- # @param block [Block, nil] Optional Block widget to wrap the canvas.
58
- def initialize(shapes: [], x_bounds: [0.0, 100.0], y_bounds: [0.0, 100.0], marker: :braille, block: nil)
59
- super
211
+ #
212
+ # [shapes] Array of Shapes.
213
+ # [x_bounds] Array of [min, max] (Numeric, duck-typed via +to_f+).
214
+ # [y_bounds] Array of [min, max] (Numeric, duck-typed via +to_f+).
215
+ # [marker] Symbol (default: <tt>:braille</tt>).
216
+ # [block] Block (optional).
217
+ # [background_color] Color (optional).
218
+ def initialize(shapes: [], x_bounds: [0.0, 100.0], y_bounds: [0.0, 100.0], marker: :braille, block: nil, background_color: nil)
219
+ super(
220
+ shapes:,
221
+ x_bounds: [Float(x_bounds[0]), Float(x_bounds[1])],
222
+ y_bounds: [Float(y_bounds[0]), Float(y_bounds[1])],
223
+ marker:,
224
+ block:,
225
+ background_color:
226
+ )
60
227
  end
61
228
  end
62
229
  end
@@ -4,16 +4,54 @@
4
4
  # SPDX-License-Identifier: AGPL-3.0-or-later
5
5
 
6
6
  module RatatuiRuby
7
- # Centers a child widget within the current area.
7
+ # Centers content within available space.
8
8
  #
9
- # [child] the widget to center.
10
- # [width_percent] the width percentage of the centered area.
11
- # [height_percent] the height percentage of the centered area.
9
+ # Layouts often require alignment. Manually calculating offsets for centering is error-prone and brittle.
10
+ #
11
+ # This widget handles the math. It centers a child widget within the current area, resizing the child
12
+ # according to optional percentage modifiers.
13
+ #
14
+ # Use it to position modals, splash screens, or floating dialogue boxes.
15
+ #
16
+ # === Examples
17
+ #
18
+ # # Center a paragraph using 50% of width and height
19
+ # Center.new(
20
+ # child: Paragraph.new(text: "Hello"),
21
+ # width_percent: 50,
22
+ # height_percent: 50
23
+ # )
12
24
  class Center < Data.define(:child, :width_percent, :height_percent)
13
- # Creates a new Center.
25
+ ##
26
+ # :attr_reader: child
27
+ # The widget to be centered.
28
+
29
+ ##
30
+ # :attr_reader: width_percent
31
+ # Width of the centered area as a percentage (0-100).
32
+ #
33
+ # If 50, the child occupies half the available width.
34
+
35
+ ##
36
+ # :attr_reader: height_percent
37
+ # Height of the centered area as a percentage (0-100).
38
+ #
39
+ # If 50, the child occupies half the available height.
40
+
41
+ # Creates a new Center widget.
14
42
  #
15
- # [child] the widget to center.
16
- # [width_percent] the width percentage of the centered area.
17
- # [height_percent] the height percentage of the centered area.
43
+ # [child]
44
+ # Widget to render.
45
+ # [width_percent]
46
+ # Target width percentage (Integer, default: 100).
47
+ # [height_percent]
48
+ # Target height percentage (Integer, default: 100).
49
+ def initialize(child:, width_percent: 100, height_percent: 100)
50
+ super(
51
+ child:,
52
+ width_percent: Float(width_percent),
53
+ height_percent: Float(height_percent)
54
+ )
55
+ end
18
56
  end
19
57
  end
@@ -9,52 +9,148 @@ module RatatuiRuby
9
9
  # [bounds] Array<Float> [min, max]
10
10
  # [labels] Array<String>
11
11
  # [style] Style
12
- class Axis < Data.define(:title, :bounds, :labels, :style)
12
+ # [labels_alignment] Symbol (<tt>:left</tt>, <tt>:center</tt>, <tt>:right</tt>)
13
+ class Axis < Data.define(:title, :bounds, :labels, :style, :labels_alignment)
14
+ ##
15
+ # :attr_reader: title
16
+ # Label for the axis (String).
17
+
18
+ ##
19
+ # :attr_reader: bounds
20
+ # Range [min, max] (Array of Floats).
21
+
22
+ ##
23
+ # :attr_reader: labels
24
+ # Explicit labels for ticks (Array of Strings).
25
+
26
+ ##
27
+ # :attr_reader: style
28
+ # Style for axis lines/text.
29
+
30
+ ##
31
+ # :attr_reader: labels_alignment
32
+ # Alignment of axis labels (:left, :center, :right).
33
+
13
34
  # Creates a new Axis.
14
35
  #
15
- # [title] String
16
- # [bounds] Array<Float> [min, max]
17
- # [labels] Array<String>
18
- # [style] Style
19
- def initialize(title: "", bounds: [0.0, 10.0], labels: [], style: nil)
20
- super
36
+ # [title] String.
37
+ # [bounds] Array [min, max].
38
+ # [labels] Array of Strings.
39
+ # [style] Style.
40
+ # [labels_alignment] Symbol (:left, :center, :right).
41
+ def initialize(title: "", bounds: [0.0, 10.0], labels: [], style: nil, labels_alignment: nil)
42
+ super(
43
+ title:,
44
+ bounds: [Float(bounds[0]), Float(bounds[1])],
45
+ labels:,
46
+ style:,
47
+ labels_alignment:
48
+ )
21
49
  end
22
50
  end
23
51
 
24
52
  # Defines a Dataset for a Chart.
25
53
  # [name] The name of the dataset.
26
54
  # [data] Array of arrays [[x, y], [x, y]] (Floats).
27
- # [color] The color of the line.
28
- # [marker] Symbol (:dot, :braille, :block, :bar)
29
- # [graph_type] Symbol (:line, :scatter)
30
- class Dataset < Data.define(:name, :data, :color, :marker, :graph_type)
55
+ # [style] The style of the line.
56
+ # [marker] Symbol (<tt>:dot</tt>, <tt>:braille</tt>, <tt>:block</tt>, <tt>:bar</tt>)
57
+ # [graph_type] Symbol (<tt>:line</tt>, <tt>:scatter</tt>)
58
+ class Dataset < Data.define(:name, :data, :style, :marker, :graph_type)
59
+ ##
60
+ # :attr_reader: name
61
+ # Name for logical identification or legend.
62
+
63
+ ##
64
+ # :attr_reader: data
65
+ # list of [x, y] coordinates.
66
+
67
+ ##
68
+ # :attr_reader: style
69
+ # Style applied to the dataset (Style).
70
+ #
71
+ # **Note**: Due to Ratatui's Chart widget design, only the foreground color (<tt>fg</tt>) is applied to markers in the chart area.
72
+ # The full style (including <tt>bg</tt> and <tt>modifiers</tt>) is displayed in the legend.
73
+ #
74
+ # Supports:
75
+ # - +fg+: Foreground color of markers (Symbol/Hex) - _applied to chart_
76
+ # - +bg+: Background color (Symbol/Hex) - _legend only_
77
+ # - +modifiers+: Array of effects (<tt>:bold</tt>, <tt>:dim</tt>, <tt>:italic</tt>, <tt>:underlined</tt>, <tt>:slow_blink</tt>, <tt>:rapid_blink</tt>, <tt>:reversed</tt>, <tt>:hidden</tt>, <tt>:crossed_out</tt>) - _legend only_
78
+
79
+ ##
80
+ # :attr_reader: marker
81
+ # Marker type (<tt>:dot</tt>, <tt>:braille</tt>).
82
+
83
+ ##
84
+ # :attr_reader: graph_type
85
+ # Type of graph (<tt>:line</tt>, <tt>:scatter</tt>).
86
+
31
87
  # Creates a new Dataset.
32
88
  #
33
- # [name] The name of the dataset.
34
- # [data] Array of arrays [[x, y], [x, y]] (Floats).
35
- # [color] The color of the line.
36
- # [marker] Symbol (:dot, :braille, :block, :bar)
37
- # [graph_type] Symbol (:line, :scatter)
38
- def initialize(name:, data:, color: "reset", marker: :dot, graph_type: :line)
39
- super
89
+ # [name] String.
90
+ # [data] Array of [x, y] (Numeric, duck-typed via +to_f+).
91
+ # [style] Style.
92
+ # [marker] Symbol.
93
+ # [graph_type] Symbol.
94
+ def initialize(name:, data:, style: nil, marker: :dot, graph_type: :line)
95
+ coerced_data = data.map { |point| [Float(point[0]), Float(point[1])] }
96
+ super(name:, data: coerced_data, style:, marker:, graph_type:)
40
97
  end
41
98
  end
42
99
 
43
- # A generic Cartesian chart.
44
- # [datasets] Array<Dataset>
45
- # [x_axis] Axis
46
- # [y_axis] Axis
47
- # [block] Block
48
- # [style] Style (base style)
49
- class Chart < Data.define(:datasets, :x_axis, :y_axis, :block, :style)
100
+ # Plots data points on a Cartesian coordinate system.
101
+ #
102
+ # Trends and patterns are invisible in raw logs. You need to see the shape of the data to understand the story it tells.
103
+ #
104
+ # This widget plots X/Y coordinates. It supports multiple datasets, custom axes, and different marker types.
105
+ #
106
+ # Use it for analytics, scientific data, or monitoring metrics over time.
107
+ #
108
+ # {rdoc-image:/doc/images/widget_chart_demo.png}[link:/examples/widget_chart_demo/app_rb.html]
109
+ #
110
+ # === Example
111
+ #
112
+ # Run the interactive demo from the terminal:
113
+ #
114
+ # ruby examples/widget_chart_demo/app.rb
115
+ class Chart < Data.define(:datasets, :x_axis, :y_axis, :block, :style, :legend_position, :hidden_legend_constraints)
116
+ ##
117
+ # :attr_reader: datasets
118
+ # Array of Dataset objects to plot.
119
+
120
+ ##
121
+ # :attr_reader: x_axis
122
+ # Configuration for the X Axis.
123
+
124
+ ##
125
+ # :attr_reader: y_axis
126
+ # Configuration for the Y Axis.
127
+
128
+ ##
129
+ # :attr_reader: block
130
+ # Optional wrapping block.
131
+
132
+ ##
133
+ # :attr_reader: style
134
+ # Base style for the chart area.
135
+
136
+ ##
137
+ # :attr_reader: legend_position
138
+ # Position of the legend (<tt>:top_left</tt>, <tt>:top_right</tt>, <tt>:bottom_left</tt>, <tt>:bottom_right</tt>).
139
+
140
+ ##
141
+ # :attr_reader: hidden_legend_constraints
142
+ # Constraints for hiding the legend when the chart is too small (Array of [width, height]).
143
+
50
144
  # Creates a new Chart widget.
51
145
  #
52
- # [datasets] Array<Dataset>
53
- # [x_axis] Axis
54
- # [y_axis] Axis
55
- # [block] Block
56
- # [style] Style (base style)
57
- def initialize(datasets:, x_axis:, y_axis:, block: nil, style: nil)
146
+ # [datasets] Array of Datasets.
147
+ # [x_axis] X Axis config.
148
+ # [y_axis] Y Axis config.
149
+ # [block] Wrapper (optional).
150
+ # [style] Base style (optional).
151
+ # [legend_position] Symbol (<tt>:top_left</tt>, <tt>:top_right</tt>, <tt>:bottom_left</tt>, <tt>:bottom_right</tt>).
152
+ # [hidden_legend_constraints] Array of two Constraints [width, height] (optional).
153
+ def initialize(datasets:, x_axis:, y_axis:, block: nil, style: nil, legend_position: nil, hidden_legend_constraints: [])
58
154
  super
59
155
  end
60
156
  end
@@ -75,7 +171,13 @@ module RatatuiRuby
75
171
  # [y_bounds] Array of two Floats [min, max] for the Y-axis.
76
172
  # [block] Optional block widget to wrap the chart.
77
173
  def initialize(datasets:, x_labels: [], y_labels: [], y_bounds: [0.0, 100.0], block: nil)
78
- super
174
+ super(
175
+ datasets:,
176
+ x_labels:,
177
+ y_labels:,
178
+ y_bounds: [Float(y_bounds[0]), Float(y_bounds[1])],
179
+ block:
180
+ )
79
181
  end
80
182
  end
81
183
  end
@@ -4,78 +4,47 @@
4
4
  # SPDX-License-Identifier: AGPL-3.0-or-later
5
5
 
6
6
  module RatatuiRuby
7
- # A widget that clears (resets) the terminal buffer in the area it is rendered into.
7
+ # Resets the terminal buffer for a specific area.
8
8
  #
9
- # The Clear widget is essential for creating opaque popups and modals. Without it,
10
- # background content or styles (like background colors) will "bleed through"
11
- # empty spaces or transparent widgets.
9
+ # Painting in a terminal is additive. New content draws over old content. If the new content has transparency
10
+ # or empty spaces, the old content "bleeds" through. This ruins popups and modals.
12
11
  #
13
- # > [!TIP]
14
- # > Use `Clear` to prevent "Style Bleed". If a widget rendered behind the popup
15
- # > has a background color, widgets rendered on top with `Style.default` will
16
- # > inherit that background color unless you `Clear` the area first.
12
+ # This widget wipes the slate clean. It resets all cells in its area to their default state (spaces with default background).
17
13
  #
18
- # == Usage with Overlay
14
+ # Use it as the first layer in an Overlay stack when building popups. Ensure your floating windows are truly opaque.
19
15
  #
20
- # Because RatatuiRuby uses an immediate-mode UI pattern, you must use {Overlay} to
21
- # layer widgets properly. The typical pattern for creating an opaque popup is:
16
+ # === Examples
22
17
  #
23
- # background = Paragraph.new(text: "Background content...")
24
- # popup = Paragraph.new(
25
- # text: "Popup content",
26
- # block: Block.new(title: "Popup", borders: [:all])
27
- # )
28
- #
29
- # # Create an opaque popup by layering: background -> Clear -> popup
30
- # ui = Overlay.new(
18
+ # # Opaque Popup Construction
19
+ # Overlay.new(
31
20
  # layers: [
32
- # background,
21
+ # MainUI.new,
33
22
  # Center.new(
34
23
  # child: Overlay.new(
35
24
  # layers: [
36
- # Clear.new, # Erases background in this area
37
- # popup # Draws on top of cleared area
25
+ # Clear.new, # Wipe the area first
26
+ # Block.new(title: "Modal", borders: [:all])
38
27
  # ]
39
28
  # ),
40
29
  # width_percent: 50,
41
- # height_percent: 40
30
+ # height_percent: 50
42
31
  # )
43
32
  # ]
44
33
  # )
45
34
  #
46
- # Without the Clear widget, the background text would be visible through the
47
- # empty spaces in the popup.
48
- #
49
- # == Optional Block Parameter
50
- #
51
- # You can optionally provide a {Block} to draw borders around the cleared area:
52
- #
53
- # Clear.new(block: Block.new(title: "Cleared Area", borders: [:all]))
54
- #
55
- # This is equivalent to:
56
- #
57
- # Overlay.new(
58
- # layers: [
59
- # Clear.new,
60
- # Block.new(title: "Cleared Area", borders: [:all])
61
- # ]
62
- # )
63
- #
64
- # [block] Optional {Block} widget to render on top of the cleared area.
65
- #
66
- # @see Overlay
67
- # @see Center
68
- # @see Block
35
+ # # Shortcut: rendering a block directly
36
+ # Clear.new(block: Block.new(title: "Cleared area", borders: [:all]))
69
37
  class Clear < Data.define(:block)
70
- # Creates a new Clear widget.
71
- #
72
- # @param block [Block, nil] Optional block widget to render on top of the cleared area.
38
+ ##
39
+ # :attr_reader: block
40
+ # Optional Block to render after clearing.
73
41
  #
74
- # @example Basic usage
75
- # Clear.new
42
+ # If provided, the borders/title of this block are drawn on top of the cleared area.
43
+
44
+ # Creates a new Clear widget.
76
45
  #
77
- # @example With a border
78
- # Clear.new(block: Block.new(title: "Modal", borders: [:all]))
46
+ # [block]
47
+ # Block widget to render (optional).
79
48
  def initialize(block: nil)
80
49
  super
81
50
  end