ratatui_ruby 0.4.0 → 0.5.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.
- 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 +87 -171
- data/CHANGELOG.md +38 -1
- data/README.md +8 -3
- data/REUSE.toml +20 -0
- data/doc/application_architecture.md +105 -45
- data/doc/application_testing.md +5 -3
- data/doc/contributors/design/ruby_frontend.md +9 -5
- data/doc/contributors/developing_examples.md +76 -18
- data/doc/contributors/documentation_style.md +7 -0
- data/doc/contributors/index.md +2 -0
- data/doc/event_handling.md +10 -4
- data/doc/images/app_all_events.png +0 -0
- data/doc/images/app_color_picker.png +0 -0
- data/doc/images/verify_readme_usage.png +0 -0
- data/doc/images/widget_barchart_demo.png +0 -0
- data/doc/images/widget_block_padding.png +0 -0
- data/doc/images/widget_block_titles.png +0 -0
- data/doc/images/widget_box_demo.png +0 -0
- data/doc/images/widget_calendar_demo.png +0 -0
- data/doc/images/widget_cell_demo.png +0 -0
- data/doc/images/widget_chart_demo.png +0 -0
- data/doc/images/widget_gauge_demo.png +0 -0
- data/doc/images/widget_layout_split.png +0 -0
- data/doc/images/widget_line_gauge_demo.png +0 -0
- data/doc/images/widget_list_demo.png +0 -0
- data/doc/images/widget_ratatui_logo_demo.png +0 -0
- data/doc/images/widget_ratatui_mascot_demo.png +0 -0
- data/doc/images/widget_render.png +0 -0
- data/doc/images/widget_scrollbar_demo.png +0 -0
- data/doc/images/widget_sparkline_demo.png +0 -0
- data/doc/images/widget_style_colors.png +0 -0
- data/doc/images/widget_table_flex.png +0 -0
- data/doc/images/widget_tabs_demo.png +0 -0
- data/doc/interactive_design.md +25 -30
- data/doc/quickstart.md +147 -120
- data/examples/app_all_events/README.md +81 -0
- data/examples/app_all_events/app.rb +93 -0
- data/examples/app_all_events/model/event_color_cycle.rb +41 -0
- data/examples/app_all_events/model/event_entry.rb +75 -0
- data/examples/app_all_events/model/events.rb +180 -0
- data/examples/app_all_events/model/highlight.rb +57 -0
- data/examples/app_all_events/model/timestamp.rb +54 -0
- data/examples/app_all_events/test/snapshots/after_focus_lost.txt +24 -0
- data/examples/app_all_events/test/snapshots/after_focus_regained.txt +24 -0
- data/examples/app_all_events/test/snapshots/after_horizontal_resize.txt +24 -0
- data/examples/app_all_events/test/snapshots/after_key_a.txt +24 -0
- data/examples/app_all_events/test/snapshots/after_key_ctrl_x.txt +24 -0
- data/examples/app_all_events/test/snapshots/after_mouse_click.txt +24 -0
- data/examples/app_all_events/test/snapshots/after_mouse_drag.txt +24 -0
- data/examples/app_all_events/test/snapshots/after_multiple_events.txt +24 -0
- data/examples/app_all_events/test/snapshots/after_paste.txt +24 -0
- data/examples/app_all_events/test/snapshots/after_resize.txt +24 -0
- data/examples/app_all_events/test/snapshots/after_right_click.txt +24 -0
- data/examples/app_all_events/test/snapshots/after_vertical_resize.txt +24 -0
- data/examples/app_all_events/test/snapshots/initial_state.txt +24 -0
- data/examples/app_all_events/view/app_view.rb +78 -0
- data/examples/app_all_events/view/controls_view.rb +50 -0
- data/examples/app_all_events/view/counts_view.rb +55 -0
- data/examples/app_all_events/view/live_view.rb +69 -0
- data/examples/app_all_events/view/log_view.rb +60 -0
- data/examples/app_all_events/view.rb +7 -0
- data/examples/app_all_events/view_state.rb +42 -0
- data/examples/app_color_picker/README.md +94 -0
- data/examples/app_color_picker/app.rb +112 -0
- data/examples/app_color_picker/clipboard.rb +84 -0
- data/examples/app_color_picker/color.rb +191 -0
- data/examples/app_color_picker/copy_dialog.rb +170 -0
- data/examples/app_color_picker/harmony.rb +56 -0
- data/examples/app_color_picker/input.rb +142 -0
- data/examples/app_color_picker/palette.rb +80 -0
- data/examples/app_color_picker/scene.rb +201 -0
- data/examples/{login_form → app_login_form}/app.rb +39 -42
- data/examples/{map_demo → app_map_demo}/app.rb +24 -21
- data/examples/{table_select → app_table_select}/app.rb +68 -65
- data/examples/{quickstart_dsl → verify_quickstart_dsl}/app.rb +15 -6
- data/examples/verify_quickstart_layout/app.rb +69 -0
- data/examples/{quickstart_lifecycle → verify_quickstart_lifecycle}/app.rb +19 -10
- data/examples/verify_readme_usage/app.rb +34 -0
- data/examples/widget_barchart_demo/app.rb +238 -0
- data/examples/{block_padding → widget_block_padding}/app.rb +17 -13
- data/examples/{block_titles → widget_block_titles}/app.rb +25 -17
- data/examples/{box_demo → widget_box_demo}/app.rb +99 -65
- data/examples/widget_calendar_demo/app.rb +109 -0
- data/examples/widget_cell_demo/app.rb +104 -0
- data/examples/widget_chart_demo/app.rb +213 -0
- data/examples/widget_gauge_demo/app.rb +212 -0
- data/examples/widget_layout_split/app.rb +246 -0
- data/examples/widget_line_gauge_demo/app.rb +217 -0
- data/examples/widget_list_demo/app.rb +382 -0
- data/examples/widget_list_styles/app.rb +141 -0
- data/examples/widget_popup_demo/app.rb +104 -0
- data/examples/widget_ratatui_logo_demo/app.rb +103 -0
- data/examples/widget_ratatui_mascot_demo/app.rb +93 -0
- data/examples/widget_rect/app.rb +205 -0
- data/examples/widget_render/app.rb +184 -0
- data/examples/widget_rich_text/app.rb +137 -0
- data/examples/widget_scroll_text/app.rb +108 -0
- data/examples/widget_scrollbar_demo/app.rb +153 -0
- data/examples/widget_sparkline_demo/app.rb +274 -0
- data/examples/widget_style_colors/app.rb +19 -21
- data/examples/widget_table_flex/app.rb +95 -0
- data/examples/widget_tabs_demo/app.rb +167 -0
- data/ext/ratatui_ruby/Cargo.lock +1 -1
- data/ext/ratatui_ruby/Cargo.toml +1 -1
- data/ext/ratatui_ruby/src/events.rs +121 -36
- data/ext/ratatui_ruby/src/frame.rs +115 -0
- data/ext/ratatui_ruby/src/lib.rs +79 -26
- data/ext/ratatui_ruby/src/rendering.rs +8 -4
- data/ext/ratatui_ruby/src/style.rs +138 -57
- data/ext/ratatui_ruby/src/terminal.rs +5 -9
- data/ext/ratatui_ruby/src/text.rs +13 -6
- data/ext/ratatui_ruby/src/widgets/barchart.rs +56 -54
- data/ext/ratatui_ruby/src/widgets/block.rs +7 -6
- data/ext/ratatui_ruby/src/widgets/canvas.rs +21 -3
- data/ext/ratatui_ruby/src/widgets/chart.rs +20 -10
- data/ext/ratatui_ruby/src/widgets/layout.rs +9 -4
- data/ext/ratatui_ruby/src/widgets/list.rs +32 -9
- data/ext/ratatui_ruby/src/widgets/overlay.rs +2 -1
- data/ext/ratatui_ruby/src/widgets/paragraph.rs +1 -1
- data/ext/ratatui_ruby/src/widgets/ratatui_logo.rs +19 -8
- data/ext/ratatui_ruby/src/widgets/ratatui_mascot.rs +17 -10
- data/ext/ratatui_ruby/src/widgets/scrollbar.rs +4 -2
- data/ext/ratatui_ruby/src/widgets/sparkline.rs +14 -11
- data/ext/ratatui_ruby/src/widgets/table.rs +8 -4
- data/ext/ratatui_ruby/src/widgets/tabs.rs +11 -11
- data/lib/ratatui_ruby/cell.rb +3 -3
- data/lib/ratatui_ruby/event/key.rb +1 -1
- data/lib/ratatui_ruby/event/none.rb +43 -0
- data/lib/ratatui_ruby/event.rb +56 -4
- data/lib/ratatui_ruby/frame.rb +87 -0
- data/lib/ratatui_ruby/schema/bar_chart/bar.rb +11 -11
- data/lib/ratatui_ruby/schema/bar_chart/bar_group.rb +1 -5
- data/lib/ratatui_ruby/schema/bar_chart.rb +217 -217
- data/lib/ratatui_ruby/schema/block.rb +163 -168
- data/lib/ratatui_ruby/schema/calendar.rb +66 -67
- data/lib/ratatui_ruby/schema/canvas.rb +63 -63
- data/lib/ratatui_ruby/schema/center.rb +46 -46
- data/lib/ratatui_ruby/schema/chart.rb +135 -143
- data/lib/ratatui_ruby/schema/clear.rb +42 -42
- data/lib/ratatui_ruby/schema/constraint.rb +76 -76
- data/lib/ratatui_ruby/schema/cursor.rb +25 -25
- data/lib/ratatui_ruby/schema/gauge.rb +53 -53
- data/lib/ratatui_ruby/schema/layout.rb +87 -87
- data/lib/ratatui_ruby/schema/line_gauge.rb +62 -62
- data/lib/ratatui_ruby/schema/list.rb +86 -84
- data/lib/ratatui_ruby/schema/overlay.rb +31 -31
- data/lib/ratatui_ruby/schema/paragraph.rb +80 -80
- data/lib/ratatui_ruby/schema/ratatui_logo.rb +10 -6
- data/lib/ratatui_ruby/schema/ratatui_mascot.rb +10 -5
- data/lib/ratatui_ruby/schema/rect.rb +60 -60
- data/lib/ratatui_ruby/schema/scrollbar.rb +119 -119
- data/lib/ratatui_ruby/schema/shape/label.rb +1 -1
- data/lib/ratatui_ruby/schema/sparkline.rb +111 -110
- data/lib/ratatui_ruby/schema/style.rb +46 -46
- data/lib/ratatui_ruby/schema/table.rb +112 -119
- data/lib/ratatui_ruby/schema/tabs.rb +66 -67
- data/lib/ratatui_ruby/session/autodoc.rb +417 -0
- data/lib/ratatui_ruby/session.rb +40 -23
- data/lib/ratatui_ruby/test_helper.rb +185 -19
- data/lib/ratatui_ruby/version.rb +1 -1
- data/lib/ratatui_ruby.rb +65 -39
- data/{examples/sparkline_demo → sig/examples/app_all_events}/app.rbs +3 -2
- data/sig/examples/app_all_events/model/event_entry.rbs +16 -0
- data/sig/examples/app_all_events/model/events.rbs +15 -0
- data/sig/examples/app_all_events/model/timestamp.rbs +11 -0
- data/sig/examples/app_all_events/view/app_view.rbs +8 -0
- data/sig/examples/app_all_events/view/controls_view.rbs +6 -0
- data/sig/examples/app_all_events/view/counts_view.rbs +6 -0
- data/sig/examples/app_all_events/view/live_view.rbs +6 -0
- data/sig/examples/app_all_events/view/log_view.rbs +6 -0
- data/sig/examples/app_all_events/view.rbs +8 -0
- data/sig/examples/app_all_events/view_state.rbs +15 -0
- data/{examples/list_demo → sig/examples/app_color_picker}/app.rbs +2 -2
- data/sig/examples/app_login_form/app.rbs +11 -0
- data/sig/examples/app_map_demo/app.rbs +11 -0
- data/sig/examples/app_table_select/app.rbs +11 -0
- data/sig/examples/verify_quickstart_dsl/app.rbs +11 -0
- data/sig/examples/verify_quickstart_lifecycle/app.rbs +11 -0
- data/sig/examples/verify_readme_usage/app.rbs +11 -0
- data/sig/examples/widget_block_padding/app.rbs +11 -0
- data/sig/examples/widget_block_titles/app.rbs +11 -0
- data/sig/examples/widget_box_demo/app.rbs +11 -0
- data/sig/examples/widget_calendar_demo/app.rbs +11 -0
- data/sig/examples/widget_cell_demo/app.rbs +11 -0
- data/sig/examples/widget_chart_demo/app.rbs +11 -0
- data/{examples/gauge_demo → sig/examples/widget_gauge_demo}/app.rbs +4 -0
- data/sig/examples/widget_layout_split/app.rbs +10 -0
- data/sig/examples/widget_line_gauge_demo/app.rbs +11 -0
- data/sig/examples/widget_list_demo/app.rbs +12 -0
- data/sig/examples/widget_list_styles/app.rbs +11 -0
- data/sig/examples/widget_popup_demo/app.rbs +11 -0
- data/sig/examples/widget_ratatui_logo_demo/app.rbs +11 -0
- data/sig/examples/widget_ratatui_mascot_demo/app.rbs +11 -0
- data/sig/examples/widget_rect/app.rbs +12 -0
- data/sig/examples/widget_render/app.rbs +10 -0
- data/sig/examples/widget_rich_text/app.rbs +11 -0
- data/sig/examples/widget_scroll_text/app.rbs +11 -0
- data/sig/examples/widget_scrollbar_demo/app.rbs +11 -0
- data/sig/examples/widget_sparkline_demo/app.rbs +10 -0
- data/{examples → sig/examples}/widget_style_colors/app.rbs +1 -1
- data/sig/examples/widget_table_flex/app.rbs +11 -0
- data/sig/ratatui_ruby/frame.rbs +9 -0
- data/sig/ratatui_ruby/ratatui_ruby.rbs +3 -2
- data/sig/ratatui_ruby/schema/draw.rbs +4 -0
- data/sig/ratatui_ruby/schema/layout.rbs +1 -1
- data/sig/ratatui_ruby/session.rbs +94 -0
- data/tasks/autodoc/inventory.rb +61 -0
- data/tasks/autodoc/member.rb +56 -0
- data/tasks/autodoc/name.rb +19 -0
- data/tasks/autodoc/notice.rb +26 -0
- data/tasks/autodoc/rbs.rb +38 -0
- data/tasks/autodoc/rdoc.rb +45 -0
- data/tasks/autodoc.rake +47 -0
- data/tasks/bump/history.rb +2 -2
- data/tasks/doc.rake +600 -6
- data/tasks/example_viewer.html.erb +172 -0
- data/tasks/lint.rake +8 -4
- data/tasks/resources/index.html.erb +6 -0
- data/tasks/sourcehut.rake +4 -4
- data/tasks/terminal_preview/app_screenshot.rb +1 -3
- data/tasks/terminal_preview/crash_report.rb +7 -9
- data/tasks/terminal_preview/launcher_script.rb +4 -6
- data/tasks/terminal_preview/preview_collection.rb +4 -6
- data/tasks/terminal_preview/safety_confirmation.rb +3 -5
- data/tasks/terminal_preview/saved_screenshot.rb +7 -9
- data/tasks/terminal_preview/terminal_window.rb +7 -9
- data/tasks/test.rake +1 -1
- data/tasks/website/index_page.rb +3 -3
- data/tasks/website/version.rb +10 -10
- data/tasks/website/version_menu.rb +10 -12
- data/tasks/website/versioned_documentation.rb +49 -17
- data/tasks/website/website.rb +6 -8
- data/tasks/website.rake +4 -4
- metadata +156 -125
- data/LICENSES/BSD-2-Clause.txt +0 -9
- data/doc/contributors/better_dx.md +0 -543
- data/doc/contributors/example_analysis.md +0 -82
- data/doc/images/all_events.png +0 -0
- data/doc/images/block_padding.png +0 -0
- data/doc/images/block_titles.png +0 -0
- data/doc/images/box_demo.png +0 -0
- data/doc/images/calendar_demo.png +0 -0
- data/doc/images/cell_demo.png +0 -0
- data/doc/images/chart_demo.png +0 -0
- data/doc/images/flex_layout.png +0 -0
- data/doc/images/gauge_demo.png +0 -0
- data/doc/images/line_gauge_demo.png +0 -0
- data/doc/images/list_demo.png +0 -0
- data/doc/images/readme_usage.png +0 -0
- data/doc/images/scrollbar_demo.png +0 -0
- data/doc/images/sparkline_demo.png +0 -0
- data/doc/images/table_flex.png +0 -0
- data/examples/all_events/app.rb +0 -169
- data/examples/all_events/app.rbs +0 -7
- data/examples/all_events/test_app.rb +0 -139
- data/examples/analytics/app.rb +0 -258
- data/examples/analytics/app.rbs +0 -7
- data/examples/analytics/test_app.rb +0 -132
- data/examples/block_padding/app.rbs +0 -7
- data/examples/block_padding/test_app.rb +0 -31
- data/examples/block_titles/app.rbs +0 -7
- data/examples/block_titles/test_app.rb +0 -34
- data/examples/box_demo/app.rbs +0 -7
- data/examples/box_demo/test_app.rb +0 -88
- data/examples/calendar_demo/app.rb +0 -101
- data/examples/calendar_demo/app.rbs +0 -7
- data/examples/calendar_demo/test_app.rb +0 -108
- data/examples/cell_demo/app.rb +0 -108
- data/examples/cell_demo/app.rbs +0 -7
- data/examples/cell_demo/test_app.rb +0 -36
- data/examples/chart_demo/app.rb +0 -203
- data/examples/chart_demo/app.rbs +0 -7
- data/examples/chart_demo/test_app.rb +0 -102
- data/examples/custom_widget/app.rb +0 -51
- data/examples/custom_widget/app.rbs +0 -7
- data/examples/custom_widget/test_app.rb +0 -30
- data/examples/flex_layout/app.rb +0 -156
- data/examples/flex_layout/app.rbs +0 -7
- data/examples/flex_layout/test_app.rb +0 -65
- data/examples/gauge_demo/app.rb +0 -182
- data/examples/gauge_demo/test_app.rb +0 -120
- data/examples/hit_test/app.rb +0 -175
- data/examples/hit_test/app.rbs +0 -7
- data/examples/hit_test/test_app.rb +0 -102
- data/examples/line_gauge_demo/app.rb +0 -190
- data/examples/line_gauge_demo/app.rbs +0 -7
- data/examples/line_gauge_demo/test_app.rb +0 -129
- data/examples/list_demo/app.rb +0 -253
- data/examples/list_demo/test_app.rb +0 -237
- data/examples/list_styles/app.rb +0 -140
- data/examples/list_styles/app.rbs +0 -7
- data/examples/list_styles/test_app.rb +0 -157
- data/examples/login_form/app.rbs +0 -7
- data/examples/login_form/test_app.rb +0 -51
- data/examples/map_demo/app.rbs +0 -7
- data/examples/map_demo/test_app.rb +0 -149
- data/examples/mouse_events/app.rb +0 -97
- data/examples/mouse_events/app.rbs +0 -7
- data/examples/mouse_events/test_app.rb +0 -53
- data/examples/popup_demo/app.rb +0 -103
- data/examples/popup_demo/app.rbs +0 -7
- data/examples/popup_demo/test_app.rb +0 -54
- data/examples/quickstart_dsl/app.rbs +0 -7
- data/examples/quickstart_dsl/test_app.rb +0 -29
- data/examples/quickstart_lifecycle/app.rbs +0 -7
- data/examples/quickstart_lifecycle/test_app.rb +0 -29
- data/examples/ratatui_logo_demo/app.rb +0 -79
- data/examples/ratatui_logo_demo/app.rbs +0 -7
- data/examples/ratatui_logo_demo/test_app.rb +0 -51
- data/examples/ratatui_mascot_demo/app.rb +0 -84
- data/examples/ratatui_mascot_demo/app.rbs +0 -7
- data/examples/ratatui_mascot_demo/test_app.rb +0 -47
- data/examples/readme_usage/app.rb +0 -29
- data/examples/readme_usage/app.rbs +0 -7
- data/examples/readme_usage/test_app.rb +0 -29
- data/examples/rich_text/app.rb +0 -141
- data/examples/rich_text/app.rbs +0 -7
- data/examples/rich_text/test_app.rb +0 -166
- data/examples/scroll_text/app.rb +0 -103
- data/examples/scroll_text/app.rbs +0 -7
- data/examples/scroll_text/test_app.rb +0 -110
- data/examples/scrollbar_demo/app.rb +0 -143
- data/examples/scrollbar_demo/app.rbs +0 -7
- data/examples/scrollbar_demo/test_app.rb +0 -77
- data/examples/sparkline_demo/app.rb +0 -240
- data/examples/sparkline_demo/test_app.rb +0 -107
- data/examples/table_flex/app.rb +0 -65
- data/examples/table_flex/app.rbs +0 -7
- data/examples/table_flex/test_app.rb +0 -36
- data/examples/table_select/app.rbs +0 -7
- data/examples/table_select/test_app.rb +0 -180
- data/examples/widget_style_colors/test_app.rb +0 -48
- /data/doc/images/{analytics.png → app_analytics.png} +0 -0
- /data/doc/images/{custom_widget.png → app_custom_widget.png} +0 -0
- /data/doc/images/{login_form.png → app_login_form.png} +0 -0
- /data/doc/images/{map_demo.png → app_map_demo.png} +0 -0
- /data/doc/images/{mouse_events.png → app_mouse_events.png} +0 -0
- /data/doc/images/{table_select.png → app_table_select.png} +0 -0
- /data/doc/images/{quickstart_dsl.png → verify_quickstart_dsl.png} +0 -0
- /data/doc/images/{ratatui_logo_demo.png → verify_quickstart_layout.png} +0 -0
- /data/doc/images/{quickstart_lifecycle.png → verify_quickstart_lifecycle.png} +0 -0
- /data/doc/images/{list_styles.png → widget_list_styles.png} +0 -0
- /data/doc/images/{popup_demo.png → widget_popup_demo.png} +0 -0
- /data/doc/images/{hit_test.png → widget_rect.png} +0 -0
- /data/doc/images/{rich_text.png → widget_rich_text.png} +0 -0
- /data/doc/images/{scroll_text.png → widget_scroll_text.png} +0 -0
|
@@ -4,75 +4,75 @@
|
|
|
4
4
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
|
|
6
6
|
module RatatuiRuby
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
7
|
+
# Displays a compact, single-line progress bar.
|
|
8
|
+
#
|
|
9
|
+
# Screen space is precious. Standard block gauges are bulky and consume multiple rows.
|
|
10
|
+
#
|
|
11
|
+
# This widget compresses the feedback. It draws a progress bar using line characters, fitting perfectly into tight layouts or lists.
|
|
12
|
+
#
|
|
13
|
+
# Use it when you need to show status without stealing focus or space.
|
|
14
|
+
#
|
|
15
|
+
# {rdoc-image:/doc/images/widget_line_gauge_demo.png}[link:/examples/widget_line_gauge_demo/app_rb.html]
|
|
16
|
+
#
|
|
17
|
+
# === Example
|
|
18
|
+
#
|
|
19
|
+
# Run the interactive demo from the terminal:
|
|
20
|
+
#
|
|
21
|
+
# ruby examples/widget_line_gauge_demo/app.rb
|
|
22
|
+
class LineGauge < Data.define(:ratio, :label, :style, :filled_style, :unfilled_style, :block, :filled_symbol, :unfilled_symbol)
|
|
23
|
+
##
|
|
24
|
+
# :attr_reader: ratio
|
|
25
|
+
# Progress ratio from 0.0 to 1.0.
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
##
|
|
28
|
+
# :attr_reader: label
|
|
29
|
+
# Optional label.
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
##
|
|
32
|
+
# :attr_reader: style
|
|
33
|
+
# Base style applied to the entire gauge.
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
##
|
|
36
|
+
# :attr_reader: filled_style
|
|
37
|
+
# Style for the completed portion.
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
##
|
|
40
|
+
# :attr_reader: unfilled_style
|
|
41
|
+
# Style for the remainder.
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
##
|
|
44
|
+
# :attr_reader: block
|
|
45
|
+
# Optional wrapping block.
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
##
|
|
48
|
+
# :attr_reader: filled_symbol
|
|
49
|
+
# Character for filled segments.
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
##
|
|
52
|
+
# :attr_reader: unfilled_symbol
|
|
53
|
+
# Character for empty segments.
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
end
|
|
55
|
+
# Creates a new LineGauge.
|
|
56
|
+
#
|
|
57
|
+
# [ratio] Float (0.0 - 1.0).
|
|
58
|
+
# [label] String (optional).
|
|
59
|
+
# [style] Style (optional, base style for the gauge).
|
|
60
|
+
# [filled_style] Style.
|
|
61
|
+
# [unfilled_style] Style.
|
|
62
|
+
# [block] Block.
|
|
63
|
+
# [filled_symbol] String (default: <tt>"█"</tt>).
|
|
64
|
+
# [unfilled_symbol] String (default: <tt>"░"</tt>).
|
|
65
|
+
def initialize(ratio: 0.0, label: nil, style: nil, filled_style: nil, unfilled_style: nil, block: nil, filled_symbol: "█", unfilled_symbol: "░")
|
|
66
|
+
super(
|
|
67
|
+
ratio: Float(ratio),
|
|
68
|
+
label:,
|
|
69
|
+
style:,
|
|
70
|
+
filled_style:,
|
|
71
|
+
unfilled_style:,
|
|
72
|
+
block:,
|
|
73
|
+
filled_symbol:,
|
|
74
|
+
unfilled_symbol:
|
|
75
|
+
)
|
|
77
76
|
end
|
|
77
|
+
end
|
|
78
78
|
end
|
|
@@ -4,99 +4,101 @@
|
|
|
4
4
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
|
|
6
6
|
module RatatuiRuby
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
7
|
+
# Displays a selectable list of items.
|
|
8
|
+
#
|
|
9
|
+
# Users need to choose from options. Menus, file explorers, and selectors are everywhere.
|
|
10
|
+
# Implementing navigation, highlighting, and scrolling state from scratch is tedious.
|
|
11
|
+
#
|
|
12
|
+
# This widget manages the list. It renders the items. It highlights the selection. It handles the scrolling window.
|
|
13
|
+
#
|
|
14
|
+
# Use it to build main menus, navigation sidebars, or logs.
|
|
15
|
+
#
|
|
16
|
+
# {rdoc-image:/doc/images/widget_list_demo.png}[link:/examples/widget_list_demo/app_rb.html]
|
|
17
|
+
#
|
|
18
|
+
# === Examples
|
|
19
|
+
#
|
|
20
|
+
# # Basic List
|
|
21
|
+
# List.new(items: ["Item 1", "Item 2"])
|
|
22
|
+
#
|
|
23
|
+
# # Navigation Menu
|
|
24
|
+
# List.new(
|
|
25
|
+
# items: ["New Game", "Load Game", "Options", "Quit"],
|
|
26
|
+
# selected_index: 0,
|
|
27
|
+
# highlight_style: Style.new(bg: :blue),
|
|
28
|
+
# highlight_symbol: ">> "
|
|
29
|
+
# )
|
|
30
|
+
class List < Data.define(:items, :selected_index, :style, :highlight_style, :highlight_symbol, :repeat_highlight_symbol, :highlight_spacing, :direction, :scroll_padding, :block)
|
|
31
|
+
##
|
|
32
|
+
# :attr_reader: items
|
|
33
|
+
# The items to display (Array of Strings).
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
##
|
|
36
|
+
# :attr_reader: selected_index
|
|
37
|
+
# Index of the active selection (Integer or nil).
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
##
|
|
40
|
+
# :attr_reader: style
|
|
41
|
+
# Base style for unselected items.
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
##
|
|
44
|
+
# :attr_reader: highlight_style
|
|
45
|
+
# Style for the selected item.
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
##
|
|
48
|
+
# :attr_reader: highlight_symbol
|
|
49
|
+
# Symbol drawn before the selected item.
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
##
|
|
52
|
+
# :attr_reader: repeat_highlight_symbol
|
|
53
|
+
# Whether to repeat the highlight symbol for each line of the selected item.
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
##
|
|
56
|
+
# :attr_reader: highlight_spacing
|
|
57
|
+
# When to show the highlight symbol column.
|
|
58
|
+
#
|
|
59
|
+
# <tt>:always</tt>, <tt>:when_selected</tt>, or <tt>:never</tt>.
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
##
|
|
62
|
+
# :attr_reader: direction
|
|
63
|
+
# Render direction.
|
|
64
|
+
#
|
|
65
|
+
# <tt>:top_to_bottom</tt> or <tt>:bottom_to_top</tt>.
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
##
|
|
68
|
+
# :attr_reader: scroll_padding
|
|
69
|
+
# Number of items to keep visible above/below the selected item when scrolling (Integer or nil).
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
##
|
|
72
|
+
# :attr_reader: block
|
|
73
|
+
# Optional wrapping block.
|
|
72
74
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
end
|
|
75
|
+
# Creates a new List.
|
|
76
|
+
#
|
|
77
|
+
# Integer parameters accept any object responding to +to_int+ or +to_i+ (duck-typed).
|
|
78
|
+
#
|
|
79
|
+
# [items] Array of Strings.
|
|
80
|
+
# [selected_index] Numeric (nullable, coerced to Integer).
|
|
81
|
+
# [style] Style object.
|
|
82
|
+
# [highlight_style] Style object.
|
|
83
|
+
# [highlight_symbol] String (default: <tt>"> "</tt>).
|
|
84
|
+
# [repeat_highlight_symbol] Boolean (default: <tt>false</tt>).
|
|
85
|
+
# [highlight_spacing] Symbol (default: <tt>:when_selected</tt>).
|
|
86
|
+
# [direction] Symbol (default: <tt>:top_to_bottom</tt>).
|
|
87
|
+
# [scroll_padding] Numeric (nullable, coerced to Integer, default: <tt>nil</tt>).
|
|
88
|
+
# [block] Block (optional).
|
|
89
|
+
def initialize(items: [], selected_index: nil, style: nil, highlight_style: nil, highlight_symbol: "> ", repeat_highlight_symbol: false, highlight_spacing: :when_selected, direction: :top_to_bottom, scroll_padding: nil, block: nil)
|
|
90
|
+
super(
|
|
91
|
+
items:,
|
|
92
|
+
selected_index: selected_index.nil? ? nil : Integer(selected_index),
|
|
93
|
+
style:,
|
|
94
|
+
highlight_style:,
|
|
95
|
+
highlight_symbol:,
|
|
96
|
+
repeat_highlight_symbol:,
|
|
97
|
+
highlight_spacing:,
|
|
98
|
+
direction:,
|
|
99
|
+
scroll_padding: scroll_padding.nil? ? nil : Integer(scroll_padding),
|
|
100
|
+
block:
|
|
101
|
+
)
|
|
101
102
|
end
|
|
103
|
+
end
|
|
102
104
|
end
|
|
@@ -4,38 +4,38 @@
|
|
|
4
4
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
|
|
6
6
|
module RatatuiRuby
|
|
7
|
-
|
|
7
|
+
# Stacks widgets on top of each other.
|
|
8
|
+
#
|
|
9
|
+
# Terminal interfaces are 2D grids, but complex UIs require depth. You need to float modals over text,
|
|
10
|
+
# or place a status bar on top of a map.
|
|
11
|
+
#
|
|
12
|
+
# This widget manages the Z-axis. It renders a list of widgets sequentially into the same area.
|
|
13
|
+
# Later widgets draw over earlier ones (Painter's Algorithm).
|
|
14
|
+
#
|
|
15
|
+
# Use overlays to compose complex scenes. Combine backgrounds, main content, and floating elements.
|
|
16
|
+
#
|
|
17
|
+
# === Examples
|
|
18
|
+
#
|
|
19
|
+
# Overlay.new(
|
|
20
|
+
# layers: [
|
|
21
|
+
# BackgroundMap.new,
|
|
22
|
+
# StatusBar.new, # Draws over map
|
|
23
|
+
# ModalDialog.new # Draws over everything
|
|
24
|
+
# ]
|
|
25
|
+
# )
|
|
26
|
+
class Overlay < Data.define(:layers)
|
|
27
|
+
##
|
|
28
|
+
# :attr_reader: layers
|
|
29
|
+
# The stack of widgets to render.
|
|
8
30
|
#
|
|
9
|
-
#
|
|
10
|
-
# or place a status bar on top of a map.
|
|
11
|
-
#
|
|
12
|
-
# This widget manages the Z-axis. It renders a list of widgets sequentially into the same area.
|
|
13
|
-
# Later widgets draw over earlier ones (Painter's Algorithm).
|
|
14
|
-
#
|
|
15
|
-
# Use overlays to compose complex scenes. Combine backgrounds, main content, and floating elements.
|
|
16
|
-
#
|
|
17
|
-
# === Examples
|
|
18
|
-
#
|
|
19
|
-
# Overlay.new(
|
|
20
|
-
# layers: [
|
|
21
|
-
# BackgroundMap.new,
|
|
22
|
-
# StatusBar.new, # Draws over map
|
|
23
|
-
# ModalDialog.new # Draws over everything
|
|
24
|
-
# ]
|
|
25
|
-
# )
|
|
26
|
-
class Overlay < Data.define(:layers)
|
|
27
|
-
##
|
|
28
|
-
# :attr_reader: layers
|
|
29
|
-
# The stack of widgets to render.
|
|
30
|
-
#
|
|
31
|
-
# Rendered from index 0 to N. Index N is the top-most layer.
|
|
31
|
+
# Rendered from index 0 to N. Index N is the top-most layer.
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
end
|
|
33
|
+
# Creates a new Overlay.
|
|
34
|
+
#
|
|
35
|
+
# [layers]
|
|
36
|
+
# Array of widgets.
|
|
37
|
+
def initialize(layers: [])
|
|
38
|
+
super
|
|
40
39
|
end
|
|
40
|
+
end
|
|
41
41
|
end
|
|
@@ -4,94 +4,94 @@
|
|
|
4
4
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
|
|
6
6
|
module RatatuiRuby
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
7
|
+
# Displays a block of text.
|
|
8
|
+
#
|
|
9
|
+
# Raw strings are insufficient for UIs. They overflow constraints. They don't respect alignment (left, center, right).
|
|
10
|
+
#
|
|
11
|
+
# This widget creates a smart text container. It wraps content to fit the area. It aligns text as requested. It supports scrolling.
|
|
12
|
+
#
|
|
13
|
+
# Use it for everything from simple labels to complex, multi-paragraph documents.
|
|
14
|
+
#
|
|
15
|
+
# === Examples
|
|
16
|
+
#
|
|
17
|
+
# # Basic Text
|
|
18
|
+
# Paragraph.new(text: "Hello, World!")
|
|
19
|
+
#
|
|
20
|
+
# # Styled container with wrapping
|
|
21
|
+
# Paragraph.new(
|
|
22
|
+
# text: "This is a long line that will wrap automatically.",
|
|
23
|
+
# style: Style.new(fg: :green),
|
|
24
|
+
# wrap: true,
|
|
25
|
+
# block: Block.new(title: "Output", borders: [:all])
|
|
26
|
+
# )
|
|
27
|
+
#
|
|
28
|
+
# # Scrolling mechanism
|
|
29
|
+
# Paragraph.new(text: large_text, scroll: [scroll_y, 0])
|
|
30
|
+
class Paragraph < Data.define(:text, :style, :block, :wrap, :alignment, :scroll)
|
|
31
|
+
##
|
|
32
|
+
# :attr_reader: text
|
|
33
|
+
# The content to display.
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
##
|
|
36
|
+
# :attr_reader: style
|
|
37
|
+
# Base style for the text.
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
##
|
|
40
|
+
# :attr_reader: block
|
|
41
|
+
# Optional wrapping block.
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
##
|
|
44
|
+
# :attr_reader: wrap
|
|
45
|
+
# Whether to wrap text at the edge of the container (Boolean).
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
##
|
|
48
|
+
# :attr_reader: alignment
|
|
49
|
+
# Text alignment.
|
|
50
|
+
#
|
|
51
|
+
# <tt>:left</tt>, <tt>:center</tt>, or <tt>:right</tt>.
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
##
|
|
54
|
+
# :attr_reader: scroll
|
|
55
|
+
# Scroll offset [y, x].
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
57
|
+
# Creates a new Paragraph.
|
|
58
|
+
#
|
|
59
|
+
# [text] String or Text::Line array.
|
|
60
|
+
# [style] Style object.
|
|
61
|
+
# [block] Block object.
|
|
62
|
+
# [wrap] Boolean (default: false).
|
|
63
|
+
# [alignment] Symbol (default: <tt>:left</tt>).
|
|
64
|
+
# [scroll] Array of [y, x] integers (duck-typed via +to_int+).
|
|
65
|
+
def initialize(text:, style: Style.default, block: nil, wrap: false, alignment: :left, scroll: [0, 0])
|
|
66
|
+
super(
|
|
67
|
+
text:,
|
|
68
|
+
style:,
|
|
69
|
+
block:,
|
|
70
|
+
wrap:,
|
|
71
|
+
alignment:,
|
|
72
|
+
scroll: [Integer(scroll[0]), Integer(scroll[1])]
|
|
73
|
+
)
|
|
74
|
+
end
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
# Legacy constructor support.
|
|
77
|
+
def self.new(text:, style: nil, fg: nil, bg: nil, block: nil, wrap: false, alignment: :left, scroll: [0, 0])
|
|
78
|
+
style ||= Style.new(fg:, bg:)
|
|
79
|
+
coerced_scroll = [Integer(scroll[0]), Integer(scroll[1])]
|
|
80
|
+
super(text:, style:, block:, wrap:, alignment:, scroll: coerced_scroll)
|
|
81
|
+
end
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
# Returns the number of lines the paragraph would take up if rendered with the given width.
|
|
84
|
+
#
|
|
85
|
+
# [width] Integer (max width).
|
|
86
|
+
def line_count(width)
|
|
87
|
+
RatatuiRuby.warn_experimental_feature("Paragraph#line_count")
|
|
88
|
+
RatatuiRuby._paragraph_line_count(self, Integer(width))
|
|
89
|
+
end
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
end
|
|
91
|
+
# Returns the minimum width needed to not wrap any text.
|
|
92
|
+
def line_width
|
|
93
|
+
RatatuiRuby.warn_experimental_feature("Paragraph#line_width")
|
|
94
|
+
RatatuiRuby._paragraph_line_width(self)
|
|
96
95
|
end
|
|
96
|
+
end
|
|
97
97
|
end
|
|
@@ -6,20 +6,24 @@
|
|
|
6
6
|
module RatatuiRuby
|
|
7
7
|
# Displays the Ratatui logo.
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# Branding is important for identity. Users need to recognize the tools they use.
|
|
10
10
|
#
|
|
11
|
-
#
|
|
11
|
+
# This widget renders the official Ratatui logo.
|
|
12
12
|
#
|
|
13
|
-
#
|
|
13
|
+
# Use it for splash screens, about sections, or terminal dashboards.
|
|
14
14
|
#
|
|
15
|
+
# {rdoc-image:/doc/images/widget_ratatui_logo_demo.png}[link:/examples/widget_ratatui_logo_demo/app_rb.html]
|
|
16
|
+
#
|
|
17
|
+
# === Example
|
|
18
|
+
#
|
|
19
|
+
# Run the interactive demo from the terminal:
|
|
20
|
+
#
|
|
21
|
+
# ruby examples/widget_ratatui_logo_demo/app.rb
|
|
15
22
|
class RatatuiLogo < Data.define
|
|
16
23
|
##
|
|
17
24
|
# :method: new
|
|
18
25
|
# :call-seq: new -> RatatuiLogo
|
|
19
26
|
#
|
|
20
27
|
# Creates a new RatatuiLogo.
|
|
21
|
-
def initialize
|
|
22
|
-
super
|
|
23
|
-
end
|
|
24
28
|
end
|
|
25
29
|
end
|
|
@@ -6,14 +6,19 @@
|
|
|
6
6
|
module RatatuiRuby
|
|
7
7
|
# Displays the Ratatui mascot.
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# Interfaces without personality feel clinical and dry. Users appreciate a friendly face in their terminal.
|
|
10
10
|
#
|
|
11
|
-
#
|
|
11
|
+
# This widget renders the Ratatui mascot (a mouse).
|
|
12
12
|
#
|
|
13
|
-
#
|
|
14
|
-
# block: Block.new(title: "Mascot")
|
|
15
|
-
# )
|
|
13
|
+
# Use it to add charm to your application, greet users on startup, or as a decorative element in sidebars.
|
|
16
14
|
#
|
|
15
|
+
# {rdoc-image:/doc/images/widget_ratatui_mascot_demo.png}[link:/examples/widget_ratatui_mascot_demo/app_rb.html]
|
|
16
|
+
#
|
|
17
|
+
# === Example
|
|
18
|
+
#
|
|
19
|
+
# Run the interactive demo from the terminal:
|
|
20
|
+
#
|
|
21
|
+
# ruby examples/widget_ratatui_mascot_demo/app.rb
|
|
17
22
|
class RatatuiMascot < Data.define(:block)
|
|
18
23
|
##
|
|
19
24
|
# :method: new
|