ratatui_ruby 0.6.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. checksums.yaml +4 -4
  2. data/.builds/ruby-3.2.yml +1 -1
  3. data/.builds/ruby-3.3.yml +1 -1
  4. data/.builds/ruby-3.4.yml +1 -1
  5. data/.builds/ruby-4.0.0.yml +1 -1
  6. data/AGENTS.md +4 -4
  7. data/CHANGELOG.md +48 -0
  8. data/README.md +26 -1
  9. data/doc/application_architecture.md +16 -16
  10. data/doc/application_testing.md +1 -1
  11. data/doc/async.md +160 -0
  12. data/doc/contributors/architectural_overhaul/chat_conversations.md +4952 -0
  13. data/doc/contributors/architectural_overhaul/implementation_plan.md +60 -0
  14. data/doc/contributors/architectural_overhaul/task.md +37 -0
  15. data/doc/contributors/design/ruby_frontend.md +277 -81
  16. data/doc/contributors/design/rust_backend.md +349 -55
  17. data/doc/contributors/developing_examples.md +5 -5
  18. data/doc/contributors/index.md +7 -5
  19. data/doc/contributors/v1.0.0_blockers.md +1729 -0
  20. data/doc/debugging.md +71 -0
  21. data/doc/index.md +11 -6
  22. data/doc/interactive_design.md +2 -2
  23. data/doc/quickstart.md +66 -97
  24. data/doc/v0.7.0_migration.md +236 -0
  25. data/doc/why.md +93 -0
  26. data/examples/app_all_events/README.md +6 -4
  27. data/examples/app_all_events/app.rb +1 -1
  28. data/examples/app_all_events/model/app_model.rb +1 -1
  29. data/examples/app_all_events/model/msg.rb +1 -1
  30. data/examples/app_all_events/update.rb +1 -1
  31. data/examples/app_all_events/view/app_view.rb +1 -1
  32. data/examples/app_all_events/view/controls_view.rb +1 -1
  33. data/examples/app_all_events/view/counts_view.rb +1 -1
  34. data/examples/app_all_events/view/live_view.rb +1 -1
  35. data/examples/app_all_events/view/log_view.rb +1 -1
  36. data/examples/app_color_picker/README.md +7 -5
  37. data/examples/app_color_picker/app.rb +1 -1
  38. data/examples/app_login_form/README.md +2 -0
  39. data/examples/app_stateful_interaction/README.md +2 -0
  40. data/examples/app_stateful_interaction/app.rb +1 -1
  41. data/examples/verify_quickstart_dsl/README.md +4 -3
  42. data/examples/verify_quickstart_dsl/app.rb +1 -1
  43. data/examples/verify_quickstart_layout/README.md +1 -1
  44. data/examples/verify_quickstart_lifecycle/README.md +3 -3
  45. data/examples/verify_quickstart_lifecycle/app.rb +2 -2
  46. data/examples/verify_readme_usage/README.md +1 -1
  47. data/examples/widget_barchart_demo/README.md +2 -1
  48. data/examples/widget_block_demo/README.md +2 -0
  49. data/examples/widget_box_demo/README.md +3 -3
  50. data/examples/widget_calendar_demo/README.md +3 -3
  51. data/examples/widget_calendar_demo/app.rb +5 -1
  52. data/examples/widget_canvas_demo/README.md +3 -3
  53. data/examples/widget_cell_demo/README.md +3 -3
  54. data/examples/widget_center_demo/README.md +3 -3
  55. data/examples/widget_chart_demo/README.md +3 -3
  56. data/examples/widget_gauge_demo/README.md +3 -3
  57. data/examples/widget_layout_split/README.md +3 -3
  58. data/examples/widget_line_gauge_demo/README.md +3 -3
  59. data/examples/widget_list_demo/README.md +3 -3
  60. data/examples/widget_map_demo/README.md +3 -3
  61. data/examples/widget_map_demo/app.rb +2 -2
  62. data/examples/widget_overlay_demo/README.md +36 -0
  63. data/examples/widget_popup_demo/README.md +3 -3
  64. data/examples/widget_ratatui_logo_demo/README.md +3 -3
  65. data/examples/widget_ratatui_logo_demo/app.rb +1 -1
  66. data/examples/widget_ratatui_mascot_demo/README.md +3 -3
  67. data/examples/widget_rect/README.md +3 -3
  68. data/examples/widget_render/README.md +3 -3
  69. data/examples/widget_render/app.rb +3 -3
  70. data/examples/widget_rich_text/README.md +3 -3
  71. data/examples/widget_scroll_text/README.md +3 -3
  72. data/examples/widget_scrollbar_demo/README.md +3 -3
  73. data/examples/widget_sparkline_demo/README.md +3 -3
  74. data/examples/widget_style_colors/README.md +3 -3
  75. data/examples/widget_table_demo/README.md +3 -3
  76. data/examples/widget_table_demo/app.rb +19 -4
  77. data/examples/widget_tabs_demo/README.md +3 -3
  78. data/examples/widget_text_width/README.md +3 -3
  79. data/examples/widget_text_width/app.rb +8 -1
  80. data/ext/ratatui_ruby/Cargo.lock +1 -1
  81. data/ext/ratatui_ruby/Cargo.toml +1 -1
  82. data/ext/ratatui_ruby/src/frame.rs +6 -5
  83. data/ext/ratatui_ruby/src/lib.rs +3 -2
  84. data/ext/ratatui_ruby/src/rendering.rs +22 -21
  85. data/ext/ratatui_ruby/src/style.rs +25 -9
  86. data/ext/ratatui_ruby/src/text.rs +12 -3
  87. data/ext/ratatui_ruby/src/widgets/canvas.rs +5 -5
  88. data/ext/ratatui_ruby/src/widgets/table.rs +81 -36
  89. data/lib/ratatui_ruby/buffer/cell.rb +168 -0
  90. data/lib/ratatui_ruby/buffer.rb +15 -0
  91. data/lib/ratatui_ruby/frame.rb +8 -8
  92. data/lib/ratatui_ruby/layout/constraint.rb +95 -0
  93. data/lib/ratatui_ruby/layout/layout.rb +106 -0
  94. data/lib/ratatui_ruby/layout/rect.rb +118 -0
  95. data/lib/ratatui_ruby/layout.rb +19 -0
  96. data/lib/ratatui_ruby/list_state.rb +2 -2
  97. data/lib/ratatui_ruby/schema/layout.rb +1 -1
  98. data/lib/ratatui_ruby/schema/row.rb +66 -0
  99. data/lib/ratatui_ruby/schema/table.rb +10 -10
  100. data/lib/ratatui_ruby/schema/text.rb +27 -2
  101. data/lib/ratatui_ruby/style/style.rb +81 -0
  102. data/lib/ratatui_ruby/style.rb +15 -0
  103. data/lib/ratatui_ruby/table_state.rb +1 -1
  104. data/lib/ratatui_ruby/test_helper/snapshot.rb +24 -0
  105. data/lib/ratatui_ruby/test_helper/style_assertions.rb +1 -1
  106. data/lib/ratatui_ruby/tui/buffer_factories.rb +20 -0
  107. data/lib/ratatui_ruby/tui/canvas_factories.rb +44 -0
  108. data/lib/ratatui_ruby/tui/core.rb +38 -0
  109. data/lib/ratatui_ruby/tui/layout_factories.rb +74 -0
  110. data/lib/ratatui_ruby/tui/state_factories.rb +33 -0
  111. data/lib/ratatui_ruby/tui/style_factories.rb +20 -0
  112. data/lib/ratatui_ruby/tui/text_factories.rb +44 -0
  113. data/lib/ratatui_ruby/tui/widget_factories.rb +195 -0
  114. data/lib/ratatui_ruby/tui.rb +75 -0
  115. data/lib/ratatui_ruby/version.rb +1 -1
  116. data/lib/ratatui_ruby/widgets/bar_chart/bar.rb +47 -0
  117. data/lib/ratatui_ruby/widgets/bar_chart/bar_group.rb +25 -0
  118. data/lib/ratatui_ruby/widgets/bar_chart.rb +239 -0
  119. data/lib/ratatui_ruby/widgets/block.rb +192 -0
  120. data/lib/ratatui_ruby/widgets/calendar.rb +84 -0
  121. data/lib/ratatui_ruby/widgets/canvas.rb +231 -0
  122. data/lib/ratatui_ruby/widgets/cell.rb +47 -0
  123. data/lib/ratatui_ruby/widgets/center.rb +59 -0
  124. data/lib/ratatui_ruby/widgets/chart.rb +185 -0
  125. data/lib/ratatui_ruby/widgets/clear.rb +54 -0
  126. data/lib/ratatui_ruby/widgets/cursor.rb +42 -0
  127. data/lib/ratatui_ruby/widgets/gauge.rb +72 -0
  128. data/lib/ratatui_ruby/widgets/line_gauge.rb +80 -0
  129. data/lib/ratatui_ruby/widgets/list.rb +127 -0
  130. data/lib/ratatui_ruby/widgets/list_item.rb +43 -0
  131. data/lib/ratatui_ruby/widgets/overlay.rb +43 -0
  132. data/lib/ratatui_ruby/widgets/paragraph.rb +99 -0
  133. data/lib/ratatui_ruby/widgets/ratatui_logo.rb +31 -0
  134. data/lib/ratatui_ruby/widgets/ratatui_mascot.rb +36 -0
  135. data/lib/ratatui_ruby/widgets/row.rb +68 -0
  136. data/lib/ratatui_ruby/widgets/scrollbar.rb +143 -0
  137. data/lib/ratatui_ruby/widgets/shape/label.rb +68 -0
  138. data/lib/ratatui_ruby/widgets/sparkline.rb +134 -0
  139. data/lib/ratatui_ruby/widgets/table.rb +141 -0
  140. data/lib/ratatui_ruby/widgets/tabs.rb +85 -0
  141. data/lib/ratatui_ruby/widgets.rb +40 -0
  142. data/lib/ratatui_ruby.rb +23 -39
  143. data/sig/examples/app_all_events/view.rbs +1 -1
  144. data/sig/examples/app_all_events/view_state.rbs +1 -1
  145. data/sig/ratatui_ruby/schema/row.rbs +22 -0
  146. data/sig/ratatui_ruby/schema/table.rbs +1 -1
  147. data/sig/ratatui_ruby/schema/text.rbs +1 -0
  148. data/sig/ratatui_ruby/session.rbs +29 -49
  149. data/sig/ratatui_ruby/tui/buffer_factories.rbs +10 -0
  150. data/sig/ratatui_ruby/tui/canvas_factories.rbs +14 -0
  151. data/sig/ratatui_ruby/tui/core.rbs +14 -0
  152. data/sig/ratatui_ruby/tui/layout_factories.rbs +19 -0
  153. data/sig/ratatui_ruby/tui/state_factories.rbs +12 -0
  154. data/sig/ratatui_ruby/tui/style_factories.rbs +10 -0
  155. data/sig/ratatui_ruby/tui/text_factories.rbs +14 -0
  156. data/sig/ratatui_ruby/tui/widget_factories.rbs +39 -0
  157. data/sig/ratatui_ruby/tui.rbs +19 -0
  158. data/tasks/autodoc.rake +1 -35
  159. data/tasks/bump/changelog.rb +8 -0
  160. data/tasks/bump/ruby_gem.rb +12 -0
  161. data/tasks/bump/unreleased_section.rb +16 -0
  162. data/tasks/sourcehut.rake +4 -1
  163. metadata +64 -15
  164. data/doc/contributors/dwim_dx.md +0 -366
  165. data/doc/contributors/examples_audit/p1_high.md +0 -21
  166. data/doc/contributors/examples_audit/p2_moderate.md +0 -81
  167. data/doc/contributors/examples_audit.md +0 -41
  168. data/doc/images/app_analytics.png +0 -0
  169. data/doc/images/app_custom_widget.png +0 -0
  170. data/doc/images/app_mouse_events.png +0 -0
  171. data/doc/images/widget_table_flex.png +0 -0
  172. data/lib/ratatui_ruby/session/autodoc.rb +0 -482
  173. data/lib/ratatui_ruby/session.rb +0 -178
  174. data/tasks/autodoc/inventory.rb +0 -63
  175. data/tasks/autodoc/notice.rb +0 -26
  176. data/tasks/autodoc/rbs.rb +0 -38
  177. data/tasks/autodoc/rdoc.rb +0 -45
@@ -1,482 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
4
- # SPDX-License-Identifier: AGPL-3.0-or-later
5
-
6
- # !!! DO NOT EDIT THIS FILE BY HAND !!!
7
- # This file is automatically generated by `rake autodoc:rdoc:session`.
8
- # Any changes will be overwritten.
9
-
10
- module RatatuiRuby
11
- class Session
12
- # == RatatuiRuby Delegates
13
- #
14
- # :method: _paragraph_line_count
15
- # :call-seq: _paragraph_line_count(*args, **kwargs, &block)
16
- #
17
- # Delegates to RatatuiRuby._paragraph_line_count.
18
- #
19
- # :method: _paragraph_line_width
20
- # :call-seq: _paragraph_line_width(*args, **kwargs, &block)
21
- #
22
- # Delegates to RatatuiRuby._paragraph_line_width.
23
- #
24
- # :method: _tabs_width
25
- # :call-seq: _tabs_width(*args, **kwargs, &block)
26
- #
27
- # Delegates to RatatuiRuby._tabs_width.
28
- #
29
- # :method: _text_width
30
- # :call-seq: _text_width(*args, **kwargs, &block)
31
- #
32
- # Delegates to RatatuiRuby._text_width.
33
- #
34
- # :method: clear_events
35
- # :call-seq: clear_events(*args, **kwargs, &block)
36
- #
37
- # Delegates to RatatuiRuby.clear_events.
38
- #
39
- # :method: draw
40
- # :call-seq: draw(*args, **kwargs, &block)
41
- #
42
- # Delegates to RatatuiRuby.draw.
43
- #
44
- # :method: experimental_warnings
45
- # :call-seq: experimental_warnings(*args, **kwargs, &block)
46
- #
47
- # Delegates to RatatuiRuby.experimental_warnings.
48
- #
49
- # :method: experimental_warnings=
50
- # :call-seq: experimental_warnings=(*args, **kwargs, &block)
51
- #
52
- # Delegates to RatatuiRuby.experimental_warnings=.
53
- #
54
- # :method: get_buffer_content
55
- # :call-seq: get_buffer_content(*args, **kwargs, &block)
56
- #
57
- # Delegates to RatatuiRuby.get_buffer_content.
58
- #
59
- # :method: get_cell_at
60
- # :call-seq: get_cell_at(*args, **kwargs, &block)
61
- #
62
- # Delegates to RatatuiRuby.get_cell_at.
63
- #
64
- # :method: get_cursor_position
65
- # :call-seq: get_cursor_position(*args, **kwargs, &block)
66
- #
67
- # Delegates to RatatuiRuby.get_cursor_position.
68
- #
69
- # :method: init_terminal
70
- # :call-seq: init_terminal(*args, **kwargs, &block)
71
- #
72
- # Delegates to RatatuiRuby.init_terminal.
73
- #
74
- # :method: init_test_terminal
75
- # :call-seq: init_test_terminal(*args, **kwargs, &block)
76
- #
77
- # Delegates to RatatuiRuby.init_test_terminal.
78
- #
79
- # :method: inject_test_event
80
- # :call-seq: inject_test_event(*args, **kwargs, &block)
81
- #
82
- # Delegates to RatatuiRuby.inject_test_event.
83
- #
84
- # :method: poll_event
85
- # :call-seq: poll_event(*args, **kwargs, &block)
86
- #
87
- # Delegates to RatatuiRuby.poll_event.
88
- #
89
- # :method: resize_terminal
90
- # :call-seq: resize_terminal(*args, **kwargs, &block)
91
- #
92
- # Delegates to RatatuiRuby.resize_terminal.
93
- #
94
- # :method: restore_terminal
95
- # :call-seq: restore_terminal(*args, **kwargs, &block)
96
- #
97
- # Delegates to RatatuiRuby.restore_terminal.
98
- #
99
- # :method: run
100
- # :call-seq: run(*args, **kwargs, &block)
101
- #
102
- # Delegates to RatatuiRuby.run.
103
- #
104
- # :method: warn_experimental_feature
105
- # :call-seq: warn_experimental_feature(*args, **kwargs, &block)
106
- #
107
- # Delegates to RatatuiRuby.warn_experimental_feature.
108
- #
109
- # == Widget Factories
110
- #
111
- # :method: axis
112
- # :call-seq: axis(*args, **kwargs, &block)
113
- #
114
- # Factory for RatatuiRuby::Axis.new.
115
- #
116
- # :method: bar_chart
117
- # :call-seq: bar_chart(*args, **kwargs, &block)
118
- #
119
- # Factory for RatatuiRuby::BarChart.new.
120
- #
121
- # :method: bar_chart_bar
122
- # :call-seq: bar_chart_bar(*args, **kwargs, &block)
123
- #
124
- # Factory for RatatuiRuby::BarChart::Bar.new.
125
- #
126
- # :method: bar_chart_bar_group
127
- # :call-seq: bar_chart_bar_group(*args, **kwargs, &block)
128
- #
129
- # Factory for RatatuiRuby::BarChart::BarGroup.new.
130
- #
131
- # :method: block
132
- # :call-seq: block(*args, **kwargs, &block)
133
- #
134
- # Factory for RatatuiRuby::Block.new.
135
- #
136
- # :method: calendar
137
- # :call-seq: calendar(*args, **kwargs, &block)
138
- #
139
- # Factory for RatatuiRuby::Calendar.new.
140
- #
141
- # :method: canvas
142
- # :call-seq: canvas(*args, **kwargs, &block)
143
- #
144
- # Factory for RatatuiRuby::Canvas.new.
145
- #
146
- # :method: cell
147
- # :call-seq: cell(*args, **kwargs, &block)
148
- #
149
- # Factory for RatatuiRuby::Cell.new.
150
- #
151
- # :method: cell_char
152
- # :call-seq: cell_char(*args, **kwargs, &block)
153
- #
154
- # Helper for RatatuiRuby::Cell.char.
155
- #
156
- # :method: cell_default
157
- # :call-seq: cell_default(*args, **kwargs, &block)
158
- #
159
- # Helper for RatatuiRuby::Cell.default.
160
- #
161
- # :method: cell_empty
162
- # :call-seq: cell_empty(*args, **kwargs, &block)
163
- #
164
- # Helper for RatatuiRuby::Cell.empty.
165
- #
166
- # :method: cell_symbol
167
- # :call-seq: cell_symbol(*args, **kwargs, &block)
168
- #
169
- # Helper for RatatuiRuby::Cell.symbol.
170
- #
171
- # :method: center
172
- # :call-seq: center(*args, **kwargs, &block)
173
- #
174
- # Factory for RatatuiRuby::Center.new.
175
- #
176
- # :method: chart
177
- # :call-seq: chart(*args, **kwargs, &block)
178
- #
179
- # Factory for RatatuiRuby::Chart.new.
180
- #
181
- # :method: clear
182
- # :call-seq: clear(*args, **kwargs, &block)
183
- #
184
- # Factory for RatatuiRuby::Clear.new.
185
- #
186
- # :method: constraint
187
- # :call-seq: constraint(*args, **kwargs, &block)
188
- #
189
- # Factory for RatatuiRuby::Constraint.new.
190
- #
191
- # :method: constraint_fill
192
- # :call-seq: constraint_fill(*args, **kwargs, &block)
193
- #
194
- # Helper for RatatuiRuby::Constraint.fill.
195
- #
196
- # :method: constraint_length
197
- # :call-seq: constraint_length(*args, **kwargs, &block)
198
- #
199
- # Helper for RatatuiRuby::Constraint.length.
200
- #
201
- # :method: constraint_max
202
- # :call-seq: constraint_max(*args, **kwargs, &block)
203
- #
204
- # Helper for RatatuiRuby::Constraint.max.
205
- #
206
- # :method: constraint_min
207
- # :call-seq: constraint_min(*args, **kwargs, &block)
208
- #
209
- # Helper for RatatuiRuby::Constraint.min.
210
- #
211
- # :method: constraint_percentage
212
- # :call-seq: constraint_percentage(*args, **kwargs, &block)
213
- #
214
- # Helper for RatatuiRuby::Constraint.percentage.
215
- #
216
- # :method: constraint_ratio
217
- # :call-seq: constraint_ratio(*args, **kwargs, &block)
218
- #
219
- # Helper for RatatuiRuby::Constraint.ratio.
220
- #
221
- # :method: cursor
222
- # :call-seq: cursor(*args, **kwargs, &block)
223
- #
224
- # Factory for RatatuiRuby::Cursor.new.
225
- #
226
- # :method: dataset
227
- # :call-seq: dataset(*args, **kwargs, &block)
228
- #
229
- # Factory for RatatuiRuby::Dataset.new.
230
- #
231
- # :method: draw_cell
232
- # :call-seq: draw_cell(*args, **kwargs, &block)
233
- #
234
- # Helper for RatatuiRuby::Draw.cell.
235
- #
236
- # :method: draw_string
237
- # :call-seq: draw_string(*args, **kwargs, &block)
238
- #
239
- # Helper for RatatuiRuby::Draw.string.
240
- #
241
- # :method: draw_cell_cmd
242
- # :call-seq: draw_cell_cmd(*args, **kwargs, &block)
243
- #
244
- # Factory for RatatuiRuby::Draw::CellCmd.new.
245
- #
246
- # :method: draw_string_cmd
247
- # :call-seq: draw_string_cmd(*args, **kwargs, &block)
248
- #
249
- # Factory for RatatuiRuby::Draw::StringCmd.new.
250
- #
251
- # :method: error
252
- # :call-seq: error(*args, **kwargs, &block)
253
- #
254
- # Factory for RatatuiRuby::Error.new.
255
- #
256
- # :method: error_safety
257
- # :call-seq: error_safety(*args, **kwargs, &block)
258
- #
259
- # Factory for RatatuiRuby::Error::Safety.new.
260
- #
261
- # :method: error_terminal
262
- # :call-seq: error_terminal(*args, **kwargs, &block)
263
- #
264
- # Factory for RatatuiRuby::Error::Terminal.new.
265
- #
266
- # :method: event
267
- # :call-seq: event(*args, **kwargs, &block)
268
- #
269
- # Factory for RatatuiRuby::Event.new.
270
- #
271
- # :method: event_focus_gained
272
- # :call-seq: event_focus_gained(*args, **kwargs, &block)
273
- #
274
- # Factory for RatatuiRuby::Event::FocusGained.new.
275
- #
276
- # :method: event_focus_lost
277
- # :call-seq: event_focus_lost(*args, **kwargs, &block)
278
- #
279
- # Factory for RatatuiRuby::Event::FocusLost.new.
280
- #
281
- # :method: event_key
282
- # :call-seq: event_key(*args, **kwargs, &block)
283
- #
284
- # Factory for RatatuiRuby::Event::Key.new.
285
- #
286
- # :method: event_mouse
287
- # :call-seq: event_mouse(*args, **kwargs, &block)
288
- #
289
- # Factory for RatatuiRuby::Event::Mouse.new.
290
- #
291
- # :method: event_none
292
- # :call-seq: event_none(*args, **kwargs, &block)
293
- #
294
- # Factory for RatatuiRuby::Event::None.new.
295
- #
296
- # :method: event_paste
297
- # :call-seq: event_paste(*args, **kwargs, &block)
298
- #
299
- # Factory for RatatuiRuby::Event::Paste.new.
300
- #
301
- # :method: event_resize
302
- # :call-seq: event_resize(*args, **kwargs, &block)
303
- #
304
- # Factory for RatatuiRuby::Event::Resize.new.
305
- #
306
- # :method: frame
307
- # :call-seq: frame(*args, **kwargs, &block)
308
- #
309
- # Factory for RatatuiRuby::Frame.new.
310
- #
311
- # :method: gauge
312
- # :call-seq: gauge(*args, **kwargs, &block)
313
- #
314
- # Factory for RatatuiRuby::Gauge.new.
315
- #
316
- # :method: layout
317
- # :call-seq: layout(*args, **kwargs, &block)
318
- #
319
- # Factory for RatatuiRuby::Layout.new.
320
- #
321
- # :method: layout_split
322
- # :call-seq: layout_split(*args, **kwargs, &block)
323
- #
324
- # Helper for RatatuiRuby::Layout.split.
325
- #
326
- # :method: line_chart
327
- # :call-seq: line_chart(*args, **kwargs, &block)
328
- #
329
- # Factory for RatatuiRuby::LineChart.new.
330
- #
331
- # :method: line_gauge
332
- # :call-seq: line_gauge(*args, **kwargs, &block)
333
- #
334
- # Factory for RatatuiRuby::LineGauge.new.
335
- #
336
- # :method: list
337
- # :call-seq: list(*args, **kwargs, &block)
338
- #
339
- # Factory for RatatuiRuby::List.new.
340
- #
341
- # :method: list_item
342
- # :call-seq: list_item(*args, **kwargs, &block)
343
- #
344
- # Factory for RatatuiRuby::ListItem.new.
345
- #
346
- # :method: list_state
347
- # :call-seq: list_state(*args, **kwargs, &block)
348
- #
349
- # Factory for RatatuiRuby::ListState.new.
350
- #
351
- # :method: list_state_new
352
- # :call-seq: list_state_new(*args, **kwargs, &block)
353
- #
354
- # Helper for RatatuiRuby::ListState.new.
355
- #
356
- # :method: overlay
357
- # :call-seq: overlay(*args, **kwargs, &block)
358
- #
359
- # Factory for RatatuiRuby::Overlay.new.
360
- #
361
- # :method: paragraph
362
- # :call-seq: paragraph(*args, **kwargs, &block)
363
- #
364
- # Factory for RatatuiRuby::Paragraph.new.
365
- #
366
- # :method: paragraph_new
367
- # :call-seq: paragraph_new(*args, **kwargs, &block)
368
- #
369
- # Helper for RatatuiRuby::Paragraph.new.
370
- #
371
- # :method: ratatui_logo
372
- # :call-seq: ratatui_logo(*args, **kwargs, &block)
373
- #
374
- # Factory for RatatuiRuby::RatatuiLogo.new.
375
- #
376
- # :method: ratatui_mascot
377
- # :call-seq: ratatui_mascot(*args, **kwargs, &block)
378
- #
379
- # Factory for RatatuiRuby::RatatuiMascot.new.
380
- #
381
- # :method: rect
382
- # :call-seq: rect(*args, **kwargs, &block)
383
- #
384
- # Factory for RatatuiRuby::Rect.new.
385
- #
386
- # :method: scrollbar
387
- # :call-seq: scrollbar(*args, **kwargs, &block)
388
- #
389
- # Factory for RatatuiRuby::Scrollbar.new.
390
- #
391
- # :method: scrollbar_state
392
- # :call-seq: scrollbar_state(*args, **kwargs, &block)
393
- #
394
- # Factory for RatatuiRuby::ScrollbarState.new.
395
- #
396
- # :method: scrollbar_state_new
397
- # :call-seq: scrollbar_state_new(*args, **kwargs, &block)
398
- #
399
- # Helper for RatatuiRuby::ScrollbarState.new.
400
- #
401
- # :method: shape_circle
402
- # :call-seq: shape_circle(*args, **kwargs, &block)
403
- #
404
- # Factory for RatatuiRuby::Shape::Circle.new.
405
- #
406
- # :method: shape_label
407
- # :call-seq: shape_label(*args, **kwargs, &block)
408
- #
409
- # Factory for RatatuiRuby::Shape::Label.new.
410
- #
411
- # :method: shape_line
412
- # :call-seq: shape_line(*args, **kwargs, &block)
413
- #
414
- # Factory for RatatuiRuby::Shape::Line.new.
415
- #
416
- # :method: shape_map
417
- # :call-seq: shape_map(*args, **kwargs, &block)
418
- #
419
- # Factory for RatatuiRuby::Shape::Map.new.
420
- #
421
- # :method: shape_point
422
- # :call-seq: shape_point(*args, **kwargs, &block)
423
- #
424
- # Factory for RatatuiRuby::Shape::Point.new.
425
- #
426
- # :method: shape_rectangle
427
- # :call-seq: shape_rectangle(*args, **kwargs, &block)
428
- #
429
- # Factory for RatatuiRuby::Shape::Rectangle.new.
430
- #
431
- # :method: sparkline
432
- # :call-seq: sparkline(*args, **kwargs, &block)
433
- #
434
- # Factory for RatatuiRuby::Sparkline.new.
435
- #
436
- # :method: style
437
- # :call-seq: style(*args, **kwargs, &block)
438
- #
439
- # Factory for RatatuiRuby::Style.new.
440
- #
441
- # :method: style_default
442
- # :call-seq: style_default(*args, **kwargs, &block)
443
- #
444
- # Helper for RatatuiRuby::Style.default.
445
- #
446
- # :method: table
447
- # :call-seq: table(*args, **kwargs, &block)
448
- #
449
- # Factory for RatatuiRuby::Table.new.
450
- #
451
- # :method: table_state
452
- # :call-seq: table_state(*args, **kwargs, &block)
453
- #
454
- # Factory for RatatuiRuby::TableState.new.
455
- #
456
- # :method: table_state_new
457
- # :call-seq: table_state_new(*args, **kwargs, &block)
458
- #
459
- # Helper for RatatuiRuby::TableState.new.
460
- #
461
- # :method: tabs
462
- # :call-seq: tabs(*args, **kwargs, &block)
463
- #
464
- # Factory for RatatuiRuby::Tabs.new.
465
- #
466
- # :method: text_width
467
- # :call-seq: text_width(*args, **kwargs, &block)
468
- #
469
- # Helper for RatatuiRuby::Text.width.
470
- #
471
- # :method: text_line
472
- # :call-seq: text_line(*args, **kwargs, &block)
473
- #
474
- # Factory for RatatuiRuby::Text::Line.new.
475
- #
476
- # :method: text_span
477
- # :call-seq: text_span(*args, **kwargs, &block)
478
- #
479
- # Factory for RatatuiRuby::Text::Span.new.
480
- #
481
- end
482
- end
@@ -1,178 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
4
- # SPDX-License-Identifier: AGPL-3.0-or-later
5
-
6
- module RatatuiRuby
7
- # Manages the terminal lifecycle and provides a concise API for the render loop.
8
- #
9
- # Writing a TUI loop involves repetitive boilerplate. You constantly instantiate widgets (<tt>RatatuiRuby::Paragraph.new</tt>) and call global methods (<tt>RatatuiRuby.draw</tt>). This is verbose and hard to read.
10
- #
11
- # The Session object simplifies this. It acts as a factory and a facade. It provides short helper methods for every widget and delegates core commands to the main module.
12
- #
13
- # Use it within <tt>RatatuiRuby.run</tt> to build your interface cleanly.
14
- #
15
- # == Thread/Ractor Safety
16
- #
17
- # Session is an *I/O handle*, not a data object. It has side effects (draw,
18
- # poll_event) and is intentionally *not* Ractor-shareable. Caching it in
19
- # instance variables (<tt>@tui = tui</tt>) during your application's run loop
20
- # is fine. However, do not include it in immutable TEA Models/Messages or
21
- # pass it to other Ractors.
22
- #
23
- # == Available Methods
24
- #
25
- # The session dynamically defines factory methods for all RatatuiRuby constants.
26
- #
27
- # * <tt>draw(node)</tt> -> Delegates to <tt>RatatuiRuby.draw</tt>
28
- # * <tt>poll_event</tt> -> Delegates to <tt>RatatuiRuby.poll_event</tt>
29
- #
30
- # === Widget Factories
31
- #
32
- # The session acts as a dynamic factory. It creates a helper method for **every** class defined in the `RatatuiRuby` module.
33
- #
34
- # **The Rule:**
35
- # To instantiate a class like `RatatuiRuby::SomeWidget`, call `tui.some_widget(...)`.
36
- #
37
- # **Common Examples:**
38
- # * <tt>paragraph(...)</tt> -> <tt>RatatuiRuby::Paragraph.new(...)</tt>
39
- # * <tt>block(...)</tt> -> <tt>RatatuiRuby::Block.new(...)</tt>
40
- # * <tt>layout(...)</tt> -> <tt>RatatuiRuby::Layout.new(...)</tt>
41
- # * <tt>list(...)</tt> -> <tt>RatatuiRuby::List.new(...)</tt>
42
- # * <tt>table(...)</tt> -> <tt>RatatuiRuby::Table.new(...)</tt>
43
- # * <tt>style(...)</tt> -> <tt>RatatuiRuby::Style.new(...)</tt>
44
- #
45
- # If a new class is added to the library, it is automatically available here.
46
- #
47
- # === Nested Helpers
48
- #
49
- # * <tt>text_span(...)</tt> -> <tt>RatatuiRuby::Text::Span.new(...)</tt>
50
- # * <tt>text_line(...)</tt> -> <tt>RatatuiRuby::Text::Line.new(...)</tt>
51
- # * <tt>text_width(string)</tt> -> <tt>RatatuiRuby::Text.width(string)</tt>
52
- #
53
- # === Examples
54
- #
55
- # ==== Basic Usage (Recommended)
56
- #
57
- # RatatuiRuby.run do |tui|
58
- # loop do
59
- # tui.draw \
60
- # tui.paragraph \
61
- # text: "Hello, Ratatui! Press 'q' to quit.",
62
- # alignment: :center,
63
- # block: tui.block(
64
- # title: "My Ruby TUI App",
65
- # borders: [:all],
66
- # border_color: "cyan"
67
- # )
68
- # event = tui.poll_event
69
- # break if event == "q" || event == :ctrl_c
70
- # end
71
- # end
72
- #
73
- # ==== Raw API (Verbose)
74
- #
75
- # RatatuiRuby.run do
76
- # loop do
77
- # RatatuiRuby.draw \
78
- # RatatuiRuby::Paragraph.new(
79
- # text: "Hello, Ratatui! Press 'q' to quit.",
80
- # alignment: :center,
81
- # block: RatatuiRuby::Block.new(
82
- # title: "My Ruby TUI App",
83
- # borders: [:all],
84
- # border_color: "cyan"
85
- # )
86
- # )
87
- # event = RatatuiRuby.poll_event
88
- # break if event == "q" || event == :ctrl_c
89
- # end
90
- # end
91
- #
92
- # ==== Mixed Usage (Flexible)
93
- #
94
- # RatatuiRuby.run do |tui|
95
- # loop do
96
- # RatatuiRuby.draw \
97
- # tui.paragraph \
98
- # text: "Hello, Ratatui! Press 'q' to quit.",
99
- # alignment: :center,
100
- # block: tui.block(
101
- # title: "My Ruby TUI App",
102
- # borders: [:all],
103
- # border_color: "cyan"
104
- # )
105
- # event = RatatuiRuby.poll_event
106
- # break if event == "q" || event == :ctrl_c
107
- # end
108
- # end
109
- class Session
110
- # Wrap methods directly
111
- RatatuiRuby.singleton_methods(false).each do |method_name|
112
- define_method(method_name) do |*args, **kwargs, &block|
113
- RatatuiRuby.public_send(method_name, *args, **kwargs, &block)
114
- end
115
- end
116
-
117
- # Wrap classes and modules as snake_case factories
118
- RatatuiRuby.constants.each do |const_name|
119
- next if const_name == :Buffer
120
-
121
- const = RatatuiRuby.const_get(const_name)
122
- next unless const.is_a?(Module) # Class is a Module, so this catches both
123
-
124
- # 1. Top-level factories (for Classes only)
125
- # e.g. RatatuiRuby::Paragraph -> tui.paragraph(...)
126
- if const.is_a?(Class)
127
- method_name = const_name.to_s
128
- .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
129
- .gsub(/([a-z\d])([A-Z])/, '\1_\2')
130
- .downcase
131
-
132
- define_method(method_name) do |*args, **kwargs, &block|
133
- const.new(*args, **kwargs, &block)
134
- end
135
- end
136
-
137
- # 2. Singleton Method Helpers (for both Classes and Modules)
138
- # e.g. Layout.split -> layout_split
139
- # e.g. Text.width -> text_width
140
- const.singleton_methods(false).each do |class_method|
141
- parent_prefix = const_name.to_s
142
- .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
143
- .gsub(/([a-z\d])([A-Z])/, '\1_\2')
144
- .downcase
145
-
146
- session_method_name = "#{parent_prefix}_#{class_method}"
147
-
148
- define_method(session_method_name) do |*args, **kwargs, &block|
149
- const.public_send(class_method, *args, **kwargs, &block)
150
- end
151
- end
152
-
153
- # 3. Nested Class Factories (for both Modules and Classes)
154
- # e.g. RatatuiRuby::Text::Span -> tui.text_span(...)
155
- # e.g. RatatuiRuby::Shape::Line -> tui.shape_line(...)
156
- const.constants.each do |child_name|
157
- child = const.const_get(child_name)
158
- next unless child.is_a?(Class)
159
-
160
- parent_prefix = const_name.to_s
161
- .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
162
- .gsub(/([a-z\d])([A-Z])/, '\1_\2')
163
- .downcase
164
-
165
- child_suffix = child_name.to_s
166
- .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
167
- .gsub(/([a-z\d])([A-Z])/, '\1_\2')
168
- .downcase
169
-
170
- method_name = "#{parent_prefix}_#{child_suffix}"
171
-
172
- define_method(method_name) do |*args, **kwargs, &block|
173
- child.new(*args, **kwargs, &block)
174
- end
175
- end
176
- end
177
- end
178
- end