ratatui_ruby 0.7.4 → 0.9.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 (352) hide show
  1. checksums.yaml +4 -4
  2. data/.builds/ruby-3.2.yml +2 -2
  3. data/.builds/ruby-3.3.yml +2 -2
  4. data/.builds/ruby-3.4.yml +2 -2
  5. data/.builds/ruby-4.0.0.yml +2 -2
  6. data/.pre-commit-config.yaml +1 -1
  7. data/AGENTS.md +3 -3
  8. data/CHANGELOG.md +70 -1
  9. data/LICENSES/LGPL-3.0-or-later.txt +304 -0
  10. data/LICENSES/MIT-0.txt +16 -0
  11. data/README.md +33 -5
  12. data/Rakefile +1 -1
  13. data/doc/concepts/application_architecture.md +44 -3
  14. data/doc/concepts/application_testing.md +43 -1
  15. data/doc/concepts/async.md +32 -2
  16. data/doc/concepts/custom_widgets.md +247 -0
  17. data/doc/concepts/event_handling.md +32 -3
  18. data/doc/concepts/interactive_design.md +32 -2
  19. data/doc/contributors/auditing/parity.md +7 -1
  20. data/doc/contributors/design/ruby_frontend.md +85 -1
  21. data/doc/contributors/design/rust_backend.md +67 -1
  22. data/doc/contributors/developing_examples.md +56 -2
  23. data/doc/contributors/documentation_style.md +20 -3
  24. data/doc/contributors/future_work.md +169 -0
  25. data/doc/contributors/index.md +1 -1
  26. data/doc/contributors/v1.0.0_blockers.md +15 -175
  27. data/doc/getting_started/quickstart.md +35 -9
  28. data/doc/getting_started/why.md +1 -1
  29. data/doc/index.md +2 -1
  30. data/doc/troubleshooting/debugging.md +32 -2
  31. data/doc/troubleshooting/terminal_limitations.md +8 -2
  32. data/doc/troubleshooting/tui_output.md +127 -6
  33. data/examples/app_all_events/README.md +14 -2
  34. data/examples/app_all_events/app.rb +1 -1
  35. data/examples/app_all_events/model/app_model.rb +1 -1
  36. data/examples/app_all_events/model/event_color_cycle.rb +1 -1
  37. data/examples/app_all_events/model/event_entry.rb +1 -1
  38. data/examples/app_all_events/model/msg.rb +1 -1
  39. data/examples/app_all_events/model/timestamp.rb +1 -1
  40. data/examples/app_all_events/update.rb +1 -1
  41. data/examples/app_all_events/view/app_view.rb +1 -1
  42. data/examples/app_all_events/view/controls_view.rb +1 -1
  43. data/examples/app_all_events/view/counts_view.rb +1 -1
  44. data/examples/app_all_events/view/live_view.rb +1 -1
  45. data/examples/app_all_events/view/log_view.rb +1 -1
  46. data/examples/app_all_events/view.rb +1 -1
  47. data/examples/app_color_picker/README.md +20 -2
  48. data/examples/app_color_picker/app.rb +1 -1
  49. data/examples/app_color_picker/clipboard.rb +1 -1
  50. data/examples/app_color_picker/color.rb +1 -1
  51. data/examples/app_color_picker/controls.rb +1 -1
  52. data/examples/app_color_picker/copy_dialog.rb +1 -1
  53. data/examples/app_color_picker/export_pane.rb +1 -1
  54. data/examples/app_color_picker/harmony.rb +1 -1
  55. data/examples/app_color_picker/input.rb +1 -1
  56. data/examples/app_color_picker/main_container.rb +1 -1
  57. data/examples/app_color_picker/palette.rb +1 -1
  58. data/examples/app_login_form/README.md +8 -2
  59. data/examples/app_login_form/app.rb +1 -1
  60. data/examples/app_stateful_interaction/README.md +2 -2
  61. data/examples/app_stateful_interaction/app.rb +71 -17
  62. data/examples/timeout_demo.rb +1 -1
  63. data/examples/verify_quickstart_dsl/README.md +6 -0
  64. data/examples/verify_quickstart_dsl/app.rb +3 -3
  65. data/examples/verify_quickstart_layout/README.md +6 -0
  66. data/examples/verify_quickstart_layout/app.rb +3 -3
  67. data/examples/verify_quickstart_lifecycle/README.md +13 -1
  68. data/examples/verify_quickstart_lifecycle/app.rb +10 -4
  69. data/examples/verify_readme_usage/README.md +6 -0
  70. data/examples/verify_readme_usage/app.rb +3 -3
  71. data/examples/widget_barchart/README.md +6 -0
  72. data/examples/widget_barchart/app.rb +2 -2
  73. data/examples/widget_block/README.md +7 -1
  74. data/examples/widget_block/app.rb +2 -2
  75. data/examples/widget_box/README.md +6 -0
  76. data/examples/widget_box/app.rb +9 -6
  77. data/examples/widget_calendar/README.md +6 -0
  78. data/examples/widget_calendar/app.rb +2 -2
  79. data/examples/widget_canvas/README.md +4 -0
  80. data/examples/widget_canvas/app.rb +2 -2
  81. data/examples/widget_cell/README.md +6 -0
  82. data/examples/widget_cell/app.rb +2 -3
  83. data/examples/widget_center/README.md +4 -0
  84. data/examples/widget_center/app.rb +2 -2
  85. data/examples/widget_chart/README.md +6 -0
  86. data/examples/widget_chart/app.rb +2 -2
  87. data/examples/widget_gauge/README.md +6 -0
  88. data/examples/widget_gauge/app.rb +2 -2
  89. data/examples/widget_layout_split/README.md +6 -0
  90. data/examples/widget_layout_split/app.rb +3 -3
  91. data/examples/widget_line_gauge/README.md +6 -0
  92. data/examples/widget_line_gauge/app.rb +2 -2
  93. data/examples/widget_list/README.md +6 -0
  94. data/examples/widget_list/app.rb +2 -2
  95. data/examples/widget_map/README.md +8 -2
  96. data/examples/widget_map/app.rb +2 -2
  97. data/examples/widget_overlay/README.md +7 -1
  98. data/examples/widget_overlay/app.rb +2 -2
  99. data/examples/widget_popup/README.md +6 -0
  100. data/examples/widget_popup/app.rb +2 -2
  101. data/examples/widget_ratatui_logo/README.md +6 -0
  102. data/examples/widget_ratatui_logo/app.rb +2 -3
  103. data/examples/widget_ratatui_mascot/README.md +6 -0
  104. data/examples/widget_ratatui_mascot/app.rb +2 -2
  105. data/examples/widget_rect/README.md +12 -0
  106. data/examples/widget_rect/app.rb +40 -26
  107. data/examples/widget_render/README.md +6 -0
  108. data/examples/widget_render/app.rb +2 -2
  109. data/examples/widget_render/app.rbs +41 -0
  110. data/examples/widget_rich_text/README.md +6 -0
  111. data/examples/widget_rich_text/app.rb +2 -2
  112. data/examples/widget_scroll_text/README.md +6 -0
  113. data/examples/widget_scroll_text/app.rb +2 -2
  114. data/examples/widget_scrollbar/README.md +6 -0
  115. data/examples/widget_scrollbar/app.rb +2 -2
  116. data/examples/widget_sparkline/README.md +6 -0
  117. data/examples/widget_sparkline/app.rb +2 -2
  118. data/examples/widget_style_colors/README.md +6 -0
  119. data/examples/widget_style_colors/app.rb +2 -2
  120. data/examples/widget_table/README.md +8 -2
  121. data/examples/widget_table/app.rb +2 -2
  122. data/examples/widget_tabs/README.md +6 -0
  123. data/examples/widget_tabs/app.rb +2 -2
  124. data/examples/widget_text_width/README.md +6 -0
  125. data/examples/widget_text_width/app.rb +4 -4
  126. data/ext/ratatui_ruby/Cargo.lock +1 -1
  127. data/ext/ratatui_ruby/Cargo.toml +1 -1
  128. data/ext/ratatui_ruby/extconf.rb +2 -2
  129. data/ext/ratatui_ruby/src/rendering.rs +1 -1
  130. data/ext/ratatui_ruby/src/style.rs +0 -8
  131. data/ext/ratatui_ruby/src/widgets/chart.rs +0 -118
  132. data/ext/ratatui_ruby/src/widgets/list_state.rs +36 -0
  133. data/lib/ratatui_ruby/buffer/cell.rb +34 -2
  134. data/lib/ratatui_ruby/buffer.rb +2 -2
  135. data/lib/ratatui_ruby/cell.rb +34 -2
  136. data/lib/ratatui_ruby/event/focus_gained.rb +26 -2
  137. data/lib/ratatui_ruby/event/focus_lost.rb +26 -2
  138. data/lib/ratatui_ruby/event/key/character.rb +18 -2
  139. data/lib/ratatui_ruby/event/key/media.rb +2 -2
  140. data/lib/ratatui_ruby/event/key/modifier.rb +10 -2
  141. data/lib/ratatui_ruby/event/key/navigation.rb +2 -2
  142. data/lib/ratatui_ruby/event/key/system.rb +2 -2
  143. data/lib/ratatui_ruby/event/key.rb +114 -2
  144. data/lib/ratatui_ruby/event/mouse.rb +42 -2
  145. data/lib/ratatui_ruby/event/none.rb +10 -2
  146. data/lib/ratatui_ruby/event/paste.rb +34 -2
  147. data/lib/ratatui_ruby/event/resize.rb +34 -2
  148. data/lib/ratatui_ruby/event.rb +26 -2
  149. data/lib/ratatui_ruby/frame.rb +74 -2
  150. data/lib/ratatui_ruby/layout/constraint.rb +58 -2
  151. data/lib/ratatui_ruby/layout/layout.rb +47 -2
  152. data/lib/ratatui_ruby/layout/rect.rb +403 -2
  153. data/lib/ratatui_ruby/layout.rb +2 -2
  154. data/lib/ratatui_ruby/list_state.rb +113 -2
  155. data/lib/ratatui_ruby/output_guard.rb +171 -0
  156. data/lib/ratatui_ruby/schema/bar_chart/bar.rb +2 -2
  157. data/lib/ratatui_ruby/schema/bar_chart/bar_group.rb +2 -2
  158. data/lib/ratatui_ruby/schema/bar_chart.rb +50 -2
  159. data/lib/ratatui_ruby/schema/block.rb +21 -15
  160. data/lib/ratatui_ruby/schema/calendar.rb +2 -2
  161. data/lib/ratatui_ruby/schema/canvas.rb +10 -2
  162. data/lib/ratatui_ruby/schema/center.rb +10 -2
  163. data/lib/ratatui_ruby/schema/chart.rb +2 -28
  164. data/lib/ratatui_ruby/schema/clear.rb +10 -2
  165. data/lib/ratatui_ruby/schema/constraint.rb +58 -2
  166. data/lib/ratatui_ruby/schema/cursor.rb +10 -2
  167. data/lib/ratatui_ruby/schema/draw.rb +10 -2
  168. data/lib/ratatui_ruby/schema/gauge.rb +2 -2
  169. data/lib/ratatui_ruby/schema/layout.rb +18 -2
  170. data/lib/ratatui_ruby/schema/line_gauge.rb +2 -2
  171. data/lib/ratatui_ruby/schema/list.rb +10 -2
  172. data/lib/ratatui_ruby/schema/list_item.rb +10 -2
  173. data/lib/ratatui_ruby/schema/overlay.rb +10 -2
  174. data/lib/ratatui_ruby/schema/paragraph.rb +10 -2
  175. data/lib/ratatui_ruby/schema/ratatui_logo.rb +2 -2
  176. data/lib/ratatui_ruby/schema/ratatui_mascot.rb +2 -2
  177. data/lib/ratatui_ruby/schema/rect.rb +58 -2
  178. data/lib/ratatui_ruby/schema/row.rb +10 -2
  179. data/lib/ratatui_ruby/schema/scrollbar.rb +2 -2
  180. data/lib/ratatui_ruby/schema/shape/label.rb +10 -2
  181. data/lib/ratatui_ruby/schema/sparkline.rb +10 -2
  182. data/lib/ratatui_ruby/schema/style.rb +18 -2
  183. data/lib/ratatui_ruby/schema/table.rb +2 -2
  184. data/lib/ratatui_ruby/schema/tabs.rb +2 -2
  185. data/lib/ratatui_ruby/schema/text.rb +34 -2
  186. data/lib/ratatui_ruby/scrollbar_state.rb +10 -2
  187. data/lib/ratatui_ruby/style/style.rb +18 -2
  188. data/lib/ratatui_ruby/style.rb +2 -2
  189. data/lib/ratatui_ruby/table_state.rb +10 -2
  190. data/lib/ratatui_ruby/terminal_lifecycle.rb +144 -0
  191. data/lib/ratatui_ruby/test_helper/event_injection.rb +34 -2
  192. data/lib/ratatui_ruby/test_helper/snapshot.rb +74 -9
  193. data/lib/ratatui_ruby/test_helper/style_assertions.rb +98 -2
  194. data/lib/ratatui_ruby/test_helper/terminal.rb +50 -2
  195. data/lib/ratatui_ruby/test_helper/test_doubles.rb +18 -2
  196. data/lib/ratatui_ruby/test_helper.rb +10 -2
  197. data/lib/ratatui_ruby/tui/buffer_factories.rb +2 -2
  198. data/lib/ratatui_ruby/tui/canvas_factories.rb +2 -2
  199. data/lib/ratatui_ruby/tui/core.rb +2 -2
  200. data/lib/ratatui_ruby/tui/layout_factories.rb +32 -2
  201. data/lib/ratatui_ruby/tui/state_factories.rb +2 -2
  202. data/lib/ratatui_ruby/tui/style_factories.rb +2 -2
  203. data/lib/ratatui_ruby/tui/text_factories.rb +2 -2
  204. data/lib/ratatui_ruby/tui/widget_factories.rb +2 -2
  205. data/lib/ratatui_ruby/tui.rb +11 -3
  206. data/lib/ratatui_ruby/version.rb +3 -3
  207. data/lib/ratatui_ruby/widgets/bar_chart/bar.rb +2 -2
  208. data/lib/ratatui_ruby/widgets/bar_chart/bar_group.rb +2 -2
  209. data/lib/ratatui_ruby/widgets/bar_chart.rb +58 -2
  210. data/lib/ratatui_ruby/widgets/block.rb +37 -15
  211. data/lib/ratatui_ruby/widgets/calendar.rb +2 -2
  212. data/lib/ratatui_ruby/widgets/canvas.rb +10 -2
  213. data/lib/ratatui_ruby/widgets/cell.rb +10 -2
  214. data/lib/ratatui_ruby/widgets/center.rb +10 -2
  215. data/lib/ratatui_ruby/widgets/chart.rb +2 -28
  216. data/lib/ratatui_ruby/widgets/clear.rb +10 -2
  217. data/lib/ratatui_ruby/widgets/cursor.rb +10 -2
  218. data/lib/ratatui_ruby/widgets/gauge.rb +16 -2
  219. data/lib/ratatui_ruby/widgets/line_gauge.rb +16 -2
  220. data/lib/ratatui_ruby/widgets/list.rb +41 -2
  221. data/lib/ratatui_ruby/widgets/list_item.rb +10 -2
  222. data/lib/ratatui_ruby/widgets/overlay.rb +10 -2
  223. data/lib/ratatui_ruby/widgets/paragraph.rb +10 -2
  224. data/lib/ratatui_ruby/widgets/ratatui_logo.rb +2 -2
  225. data/lib/ratatui_ruby/widgets/ratatui_mascot.rb +2 -2
  226. data/lib/ratatui_ruby/widgets/row.rb +10 -2
  227. data/lib/ratatui_ruby/widgets/scrollbar.rb +2 -2
  228. data/lib/ratatui_ruby/widgets/shape/label.rb +10 -2
  229. data/lib/ratatui_ruby/widgets/sparkline.rb +10 -2
  230. data/lib/ratatui_ruby/widgets/table.rb +62 -2
  231. data/lib/ratatui_ruby/widgets/tabs.rb +2 -2
  232. data/lib/ratatui_ruby/widgets.rb +2 -2
  233. data/lib/ratatui_ruby.rb +116 -81
  234. data/sig/examples/app_all_events/view.rbs +7 -1
  235. data/sig/examples/app_all_events/view_state.rbs +7 -1
  236. data/sig/examples/app_color_picker/app.rbs +5 -0
  237. data/sig/examples/app_stateful_interaction/app.rbs +7 -1
  238. data/sig/examples/verify_quickstart_dsl/app.rbs +7 -1
  239. data/sig/examples/verify_quickstart_lifecycle/app.rbs +7 -1
  240. data/sig/examples/verify_readme_usage/app.rbs +7 -1
  241. data/sig/examples/widget_block_demo/app.rbs +6 -0
  242. data/sig/examples/widget_box_demo/app.rbs +7 -1
  243. data/sig/examples/widget_calendar_demo/app.rbs +7 -1
  244. data/sig/examples/widget_cell_demo/app.rbs +7 -1
  245. data/sig/examples/widget_chart_demo/app.rbs +7 -1
  246. data/sig/examples/widget_gauge_demo/app.rbs +7 -1
  247. data/sig/examples/widget_layout_split/app.rbs +7 -1
  248. data/sig/examples/widget_line_gauge_demo/app.rbs +7 -1
  249. data/sig/examples/widget_list_demo/app.rbs +5 -0
  250. data/sig/examples/widget_map_demo/app.rbs +7 -1
  251. data/sig/examples/widget_popup_demo/app.rbs +7 -1
  252. data/sig/examples/widget_ratatui_logo_demo/app.rbs +7 -1
  253. data/sig/examples/widget_ratatui_mascot_demo/app.rbs +7 -1
  254. data/sig/examples/widget_rect/app.rbs +7 -1
  255. data/sig/examples/widget_render/app.rbs +7 -1
  256. data/sig/examples/widget_rich_text/app.rbs +7 -1
  257. data/sig/examples/widget_scroll_text/app.rbs +7 -1
  258. data/sig/examples/widget_scrollbar_demo/app.rbs +7 -1
  259. data/sig/examples/widget_sparkline_demo/app.rbs +7 -1
  260. data/sig/examples/widget_style_colors/app.rbs +7 -1
  261. data/sig/examples/widget_table_demo/app.rbs +7 -1
  262. data/sig/examples/widget_text_width/app.rbs +7 -1
  263. data/sig/ratatui_ruby/event.rbs +7 -1
  264. data/sig/ratatui_ruby/frame.rbs +15 -3
  265. data/sig/ratatui_ruby/list_state.rbs +11 -1
  266. data/sig/ratatui_ruby/ratatui_ruby.rbs +8 -2
  267. data/sig/ratatui_ruby/schema/bar_chart/bar.rbs +7 -1
  268. data/sig/ratatui_ruby/schema/bar_chart/bar_group.rbs +6 -0
  269. data/sig/ratatui_ruby/schema/bar_chart.rbs +6 -0
  270. data/sig/ratatui_ruby/schema/block.rbs +7 -1
  271. data/sig/ratatui_ruby/schema/calendar.rbs +6 -0
  272. data/sig/ratatui_ruby/schema/canvas.rbs +6 -0
  273. data/sig/ratatui_ruby/schema/center.rbs +6 -0
  274. data/sig/ratatui_ruby/schema/chart.rbs +6 -9
  275. data/sig/ratatui_ruby/schema/constraint.rbs +6 -0
  276. data/sig/ratatui_ruby/schema/cursor.rbs +6 -0
  277. data/sig/ratatui_ruby/schema/draw.rbs +6 -0
  278. data/sig/ratatui_ruby/schema/gauge.rbs +9 -1
  279. data/sig/ratatui_ruby/schema/layout.rbs +6 -0
  280. data/sig/ratatui_ruby/schema/line_gauge.rbs +9 -1
  281. data/sig/ratatui_ruby/schema/list.rbs +9 -1
  282. data/sig/ratatui_ruby/schema/list_item.rbs +7 -1
  283. data/sig/ratatui_ruby/schema/overlay.rbs +6 -0
  284. data/sig/ratatui_ruby/schema/paragraph.rbs +6 -0
  285. data/sig/ratatui_ruby/schema/ratatui_logo.rbs +6 -0
  286. data/sig/ratatui_ruby/schema/ratatui_mascot.rbs +5 -0
  287. data/sig/ratatui_ruby/schema/rect.rbs +30 -0
  288. data/sig/ratatui_ruby/schema/row.rbs +7 -1
  289. data/sig/ratatui_ruby/schema/scrollbar.rbs +6 -0
  290. data/sig/ratatui_ruby/schema/sparkline.rbs +6 -0
  291. data/sig/ratatui_ruby/schema/style.rbs +7 -1
  292. data/sig/ratatui_ruby/schema/table.rbs +11 -1
  293. data/sig/ratatui_ruby/schema/tabs.rbs +6 -0
  294. data/sig/ratatui_ruby/schema/text.rbs +7 -1
  295. data/sig/ratatui_ruby/scrollbar_state.rbs +7 -1
  296. data/sig/ratatui_ruby/session.rbs +7 -1
  297. data/sig/ratatui_ruby/table_state.rbs +7 -1
  298. data/sig/ratatui_ruby/test_helper/event_injection.rbs +7 -1
  299. data/sig/ratatui_ruby/test_helper/snapshot.rbs +7 -1
  300. data/sig/ratatui_ruby/test_helper/style_assertions.rbs +7 -1
  301. data/sig/ratatui_ruby/test_helper/terminal.rbs +7 -1
  302. data/sig/ratatui_ruby/test_helper/test_doubles.rbs +7 -1
  303. data/sig/ratatui_ruby/test_helper.rbs +7 -1
  304. data/sig/ratatui_ruby/tui/buffer_factories.rbs +7 -1
  305. data/sig/ratatui_ruby/tui/canvas_factories.rbs +7 -1
  306. data/sig/ratatui_ruby/tui/core.rbs +7 -1
  307. data/sig/ratatui_ruby/tui/layout_factories.rbs +7 -1
  308. data/sig/ratatui_ruby/tui/state_factories.rbs +7 -1
  309. data/sig/ratatui_ruby/tui/style_factories.rbs +7 -1
  310. data/sig/ratatui_ruby/tui/text_factories.rbs +7 -1
  311. data/sig/ratatui_ruby/tui/widget_factories.rbs +7 -1
  312. data/sig/ratatui_ruby/tui.rbs +7 -1
  313. data/sig/ratatui_ruby/version.rbs +6 -0
  314. data/tasks/autodoc/examples.rb +9 -3
  315. data/tasks/autodoc/member.rb +1 -1
  316. data/tasks/autodoc/name.rb +1 -1
  317. data/tasks/bump/cargo_lockfile.rb +1 -1
  318. data/tasks/bump/changelog.rb +1 -1
  319. data/tasks/bump/header.rb +1 -1
  320. data/tasks/bump/history.rb +1 -1
  321. data/tasks/bump/links.rb +1 -1
  322. data/tasks/bump/manifest.rb +1 -1
  323. data/tasks/bump/ruby_gem.rb +1 -1
  324. data/tasks/bump/sem_ver.rb +1 -1
  325. data/tasks/bump/unreleased_section.rb +1 -1
  326. data/tasks/license/headers_md.rb +223 -0
  327. data/tasks/license/headers_rb.rb +210 -0
  328. data/tasks/license/license_utils.rb +130 -0
  329. data/tasks/license/snippets_md.rb +315 -0
  330. data/tasks/license/snippets_rdoc.rb +150 -0
  331. data/tasks/license.rake +91 -0
  332. data/tasks/rdoc_config.rb +1 -1
  333. data/tasks/resources/build.yml.erb +13 -7
  334. data/tasks/sourcehut.rake +3 -1
  335. data/tasks/terminal_preview/app_screenshot.rb +1 -1
  336. data/tasks/terminal_preview/crash_report.rb +1 -1
  337. data/tasks/terminal_preview/example_app.rb +1 -1
  338. data/tasks/terminal_preview/launcher_script.rb +1 -1
  339. data/tasks/terminal_preview/preview_collection.rb +1 -1
  340. data/tasks/terminal_preview/preview_timing.rb +1 -1
  341. data/tasks/terminal_preview/safety_confirmation.rb +1 -1
  342. data/tasks/terminal_preview/saved_screenshot.rb +1 -1
  343. data/tasks/terminal_preview/system_appearance.rb +1 -1
  344. data/tasks/terminal_preview/terminal_window.rb +1 -1
  345. data/tasks/terminal_preview/window_id.rb +1 -1
  346. data/tasks/website/index_page.rb +1 -1
  347. data/tasks/website/version.rb +1 -1
  348. data/tasks/website/version_menu.rb +1 -1
  349. data/tasks/website/versioned_documentation.rb +1 -1
  350. data/tasks/website/website.rb +1 -1
  351. metadata +15 -3
  352. data/doc/migration/v0_7_0.md +0 -236
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -16,8 +16,16 @@ module RatatuiRuby
16
16
  #
17
17
  # === Examples
18
18
  #
19
+ #--
20
+ # SPDX-SnippetBegin
21
+ # SPDX-FileCopyrightText: 2026 Kerrick Long
22
+ # SPDX-License-Identifier: MIT-0
23
+ #++
19
24
  # Cursor.new(x: 10, y: 5)
20
25
  #
26
+ #--
27
+ # SPDX-SnippetEnd
28
+ #++
21
29
  # See also:
22
30
  # - {Declarative implementation using Tree API}[link:/examples/app_login_form/app_rb.html]
23
31
  # - {Component-based implementation using Frame API}[link:/examples/app_color_picker/app_rb.html]
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -13,6 +13,11 @@ module RatatuiRuby
13
13
  #
14
14
  # === Example
15
15
  #
16
+ #--
17
+ # SPDX-SnippetBegin
18
+ # SPDX-FileCopyrightText: 2025 Kerrick Long
19
+ # SPDX-License-Identifier: MIT-0
20
+ #++
16
21
  # class MyWidget
17
22
  # def render(area)
18
23
  # [
@@ -21,6 +26,9 @@ module RatatuiRuby
21
26
  # ]
22
27
  # end
23
28
  # end
29
+ #--
30
+ # SPDX-SnippetEnd
31
+ #++
24
32
  module Draw
25
33
  # Command to draw a string at the given coordinates.
26
34
  #
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -70,6 +70,11 @@ module RatatuiRuby
70
70
  # This is a pure calculation helper for hit testing. It computes where
71
71
  # widgets *would* be placed without actually rendering them.
72
72
  #
73
+ #--
74
+ # SPDX-SnippetBegin
75
+ # SPDX-FileCopyrightText: 2025 Kerrick Long
76
+ # SPDX-License-Identifier: MIT-0
77
+ #++
73
78
  # rects = Layout.split(
74
79
  # area,
75
80
  # direction: :horizontal,
@@ -77,6 +82,9 @@ module RatatuiRuby
77
82
  # )
78
83
  # left, right = rects
79
84
  #
85
+ #--
86
+ # SPDX-SnippetEnd
87
+ #++
80
88
  # [area]
81
89
  # The area to split. Can be a <tt>Rect</tt> or a <tt>Hash</tt> containing <tt>:x</tt>, <tt>:y</tt>, <tt>:width</tt>, and <tt>:height</tt>.
82
90
  # [direction]
@@ -84,8 +92,16 @@ module RatatuiRuby
84
92
  # [constraints]
85
93
  # Array of <tt>Constraint</tt> objects defining section sizes.
86
94
  # [flex]
95
+ #--
96
+ # SPDX-SnippetBegin
97
+ # SPDX-FileCopyrightText: 2025 Kerrick Long
98
+ # SPDX-License-Identifier: MIT-0
99
+ #++
87
100
  # Flex mode for spacing (default: <tt>:legacy</tt>).
88
101
  #
102
+ #--
103
+ # SPDX-SnippetEnd
104
+ #++
89
105
  # Returns an Array of <tt>Rect</tt> objects.
90
106
  def self.split(area, direction: :vertical, constraints:, flex: :legacy)
91
107
  # Duck-typing: If it lacks geometry methods but can be a Hash, convert it.
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -19,6 +19,11 @@ module RatatuiRuby
19
19
  #
20
20
  # === Examples
21
21
  #
22
+ #--
23
+ # SPDX-SnippetBegin
24
+ # SPDX-FileCopyrightText: 2025 Kerrick Long
25
+ # SPDX-License-Identifier: MIT-0
26
+ #++
22
27
  # # Basic List
23
28
  # List.new(items: ["Item 1", "Item 2"])
24
29
  #
@@ -29,6 +34,9 @@ module RatatuiRuby
29
34
  # highlight_style: Style.new(bg: :blue),
30
35
  # highlight_symbol: ">> "
31
36
  # )
37
+ #--
38
+ # SPDX-SnippetEnd
39
+ #++
32
40
  class List < Data.define(:items, :selected_index, :offset, :style, :highlight_style, :highlight_symbol, :repeat_highlight_symbol, :highlight_spacing, :direction, :scroll_padding, :block)
33
41
  ##
34
42
  # :attr_reader: items
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -16,6 +16,11 @@ module RatatuiRuby
16
16
  #
17
17
  # === Examples
18
18
  #
19
+ #--
20
+ # SPDX-SnippetBegin
21
+ # SPDX-FileCopyrightText: 2026 Kerrick Long
22
+ # SPDX-License-Identifier: MIT-0
23
+ #++
19
24
  # # Item with red background
20
25
  # ListItem.new(content: "Error", style: Style.new(bg: :red))
21
26
  #
@@ -23,6 +28,9 @@ module RatatuiRuby
23
28
  # ListItem.new(
24
29
  # content: Text::Span.new(content: "Status: OK", style: Style.new(fg: :green, modifiers: [:bold]))
25
30
  # )
31
+ #--
32
+ # SPDX-SnippetEnd
33
+ #++
26
34
  class ListItem < Data.define(:content, :style)
27
35
  ##
28
36
  # :attr_reader: content
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -18,6 +18,11 @@ module RatatuiRuby
18
18
  #
19
19
  # === Examples
20
20
  #
21
+ #--
22
+ # SPDX-SnippetBegin
23
+ # SPDX-FileCopyrightText: 2025 Kerrick Long
24
+ # SPDX-License-Identifier: MIT-0
25
+ #++
21
26
  # Overlay.new(
22
27
  # layers: [
23
28
  # BackgroundMap.new,
@@ -25,6 +30,9 @@ module RatatuiRuby
25
30
  # ModalDialog.new # Draws over everything
26
31
  # ]
27
32
  # )
33
+ #--
34
+ # SPDX-SnippetEnd
35
+ #++
28
36
  class Overlay < Data.define(:layers)
29
37
  ##
30
38
  # :attr_reader: layers
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -16,6 +16,11 @@ module RatatuiRuby
16
16
  #
17
17
  # === Examples
18
18
  #
19
+ #--
20
+ # SPDX-SnippetBegin
21
+ # SPDX-FileCopyrightText: 2025 Kerrick Long
22
+ # SPDX-License-Identifier: MIT-0
23
+ #++
19
24
  # # Basic Text
20
25
  # Paragraph.new(text: "Hello, World!")
21
26
  #
@@ -29,6 +34,9 @@ module RatatuiRuby
29
34
  #
30
35
  # # Scrolling mechanism
31
36
  # Paragraph.new(text: large_text, scroll: [scroll_y, 0])
37
+ #--
38
+ # SPDX-SnippetEnd
39
+ #++
32
40
  class Paragraph < Data.define(:text, :style, :block, :wrap, :alignment, :scroll)
33
41
  ##
34
42
  # :attr_reader: text
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -18,8 +18,16 @@ module RatatuiRuby
18
18
  #
19
19
  # === Examples
20
20
  #
21
+ #--
22
+ # SPDX-SnippetBegin
23
+ # SPDX-FileCopyrightText: 2025 Kerrick Long
24
+ # SPDX-License-Identifier: MIT-0
25
+ #++
21
26
  # area = Rect.new(x: 0, y: 0, width: 80, height: 24)
22
27
  # puts area.width # => 80
28
+ #--
29
+ # SPDX-SnippetEnd
30
+ #++
23
31
  class Rect < Data.define(:x, :y, :width, :height)
24
32
  ##
25
33
  # :attr_reader: x
@@ -58,15 +66,31 @@ module RatatuiRuby
58
66
  #
59
67
  # Essential for hit testing mouse clicks against layout regions.
60
68
  #
69
+ #--
70
+ # SPDX-SnippetBegin
71
+ # SPDX-FileCopyrightText: 2025 Kerrick Long
72
+ # SPDX-License-Identifier: MIT-0
73
+ #++
61
74
  # area = Rect.new(x: 10, y: 5, width: 20, height: 10)
62
75
  # area.contains?(15, 8) # => true
63
76
  # area.contains?(5, 8) # => false
64
77
  #
78
+ #--
79
+ # SPDX-SnippetEnd
80
+ #++
65
81
  # [px]
66
82
  # X coordinate to test (column).
67
83
  # [py]
84
+ #--
85
+ # SPDX-SnippetBegin
86
+ # SPDX-FileCopyrightText: 2025 Kerrick Long
87
+ # SPDX-License-Identifier: MIT-0
88
+ #++
68
89
  # Y coordinate to test (row).
69
90
  #
91
+ #--
92
+ # SPDX-SnippetEnd
93
+ #++
70
94
  # Returns true if the point (px, py) is within the rectangle bounds.
71
95
  def contains?(px, py)
72
96
  px >= x && px < x + width && py >= y && py < y + height
@@ -76,13 +100,29 @@ module RatatuiRuby
76
100
  #
77
101
  # Essential for determining if a widget is visible within a viewport or clipping area.
78
102
  #
103
+ #--
104
+ # SPDX-SnippetBegin
105
+ # SPDX-FileCopyrightText: 2026 Kerrick Long
106
+ # SPDX-License-Identifier: MIT-0
107
+ #++
79
108
  # viewport = Rect.new(x: 0, y: 0, width: 80, height: 24)
80
109
  # widget = Rect.new(x: 70, y: 20, width: 20, height: 10)
81
110
  # viewport.intersects?(widget) # => true (partial overlap)
82
111
  #
112
+ #--
113
+ # SPDX-SnippetEnd
114
+ #++
83
115
  # [other]
116
+ #--
117
+ # SPDX-SnippetBegin
118
+ # SPDX-FileCopyrightText: 2026 Kerrick Long
119
+ # SPDX-License-Identifier: MIT-0
120
+ #++
84
121
  # Another Rect to test against.
85
122
  #
123
+ #--
124
+ # SPDX-SnippetEnd
125
+ #++
86
126
  # Returns true if the rectangles overlap.
87
127
  def intersects?(other)
88
128
  x < other.x + other.width &&
@@ -95,14 +135,30 @@ module RatatuiRuby
95
135
  #
96
136
  # Essential for calculating visible portions of widgets inside scroll views.
97
137
  #
138
+ #--
139
+ # SPDX-SnippetBegin
140
+ # SPDX-FileCopyrightText: 2026 Kerrick Long
141
+ # SPDX-License-Identifier: MIT-0
142
+ #++
98
143
  # viewport = Rect.new(x: 0, y: 0, width: 80, height: 24)
99
144
  # widget = Rect.new(x: 70, y: 20, width: 20, height: 10)
100
145
  # visible = viewport.intersection(widget)
101
146
  # # => Rect(x: 70, y: 20, width: 10, height: 4)
102
147
  #
148
+ #--
149
+ # SPDX-SnippetEnd
150
+ #++
103
151
  # [other]
152
+ #--
153
+ # SPDX-SnippetBegin
154
+ # SPDX-FileCopyrightText: 2026 Kerrick Long
155
+ # SPDX-License-Identifier: MIT-0
156
+ #++
104
157
  # Another Rect to intersect with.
105
158
  #
159
+ #--
160
+ # SPDX-SnippetEnd
161
+ #++
106
162
  # Returns a new Rect representing the intersection, or +nil+ if no overlap.
107
163
  def intersection(other)
108
164
  return nil unless intersects?(other)
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -16,6 +16,11 @@ module RatatuiRuby
16
16
  #
17
17
  # === Examples
18
18
  #
19
+ #--
20
+ # SPDX-SnippetBegin
21
+ # SPDX-FileCopyrightText: 2026 Kerrick Long
22
+ # SPDX-License-Identifier: MIT-0
23
+ #++
19
24
  # # Row with red background
20
25
  # Row.new(cells: ["Error", "Something went wrong"], style: Style.new(bg: :red))
21
26
  #
@@ -27,6 +32,9 @@ module RatatuiRuby
27
32
  # ],
28
33
  # height: 2
29
34
  # )
35
+ #--
36
+ # SPDX-SnippetEnd
37
+ #++
30
38
  class Row < Data.define(:cells, :style, :height, :top_margin, :bottom_margin)
31
39
  ##
32
40
  # :attr_reader: cells
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -19,6 +19,11 @@ module RatatuiRuby
19
19
  #
20
20
  # === Examples
21
21
  #
22
+ #--
23
+ # SPDX-SnippetBegin
24
+ # SPDX-FileCopyrightText: 2025 Kerrick Long
25
+ # SPDX-License-Identifier: MIT-0
26
+ #++
22
27
  # # Simple label
23
28
  # Shape::Label.new(x: 0, y: 0, text: "Origin")
24
29
  #
@@ -37,6 +42,9 @@ module RatatuiRuby
37
42
  # Text::Span.new(content: "World", style: Style.new(fg: :blue))
38
43
  # ])
39
44
  # )
45
+ #--
46
+ # SPDX-SnippetEnd
47
+ #++
40
48
  class Label < Data.define(:x, :y, :text, :style)
41
49
  ##
42
50
  # :attr_reader: x
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -71,6 +71,11 @@ module RatatuiRuby
71
71
  #
72
72
  # === Examples
73
73
  #
74
+ #--
75
+ # SPDX-SnippetBegin
76
+ # SPDX-FileCopyrightText: 2025 Kerrick Long
77
+ # SPDX-License-Identifier: MIT-0
78
+ #++
74
79
  # bar_set: {
75
80
  # empty: " ",
76
81
  # one_eighth: " ",
@@ -90,6 +95,9 @@ module RatatuiRuby
90
95
  #
91
96
  # # Array (9 items)
92
97
  # bar_set: [" ", " ", "▂", "▃", "▄", "▅", "▆", "▇", "█"]
98
+ #--
99
+ # SPDX-SnippetEnd
100
+ #++
93
101
 
94
102
  BAR_KEYS = %i[empty one_eighth one_quarter three_eighths half five_eighths three_quarters seven_eighths full].freeze
95
103
 
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -17,12 +17,20 @@ module RatatuiRuby
17
17
  #
18
18
  # === Examples
19
19
  #
20
+ #--
21
+ # SPDX-SnippetBegin
22
+ # SPDX-FileCopyrightText: 2026 Kerrick Long
23
+ # SPDX-License-Identifier: MIT-0
24
+ #++
20
25
  # # Standard colors
21
26
  # Style.new(fg: :red, bg: :white, modifiers: [:bold])
22
27
  #
23
28
  # # Hex colors
24
29
  # Style.new(fg: "#ff00ff")
25
30
  #
31
+ #--
32
+ # SPDX-SnippetEnd
33
+ #++
26
34
  # === Supported Colors
27
35
  #
28
36
  # ==== Integer
@@ -36,9 +44,17 @@ module RatatuiRuby
36
44
  # * <tt>:black</tt>, <tt>:red</tt>, <tt>:green</tt>, <tt>:yellow</tt>,
37
45
  # <tt>:blue</tt>, <tt>:magenta</tt>, <tt>:cyan</tt>, <tt>:gray</tt>
38
46
  # * <tt>:dark_gray</tt>, <tt>:light_red</tt>, <tt>:light_green</tt>,
47
+ #--
48
+ # SPDX-SnippetBegin
49
+ # SPDX-FileCopyrightText: 2026 Kerrick Long
50
+ # SPDX-License-Identifier: MIT-0
51
+ #++
39
52
  # <tt>:light_yellow</tt>, <tt>:light_blue</tt>, <tt>:light_magenta</tt>,
40
53
  # <tt>:light_cyan</tt>, <tt>:white</tt>
41
54
  #
55
+ #--
56
+ # SPDX-SnippetEnd
57
+ #++
42
58
  # ==== String
43
59
  # Represents a specific RGB color using a Hex code (<tt>"#RRGGBB"</tt>).
44
60
  # Requires a terminal emulator with "True Color" (24-bit color) support.
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
+ # SPDX-License-Identifier: LGPL-3.0-or-later
6
6
  #++
7
7
 
8
8
  module RatatuiRuby
@@ -31,6 +31,11 @@ module RatatuiRuby
31
31
  #
32
32
  # === Examples
33
33
  #
34
+ #--
35
+ # SPDX-SnippetBegin
36
+ # SPDX-FileCopyrightText: 2026 Kerrick Long
37
+ # SPDX-License-Identifier: MIT-0
38
+ #++
34
39
  # # Simple ASCII text
35
40
  # RatatuiRuby::Text.width("Hello") # => 5
36
41
  #
@@ -42,6 +47,9 @@ module RatatuiRuby
42
47
  #
43
48
  # # Mixed content
44
49
  # RatatuiRuby::Text.width("Hi 你好 👍") # => 11 (2 + space + 4 + space + 2)
50
+ #--
51
+ # SPDX-SnippetEnd
52
+ #++
45
53
  module Text
46
54
  # A styled string fragment.
47
55
  #
@@ -90,12 +98,20 @@ module RatatuiRuby
90
98
  #
91
99
  # === Examples
92
100
  #
101
+ #--
102
+ # SPDX-SnippetBegin
103
+ # SPDX-FileCopyrightText: 2025 Kerrick Long
104
+ # SPDX-License-Identifier: MIT-0
105
+ #++
93
106
  # Text::Line.new(
94
107
  # spans: [
95
108
  # Text::Span.styled("User: ", Style.new(modifiers: [:bold])),
96
109
  # Text::Span.styled("kerrick", Style.new(fg: :blue))
97
110
  # ]
98
111
  # )
112
+ #--
113
+ # SPDX-SnippetEnd
114
+ #++
99
115
  class Line < Data.define(:spans, :alignment, :style)
100
116
  ##
101
117
  # :attr_reader: spans
@@ -136,12 +152,20 @@ module RatatuiRuby
136
152
  #
137
153
  # === Examples
138
154
  #
155
+ #--
156
+ # SPDX-SnippetBegin
157
+ # SPDX-FileCopyrightText: 2026 Kerrick Long
158
+ # SPDX-License-Identifier: MIT-0
159
+ #++
139
160
  # line = Text::Line.new(spans: [
140
161
  # Text::Span.new(content: "Hello "),
141
162
  # Text::Span.new(content: "世界")
142
163
  # ])
143
164
  # line.width # => 10 (6 ASCII + 4 CJK)
144
165
  #
166
+ #--
167
+ # SPDX-SnippetEnd
168
+ #++
145
169
  # Returns: Integer (number of terminal cells)
146
170
  def width
147
171
  RatatuiRuby::Text.width(spans.map { |s| s.content.to_s }.join)
@@ -162,6 +186,11 @@ module RatatuiRuby
162
186
  #
163
187
  # === Examples
164
188
  #
189
+ #--
190
+ # SPDX-SnippetBegin
191
+ # SPDX-FileCopyrightText: 2026 Kerrick Long
192
+ # SPDX-License-Identifier: MIT-0
193
+ #++
165
194
  # RatatuiRuby::Text.width("Hello") # => 5 (5 ASCII chars × 1 cell)
166
195
  #
167
196
  # RatatuiRuby::Text.width("你好") # => 4 (2 CJK chars × 2 cells)
@@ -173,6 +202,9 @@ module RatatuiRuby
173
202
  # width = tui.text_width("Hello 👍")
174
203
  # end
175
204
  #
205
+ #--
206
+ # SPDX-SnippetEnd
207
+ #++
176
208
  # [string] String to measure (String or object convertible to String)
177
209
  # Returns: Integer (number of terminal cells the string occupies)
178
210
  # Raises: TypeError if the argument is not a String