ratatui_ruby 0.7.1 → 0.7.2
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.
- checksums.yaml +4 -4
- data/.builds/ruby-3.2.yml +1 -1
- data/.builds/ruby-3.3.yml +1 -1
- data/.builds/ruby-3.4.yml +1 -1
- data/.builds/ruby-4.0.0.yml +1 -1
- data/AGENTS.md +8 -1
- data/CHANGELOG.md +21 -0
- data/README.md +5 -5
- data/Rakefile +1 -1
- data/doc/{application_architecture.md → concepts/application_architecture.md} +30 -0
- data/doc/{event_handling.md → concepts/event_handling.md} +1 -1
- data/doc/contributors/auditing/parity.md +233 -0
- data/doc/contributors/developing_examples.md +3 -3
- data/doc/contributors/v1.0.0_blockers.md +8 -8
- data/doc/{quickstart.md → getting_started/quickstart.md} +26 -26
- data/doc/{why.md → getting_started/why.md} +1 -1
- data/doc/index.md +23 -9
- data/doc/{terminal_limitations.md → troubleshooting/terminal_limitations.md} +33 -0
- data/examples/app_all_events/README.md +1 -0
- data/examples/app_all_events/app.rb +2 -0
- data/examples/app_all_events/model/app_model.rb +2 -0
- data/examples/app_all_events/model/event_color_cycle.rb +2 -0
- data/examples/app_all_events/model/event_entry.rb +2 -0
- data/examples/app_all_events/model/msg.rb +2 -0
- data/examples/app_all_events/model/timestamp.rb +2 -0
- data/examples/app_all_events/update.rb +2 -0
- data/examples/app_all_events/view/app_view.rb +2 -0
- data/examples/app_all_events/view/controls_view.rb +2 -0
- data/examples/app_all_events/view/counts_view.rb +2 -0
- data/examples/app_all_events/view/live_view.rb +2 -0
- data/examples/app_all_events/view/log_view.rb +2 -0
- data/examples/app_all_events/view.rb +2 -0
- data/examples/app_color_picker/README.md +2 -0
- data/examples/app_color_picker/app.rb +2 -0
- data/examples/app_color_picker/clipboard.rb +2 -0
- data/examples/app_color_picker/color.rb +2 -0
- data/examples/app_color_picker/controls.rb +2 -0
- data/examples/app_color_picker/copy_dialog.rb +2 -0
- data/examples/app_color_picker/export_pane.rb +2 -0
- data/examples/app_color_picker/harmony.rb +2 -0
- data/examples/app_color_picker/input.rb +2 -0
- data/examples/app_color_picker/main_container.rb +2 -0
- data/examples/app_color_picker/palette.rb +2 -0
- data/examples/app_login_form/README.md +3 -0
- data/examples/app_login_form/app.rb +2 -0
- data/examples/app_stateful_interaction/README.md +2 -0
- data/examples/app_stateful_interaction/app.rb +2 -0
- data/examples/timeout_demo.rb +2 -0
- data/examples/verify_quickstart_dsl/README.md +2 -2
- data/examples/verify_quickstart_dsl/app.rb +2 -0
- data/examples/verify_quickstart_layout/README.md +2 -2
- data/examples/verify_quickstart_layout/app.rb +2 -0
- data/examples/verify_quickstart_lifecycle/README.md +2 -2
- data/examples/verify_quickstart_lifecycle/app.rb +2 -0
- data/examples/verify_readme_usage/app.rb +2 -0
- data/examples/{widget_barchart_demo → widget_barchart}/README.md +5 -3
- data/examples/{widget_barchart_demo → widget_barchart}/app.rb +7 -5
- data/examples/{widget_block_demo → widget_block}/README.md +5 -3
- data/examples/{widget_block_demo → widget_block}/app.rb +6 -4
- data/examples/{widget_box_demo → widget_box}/README.md +7 -4
- data/examples/{widget_box_demo → widget_box}/app.rb +7 -5
- data/examples/{widget_calendar_demo → widget_calendar}/README.md +6 -3
- data/examples/{widget_calendar_demo → widget_calendar}/app.rb +6 -4
- data/examples/{widget_canvas_demo → widget_canvas}/README.md +2 -2
- data/examples/{widget_canvas_demo → widget_canvas}/app.rb +6 -4
- data/examples/{widget_cell_demo → widget_cell}/README.md +6 -3
- data/examples/{widget_cell_demo → widget_cell}/app.rb +7 -5
- data/examples/{widget_center_demo → widget_center}/README.md +2 -2
- data/examples/{widget_center_demo → widget_center}/app.rb +6 -4
- data/examples/{widget_chart_demo → widget_chart}/README.md +7 -4
- data/examples/{widget_chart_demo → widget_chart}/app.rb +7 -5
- data/examples/{widget_gauge_demo → widget_gauge}/README.md +6 -3
- data/examples/{widget_gauge_demo → widget_gauge}/app.rb +7 -5
- data/examples/widget_layout_split/README.md +5 -2
- data/examples/widget_layout_split/app.rb +3 -1
- data/examples/{widget_line_gauge_demo → widget_line_gauge}/README.md +6 -3
- data/examples/{widget_line_gauge_demo → widget_line_gauge}/app.rb +7 -5
- data/examples/{widget_list_demo → widget_list}/README.md +7 -4
- data/examples/{widget_list_demo → widget_list}/app.rb +7 -5
- data/examples/{widget_map_demo → widget_map}/README.md +7 -4
- data/examples/{widget_map_demo → widget_map}/app.rb +4 -2
- data/examples/{widget_overlay_demo → widget_overlay}/README.md +6 -3
- data/examples/{widget_overlay_demo → widget_overlay}/app.rb +5 -3
- data/examples/{widget_popup_demo → widget_popup}/README.md +7 -4
- data/examples/{widget_popup_demo → widget_popup}/app.rb +6 -4
- data/examples/{widget_ratatui_logo_demo → widget_ratatui_logo}/README.md +6 -3
- data/examples/{widget_ratatui_logo_demo → widget_ratatui_logo}/app.rb +8 -6
- data/examples/{widget_ratatui_mascot_demo → widget_ratatui_mascot}/README.md +6 -3
- data/examples/{widget_ratatui_mascot_demo → widget_ratatui_mascot}/app.rb +6 -4
- data/examples/widget_rect/README.md +5 -2
- data/examples/widget_rect/app.rb +2 -0
- data/examples/widget_render/README.md +4 -1
- data/examples/widget_render/app.rb +2 -0
- data/examples/widget_rich_text/README.md +4 -1
- data/examples/widget_rich_text/app.rb +2 -0
- data/examples/widget_scroll_text/README.md +4 -1
- data/examples/widget_scroll_text/app.rb +3 -1
- data/examples/{widget_scrollbar_demo → widget_scrollbar}/README.md +7 -4
- data/examples/{widget_scrollbar_demo → widget_scrollbar}/app.rb +6 -4
- data/examples/{widget_sparkline_demo → widget_sparkline}/README.md +6 -3
- data/examples/{widget_sparkline_demo → widget_sparkline}/app.rb +7 -5
- data/examples/widget_style_colors/README.md +4 -1
- data/examples/widget_style_colors/app.rb +2 -0
- data/examples/{widget_table_demo → widget_table}/README.md +7 -4
- data/examples/{widget_table_demo → widget_table}/app.rb +4 -2
- data/examples/{widget_tabs_demo → widget_tabs}/README.md +6 -3
- data/examples/{widget_tabs_demo → widget_tabs}/app.rb +7 -5
- data/examples/widget_text_width/README.md +5 -2
- data/examples/widget_text_width/app.rb +2 -0
- data/exe/.gitkeep +0 -0
- data/ext/ratatui_ruby/Cargo.lock +1 -1
- data/ext/ratatui_ruby/Cargo.toml +1 -1
- data/ext/ratatui_ruby/extconf.rb +2 -0
- data/ext/ratatui_ruby/src/widgets/barchart.rs +8 -6
- data/ext/ratatui_ruby/src/widgets/chart.rs +26 -4
- data/ext/ratatui_ruby/src/widgets/table.rs +13 -5
- data/ext/ratatui_ruby/src/widgets/tabs.rs +49 -9
- data/lib/ratatui_ruby/buffer/cell.rb +2 -0
- data/lib/ratatui_ruby/buffer.rb +2 -0
- data/lib/ratatui_ruby/cell.rb +2 -0
- data/lib/ratatui_ruby/event/focus_gained.rb +2 -0
- data/lib/ratatui_ruby/event/focus_lost.rb +2 -0
- data/lib/ratatui_ruby/event/key/character.rb +2 -0
- data/lib/ratatui_ruby/event/key/media.rb +2 -0
- data/lib/ratatui_ruby/event/key/modifier.rb +2 -0
- data/lib/ratatui_ruby/event/key/navigation.rb +2 -0
- data/lib/ratatui_ruby/event/key/system.rb +2 -0
- data/lib/ratatui_ruby/event/key.rb +2 -0
- data/lib/ratatui_ruby/event/mouse.rb +2 -0
- data/lib/ratatui_ruby/event/none.rb +2 -0
- data/lib/ratatui_ruby/event/paste.rb +2 -0
- data/lib/ratatui_ruby/event/resize.rb +2 -0
- data/lib/ratatui_ruby/event.rb +2 -0
- data/lib/ratatui_ruby/frame.rb +2 -0
- data/lib/ratatui_ruby/layout/constraint.rb +2 -0
- data/lib/ratatui_ruby/layout/layout.rb +2 -0
- data/lib/ratatui_ruby/layout/rect.rb +2 -0
- data/lib/ratatui_ruby/layout.rb +2 -0
- data/lib/ratatui_ruby/list_state.rb +2 -0
- data/lib/ratatui_ruby/schema/bar_chart/bar.rb +2 -0
- data/lib/ratatui_ruby/schema/bar_chart/bar_group.rb +2 -0
- data/lib/ratatui_ruby/schema/bar_chart.rb +4 -2
- data/lib/ratatui_ruby/schema/block.rb +4 -2
- data/lib/ratatui_ruby/schema/calendar.rb +4 -2
- data/lib/ratatui_ruby/schema/canvas.rb +2 -0
- data/lib/ratatui_ruby/schema/center.rb +2 -0
- data/lib/ratatui_ruby/schema/chart.rb +4 -2
- data/lib/ratatui_ruby/schema/clear.rb +2 -0
- data/lib/ratatui_ruby/schema/constraint.rb +2 -0
- data/lib/ratatui_ruby/schema/cursor.rb +2 -0
- data/lib/ratatui_ruby/schema/draw.rb +2 -0
- data/lib/ratatui_ruby/schema/gauge.rb +4 -2
- data/lib/ratatui_ruby/schema/layout.rb +2 -0
- data/lib/ratatui_ruby/schema/line_gauge.rb +4 -2
- data/lib/ratatui_ruby/schema/list.rb +3 -1
- data/lib/ratatui_ruby/schema/list_item.rb +2 -0
- data/lib/ratatui_ruby/schema/overlay.rb +2 -0
- data/lib/ratatui_ruby/schema/paragraph.rb +2 -0
- data/lib/ratatui_ruby/schema/ratatui_logo.rb +4 -2
- data/lib/ratatui_ruby/schema/ratatui_mascot.rb +4 -2
- data/lib/ratatui_ruby/schema/rect.rb +2 -0
- data/lib/ratatui_ruby/schema/row.rb +2 -0
- data/lib/ratatui_ruby/schema/scrollbar.rb +4 -2
- data/lib/ratatui_ruby/schema/shape/label.rb +2 -0
- data/lib/ratatui_ruby/schema/sparkline.rb +4 -2
- data/lib/ratatui_ruby/schema/style.rb +2 -0
- data/lib/ratatui_ruby/schema/table.rb +2 -0
- data/lib/ratatui_ruby/schema/tabs.rb +4 -2
- data/lib/ratatui_ruby/schema/text.rb +2 -0
- data/lib/ratatui_ruby/scrollbar_state.rb +2 -0
- data/lib/ratatui_ruby/style/style.rb +2 -0
- data/lib/ratatui_ruby/style.rb +2 -0
- data/lib/ratatui_ruby/table_state.rb +2 -0
- data/lib/ratatui_ruby/test_helper/event_injection.rb +2 -0
- data/lib/ratatui_ruby/test_helper/snapshot.rb +2 -0
- data/lib/ratatui_ruby/test_helper/style_assertions.rb +2 -0
- data/lib/ratatui_ruby/test_helper/terminal.rb +2 -0
- data/lib/ratatui_ruby/test_helper/test_doubles.rb +2 -0
- data/lib/ratatui_ruby/test_helper.rb +5 -3
- data/lib/ratatui_ruby/tui/buffer_factories.rb +2 -0
- data/lib/ratatui_ruby/tui/canvas_factories.rb +2 -0
- data/lib/ratatui_ruby/tui/core.rb +2 -0
- data/lib/ratatui_ruby/tui/layout_factories.rb +2 -0
- data/lib/ratatui_ruby/tui/state_factories.rb +2 -0
- data/lib/ratatui_ruby/tui/style_factories.rb +2 -0
- data/lib/ratatui_ruby/tui/text_factories.rb +2 -0
- data/lib/ratatui_ruby/tui/widget_factories.rb +2 -0
- data/lib/ratatui_ruby/tui.rb +2 -0
- data/lib/ratatui_ruby/version.rb +3 -1
- data/lib/ratatui_ruby/widgets/bar_chart/bar.rb +2 -0
- data/lib/ratatui_ruby/widgets/bar_chart/bar_group.rb +2 -0
- data/lib/ratatui_ruby/widgets/bar_chart.rb +4 -2
- data/lib/ratatui_ruby/widgets/block.rb +4 -2
- data/lib/ratatui_ruby/widgets/calendar.rb +4 -2
- data/lib/ratatui_ruby/widgets/canvas.rb +2 -0
- data/lib/ratatui_ruby/widgets/cell.rb +2 -0
- data/lib/ratatui_ruby/widgets/center.rb +2 -0
- data/lib/ratatui_ruby/widgets/chart.rb +4 -2
- data/lib/ratatui_ruby/widgets/clear.rb +2 -0
- data/lib/ratatui_ruby/widgets/cursor.rb +2 -0
- data/lib/ratatui_ruby/widgets/gauge.rb +4 -2
- data/lib/ratatui_ruby/widgets/line_gauge.rb +4 -2
- data/lib/ratatui_ruby/widgets/list.rb +3 -1
- data/lib/ratatui_ruby/widgets/list_item.rb +2 -0
- data/lib/ratatui_ruby/widgets/overlay.rb +2 -0
- data/lib/ratatui_ruby/widgets/paragraph.rb +2 -0
- data/lib/ratatui_ruby/widgets/ratatui_logo.rb +4 -2
- data/lib/ratatui_ruby/widgets/ratatui_mascot.rb +4 -2
- data/lib/ratatui_ruby/widgets/row.rb +2 -0
- data/lib/ratatui_ruby/widgets/scrollbar.rb +4 -2
- data/lib/ratatui_ruby/widgets/shape/label.rb +2 -0
- data/lib/ratatui_ruby/widgets/sparkline.rb +4 -2
- data/lib/ratatui_ruby/widgets/table.rb +2 -0
- data/lib/ratatui_ruby/widgets/tabs.rb +12 -8
- data/lib/ratatui_ruby/widgets.rb +2 -0
- data/lib/ratatui_ruby.rb +2 -0
- data/tasks/autodoc/examples.rb +2 -0
- data/tasks/autodoc/member.rb +2 -0
- data/tasks/autodoc/name.rb +2 -0
- data/tasks/autodoc.rake +2 -0
- data/tasks/bump/cargo_lockfile.rb +2 -0
- data/tasks/bump/changelog.rb +2 -0
- data/tasks/bump/header.rb +2 -0
- data/tasks/bump/history.rb +2 -0
- data/tasks/bump/links.rb +2 -0
- data/tasks/bump/manifest.rb +2 -0
- data/tasks/bump/ruby_gem.rb +2 -0
- data/tasks/bump/sem_ver.rb +2 -0
- data/tasks/bump/unreleased_section.rb +2 -0
- data/tasks/bump.rake +2 -0
- data/tasks/doc.rake +268 -0
- data/tasks/extension.rake +2 -0
- data/tasks/lint.rake +115 -0
- data/tasks/rdoc_config.rb +18 -4
- data/tasks/sourcehut.rake +2 -0
- data/tasks/terminal_preview/app_screenshot.rb +2 -0
- data/tasks/terminal_preview/crash_report.rb +2 -0
- data/tasks/terminal_preview/example_app.rb +2 -0
- data/tasks/terminal_preview/launcher_script.rb +2 -0
- data/tasks/terminal_preview/preview_collection.rb +2 -0
- data/tasks/terminal_preview/preview_timing.rb +2 -0
- data/tasks/terminal_preview/safety_confirmation.rb +2 -0
- data/tasks/terminal_preview/saved_screenshot.rb +2 -0
- data/tasks/terminal_preview/system_appearance.rb +2 -0
- data/tasks/terminal_preview/terminal_window.rb +2 -0
- data/tasks/terminal_preview/window_id.rb +2 -0
- data/tasks/terminal_preview.rake +2 -0
- data/tasks/test.rake +2 -0
- data/tasks/website/index_page.rb +2 -0
- data/tasks/website/version.rb +12 -2
- data/tasks/website/version_menu.rb +2 -0
- data/tasks/website/versioned_documentation.rb +2 -0
- data/tasks/website/website.rb +2 -0
- data/tasks/website.rake +2 -0
- metadata +72 -74
- data/doc/contributors/architectural_overhaul/chat_conversations.md +0 -4952
- data/doc/contributors/architectural_overhaul/implementation_plan.md +0 -60
- data/doc/contributors/architectural_overhaul/task.md +0 -37
- /data/doc/{application_testing.md → concepts/application_testing.md} +0 -0
- /data/doc/{async.md → concepts/async.md} +0 -0
- /data/doc/{interactive_design.md → concepts/interactive_design.md} +0 -0
- /data/doc/images/{widget_barchart_demo.png → widget_barchart.png} +0 -0
- /data/doc/images/{widget_block_demo.png → widget_block.png} +0 -0
- /data/doc/images/{widget_box_demo.png → widget_box.png} +0 -0
- /data/doc/images/{widget_calendar_demo.png → widget_calendar.png} +0 -0
- /data/doc/images/{widget_canvas_demo.png → widget_canvas.png} +0 -0
- /data/doc/images/{widget_cell_demo.png → widget_cell.png} +0 -0
- /data/doc/images/{widget_center_demo.png → widget_center.png} +0 -0
- /data/doc/images/{widget_chart_demo.png → widget_chart.png} +0 -0
- /data/doc/images/{widget_gauge_demo.png → widget_gauge.png} +0 -0
- /data/doc/images/{widget_line_gauge_demo.png → widget_line_gauge.png} +0 -0
- /data/doc/images/{widget_list_demo.png → widget_list.png} +0 -0
- /data/doc/images/{widget_map_demo.png → widget_map.png} +0 -0
- /data/doc/images/{widget_overlay_demo.png → widget_overlay.png} +0 -0
- /data/doc/images/{widget_popup_demo.png → widget_popup.png} +0 -0
- /data/doc/images/{widget_ratatui_logo_demo.png → widget_ratatui_logo.png} +0 -0
- /data/doc/images/{widget_ratatui_mascot_demo.png → widget_ratatui_mascot.png} +0 -0
- /data/doc/images/{widget_scrollbar_demo.png → widget_scrollbar.png} +0 -0
- /data/doc/images/{widget_sparkline_demo.png → widget_sparkline.png} +0 -0
- /data/doc/images/{widget_table_demo.png → widget_table.png} +0 -0
- /data/doc/images/{widget_tabs_demo.png → widget_tabs.png} +0 -0
- /data/doc/{v0.7.0_migration.md → migration/v0_7_0.md} +0 -0
- /data/doc/{debugging.md → troubleshooting/debugging.md} +0 -0
|
@@ -3,9 +3,9 @@ SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
|
3
3
|
SPDX-License-Identifier: CC-BY-SA-4.0
|
|
4
4
|
-->
|
|
5
5
|
|
|
6
|
-
# Popup
|
|
6
|
+
# Clear (Popup, Modal) Example
|
|
7
7
|
|
|
8
|
-
[](app.rb)
|
|
9
9
|
|
|
10
10
|
Demonstrates how to render opaque overlays on top of content.
|
|
11
11
|
|
|
@@ -25,12 +25,15 @@ Terminal renders are additive. If you draw a new widget over an old one, the bac
|
|
|
25
25
|
## Usage
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
ruby examples/
|
|
28
|
+
ruby examples/widget_popup/app.rb
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
## Learning Outcomes
|
|
32
32
|
|
|
33
33
|
Use this example if you need to...
|
|
34
|
+
|
|
34
35
|
- Create a modal dialog (Confirm, Alert, Form).
|
|
35
36
|
- Implement a dropdown menu that overlays other content.
|
|
36
|
-
- Fix visual artifacts where old text shows through new widgets.
|
|
37
|
+
- Fix visual artifacts where old text shows through new widgets.
|
|
38
|
+
|
|
39
|
+
[Read the source code →](app.rb)
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
#--
|
|
3
4
|
# SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
|
|
4
5
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
+
#++
|
|
5
7
|
|
|
6
8
|
$LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
|
|
7
9
|
require "ratatui_ruby"
|
|
8
10
|
|
|
9
|
-
# Popup
|
|
11
|
+
# Popup Example
|
|
10
12
|
# Demonstrates the Clear widget for creating opaque popups.
|
|
11
13
|
|
|
12
|
-
class
|
|
14
|
+
class WidgetPopup
|
|
13
15
|
def initialize
|
|
14
16
|
@clear_enabled = false
|
|
15
17
|
end
|
|
@@ -75,7 +77,7 @@ class WidgetPopupDemo
|
|
|
75
77
|
text: popup_text,
|
|
76
78
|
alignment: :center,
|
|
77
79
|
block: tui.block(
|
|
78
|
-
title: "Popup
|
|
80
|
+
title: "Popup (q to quit, space to toggle)",
|
|
79
81
|
borders: [:all]
|
|
80
82
|
)
|
|
81
83
|
)
|
|
@@ -101,4 +103,4 @@ class WidgetPopupDemo
|
|
|
101
103
|
end
|
|
102
104
|
end
|
|
103
105
|
|
|
104
|
-
|
|
106
|
+
WidgetPopup.new.run if __FILE__ == $0
|
|
@@ -5,7 +5,7 @@ SPDX-License-Identifier: CC-BY-SA-4.0
|
|
|
5
5
|
|
|
6
6
|
# Ratatui Logo Example
|
|
7
7
|
|
|
8
|
-
[](app.rb)
|
|
9
9
|
|
|
10
10
|
Demonstrates branding with the official logo widget.
|
|
11
11
|
|
|
@@ -23,12 +23,15 @@ A polished application often needs an "About" screen or a splash screen. This wi
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
|
-
ruby examples/
|
|
26
|
+
ruby examples/widget_ratatui_logo/app.rb
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
## Learning Outcomes
|
|
30
30
|
|
|
31
31
|
Use this example if you need to...
|
|
32
|
+
|
|
32
33
|
- Create a splash screen.
|
|
33
34
|
- Add an "About" modal to your application.
|
|
34
|
-
- See how to center a widget both vertically and horizontally.
|
|
35
|
+
- See how to center a widget both vertically and horizontally.
|
|
36
|
+
|
|
37
|
+
[Read the source code →](app.rb)
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
#--
|
|
1
4
|
# SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
|
|
2
5
|
#
|
|
3
6
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
|
-
|
|
5
|
-
# frozen_string_literal: true
|
|
7
|
+
#++
|
|
6
8
|
|
|
7
9
|
$LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
|
|
8
10
|
require "ratatui_ruby"
|
|
@@ -19,10 +21,10 @@ require "ratatui_ruby"
|
|
|
19
21
|
#
|
|
20
22
|
# Run the demo from the terminal:
|
|
21
23
|
#
|
|
22
|
-
# ruby examples/
|
|
24
|
+
# ruby examples/widget_ratatui_logo/app.rb
|
|
23
25
|
#
|
|
24
|
-
# rdoc-image:/doc/images/
|
|
25
|
-
class
|
|
26
|
+
# rdoc-image:/doc/images/widget_ratatui_logo.png
|
|
27
|
+
class WidgetRatatuiLogo
|
|
26
28
|
def run
|
|
27
29
|
RatatuiRuby.run do |tui|
|
|
28
30
|
loop do
|
|
@@ -100,4 +102,4 @@ class WidgetRatatuiLogoDemo
|
|
|
100
102
|
end
|
|
101
103
|
end
|
|
102
104
|
|
|
103
|
-
|
|
105
|
+
WidgetRatatuiLogo.new.run if __FILE__ == $0
|
|
@@ -5,7 +5,7 @@ SPDX-License-Identifier: CC-BY-SA-4.0
|
|
|
5
5
|
|
|
6
6
|
# Ratatui Mascot Example
|
|
7
7
|
|
|
8
|
-
[](app.rb)
|
|
9
9
|
|
|
10
10
|
Demonstrates the project mascot widget for adding personality.
|
|
11
11
|
|
|
@@ -24,11 +24,14 @@ Interfaces can feel clinical. A friendly mascot adds charm and brand identity to
|
|
|
24
24
|
## Usage
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
|
-
ruby examples/
|
|
27
|
+
ruby examples/widget_ratatui_mascot/app.rb
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
## Learning Outcomes
|
|
31
31
|
|
|
32
32
|
Use this example if you need to...
|
|
33
|
+
|
|
33
34
|
- Add visual flair to your UI.
|
|
34
|
-
- Create a friendly empty state or success screen.
|
|
35
|
+
- Create a friendly empty state or success screen.
|
|
36
|
+
|
|
37
|
+
[Read the source code →](app.rb)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
#--
|
|
3
4
|
# SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
|
|
4
5
|
# SPDX-License-Identifier: CC-BY-SA-4.0
|
|
6
|
+
#++
|
|
5
7
|
|
|
6
8
|
$LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
|
|
7
9
|
require "ratatui_ruby"
|
|
@@ -18,10 +20,10 @@ require "ratatui_ruby"
|
|
|
18
20
|
#
|
|
19
21
|
# Run the demo from the terminal:
|
|
20
22
|
#
|
|
21
|
-
# ruby examples/
|
|
23
|
+
# ruby examples/widget_ratatui_mascot/app.rb
|
|
22
24
|
#
|
|
23
|
-
# rdoc-image:/doc/images/
|
|
24
|
-
class
|
|
25
|
+
# rdoc-image:/doc/images/widget_ratatui_mascot.png
|
|
26
|
+
class WidgetRatatuiMascot
|
|
25
27
|
def initialize
|
|
26
28
|
@show_block = true
|
|
27
29
|
end
|
|
@@ -90,4 +92,4 @@ class WidgetRatatuiMascotDemo
|
|
|
90
92
|
end
|
|
91
93
|
end
|
|
92
94
|
|
|
93
|
-
|
|
95
|
+
WidgetRatatuiMascot.new.run if __FILE__ == $PROGRAM_NAME
|
|
@@ -3,7 +3,7 @@ SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
|
3
3
|
SPDX-License-Identifier: CC-BY-SA-4.0
|
|
4
4
|
-->
|
|
5
5
|
|
|
6
|
-
# Rect (
|
|
6
|
+
# Rect (Area, Rectangle) Example
|
|
7
7
|
|
|
8
8
|
[](app.rb)
|
|
9
9
|
|
|
@@ -33,6 +33,9 @@ ruby examples/widget_rect/app.rb
|
|
|
33
33
|
## Learning Outcomes
|
|
34
34
|
|
|
35
35
|
Use this example if you need to...
|
|
36
|
+
|
|
36
37
|
- Handle mouse clicks on specific buttons or areas.
|
|
37
38
|
- Create resizable panes (like a split pane in an IDE).
|
|
38
|
-
- Debug layout issues by inspecting Rect coordinates.
|
|
39
|
+
- Debug layout issues by inspecting Rect coordinates.
|
|
40
|
+
|
|
41
|
+
[Read the source code →](app.rb)
|
data/examples/widget_rect/app.rb
CHANGED
|
@@ -32,6 +32,9 @@ ruby examples/widget_render/app.rb
|
|
|
32
32
|
## Learning Outcomes
|
|
33
33
|
|
|
34
34
|
Use this example if you need to...
|
|
35
|
+
|
|
35
36
|
- Build a game (Snake, Tetris) inside the terminal.
|
|
36
37
|
- Create a specialized visualization (Network topology graph).
|
|
37
|
-
- Draw custom UI elements not provided by the library.
|
|
38
|
+
- Draw custom UI elements not provided by the library.
|
|
39
|
+
|
|
40
|
+
[Read the source code →](app.rb)
|
|
@@ -30,6 +30,9 @@ ruby examples/widget_rich_text/app.rb
|
|
|
30
30
|
## Learning Outcomes
|
|
31
31
|
|
|
32
32
|
Use this example if you need to...
|
|
33
|
+
|
|
33
34
|
- Highlight keywords in code (Syntax highlighting).
|
|
34
35
|
- Create status lines with icons (e.g., "✔ Success" where the checkmark is green).
|
|
35
|
-
- Emphasize specific data points in a paragraph.
|
|
36
|
+
- Emphasize specific data points in a paragraph.
|
|
37
|
+
|
|
38
|
+
[Read the source code →](app.rb)
|
|
@@ -32,6 +32,9 @@ ruby examples/widget_scroll_text/app.rb
|
|
|
32
32
|
## Learning Outcomes
|
|
33
33
|
|
|
34
34
|
Use this example if you need to...
|
|
35
|
+
|
|
35
36
|
- Build a log viewer.
|
|
36
37
|
- Create a "terms and conditions" scrollbox.
|
|
37
|
-
- Display code snippets that might be wider than the terminal.
|
|
38
|
+
- Display code snippets that might be wider than the terminal.
|
|
39
|
+
|
|
40
|
+
[Read the source code →](app.rb)
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
#--
|
|
3
4
|
# SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
|
|
4
5
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
+
#++
|
|
5
7
|
|
|
6
8
|
$LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
|
|
7
9
|
require "ratatui_ruby"
|
|
8
10
|
|
|
9
|
-
#
|
|
11
|
+
# Scrollable Paragraph
|
|
10
12
|
# Shows how to scroll through long text content using arrow keys
|
|
11
13
|
#
|
|
12
14
|
# Helper: Disable experimental warnings since we use line_count/line_width
|
|
@@ -3,9 +3,9 @@ SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
|
3
3
|
SPDX-License-Identifier: CC-BY-SA-4.0
|
|
4
4
|
-->
|
|
5
5
|
|
|
6
|
-
# Scrollbar
|
|
6
|
+
# Scrollbar (Scroll) Example
|
|
7
7
|
|
|
8
|
-
[](app.rb)
|
|
9
9
|
|
|
10
10
|
Demonstrates explicit scrollbars for navigation feedback.
|
|
11
11
|
|
|
@@ -27,11 +27,14 @@ Content overflows. Users get lost in long lists. Scrollbars provide essential sp
|
|
|
27
27
|
## Usage
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
|
-
ruby examples/
|
|
30
|
+
ruby examples/widget_scrollbar/app.rb
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
## Learning Outcomes
|
|
34
34
|
|
|
35
35
|
Use this example if you need to...
|
|
36
|
+
|
|
36
37
|
- Add visual scroll indicators to Lists or Tables.
|
|
37
|
-
- Implement specialized inputs like sliders or volume controls.
|
|
38
|
+
- Implement specialized inputs like sliders or volume controls.
|
|
39
|
+
|
|
40
|
+
[Read the source code →](app.rb)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
#--
|
|
3
4
|
# SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
|
|
4
5
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
+
#++
|
|
5
7
|
|
|
6
8
|
$LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
|
|
7
9
|
require "ratatui_ruby"
|
|
@@ -18,10 +20,10 @@ require "ratatui_ruby"
|
|
|
18
20
|
#
|
|
19
21
|
# Run the demo from the terminal:
|
|
20
22
|
#
|
|
21
|
-
# ruby examples/
|
|
23
|
+
# ruby examples/widget_scrollbar/app.rb
|
|
22
24
|
#
|
|
23
|
-
# rdoc-image:/doc/images/
|
|
24
|
-
class
|
|
25
|
+
# rdoc-image:/doc/images/widget_scrollbar.png
|
|
26
|
+
class WidgetScrollbar
|
|
25
27
|
def initialize
|
|
26
28
|
@scroll_position = 0
|
|
27
29
|
@content_length = 50
|
|
@@ -150,4 +152,4 @@ class WidgetScrollbarDemo
|
|
|
150
152
|
end
|
|
151
153
|
end
|
|
152
154
|
|
|
153
|
-
|
|
155
|
+
WidgetScrollbar.new.run if __FILE__ == $PROGRAM_NAME
|
|
@@ -5,7 +5,7 @@ SPDX-License-Identifier: CC-BY-SA-4.0
|
|
|
5
5
|
|
|
6
6
|
# Sparkline Widget Example
|
|
7
7
|
|
|
8
|
-
[](app.rb)
|
|
9
9
|
|
|
10
10
|
Demonstrates high-density data visualization in a condensed footprint.
|
|
11
11
|
|
|
@@ -31,12 +31,15 @@ Users need context. A single number ("90% CPU") tells you status, but not the tr
|
|
|
31
31
|
## Usage
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
|
-
ruby examples/
|
|
34
|
+
ruby examples/widget_sparkline/app.rb
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
## Learning Outcomes
|
|
38
38
|
|
|
39
39
|
Use this example if you need to...
|
|
40
|
+
|
|
40
41
|
- Add a "CPU Load" graph to your header.
|
|
41
42
|
- Visualize stock price trends in a list row.
|
|
42
|
-
- Monitor memory usage over the last 60 seconds.
|
|
43
|
+
- Monitor memory usage over the last 60 seconds.
|
|
44
|
+
|
|
45
|
+
[Read the source code →](app.rb)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
#--
|
|
3
4
|
# SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
|
|
4
5
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
+
#++
|
|
5
7
|
|
|
6
8
|
$LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
|
|
7
9
|
require "ratatui_ruby"
|
|
@@ -18,10 +20,10 @@ require "ratatui_ruby"
|
|
|
18
20
|
#
|
|
19
21
|
# Run the demo from the terminal:
|
|
20
22
|
#
|
|
21
|
-
# ruby examples/
|
|
23
|
+
# ruby examples/widget_sparkline/app.rb
|
|
22
24
|
#
|
|
23
|
-
# rdoc-image:/doc/images/
|
|
24
|
-
class
|
|
25
|
+
# rdoc-image:/doc/images/widget_sparkline.png
|
|
26
|
+
class WidgetSparkline
|
|
25
27
|
def run
|
|
26
28
|
RatatuiRuby.run do |tui|
|
|
27
29
|
@tui = tui
|
|
@@ -144,7 +146,7 @@ class WidgetSparklineDemo
|
|
|
144
146
|
)
|
|
145
147
|
|
|
146
148
|
frame.render_widget(
|
|
147
|
-
@tui.paragraph(text: "Sparkline Widget
|
|
149
|
+
@tui.paragraph(text: "Sparkline Widget - Cycle attributes with hotkeys"),
|
|
148
150
|
main_layout[0]
|
|
149
151
|
)
|
|
150
152
|
|
|
@@ -272,4 +274,4 @@ class WidgetSparklineDemo
|
|
|
272
274
|
end
|
|
273
275
|
end
|
|
274
276
|
|
|
275
|
-
|
|
277
|
+
WidgetSparkline.new.run if __FILE__ == $PROGRAM_NAME
|
|
@@ -29,6 +29,9 @@ ruby examples/widget_style_colors/app.rb
|
|
|
29
29
|
## Learning Outcomes
|
|
30
30
|
|
|
31
31
|
Use this example if you need to...
|
|
32
|
+
|
|
32
33
|
- Create meaningful heatmaps.
|
|
33
34
|
- Generate color palettes dynamically.
|
|
34
|
-
- Test your terminal's color support capabilities.
|
|
35
|
+
- Test your terminal's color support capabilities.
|
|
36
|
+
|
|
37
|
+
[Read the source code →](app.rb)
|
|
@@ -3,9 +3,9 @@ SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
|
|
|
3
3
|
SPDX-License-Identifier: CC-BY-SA-4.0
|
|
4
4
|
-->
|
|
5
5
|
|
|
6
|
-
# Table
|
|
6
|
+
# Table (Row, Cell) Example
|
|
7
7
|
|
|
8
|
-
[](app.rb)
|
|
9
9
|
|
|
10
10
|
Demonstrates advanced options for the `Table` widget, including selection, row-level highlighting, and column-level highlighting.
|
|
11
11
|
|
|
@@ -37,12 +37,15 @@ Data grids are complex. Users expect to navigate them with keys, select rows, an
|
|
|
37
37
|
## Usage
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
|
-
ruby examples/
|
|
40
|
+
ruby examples/widget_table/app.rb
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
## Learning Outcomes
|
|
44
44
|
|
|
45
45
|
Use this example if you need to...
|
|
46
|
+
|
|
46
47
|
- Build a file explorer or process list.
|
|
47
48
|
- Create a data-heavy dashboard.
|
|
48
|
-
- Handle conflicting style requirements (e.g., "Highlight this row, but make this error cell red").
|
|
49
|
+
- Handle conflicting style requirements (e.g., "Highlight this row, but make this error cell red").
|
|
50
|
+
|
|
51
|
+
[Read the source code →](app.rb)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
#--
|
|
3
4
|
# SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
|
|
4
5
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
+
#++
|
|
5
7
|
|
|
6
8
|
$LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
|
|
7
9
|
require "bundler/setup"
|
|
@@ -18,7 +20,7 @@ PROCESSES = [
|
|
|
18
20
|
{ pid: 6789, name: "node", cpu: 18.9 },
|
|
19
21
|
].freeze
|
|
20
22
|
|
|
21
|
-
class
|
|
23
|
+
class WidgetTable
|
|
22
24
|
attr_reader :selected_index, :selected_col, :current_style_index, :column_spacing, :highlight_spacing, :column_highlight_style, :cell_highlight_style
|
|
23
25
|
|
|
24
26
|
HIGHLIGHT_SPACINGS = [
|
|
@@ -250,5 +252,5 @@ class WidgetTableDemo
|
|
|
250
252
|
end
|
|
251
253
|
|
|
252
254
|
if __FILE__ == $0
|
|
253
|
-
|
|
255
|
+
WidgetTable.new.run
|
|
254
256
|
end
|
|
@@ -5,7 +5,7 @@ SPDX-License-Identifier: CC-BY-SA-4.0
|
|
|
5
5
|
|
|
6
6
|
# Tabs Widget Example
|
|
7
7
|
|
|
8
|
-
[](app.rb)
|
|
9
9
|
|
|
10
10
|
Demonstrates view segregation with interactive navigation.
|
|
11
11
|
|
|
@@ -30,12 +30,15 @@ Screen real estate is limited. You cannot show everything at once. Tabs segregat
|
|
|
30
30
|
## Usage
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
ruby examples/
|
|
33
|
+
ruby examples/widget_tabs/app.rb
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
## Learning Outcomes
|
|
37
37
|
|
|
38
38
|
Use this example if you need to...
|
|
39
|
+
|
|
39
40
|
- Build a multi-pane dashboard.
|
|
40
41
|
- Create a "Settings" screen with different categories.
|
|
41
|
-
- Implement a "wizard" interface with steps.
|
|
42
|
+
- Implement a "wizard" interface with steps.
|
|
43
|
+
|
|
44
|
+
[Read the source code →](app.rb)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
#--
|
|
3
4
|
# SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
|
|
4
5
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
+
#++
|
|
5
7
|
|
|
6
8
|
$LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
|
|
7
9
|
require "ratatui_ruby"
|
|
@@ -19,10 +21,10 @@ require "faker"
|
|
|
19
21
|
#
|
|
20
22
|
# Run the demo from the terminal:
|
|
21
23
|
#
|
|
22
|
-
# ruby examples/
|
|
24
|
+
# ruby examples/widget_tabs/app.rb
|
|
23
25
|
#
|
|
24
|
-
# rdoc-image:/doc/images/
|
|
25
|
-
class
|
|
26
|
+
# rdoc-image:/doc/images/widget_tabs.png
|
|
27
|
+
class WidgetTabs
|
|
26
28
|
def initialize
|
|
27
29
|
@selected_tab = 0
|
|
28
30
|
@tabs = ["Revenue", "Traffic", "Errors", "Quarterly"]
|
|
@@ -93,7 +95,7 @@ class WidgetTabsDemo
|
|
|
93
95
|
tabs = @tui.tabs(
|
|
94
96
|
titles: @tabs,
|
|
95
97
|
selected_index: @selected_tab,
|
|
96
|
-
block: @tui.block(title: "Tabs
|
|
98
|
+
block: @tui.block(title: "Tabs", borders: [:all]),
|
|
97
99
|
divider: @dividers[@divider_index],
|
|
98
100
|
highlight_style: @highlight_styles[@highlight_style_index][:style],
|
|
99
101
|
style: @base_styles[@base_style_index][:style],
|
|
@@ -178,4 +180,4 @@ class WidgetTabsDemo
|
|
|
178
180
|
end
|
|
179
181
|
end
|
|
180
182
|
|
|
181
|
-
|
|
183
|
+
WidgetTabs.new.run if __FILE__ == $0
|
|
@@ -3,7 +3,7 @@ SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
|
3
3
|
SPDX-License-Identifier: CC-BY-SA-4.0
|
|
4
4
|
-->
|
|
5
5
|
|
|
6
|
-
# Text Width Calculator
|
|
6
|
+
# Text Width (Unicode Width) Calculator
|
|
7
7
|
|
|
8
8
|
[](app.rb)
|
|
9
9
|
|
|
@@ -30,6 +30,9 @@ ruby examples/widget_text_width/app.rb
|
|
|
30
30
|
## Learning Outcomes
|
|
31
31
|
|
|
32
32
|
Use this example if you need to...
|
|
33
|
+
|
|
33
34
|
- Align text correctly in columns.
|
|
34
35
|
- Truncate strings that are too long for a widget.
|
|
35
|
-
- Build your own custom layout engine.
|
|
36
|
+
- Build your own custom layout engine.
|
|
37
|
+
|
|
38
|
+
[Read the source code →](app.rb)
|
data/exe/.gitkeep
CHANGED
|
File without changes
|
data/ext/ratatui_ruby/Cargo.lock
CHANGED
data/ext/ratatui_ruby/Cargo.toml
CHANGED
data/ext/ratatui_ruby/extconf.rb
CHANGED
|
@@ -48,12 +48,14 @@ pub fn render(frame: &mut Frame, area: Rect, node: Value) -> Result<(), Error> {
|
|
|
48
48
|
let group_obj: Value = array.entry(index)?;
|
|
49
49
|
|
|
50
50
|
let label_val: Value = group_obj.funcall("label", ())?;
|
|
51
|
-
let
|
|
52
|
-
|
|
51
|
+
let group_label: Line = if label_val.is_nil() {
|
|
52
|
+
Line::from("")
|
|
53
|
+
} else if let Ok(line) = parse_line(label_val) {
|
|
54
|
+
line
|
|
53
55
|
} else {
|
|
54
|
-
label_val.funcall("to_s", ())
|
|
56
|
+
let label_str: String = label_val.funcall("to_s", ())?;
|
|
57
|
+
Line::from(label_str)
|
|
55
58
|
};
|
|
56
|
-
let label_ref = bump.alloc_str(&label_str) as &str;
|
|
57
59
|
|
|
58
60
|
let bars_array: RArray = group_obj.funcall("bars", ())?;
|
|
59
61
|
let mut bars: Vec<Bar> = Vec::new();
|
|
@@ -110,8 +112,8 @@ pub fn render(frame: &mut Frame, area: Rect, node: Value) -> Result<(), Error> {
|
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
let mut group = BarGroup::new(bars);
|
|
113
|
-
if !
|
|
114
|
-
group = group.label(
|
|
115
|
+
if !group_label.spans.is_empty() {
|
|
116
|
+
group = group.label(group_label);
|
|
115
117
|
}
|
|
116
118
|
bar_chart = bar_chart.data(group);
|
|
117
119
|
}
|