ratatui_ruby 0.7.0 → 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 +34 -0
- data/README.md +5 -5
- data/Rakefile +1 -1
- data/doc/{application_architecture.md → concepts/application_architecture.md} +30 -0
- data/doc/concepts/async.md +160 -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/troubleshooting/debugging.md +71 -0
- 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/style.rs +25 -9
- 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 +10 -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 +14 -0
- data/tasks/bump/sem_ver.rb +2 -0
- data/tasks/bump/unreleased_section.rb +18 -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 -72
- 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/{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
|
@@ -5,7 +5,7 @@ SPDX-License-Identifier: CC-BY-SA-4.0
|
|
|
5
5
|
|
|
6
6
|
# Line Gauge Widget Example
|
|
7
7
|
|
|
8
|
-
[](app.rb)
|
|
9
9
|
|
|
10
10
|
Demonstrates compact progress bars for constrained spaces.
|
|
11
11
|
|
|
@@ -30,12 +30,15 @@ Standard block gauges take up vertical space. Sometimes you only have one line t
|
|
|
30
30
|
## Usage
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
ruby examples/
|
|
33
|
+
ruby examples/widget_line_gauge/app.rb
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
## Learning Outcomes
|
|
37
37
|
|
|
38
38
|
Use this example if you need to...
|
|
39
|
+
|
|
39
40
|
- Add a progress bar to a list item or table row.
|
|
40
41
|
- Create a status line at the bottom of the screen.
|
|
41
|
-
- Show multiple metrics (CPU, RAM, Net) in a compact list.
|
|
42
|
+
- Show multiple metrics (CPU, RAM, Net) in a compact list.
|
|
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"
|
|
@@ -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_line_gauge/app.rb
|
|
22
24
|
#
|
|
23
|
-
# rdoc-image:/doc/images/
|
|
24
|
-
class
|
|
25
|
+
# rdoc-image:/doc/images/widget_line_gauge.png
|
|
26
|
+
class WidgetLineGauge
|
|
25
27
|
def initialize
|
|
26
28
|
@ratio = 0.5
|
|
27
29
|
@ratios = [0.2, 0.35, 0.5, 0.65, 0.8, 0.95]
|
|
@@ -119,7 +121,7 @@ class WidgetLineGaugeDemo
|
|
|
119
121
|
)
|
|
120
122
|
|
|
121
123
|
# Render title
|
|
122
|
-
title = @tui.paragraph(text: "LineGauge Widget
|
|
124
|
+
title = @tui.paragraph(text: "LineGauge Widget - Cycle attributes with hotkeys")
|
|
123
125
|
frame.render_widget(title, title_area)
|
|
124
126
|
|
|
125
127
|
# Example 1: Static gauge showing all features
|
|
@@ -214,4 +216,4 @@ class WidgetLineGaugeDemo
|
|
|
214
216
|
end
|
|
215
217
|
end
|
|
216
218
|
|
|
217
|
-
|
|
219
|
+
WidgetLineGauge.new.run if __FILE__ == $PROGRAM_NAME
|
|
@@ -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
|
-
# List
|
|
6
|
+
# List (ListItem) Example
|
|
7
7
|
|
|
8
|
-
[](app.rb)
|
|
9
9
|
|
|
10
10
|
Demonstrates a selectable list with extensive configuration options.
|
|
11
11
|
|
|
@@ -37,13 +37,16 @@ Lists are the workhorse of terminal interfaces. Managing selection state, scroll
|
|
|
37
37
|
## Usage
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
|
-
ruby examples/
|
|
40
|
+
ruby examples/widget_list/app.rb
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
## Learning Outcomes
|
|
44
44
|
|
|
45
45
|
Use this example if you need to...
|
|
46
|
+
|
|
46
47
|
- Create a file explorer.
|
|
47
48
|
- Build a navigation menu.
|
|
48
49
|
- Display a log where users can scroll back to read history.
|
|
49
|
-
- Implement "infinite select" behaviors.
|
|
50
|
+
- Implement "infinite select" behaviors.
|
|
51
|
+
|
|
52
|
+
[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" # Use Faker for large, realistic datasets
|
|
|
19
21
|
#
|
|
20
22
|
# Run the demo from the terminal:
|
|
21
23
|
#
|
|
22
|
-
# ruby examples/
|
|
24
|
+
# ruby examples/widget_list/app.rb
|
|
23
25
|
#
|
|
24
|
-
# rdoc-image:/doc/images/
|
|
25
|
-
class
|
|
26
|
+
# rdoc-image:/doc/images/widget_list.png
|
|
27
|
+
class WidgetList
|
|
26
28
|
# Initializes the demo with example data and default configuration.
|
|
27
29
|
def initialize
|
|
28
30
|
Faker::Config.random = Random.new(12345)
|
|
@@ -253,7 +255,7 @@ class WidgetListDemo
|
|
|
253
255
|
)
|
|
254
256
|
|
|
255
257
|
# Render title
|
|
256
|
-
title = @tui.paragraph(text: "List Widget
|
|
258
|
+
title = @tui.paragraph(text: "List Widget - Interactive Attribute Cycling")
|
|
257
259
|
frame.render_widget(title, title_area)
|
|
258
260
|
|
|
259
261
|
# Render list
|
|
@@ -363,4 +365,4 @@ class WidgetListDemo
|
|
|
363
365
|
end
|
|
364
366
|
end
|
|
365
367
|
|
|
366
|
-
|
|
368
|
+
WidgetList.new.run if __FILE__ == $PROGRAM_NAME
|
|
@@ -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
|
-
# Canvas
|
|
6
|
+
# Map (World Map, Canvas) Example
|
|
7
7
|
|
|
8
|
-
[](app.rb)
|
|
9
9
|
|
|
10
10
|
Demonstrates drawing custom graphics and maps using the standard Braille and Block patterns.
|
|
11
11
|
|
|
@@ -28,12 +28,15 @@ Standard widgets are great for text, but sometimes you need to draw. The `Canvas
|
|
|
28
28
|
## Usage
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
ruby examples/
|
|
31
|
+
ruby examples/widget_map/app.rb
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
## Learning Outcomes
|
|
35
35
|
|
|
36
36
|
Use this example if you need to...
|
|
37
|
+
|
|
37
38
|
- Render geographic data (World, USA, Europe).
|
|
38
39
|
- Overlay custom labels and markers on a map.
|
|
39
|
-
- Animate visual elements on top of a static background.
|
|
40
|
+
- Animate visual elements on top of a static background.
|
|
41
|
+
|
|
42
|
+
[Read the source code →](app.rb)
|
|
@@ -1,13 +1,15 @@
|
|
|
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
|
# An example of the Canvas widget showing a world map and animated shapes.
|
|
10
|
-
class
|
|
12
|
+
class WidgetMap
|
|
11
13
|
include RatatuiRuby::Widgets
|
|
12
14
|
|
|
13
15
|
COLORS = [:black, :blue, :white, nil].freeze
|
|
@@ -90,4 +92,4 @@ class WidgetMapDemo
|
|
|
90
92
|
end
|
|
91
93
|
end
|
|
92
94
|
|
|
93
|
-
|
|
95
|
+
WidgetMap.new.run if __FILE__ == $PROGRAM_NAME
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
|
|
3
3
|
SPDX-License-Identifier: CC-BY-SA-4.0
|
|
4
4
|
-->
|
|
5
|
-
# Overlay
|
|
5
|
+
# Overlay Example
|
|
6
6
|
|
|
7
|
-
[](app.rb)
|
|
8
8
|
|
|
9
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
10
|
|
|
@@ -25,12 +25,15 @@ This example demonstrates the `Overlay` composition pattern for layering widgets
|
|
|
25
25
|
## Usage
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
ruby examples/
|
|
28
|
+
ruby examples/widget_overlay/app.rb
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
## Learning Outcomes
|
|
32
32
|
|
|
33
33
|
Use this example if you need to...
|
|
34
|
+
|
|
34
35
|
- Build modal dialogs or confirmation popups.
|
|
35
36
|
- Layer notifications over existing content.
|
|
36
37
|
- Understand the Clear widget's role in opaque overlays.
|
|
38
|
+
|
|
39
|
+
[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"
|
|
@@ -33,9 +35,9 @@ HEADLINES = [
|
|
|
33
35
|
"Innovative Urban Planning Reduces Traffic Congestion by 30%",
|
|
34
36
|
].freeze
|
|
35
37
|
|
|
36
|
-
# Overlay
|
|
38
|
+
# Overlay Example
|
|
37
39
|
# Demonstrates the Overlay widget for layering widgets with depth.
|
|
38
|
-
class
|
|
40
|
+
class WidgetOverlay
|
|
39
41
|
def initialize
|
|
40
42
|
@layer_count = 2 # Start with 2 layers visible
|
|
41
43
|
@swapped = false
|
|
@@ -245,4 +247,4 @@ class WidgetOverlayDemo
|
|
|
245
247
|
end
|
|
246
248
|
end
|
|
247
249
|
|
|
248
|
-
|
|
250
|
+
WidgetOverlay.new.run if __FILE__ == $PROGRAM_NAME
|
|
@@ -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)
|