ratatui_ruby 0.6.0 → 0.7.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 (171) 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 +35 -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/contributors/architectural_overhaul/chat_conversations.md +4952 -0
  12. data/doc/contributors/architectural_overhaul/implementation_plan.md +60 -0
  13. data/doc/contributors/architectural_overhaul/task.md +37 -0
  14. data/doc/contributors/design/ruby_frontend.md +277 -81
  15. data/doc/contributors/design/rust_backend.md +349 -55
  16. data/doc/contributors/developing_examples.md +5 -5
  17. data/doc/contributors/index.md +7 -5
  18. data/doc/contributors/v1.0.0_blockers.md +1729 -0
  19. data/doc/index.md +11 -6
  20. data/doc/interactive_design.md +2 -2
  21. data/doc/quickstart.md +66 -97
  22. data/doc/v0.7.0_migration.md +236 -0
  23. data/doc/why.md +93 -0
  24. data/examples/app_all_events/README.md +6 -4
  25. data/examples/app_all_events/app.rb +1 -1
  26. data/examples/app_all_events/model/app_model.rb +1 -1
  27. data/examples/app_all_events/model/msg.rb +1 -1
  28. data/examples/app_all_events/update.rb +1 -1
  29. data/examples/app_all_events/view/app_view.rb +1 -1
  30. data/examples/app_all_events/view/controls_view.rb +1 -1
  31. data/examples/app_all_events/view/counts_view.rb +1 -1
  32. data/examples/app_all_events/view/live_view.rb +1 -1
  33. data/examples/app_all_events/view/log_view.rb +1 -1
  34. data/examples/app_color_picker/README.md +7 -5
  35. data/examples/app_color_picker/app.rb +1 -1
  36. data/examples/app_login_form/README.md +2 -0
  37. data/examples/app_stateful_interaction/README.md +2 -0
  38. data/examples/app_stateful_interaction/app.rb +1 -1
  39. data/examples/verify_quickstart_dsl/README.md +4 -3
  40. data/examples/verify_quickstart_dsl/app.rb +1 -1
  41. data/examples/verify_quickstart_layout/README.md +1 -1
  42. data/examples/verify_quickstart_lifecycle/README.md +3 -3
  43. data/examples/verify_quickstart_lifecycle/app.rb +2 -2
  44. data/examples/verify_readme_usage/README.md +1 -1
  45. data/examples/widget_barchart_demo/README.md +2 -1
  46. data/examples/widget_block_demo/README.md +2 -0
  47. data/examples/widget_box_demo/README.md +3 -3
  48. data/examples/widget_calendar_demo/README.md +3 -3
  49. data/examples/widget_calendar_demo/app.rb +5 -1
  50. data/examples/widget_canvas_demo/README.md +3 -3
  51. data/examples/widget_cell_demo/README.md +3 -3
  52. data/examples/widget_center_demo/README.md +3 -3
  53. data/examples/widget_chart_demo/README.md +3 -3
  54. data/examples/widget_gauge_demo/README.md +3 -3
  55. data/examples/widget_layout_split/README.md +3 -3
  56. data/examples/widget_line_gauge_demo/README.md +3 -3
  57. data/examples/widget_list_demo/README.md +3 -3
  58. data/examples/widget_map_demo/README.md +3 -3
  59. data/examples/widget_map_demo/app.rb +2 -2
  60. data/examples/widget_overlay_demo/README.md +36 -0
  61. data/examples/widget_popup_demo/README.md +3 -3
  62. data/examples/widget_ratatui_logo_demo/README.md +3 -3
  63. data/examples/widget_ratatui_logo_demo/app.rb +1 -1
  64. data/examples/widget_ratatui_mascot_demo/README.md +3 -3
  65. data/examples/widget_rect/README.md +3 -3
  66. data/examples/widget_render/README.md +3 -3
  67. data/examples/widget_render/app.rb +3 -3
  68. data/examples/widget_rich_text/README.md +3 -3
  69. data/examples/widget_scroll_text/README.md +3 -3
  70. data/examples/widget_scrollbar_demo/README.md +3 -3
  71. data/examples/widget_sparkline_demo/README.md +3 -3
  72. data/examples/widget_style_colors/README.md +3 -3
  73. data/examples/widget_table_demo/README.md +3 -3
  74. data/examples/widget_table_demo/app.rb +19 -4
  75. data/examples/widget_tabs_demo/README.md +3 -3
  76. data/examples/widget_text_width/README.md +3 -3
  77. data/examples/widget_text_width/app.rb +8 -1
  78. data/ext/ratatui_ruby/Cargo.lock +1 -1
  79. data/ext/ratatui_ruby/Cargo.toml +1 -1
  80. data/ext/ratatui_ruby/src/frame.rs +6 -5
  81. data/ext/ratatui_ruby/src/lib.rs +3 -2
  82. data/ext/ratatui_ruby/src/rendering.rs +22 -21
  83. data/ext/ratatui_ruby/src/text.rs +12 -3
  84. data/ext/ratatui_ruby/src/widgets/canvas.rs +5 -5
  85. data/ext/ratatui_ruby/src/widgets/table.rs +81 -36
  86. data/lib/ratatui_ruby/buffer/cell.rb +168 -0
  87. data/lib/ratatui_ruby/buffer.rb +15 -0
  88. data/lib/ratatui_ruby/frame.rb +8 -8
  89. data/lib/ratatui_ruby/layout/constraint.rb +95 -0
  90. data/lib/ratatui_ruby/layout/layout.rb +106 -0
  91. data/lib/ratatui_ruby/layout/rect.rb +118 -0
  92. data/lib/ratatui_ruby/layout.rb +19 -0
  93. data/lib/ratatui_ruby/list_state.rb +2 -2
  94. data/lib/ratatui_ruby/schema/layout.rb +1 -1
  95. data/lib/ratatui_ruby/schema/row.rb +66 -0
  96. data/lib/ratatui_ruby/schema/table.rb +10 -10
  97. data/lib/ratatui_ruby/schema/text.rb +27 -2
  98. data/lib/ratatui_ruby/style/style.rb +81 -0
  99. data/lib/ratatui_ruby/style.rb +15 -0
  100. data/lib/ratatui_ruby/table_state.rb +1 -1
  101. data/lib/ratatui_ruby/test_helper/snapshot.rb +24 -0
  102. data/lib/ratatui_ruby/test_helper/style_assertions.rb +1 -1
  103. data/lib/ratatui_ruby/tui/buffer_factories.rb +20 -0
  104. data/lib/ratatui_ruby/tui/canvas_factories.rb +44 -0
  105. data/lib/ratatui_ruby/tui/core.rb +38 -0
  106. data/lib/ratatui_ruby/tui/layout_factories.rb +74 -0
  107. data/lib/ratatui_ruby/tui/state_factories.rb +33 -0
  108. data/lib/ratatui_ruby/tui/style_factories.rb +20 -0
  109. data/lib/ratatui_ruby/tui/text_factories.rb +44 -0
  110. data/lib/ratatui_ruby/tui/widget_factories.rb +195 -0
  111. data/lib/ratatui_ruby/tui.rb +75 -0
  112. data/lib/ratatui_ruby/version.rb +1 -1
  113. data/lib/ratatui_ruby/widgets/bar_chart/bar.rb +47 -0
  114. data/lib/ratatui_ruby/widgets/bar_chart/bar_group.rb +25 -0
  115. data/lib/ratatui_ruby/widgets/bar_chart.rb +239 -0
  116. data/lib/ratatui_ruby/widgets/block.rb +192 -0
  117. data/lib/ratatui_ruby/widgets/calendar.rb +84 -0
  118. data/lib/ratatui_ruby/widgets/canvas.rb +231 -0
  119. data/lib/ratatui_ruby/widgets/cell.rb +47 -0
  120. data/lib/ratatui_ruby/widgets/center.rb +59 -0
  121. data/lib/ratatui_ruby/widgets/chart.rb +185 -0
  122. data/lib/ratatui_ruby/widgets/clear.rb +54 -0
  123. data/lib/ratatui_ruby/widgets/cursor.rb +42 -0
  124. data/lib/ratatui_ruby/widgets/gauge.rb +72 -0
  125. data/lib/ratatui_ruby/widgets/line_gauge.rb +80 -0
  126. data/lib/ratatui_ruby/widgets/list.rb +127 -0
  127. data/lib/ratatui_ruby/widgets/list_item.rb +43 -0
  128. data/lib/ratatui_ruby/widgets/overlay.rb +43 -0
  129. data/lib/ratatui_ruby/widgets/paragraph.rb +99 -0
  130. data/lib/ratatui_ruby/widgets/ratatui_logo.rb +31 -0
  131. data/lib/ratatui_ruby/widgets/ratatui_mascot.rb +36 -0
  132. data/lib/ratatui_ruby/widgets/row.rb +68 -0
  133. data/lib/ratatui_ruby/widgets/scrollbar.rb +143 -0
  134. data/lib/ratatui_ruby/widgets/shape/label.rb +68 -0
  135. data/lib/ratatui_ruby/widgets/sparkline.rb +134 -0
  136. data/lib/ratatui_ruby/widgets/table.rb +141 -0
  137. data/lib/ratatui_ruby/widgets/tabs.rb +85 -0
  138. data/lib/ratatui_ruby/widgets.rb +40 -0
  139. data/lib/ratatui_ruby.rb +23 -39
  140. data/sig/examples/app_all_events/view.rbs +1 -1
  141. data/sig/examples/app_all_events/view_state.rbs +1 -1
  142. data/sig/ratatui_ruby/schema/row.rbs +22 -0
  143. data/sig/ratatui_ruby/schema/table.rbs +1 -1
  144. data/sig/ratatui_ruby/schema/text.rbs +1 -0
  145. data/sig/ratatui_ruby/session.rbs +29 -49
  146. data/sig/ratatui_ruby/tui/buffer_factories.rbs +10 -0
  147. data/sig/ratatui_ruby/tui/canvas_factories.rbs +14 -0
  148. data/sig/ratatui_ruby/tui/core.rbs +14 -0
  149. data/sig/ratatui_ruby/tui/layout_factories.rbs +19 -0
  150. data/sig/ratatui_ruby/tui/state_factories.rbs +12 -0
  151. data/sig/ratatui_ruby/tui/style_factories.rbs +10 -0
  152. data/sig/ratatui_ruby/tui/text_factories.rbs +14 -0
  153. data/sig/ratatui_ruby/tui/widget_factories.rbs +39 -0
  154. data/sig/ratatui_ruby/tui.rbs +19 -0
  155. data/tasks/autodoc.rake +1 -35
  156. data/tasks/sourcehut.rake +4 -1
  157. metadata +62 -15
  158. data/doc/contributors/dwim_dx.md +0 -366
  159. data/doc/contributors/examples_audit/p1_high.md +0 -21
  160. data/doc/contributors/examples_audit/p2_moderate.md +0 -81
  161. data/doc/contributors/examples_audit.md +0 -41
  162. data/doc/images/app_analytics.png +0 -0
  163. data/doc/images/app_custom_widget.png +0 -0
  164. data/doc/images/app_mouse_events.png +0 -0
  165. data/doc/images/widget_table_flex.png +0 -0
  166. data/lib/ratatui_ruby/session/autodoc.rb +0 -482
  167. data/lib/ratatui_ruby/session.rb +0 -178
  168. data/tasks/autodoc/inventory.rb +0 -63
  169. data/tasks/autodoc/notice.rb +0 -26
  170. data/tasks/autodoc/rbs.rb +0 -38
  171. data/tasks/autodoc/rdoc.rb +0 -45
@@ -9,7 +9,7 @@ require_relative "model/event_entry"
9
9
  require_relative "model/timestamp"
10
10
  require_relative "model/event_color_cycle"
11
11
 
12
- # Pure update function for the Proto-TEA architecture.
12
+ # Pure update function for the Model-View-Update architecture.
13
13
  #
14
14
  # Given a Msg and the current AppModel, returns the next AppModel.
15
15
  # This function is pure: it does not mutate arguments, draw to the screen,
@@ -36,7 +36,7 @@ class View::App
36
36
  # [model] AppModel containing all application data.
37
37
  # [tui] RatatuiRuby instance.
38
38
  # [frame] RatatuiRuby::Frame being rendered.
39
- # [area] RatatuiRuby::Rect defining the total available space.
39
+ # [area] RatatuiRuby::Layout::Rect defining the total available space.
40
40
  #
41
41
  # === Example
42
42
  #
@@ -24,7 +24,7 @@ class View::Controls
24
24
  # [model] AppModel (unused, included for consistent interface).
25
25
  # [tui] RatatuiRuby instance.
26
26
  # [frame] RatatuiRuby::Frame being rendered.
27
- # [area] RatatuiRuby::Rect defining the widget's bounds.
27
+ # [area] RatatuiRuby::Layout::Rect defining the widget's bounds.
28
28
  #
29
29
  # === Example
30
30
  #
@@ -18,7 +18,7 @@ class View::Counts
18
18
  # [model] AppModel containing event data.
19
19
  # [tui] RatatuiRuby instance.
20
20
  # [frame] RatatuiRuby::Frame being rendered.
21
- # [area] RatatuiRuby::Rect defining the widget's bounds.
21
+ # [area] RatatuiRuby::Layout::Rect defining the widget's bounds.
22
22
  def call(model, tui, frame, area)
23
23
  dimmed_style = tui.style(fg: :dark_gray)
24
24
  lit_style = tui.style(fg: :green, modifiers: [:bold])
@@ -24,7 +24,7 @@ class View::Live
24
24
  # [model] AppModel containing event data.
25
25
  # [tui] RatatuiRuby instance.
26
26
  # [frame] RatatuiRuby::Frame being rendered.
27
- # [area] RatatuiRuby::Rect defining the widget's bounds.
27
+ # [area] RatatuiRuby::Layout::Rect defining the widget's bounds.
28
28
  #
29
29
  # === Example
30
30
  #
@@ -19,7 +19,7 @@ class View::Log
19
19
  # [model] AppModel containing event data.
20
20
  # [tui] RatatuiRuby instance.
21
21
  # [frame] RatatuiRuby::Frame being rendered.
22
- # [area] RatatuiRuby::Rect defining the widget's bounds.
22
+ # [area] RatatuiRuby::Layout::Rect defining the widget's bounds.
23
23
  def call(model, tui, frame, area)
24
24
  dimmed_style = tui.style(fg: :dark_gray)
25
25
  border_color = model.focused ? :green : :gray
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # Color Picker Example
7
7
 
8
+ [![Color Picker](../../doc/images/app_color_picker.png)](app.rb)
9
+
8
10
  This example demonstrates how to build a **Feature-Rich Interactive Application** using `ratatui_ruby`.
9
11
 
10
12
  It goes beyond simple widgets to show a complete, real-world architecture for handling:
@@ -13,7 +15,7 @@ It goes beyond simple widgets to show a complete, real-world architecture for ha
13
15
  - **Dynamic Layouts**
14
16
  - **Modal Dialogs**
15
17
 
16
- ## Architecture: The "Proto-Kit" Pattern (Component-Based)
18
+ ## Architecture: Component-Based
17
19
 
18
20
  This app uses a **Strict Component-Based Architecture** where every UI element encapsulates its own **Rendering**, **State**, and **Event Handling**.
19
21
 
@@ -119,16 +121,16 @@ ruby examples/app_color_picker/app.rb
119
121
 
120
122
  Complex applications require structured state habits. This Color Picker and the [App All Events](../app_all_events/README.md) example demonstrate two different approaches.
121
123
 
122
- ### The Tool Approach (Color Picker - Proto-Kit)
124
+ ### The Tool Approach (Color Picker)
123
125
 
124
126
  Tools require interaction. Users click buttons and drag sliders. Components need to know where they exist on screen for hit testing. The Container orchestrates cross-component effects.
125
127
 
126
- This example uses the **Proto-Kit (Component-Based)** pattern. Each component owns its own state, rendering, and event handling. The Container routes events and mediates communication.
128
+ This example uses a **Component-Based** pattern. Each component owns its own state, rendering, and event handling. The Container routes events and mediates communication.
127
129
 
128
130
  Use this pattern for forms, editors, and mouse-driven tools.
129
131
 
130
- ### The Dashboard Approach (AppAllEvents - Proto-TEA)
132
+ ### The Dashboard Approach (AppAllEvents)
131
133
 
132
- Dashboards display data. They rarely require complex mouse interaction. Proto-TEA (Model-View-Update) works best there. State is immutable. Logic is pure. Updates are predictable. This simplifies testing.
134
+ Dashboards display data. They rarely require complex mouse interaction. Model-View-Update works best there. State is immutable. Logic is pure. Updates are predictable. This simplifies testing.
133
135
 
134
136
  Use that pattern for logs, monitors, and data viewers.
@@ -19,7 +19,7 @@ require_relative "main_container"
19
19
  #
20
20
  # === Architecture
21
21
  #
22
- # This example uses the Proto-Kit (Component-Based) pattern:
22
+ # This example uses a Component-Based pattern:
23
23
  # - **Components**: Self-contained UI elements with `render`, `handle_event`, and optional `tick`
24
24
  # - **Container**: Owns layout, delegates to children, routes events via Chain of Responsibility
25
25
  # - **Mediator**: Container interprets symbolic signals (`:consumed`, `:submitted`) for cross-component effects
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # Login Form Example
7
7
 
8
+ [![Login Form](../../doc/images/app_login_form.png)](app.rb)
9
+
8
10
  Demonstrates how to create a modal overlay for user input.
9
11
 
10
12
  Many applications need to block interaction with the main UI while collecting specific information, like a login prompt or confirmation dialog. Managing the z-index and input focus for these overlays can be tricky.
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # Stateful Interaction Example
7
7
 
8
+ [![Stateful Interaction](../../doc/images/app_stateful_interaction.png)](app.rb)
9
+
8
10
  This example demonstrates High-Fidelity Interaction using **Stateful Widget Rendering**.
9
11
 
10
12
  It showcases a "Database Viewer" layout where:
@@ -161,7 +161,7 @@ class AppStatefulInteraction
161
161
  borders: [:all],
162
162
  border_style: is_active ? @style_active : @style_inactive
163
163
  ),
164
- highlight_style: @style_highlight
164
+ row_highlight_style: @style_highlight
165
165
  )
166
166
 
167
167
  frame.render_stateful_widget(table, area, @table_state)
@@ -5,14 +5,15 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # Quickstart DSL Verification
7
7
 
8
- Verifies the "Idiomatic Session" tutorial in the [Quickstart](../../doc/quickstart.md#idiomatic-session).
8
+ Verifies the "Simplified API" tutorial in the [Quickstart](../../doc/quickstart.md#simplified-api).
9
9
 
10
- This example exists as a documentation regression test. It ensures the recommended DSL and session-based workflow remains functional.
10
+ This example exists as a documentation regression test. It ensures the recommended TUI facade and managed lifecycle workflow remains functional.
11
11
 
12
12
  ## Usage
13
13
 
14
14
  <!-- SYNC:START:app.rb:main -->
15
15
  ```ruby
16
+ # 1. Initialize the terminal, start the run loop, and ensure the terminal is restored.
16
17
  RatatuiRuby.run do |tui|
17
18
  loop do
18
19
  # 2. Create your UI with methods instead of classes.
@@ -45,4 +46,4 @@ end
45
46
  ```
46
47
  <!-- SYNC:END -->
47
48
 
48
- ![verify_quickstart_dsl](../../doc/images/verify_quickstart_dsl.png)
49
+ [![verify_quickstart_dsl](../../doc/images/verify_quickstart_dsl.png)](../../doc/quickstart.md#simplified-api)
@@ -9,8 +9,8 @@ require "ratatui_ruby"
9
9
 
10
10
  class VerifyQuickstartDsl
11
11
  def run
12
- # 1. Initialize the terminal, start the run loop, and ensure the terminal is restored.
13
12
  # [SYNC:START:main]
13
+ # 1. Initialize the terminal, start the run loop, and ensure the terminal is restored.
14
14
  RatatuiRuby.run do |tui|
15
15
  loop do
16
16
  # 2. Create your UI with methods instead of classes.
@@ -68,4 +68,4 @@ end
68
68
  ```
69
69
  <!-- SYNC:END -->
70
70
 
71
- ![verify_quickstart_layout](../../doc/images/verify_quickstart_layout.png)
71
+ [![verify_quickstart_layout](../../doc/images/verify_quickstart_layout.png)](../../doc/quickstart.md#adding-layouts)
@@ -21,10 +21,10 @@ begin
21
21
  loop do
22
22
  # 2. Create your UI (Immediate Mode)
23
23
  # We define a Paragraph widget inside a Block with a title and borders.
24
- view = RatatuiRuby::Paragraph.new(
24
+ view = RatatuiRuby::Widgets::Paragraph.new(
25
25
  text: "Hello, Ratatui! Press 'q' to quit.",
26
26
  alignment: :center,
27
- block: RatatuiRuby::Block.new(
27
+ block: RatatuiRuby::Widgets::Block.new(
28
28
  title: "My Ruby TUI App",
29
29
  title_alignment: :center,
30
30
  borders: [:all],
@@ -53,4 +53,4 @@ end
53
53
  ```
54
54
  <!-- SYNC:END -->
55
55
 
56
- ![verify_quickstart_lifecycle](../../doc/images/verify_quickstart_lifecycle.png)
56
+ [![verify_quickstart_lifecycle](../../doc/images/verify_quickstart_lifecycle.png)](../../doc/quickstart.md#basic-application)
@@ -18,10 +18,10 @@ class VerifyQuickstartLifecycle
18
18
  loop do
19
19
  # 2. Create your UI (Immediate Mode)
20
20
  # We define a Paragraph widget inside a Block with a title and borders.
21
- view = RatatuiRuby::Paragraph.new(
21
+ view = RatatuiRuby::Widgets::Paragraph.new(
22
22
  text: "Hello, Ratatui! Press 'q' to quit.",
23
23
  alignment: :center,
24
- block: RatatuiRuby::Block.new(
24
+ block: RatatuiRuby::Widgets::Block.new(
25
25
  title: "My Ruby TUI App",
26
26
  title_alignment: :center,
27
27
  borders: [:all],
@@ -40,4 +40,4 @@ end
40
40
  ```
41
41
  <!-- SYNC:END -->
42
42
 
43
- ![verify_readme_usage](../../doc/images/verify_readme_usage.png)
43
+ [![verify_readme_usage](../../doc/images/verify_readme_usage.png)](../../README.md#usage)
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # BarChart Widget Example
7
7
 
8
+ [![BarChart Demo](../../doc/images/widget_barchart_demo.png)](app.rb)
9
+
8
10
  Visualizes categorical data with interactive attribute cycling.
9
11
 
10
12
  Comparing magnitudes in raw tables requires mental arithmetic. Bar charts make these comparisons instant and intuitive.
@@ -46,4 +48,3 @@ Use this example if you need to...
46
48
  - Create "stats" dashboards with compact visualizations.
47
49
  - Understand how `RatatuiRuby::BarChart` handles different data structures.
48
50
 
49
- ![Demo](/doc/images/widget_barchart_demo.png)
@@ -4,6 +4,8 @@
4
4
  -->
5
5
  # Block Widget Demo
6
6
 
7
+ [![Block Demo](../../doc/images/widget_block_demo.png)](app.rb)
8
+
7
9
  This example demonstrates the versatile `Block` widget, which provides the visual container, borders, and titles for almost every other widget in `ratatui_ruby`.
8
10
 
9
11
  ## Key Concepts
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # Box (Block) Widget Example
7
7
 
8
+ [![widget_box_demo](../../doc/images/widget_box_demo.png)](app.rb)
9
+
8
10
  Demonstrates visual container attributes with interactive cycling.
9
11
 
10
12
  Widgets often float in a void. Without boundaries, interfaces become a chaotic mess of text. `Block` (often called a Box) provides the structure and visual hierarchy needed to organize information.
@@ -40,6 +42,4 @@ Use this example if you need to...
40
42
  - Group related widgets together.
41
43
  - Create distinct "panels" or "cards" in your UI.
42
44
  - Style borders to indicate state (e.g., Red border for error state).
43
- - Understand the difference between `style` (content) and `border_style` (frame).
44
-
45
- ![Demo](/doc/images/widget_box_demo.png)
45
+ - Understand the difference between `style` (content) and `border_style` (frame).
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # Calendar Widget Example
7
7
 
8
+ [![widget_calendar_demo](../../doc/images/widget_calendar_demo.png)](app.rb)
9
+
8
10
  Demonstrates a monthly calendar with customizable headers and event highlighting.
9
11
 
10
12
  Rendering dates in a grid involves complex calculations for leap years and weekday offsets. This widget handles that logic, letting you focus on displaying dates.
@@ -34,6 +36,4 @@ ruby examples/widget_calendar_demo/app.rb
34
36
  Use this example if you need to...
35
37
  - Display a date picker.
36
38
  - Show a schedule or timeline view.
37
- - Highlight specific dates (deadlines, holidays) on a calendar grid.
38
-
39
- ![Demo](/doc/images/widget_calendar_demo.png)
39
+ - Highlight specific dates (deadlines, holidays) on a calendar grid.
@@ -23,6 +23,10 @@ require "ratatui_ruby"
23
23
  #
24
24
  # rdoc-image:/doc/images/widget_calendar_demo.png
25
25
  class WidgetCalendarDemo
26
+ def initialize(date: nil)
27
+ @date = date
28
+ end
29
+
26
30
  def run
27
31
  RatatuiRuby.run do |tui|
28
32
  show_header = true
@@ -32,7 +36,7 @@ class WidgetCalendarDemo
32
36
  hotkey_style = tui.style(modifiers: [:bold])
33
37
 
34
38
  loop do
35
- now = Time.now
39
+ now = @date || Time.now
36
40
  surrounding_style = show_surrounding ? tui.style(fg: "gray", modifiers: [:dim]) : nil
37
41
 
38
42
  events_map = if show_events
@@ -1,4 +1,7 @@
1
1
  # Canvas Widget Demo
2
+
3
+ [![widget_canvas_demo](../../doc/images/widget_canvas_demo.png)](app.rb)
4
+
2
5
  <!--
3
6
  SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
4
7
  SPDX-License-Identifier: CC-BY-SA-4.0
@@ -19,9 +22,6 @@ This example demonstrates the `Canvas` widget, which provides a high-resolution
19
22
  | `q` | Quit |
20
23
 
21
24
  ## Screenshot
22
-
23
- ![Screenshot of Canvas Widget Demo](../../doc/images/widget_canvas_demo.png)
24
-
25
25
  ## Source Code
26
26
 
27
27
  - [app.rb](app.rb)
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # Cell Widget Example
7
7
 
8
+ [![widget_cell_demo](../../doc/images/widget_cell_demo.png)](app.rb)
9
+
8
10
  Demonstrates using `Cell` objects for granular control over individual character grid units.
9
11
 
10
12
  Sometimes you need to render specific characters with unique styles outside of standard widgets. The `Cell` primitive allows you to build custom widgets or inject styled content into Tables.
@@ -31,6 +33,4 @@ ruby examples/widget_cell_demo/app.rb
31
33
  Use this example if you need to...
32
34
  - Create a custom widget (like a game board or specialized graph).
33
35
  - Style specific cells in a Table (e.g., Green "OK", Red "FAIL").
34
- - Understand how to position content precisely with `Cell`.
35
-
36
- ![Demo](/doc/images/widget_cell_demo.png)
36
+ - Understand how to position content precisely with `Cell`.
@@ -1,4 +1,7 @@
1
1
  # Center Widget Demo
2
+
3
+ [![widget_center_demo](../../doc/images/widget_center_demo.png)](app.rb)
4
+
2
5
  <!--
3
6
  SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
4
7
  SPDX-License-Identifier: CC-BY-SA-4.0
@@ -21,9 +24,6 @@ This example demonstrates the `Center` widget, which positions a child widget in
21
24
  | `q` | Quit |
22
25
 
23
26
  ## Screenshot
24
-
25
- ![Screenshot of Center Widget Demo](../../doc/images/widget_center_demo.png)
26
-
27
27
  ## Source Code
28
28
 
29
29
  - [app.rb](app.rb)
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # Chart Widget Example
7
7
 
8
+ [![widget_chart_demo](../../doc/images/widget_chart_demo.png)](app.rb)
9
+
8
10
  Demonstrates Cartesian plotting with interactive styling and configuration.
9
11
 
10
12
  Trends and patterns are invisible in raw logs. Charts visualize X/Y datasets to reveal the story behind the data.
@@ -36,6 +38,4 @@ ruby examples/widget_chart_demo/app.rb
36
38
  Use this example if you need to...
37
39
  - Plot real-time data monitoring (CPU history, request latency).
38
40
  - Visualize mathematical functions.
39
- - Compare multiple datasets on the same axis.
40
-
41
- ![Demo](/doc/images/widget_chart_demo.png)
41
+ - Compare multiple datasets on the same axis.
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # Gauge Widget Example
7
7
 
8
+ [![widget_gauge_demo](../../doc/images/widget_gauge_demo.png)](app.rb)
9
+
8
10
  Demonstrates progress bars with interactive configuration.
9
11
 
10
12
  Long-running tasks create anxiety. Users need to know the system is working. Gauges provide visual feedback on completion status.
@@ -36,6 +38,4 @@ ruby examples/widget_gauge_demo/app.rb
36
38
  Use this example if you need to...
37
39
  - Show download or upload progress.
38
40
  - Visualize resource quotas (disk space, memory usage).
39
- - Create "health bars" or status indicators.
40
-
41
- ![Demo](/doc/images/widget_gauge_demo.png)
41
+ - Create "health bars" or status indicators.
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # Layout Split Example
7
7
 
8
+ [![widget_layout_split](../../doc/images/widget_layout_split.png)](app.rb)
9
+
8
10
  Demonstrates dynamic geometry management with constraints and flex modes.
9
11
 
10
12
  Terminal screens vary in size. Hardcoded layouts break. `Layout.split` manages space dynamically, ensuring your interface adapts to any window dimension.
@@ -39,6 +41,4 @@ Use this example if you need to...
39
41
  - Build responsive dashboards.
40
42
  - Create 3-column layouts where the middle content fills remaining space.
41
43
  - Center a modal dialog on the screen.
42
- - Distribute buttons evenly across a control bar.
43
-
44
- ![Demo](/doc/images/widget_layout_split.png)
44
+ - Distribute buttons evenly across a control bar.
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # Line Gauge Widget Example
7
7
 
8
+ [![widget_line_gauge_demo](../../doc/images/widget_line_gauge_demo.png)](app.rb)
9
+
8
10
  Demonstrates compact progress bars for constrained spaces.
9
11
 
10
12
  Standard block gauges take up vertical space. Sometimes you only have one line to show status. The `LineGauge` provides a compact, high-density progress indicator.
@@ -36,6 +38,4 @@ ruby examples/widget_line_gauge_demo/app.rb
36
38
  Use this example if you need to...
37
39
  - Add a progress bar to a list item or table row.
38
40
  - Create a status line at the bottom of the screen.
39
- - Show multiple metrics (CPU, RAM, Net) in a compact list.
40
-
41
- ![Demo](/doc/images/widget_line_gauge_demo.png)
41
+ - Show multiple metrics (CPU, RAM, Net) in a compact list.
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # List Widget Example
7
7
 
8
+ [![widget_list_demo](../../doc/images/widget_list_demo.png)](app.rb)
9
+
8
10
  Demonstrates a selectable list with extensive configuration options.
9
11
 
10
12
  Lists are the workhorse of terminal interfaces. Managing selection state, scrolling windows, and highlight styles logic is complex. The `List` widget handles all of this.
@@ -44,6 +46,4 @@ Use this example if you need to...
44
46
  - Create a file explorer.
45
47
  - Build a navigation menu.
46
48
  - Display a log where users can scroll back to read history.
47
- - Implement "infinite select" behaviors.
48
-
49
- ![Demo](/doc/images/widget_list_demo.png)
49
+ - Implement "infinite select" behaviors.
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # Canvas Widget Example
7
7
 
8
+ [![widget_map_demo](../../doc/images/widget_map_demo.png)](app.rb)
9
+
8
10
  Demonstrates drawing custom graphics and maps using the standard Braille and Block patterns.
9
11
 
10
12
  Standard widgets are great for text, but sometimes you need to draw. The `Canvas` widget gives you a high-resolution coordinate system (x, y) to render shapes, lines, and data visualizations that go beyond the grid.
@@ -34,6 +36,4 @@ ruby examples/widget_map_demo/app.rb
34
36
  Use this example if you need to...
35
37
  - Render geographic data (World, USA, Europe).
36
38
  - Overlay custom labels and markers on a map.
37
- - Animate visual elements on top of a static background.
38
-
39
- ![Demo](/doc/images/widget_map_demo.png)
39
+ - Animate visual elements on top of a static background.
@@ -8,14 +8,14 @@ require "ratatui_ruby"
8
8
 
9
9
  # An example of the Canvas widget showing a world map and animated shapes.
10
10
  class WidgetMapDemo
11
- include RatatuiRuby
11
+ include RatatuiRuby::Widgets
12
12
 
13
13
  COLORS = [:black, :blue, :white, nil].freeze
14
14
  MARKERS = [:braille, :half_block, :dot, :block, :bar, :quadrant, :sextant, :octant].freeze
15
15
 
16
16
  # Returns a Canvas view for the map demo with the given circle radius.
17
17
  #
18
- # +tui+:: The RatatuiRuby::Session instance.
18
+ # +tui+:: The RatatuiRuby::TUI instance.
19
19
  # +radius+:: The radius of the animated circle.
20
20
  # +marker+:: The marker type.
21
21
  # +background_color+:: The background color of the canvas.
@@ -0,0 +1,36 @@
1
+ <!--
2
+ SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
3
+ SPDX-License-Identifier: CC-BY-SA-4.0
4
+ -->
5
+ # Overlay Widget Demo
6
+
7
+ [![Overlay Demo](../../doc/images/widget_overlay_demo.png)](app.rb)
8
+
9
+ This example demonstrates the `Overlay` composition pattern for layering widgets with depth. Modals, notifications, and floating panels all require stacking widgets on top of each other.
10
+
11
+ ## Key Concepts
12
+
13
+ - **Layer Composition:** Rendering widgets in order creates visual depth — later renders appear "on top."
14
+ - **Clear Widget:** Using `tui.clear` before rendering a modal erases the background, preventing content bleed-through.
15
+ - **Dynamic Layer Control:** Toggle the number of visible overlay layers at runtime.
16
+ - **Layer Ordering:** Swap which overlay appears in front to demonstrate z-ordering.
17
+
18
+ ## Hotkeys
19
+
20
+ - `0`/`1`/`2`: Set number of visible overlay layers
21
+ - `space`: Swap overlay order (which modal is on top)
22
+ - `c`: Toggle Clear widget (on/off)
23
+ - `q`: Quit
24
+
25
+ ## Usage
26
+
27
+ ```bash
28
+ ruby examples/widget_overlay_demo/app.rb
29
+ ```
30
+
31
+ ## Learning Outcomes
32
+
33
+ Use this example if you need to...
34
+ - Build modal dialogs or confirmation popups.
35
+ - Layer notifications over existing content.
36
+ - Understand the Clear widget's role in opaque overlays.
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # Popup (Clear) Widget Example
7
7
 
8
+ [![widget_popup_demo](../../doc/images/widget_popup_demo.png)](app.rb)
9
+
8
10
  Demonstrates how to render opaque overlays on top of content.
9
11
 
10
12
  Terminal renders are additive. If you draw a new widget over an old one, the background colors might mix if not handled correctly. The `Clear` widget resets the area to default (usually transparent/black) to ensure a clean canvas for popups.
@@ -31,6 +33,4 @@ ruby examples/widget_popup_demo/app.rb
31
33
  Use this example if you need to...
32
34
  - Create a modal dialog (Confirm, Alert, Form).
33
35
  - Implement a dropdown menu that overlays other content.
34
- - Fix visual artifacts where old text shows through new widgets.
35
-
36
- ![Demo](/doc/images/widget_popup_demo.png)
36
+ - Fix visual artifacts where old text shows through new widgets.
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # Ratatui Logo Example
7
7
 
8
+ [![widget_ratatui_logo_demo](../../doc/images/widget_ratatui_logo_demo.png)](app.rb)
9
+
8
10
  Demonstrates branding with the official logo widget.
9
11
 
10
12
  A polished application often needs an "About" screen or a splash screen. This widget provides the standardized project branding.
@@ -29,6 +31,4 @@ ruby examples/widget_ratatui_logo_demo/app.rb
29
31
  Use this example if you need to...
30
32
  - Create a splash screen.
31
33
  - Add an "About" modal to your application.
32
- - See how to center a widget both vertically and horizontally.
33
-
34
- ![Demo](/doc/images/widget_ratatui_logo_demo.png)
34
+ - See how to center a widget both vertically and horizontally.
@@ -66,7 +66,7 @@ class WidgetRatatuiLogoDemo
66
66
  )
67
67
 
68
68
  # Main content: The Logo
69
- logo = RatatuiRuby::RatatuiLogo.new
69
+ logo = RatatuiRuby::Widgets::RatatuiLogo.new
70
70
  frame.render_widget(logo, h_center_layout[0])
71
71
 
72
72
  # Control Panel
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # Ratatui Mascot Example
7
7
 
8
+ [![widget_ratatui_mascot_demo](../../doc/images/widget_ratatui_mascot_demo.png)](app.rb)
9
+
8
10
  Demonstrates the project mascot widget for adding personality.
9
11
 
10
12
  Interfaces can feel clinical. A friendly mascot adds charm and brand identity to your terminal application.
@@ -29,6 +31,4 @@ ruby examples/widget_ratatui_mascot_demo/app.rb
29
31
 
30
32
  Use this example if you need to...
31
33
  - Add visual flair to your UI.
32
- - Create a friendly empty state or success screen.
33
-
34
- ![Demo](/doc/images/widget_ratatui_mascot_demo.png)
34
+ - Create a friendly empty state or success screen.
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # Rect (Geometry) Widget Example
7
7
 
8
+ [![widget_rect](../../doc/images/widget_rect.png)](app.rb)
9
+
8
10
  Demonstrates the Rect geometry primitive and hit-testing patterns.
9
11
 
10
12
  TUI layouts are composed of rectangles. Understanding how to manipulate `Rect` objects, reuse them from the layout phase, and use them for mouse interaction is critical for building interactive apps.
@@ -33,6 +35,4 @@ ruby examples/widget_rect/app.rb
33
35
  Use this example if you need to...
34
36
  - Handle mouse clicks on specific buttons or areas.
35
37
  - Create resizable panes (like a split pane in an IDE).
36
- - Debug layout issues by inspecting Rect coordinates.
37
-
38
- ![Demo](/doc/images/widget_rect.png)
38
+ - Debug layout issues by inspecting Rect coordinates.
@@ -5,6 +5,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0
5
5
 
6
6
  # Render (Custom Widget) Example
7
7
 
8
+ [![widget_render](../../doc/images/widget_render.png)](app.rb)
9
+
8
10
  Demonstrates how to build Custom Widgets using absolute coordinates.
9
11
 
10
12
  Sometimes standard widgets aren't enough. You need to draw custom shapes, games, or graphs. This example shows how to implement the `render(area)` contract to draw anything you want while respecting layout boundaries.
@@ -32,6 +34,4 @@ ruby examples/widget_render/app.rb
32
34
  Use this example if you need to...
33
35
  - Build a game (Snake, Tetris) inside the terminal.
34
36
  - Create a specialized visualization (Network topology graph).
35
- - Draw custom UI elements not provided by the library.
36
-
37
- ![Demo](/doc/images/widget_render.png)
37
+ - Draw custom UI elements not provided by the library.
@@ -21,7 +21,7 @@ class DiagonalWidget
21
21
  area.x + i,
22
22
  area.y + i,
23
23
  "\\",
24
- RatatuiRuby::Style.new(fg: :red, modifiers: [:bold])
24
+ RatatuiRuby::Style::Style.new(fg: :red, modifiers: [:bold])
25
25
  )
26
26
  end
27
27
  end
@@ -47,7 +47,7 @@ class CheckerboardWidget
47
47
  area.x + col,
48
48
  area.y + row,
49
49
  @char,
50
- RatatuiRuby::Style.new(fg: :cyan)
50
+ RatatuiRuby::Style::Style.new(fg: :cyan)
51
51
  )
52
52
  end
53
53
  end
@@ -63,7 +63,7 @@ end
63
63
  class BorderWidget
64
64
  def render(area)
65
65
  result = []
66
- style = RatatuiRuby::Style.new(fg: :green)
66
+ style = RatatuiRuby::Style::Style.new(fg: :green)
67
67
 
68
68
  # Top and bottom
69
69
  (0...area.width).each do |x| # rubocop:disable Lint/AmbiguousRange