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
|
@@ -65,7 +65,7 @@ module RatatuiRuby
|
|
|
65
65
|
# [y2] End Y (Numeric).
|
|
66
66
|
# [color] Line color (Symbol).
|
|
67
67
|
def initialize(x1:, y1:, x2:, y2:, color:)
|
|
68
|
-
super(x1: Float(x1), y1: Float(y1), x2: Float(x2), y2: Float(y2), color:
|
|
68
|
+
super(x1: Float(x1), y1: Float(y1), x2: Float(x2), y2: Float(y2), color:)
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
|
|
@@ -105,7 +105,7 @@ module RatatuiRuby
|
|
|
105
105
|
# [height] Height (Numeric).
|
|
106
106
|
# [color] Color (Symbol).
|
|
107
107
|
def initialize(x:, y:, width:, height:, color:)
|
|
108
|
-
super(x: Float(x), y: Float(y), width: Float(width), height: Float(height), color:
|
|
108
|
+
super(x: Float(x), y: Float(y), width: Float(width), height: Float(height), color:)
|
|
109
109
|
end
|
|
110
110
|
end
|
|
111
111
|
|
|
@@ -139,7 +139,7 @@ module RatatuiRuby
|
|
|
139
139
|
# [radius] Radius (Numeric).
|
|
140
140
|
# [color] Color (Symbol).
|
|
141
141
|
def initialize(x:, y:, radius:, color:)
|
|
142
|
-
super(x: Float(x), y: Float(y), radius: Float(radius), color:
|
|
142
|
+
super(x: Float(x), y: Float(y), radius: Float(radius), color:)
|
|
143
143
|
end
|
|
144
144
|
end
|
|
145
145
|
|
|
@@ -158,72 +158,72 @@ module RatatuiRuby
|
|
|
158
158
|
end
|
|
159
159
|
end
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
# Provides a drawing surface for custom shapes.
|
|
162
|
+
#
|
|
163
|
+
# Standard widgets cover standard cases. Sometimes you need to draw a map, a custom diagram, or a game.
|
|
164
|
+
# Character grids are too coarse for fine detail.
|
|
165
|
+
#
|
|
166
|
+
# This widget increases the resolution. It uses Braille patterns or block characters to create a "sub-pixel" drawing surface.
|
|
167
|
+
#
|
|
168
|
+
# Use it to implement free-form graphics, high-resolution plots, or geographic maps.
|
|
169
|
+
#
|
|
170
|
+
# === Examples
|
|
171
|
+
#
|
|
172
|
+
# Canvas.new(
|
|
173
|
+
# x_bounds: [-180, 180],
|
|
174
|
+
# y_bounds: [-90, 90],
|
|
175
|
+
# shapes: [
|
|
176
|
+
# Shape::Map.new(color: :green, resolution: :high),
|
|
177
|
+
# Shape::Circle.new(x: 0, y: 0, radius: 10, color: :red),
|
|
178
|
+
# Shape::Label.new(x: -122.4, y: 37.8, text: "San Francisco")
|
|
179
|
+
# ]
|
|
180
|
+
# )
|
|
181
|
+
class Canvas < Data.define(:shapes, :x_bounds, :y_bounds, :marker, :block, :background_color)
|
|
182
|
+
##
|
|
183
|
+
# :attr_reader: shapes
|
|
184
|
+
# Array of shapes to render.
|
|
162
185
|
#
|
|
163
|
-
#
|
|
164
|
-
# Character grids are too coarse for fine detail.
|
|
165
|
-
#
|
|
166
|
-
# This widget increases the resolution. It uses Braille patterns or block characters to create a "sub-pixel" drawing surface.
|
|
167
|
-
#
|
|
168
|
-
# Use it to implement free-form graphics, high-resolution plots, or geographic maps.
|
|
169
|
-
#
|
|
170
|
-
# === Examples
|
|
171
|
-
#
|
|
172
|
-
# Canvas.new(
|
|
173
|
-
# x_bounds: [-180, 180],
|
|
174
|
-
# y_bounds: [-90, 90],
|
|
175
|
-
# shapes: [
|
|
176
|
-
# Shape::Map.new(color: :green, resolution: :high),
|
|
177
|
-
# Shape::Circle.new(x: 0, y: 0, radius: 10, color: :red),
|
|
178
|
-
# Shape::Label.new(x: -122.4, y: 37.8, text: "San Francisco")
|
|
179
|
-
# ]
|
|
180
|
-
# )
|
|
181
|
-
class Canvas < Data.define(:shapes, :x_bounds, :y_bounds, :marker, :block, :background_color)
|
|
182
|
-
##
|
|
183
|
-
# :attr_reader: shapes
|
|
184
|
-
# Array of shapes to render.
|
|
185
|
-
#
|
|
186
|
-
# Includes {Shape::Line}, {Shape::Circle}, {Shape::Map}, etc.
|
|
186
|
+
# Includes {Shape::Line}, {Shape::Circle}, {Shape::Map}, etc.
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
##
|
|
189
|
+
# :attr_reader: x_bounds
|
|
190
|
+
# [min, max] range for the x-axis.
|
|
191
191
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
192
|
+
##
|
|
193
|
+
# :attr_reader: y_bounds
|
|
194
|
+
# [min, max] range for the y-axis.
|
|
195
195
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
196
|
+
##
|
|
197
|
+
# :attr_reader: marker
|
|
198
|
+
# The marker type used for drawing.
|
|
199
|
+
#
|
|
200
|
+
# <tt>:braille</tt> (high res), <tt>:half_block</tt>, <tt>:dot</tt>, <tt>:block</tt>, <tt>:bar</tt>.
|
|
201
201
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
##
|
|
203
|
+
# :attr_reader: block
|
|
204
|
+
# Optional wrapping block.
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
##
|
|
207
|
+
# :attr_reader: background_color
|
|
208
|
+
# The background color of the canvas.
|
|
209
209
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
end
|
|
210
|
+
# Creates a new Canvas.
|
|
211
|
+
#
|
|
212
|
+
# [shapes] Array of Shapes.
|
|
213
|
+
# [x_bounds] Array of [min, max] (Numeric, duck-typed via +to_f+).
|
|
214
|
+
# [y_bounds] Array of [min, max] (Numeric, duck-typed via +to_f+).
|
|
215
|
+
# [marker] Symbol (default: <tt>:braille</tt>).
|
|
216
|
+
# [block] Block (optional).
|
|
217
|
+
# [background_color] Color (optional).
|
|
218
|
+
def initialize(shapes: [], x_bounds: [0.0, 100.0], y_bounds: [0.0, 100.0], marker: :braille, block: nil, background_color: nil)
|
|
219
|
+
super(
|
|
220
|
+
shapes:,
|
|
221
|
+
x_bounds: [Float(x_bounds[0]), Float(x_bounds[1])],
|
|
222
|
+
y_bounds: [Float(y_bounds[0]), Float(y_bounds[1])],
|
|
223
|
+
marker:,
|
|
224
|
+
block:,
|
|
225
|
+
background_color:
|
|
226
|
+
)
|
|
228
227
|
end
|
|
228
|
+
end
|
|
229
229
|
end
|
|
@@ -4,54 +4,54 @@
|
|
|
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
|
-
|
|
7
|
+
# Centers content within available space.
|
|
8
|
+
#
|
|
9
|
+
# Layouts often require alignment. Manually calculating offsets for centering is error-prone and brittle.
|
|
10
|
+
#
|
|
11
|
+
# This widget handles the math. It centers a child widget within the current area, resizing the child
|
|
12
|
+
# according to optional percentage modifiers.
|
|
13
|
+
#
|
|
14
|
+
# Use it to position modals, splash screens, or floating dialogue boxes.
|
|
15
|
+
#
|
|
16
|
+
# === Examples
|
|
17
|
+
#
|
|
18
|
+
# # Center a paragraph using 50% of width and height
|
|
19
|
+
# Center.new(
|
|
20
|
+
# child: Paragraph.new(text: "Hello"),
|
|
21
|
+
# width_percent: 50,
|
|
22
|
+
# height_percent: 50
|
|
23
|
+
# )
|
|
24
|
+
class Center < Data.define(:child, :width_percent, :height_percent)
|
|
25
|
+
##
|
|
26
|
+
# :attr_reader: child
|
|
27
|
+
# The widget to be centered.
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
##
|
|
30
|
+
# :attr_reader: width_percent
|
|
31
|
+
# Width of the centered area as a percentage (0-100).
|
|
32
|
+
#
|
|
33
|
+
# If 50, the child occupies half the available width.
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
##
|
|
36
|
+
# :attr_reader: height_percent
|
|
37
|
+
# Height of the centered area as a percentage (0-100).
|
|
38
|
+
#
|
|
39
|
+
# If 50, the child occupies half the available height.
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
end
|
|
41
|
+
# Creates a new Center widget.
|
|
42
|
+
#
|
|
43
|
+
# [child]
|
|
44
|
+
# Widget to render.
|
|
45
|
+
# [width_percent]
|
|
46
|
+
# Target width percentage (Integer, default: 100).
|
|
47
|
+
# [height_percent]
|
|
48
|
+
# Target height percentage (Integer, default: 100).
|
|
49
|
+
def initialize(child:, width_percent: 100, height_percent: 100)
|
|
50
|
+
super(
|
|
51
|
+
child:,
|
|
52
|
+
width_percent: Float(width_percent),
|
|
53
|
+
height_percent: Float(height_percent)
|
|
54
|
+
)
|
|
56
55
|
end
|
|
56
|
+
end
|
|
57
57
|
end
|
|
@@ -10,44 +10,44 @@ module RatatuiRuby
|
|
|
10
10
|
# [labels] Array<String>
|
|
11
11
|
# [style] Style
|
|
12
12
|
# [labels_alignment] Symbol (<tt>:left</tt>, <tt>:center</tt>, <tt>:right</tt>)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
end
|
|
13
|
+
class Axis < Data.define(:title, :bounds, :labels, :style, :labels_alignment)
|
|
14
|
+
##
|
|
15
|
+
# :attr_reader: title
|
|
16
|
+
# Label for the axis (String).
|
|
17
|
+
|
|
18
|
+
##
|
|
19
|
+
# :attr_reader: bounds
|
|
20
|
+
# Range [min, max] (Array of Floats).
|
|
21
|
+
|
|
22
|
+
##
|
|
23
|
+
# :attr_reader: labels
|
|
24
|
+
# Explicit labels for ticks (Array of Strings).
|
|
25
|
+
|
|
26
|
+
##
|
|
27
|
+
# :attr_reader: style
|
|
28
|
+
# Style for axis lines/text.
|
|
29
|
+
|
|
30
|
+
##
|
|
31
|
+
# :attr_reader: labels_alignment
|
|
32
|
+
# Alignment of axis labels (:left, :center, :right).
|
|
33
|
+
|
|
34
|
+
# Creates a new Axis.
|
|
35
|
+
#
|
|
36
|
+
# [title] String.
|
|
37
|
+
# [bounds] Array [min, max].
|
|
38
|
+
# [labels] Array of Strings.
|
|
39
|
+
# [style] Style.
|
|
40
|
+
# [labels_alignment] Symbol (:left, :center, :right).
|
|
41
|
+
def initialize(title: "", bounds: [0.0, 10.0], labels: [], style: nil, labels_alignment: nil)
|
|
42
|
+
super(
|
|
43
|
+
title:,
|
|
44
|
+
bounds: [Float(bounds[0]), Float(bounds[1])],
|
|
45
|
+
labels:,
|
|
46
|
+
style:,
|
|
47
|
+
labels_alignment:
|
|
48
|
+
)
|
|
50
49
|
end
|
|
50
|
+
end
|
|
51
51
|
|
|
52
52
|
# Defines a Dataset for a Chart.
|
|
53
53
|
# [name] The name of the dataset.
|
|
@@ -55,113 +55,105 @@ module RatatuiRuby
|
|
|
55
55
|
# [style] The style of the line.
|
|
56
56
|
# [marker] Symbol (<tt>:dot</tt>, <tt>:braille</tt>, <tt>:block</tt>, <tt>:bar</tt>)
|
|
57
57
|
# [graph_type] Symbol (<tt>:line</tt>, <tt>:scatter</tt>)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
#
|
|
71
|
-
# **Note**: Due to Ratatui's Chart widget design, only the foreground color (<tt>fg</tt>) is applied to markers in the chart area.
|
|
72
|
-
# The full style (including <tt>bg</tt> and <tt>modifiers</tt>) is displayed in the legend.
|
|
73
|
-
#
|
|
74
|
-
# Supports:
|
|
75
|
-
# - +fg+: Foreground color of markers (Symbol/Hex) - _applied to chart_
|
|
76
|
-
# - +bg+: Background color (Symbol/Hex) - _legend only_
|
|
77
|
-
# - +modifiers+: Array of effects (<tt>:bold</tt>, <tt>:dim</tt>, <tt>:italic</tt>, <tt>:underlined</tt>, <tt>:slow_blink</tt>, <tt>:rapid_blink</tt>, <tt>:reversed</tt>, <tt>:hidden</tt>, <tt>:crossed_out</tt>) - _legend only_
|
|
78
|
-
|
|
79
|
-
##
|
|
80
|
-
# :attr_reader: marker
|
|
81
|
-
# Marker type (<tt>:dot</tt>, <tt>:braille</tt>).
|
|
82
|
-
|
|
83
|
-
##
|
|
84
|
-
# :attr_reader: graph_type
|
|
85
|
-
# Type of graph (<tt>:line</tt>, <tt>:scatter</tt>).
|
|
86
|
-
|
|
87
|
-
# Creates a new Dataset.
|
|
88
|
-
#
|
|
89
|
-
# [name] String.
|
|
90
|
-
# [data] Array of [x, y] (Numeric, duck-typed via +to_f+).
|
|
91
|
-
# [style] Style.
|
|
92
|
-
# [marker] Symbol.
|
|
93
|
-
# [graph_type] Symbol.
|
|
94
|
-
def initialize(name:, data:, style: nil, marker: :dot, graph_type: :line)
|
|
95
|
-
coerced_data = data.map { |point| [Float(point[0]), Float(point[1])] }
|
|
96
|
-
super(name: name, data: coerced_data, style: style, marker: marker, graph_type: graph_type)
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
# Plots data points on a Cartesian coordinate system.
|
|
58
|
+
class Dataset < Data.define(:name, :data, :style, :marker, :graph_type)
|
|
59
|
+
##
|
|
60
|
+
# :attr_reader: name
|
|
61
|
+
# Name for logical identification or legend.
|
|
62
|
+
|
|
63
|
+
##
|
|
64
|
+
# :attr_reader: data
|
|
65
|
+
# list of [x, y] coordinates.
|
|
66
|
+
|
|
67
|
+
##
|
|
68
|
+
# :attr_reader: style
|
|
69
|
+
# Style applied to the dataset (Style).
|
|
101
70
|
#
|
|
102
|
-
#
|
|
71
|
+
# **Note**: Due to Ratatui's Chart widget design, only the foreground color (<tt>fg</tt>) is applied to markers in the chart area.
|
|
72
|
+
# The full style (including <tt>bg</tt> and <tt>modifiers</tt>) is displayed in the legend.
|
|
103
73
|
#
|
|
104
|
-
#
|
|
105
|
-
#
|
|
106
|
-
#
|
|
74
|
+
# Supports:
|
|
75
|
+
# - +fg+: Foreground color of markers (Symbol/Hex) - _applied to chart_
|
|
76
|
+
# - +bg+: Background color (Symbol/Hex) - _legend only_
|
|
77
|
+
# - +modifiers+: Array of effects (<tt>:bold</tt>, <tt>:dim</tt>, <tt>:italic</tt>, <tt>:underlined</tt>, <tt>:slow_blink</tt>, <tt>:rapid_blink</tt>, <tt>:reversed</tt>, <tt>:hidden</tt>, <tt>:crossed_out</tt>) - _legend only_
|
|
78
|
+
|
|
79
|
+
##
|
|
80
|
+
# :attr_reader: marker
|
|
81
|
+
# Marker type (<tt>:dot</tt>, <tt>:braille</tt>).
|
|
82
|
+
|
|
83
|
+
##
|
|
84
|
+
# :attr_reader: graph_type
|
|
85
|
+
# Type of graph (<tt>:line</tt>, <tt>:scatter</tt>).
|
|
86
|
+
|
|
87
|
+
# Creates a new Dataset.
|
|
107
88
|
#
|
|
108
|
-
#
|
|
89
|
+
# [name] String.
|
|
90
|
+
# [data] Array of [x, y] (Numeric, duck-typed via +to_f+).
|
|
91
|
+
# [style] Style.
|
|
92
|
+
# [marker] Symbol.
|
|
93
|
+
# [graph_type] Symbol.
|
|
94
|
+
def initialize(name:, data:, style: nil, marker: :dot, graph_type: :line)
|
|
95
|
+
coerced_data = data.map { |point| [Float(point[0]), Float(point[1])] }
|
|
96
|
+
super(name:, data: coerced_data, style:, marker:, graph_type:)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Plots data points on a Cartesian coordinate system.
|
|
101
|
+
#
|
|
102
|
+
# Trends and patterns are invisible in raw logs. You need to see the shape of the data to understand the story it tells.
|
|
103
|
+
#
|
|
104
|
+
# This widget plots X/Y coordinates. It supports multiple datasets, custom axes, and different marker types.
|
|
105
|
+
#
|
|
106
|
+
# Use it for analytics, scientific data, or monitoring metrics over time.
|
|
107
|
+
#
|
|
108
|
+
# {rdoc-image:/doc/images/widget_chart_demo.png}[link:/examples/widget_chart_demo/app_rb.html]
|
|
109
|
+
#
|
|
110
|
+
# === Example
|
|
111
|
+
#
|
|
112
|
+
# Run the interactive demo from the terminal:
|
|
113
|
+
#
|
|
114
|
+
# ruby examples/widget_chart_demo/app.rb
|
|
115
|
+
class Chart < Data.define(:datasets, :x_axis, :y_axis, :block, :style, :legend_position, :hidden_legend_constraints)
|
|
116
|
+
##
|
|
117
|
+
# :attr_reader: datasets
|
|
118
|
+
# Array of Dataset objects to plot.
|
|
119
|
+
|
|
120
|
+
##
|
|
121
|
+
# :attr_reader: x_axis
|
|
122
|
+
# Configuration for the X Axis.
|
|
123
|
+
|
|
124
|
+
##
|
|
125
|
+
# :attr_reader: y_axis
|
|
126
|
+
# Configuration for the Y Axis.
|
|
127
|
+
|
|
128
|
+
##
|
|
129
|
+
# :attr_reader: block
|
|
130
|
+
# Optional wrapping block.
|
|
131
|
+
|
|
132
|
+
##
|
|
133
|
+
# :attr_reader: style
|
|
134
|
+
# Base style for the chart area.
|
|
135
|
+
|
|
136
|
+
##
|
|
137
|
+
# :attr_reader: legend_position
|
|
138
|
+
# Position of the legend (<tt>:top_left</tt>, <tt>:top_right</tt>, <tt>:bottom_left</tt>, <tt>:bottom_right</tt>).
|
|
139
|
+
|
|
140
|
+
##
|
|
141
|
+
# :attr_reader: hidden_legend_constraints
|
|
142
|
+
# Constraints for hiding the legend when the chart is too small (Array of [width, height]).
|
|
143
|
+
|
|
144
|
+
# Creates a new Chart widget.
|
|
109
145
|
#
|
|
110
|
-
#
|
|
111
|
-
#
|
|
112
|
-
#
|
|
113
|
-
#
|
|
114
|
-
#
|
|
115
|
-
#
|
|
116
|
-
#
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
# y_axis: Axis.new(title: "RPS", bounds: [0.0, 5.0]),
|
|
120
|
-
# legend_position: :top_right
|
|
121
|
-
# )
|
|
122
|
-
class Chart < Data.define(:datasets, :x_axis, :y_axis, :block, :style, :legend_position, :hidden_legend_constraints)
|
|
123
|
-
##
|
|
124
|
-
# :attr_reader: datasets
|
|
125
|
-
# Array of Dataset objects to plot.
|
|
126
|
-
|
|
127
|
-
##
|
|
128
|
-
# :attr_reader: x_axis
|
|
129
|
-
# Configuration for the X Axis.
|
|
130
|
-
|
|
131
|
-
##
|
|
132
|
-
# :attr_reader: y_axis
|
|
133
|
-
# Configuration for the Y Axis.
|
|
134
|
-
|
|
135
|
-
##
|
|
136
|
-
# :attr_reader: block
|
|
137
|
-
# Optional wrapping block.
|
|
138
|
-
|
|
139
|
-
##
|
|
140
|
-
# :attr_reader: style
|
|
141
|
-
# Base style for the chart area.
|
|
142
|
-
|
|
143
|
-
##
|
|
144
|
-
# :attr_reader: legend_position
|
|
145
|
-
# Position of the legend (<tt>:top_left</tt>, <tt>:top_right</tt>, <tt>:bottom_left</tt>, <tt>:bottom_right</tt>).
|
|
146
|
-
|
|
147
|
-
##
|
|
148
|
-
# :attr_reader: hidden_legend_constraints
|
|
149
|
-
# Constraints for hiding the legend when the chart is too small (Array of [width, height]).
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
# Creates a new Chart widget.
|
|
153
|
-
#
|
|
154
|
-
# [datasets] Array of Datasets.
|
|
155
|
-
# [x_axis] X Axis config.
|
|
156
|
-
# [y_axis] Y Axis config.
|
|
157
|
-
# [block] Wrapper (optional).
|
|
158
|
-
# [style] Base style (optional).
|
|
159
|
-
# [legend_position] Symbol (<tt>:top_left</tt>, <tt>:top_right</tt>, <tt>:bottom_left</tt>, <tt>:bottom_right</tt>).
|
|
160
|
-
# [hidden_legend_constraints] Array of two Constraints [width, height] (optional).
|
|
161
|
-
def initialize(datasets:, x_axis:, y_axis:, block: nil, style: nil, legend_position: nil, hidden_legend_constraints: [])
|
|
162
|
-
super
|
|
163
|
-
end
|
|
146
|
+
# [datasets] Array of Datasets.
|
|
147
|
+
# [x_axis] X Axis config.
|
|
148
|
+
# [y_axis] Y Axis config.
|
|
149
|
+
# [block] Wrapper (optional).
|
|
150
|
+
# [style] Base style (optional).
|
|
151
|
+
# [legend_position] Symbol (<tt>:top_left</tt>, <tt>:top_right</tt>, <tt>:bottom_left</tt>, <tt>:bottom_right</tt>).
|
|
152
|
+
# [hidden_legend_constraints] Array of two Constraints [width, height] (optional).
|
|
153
|
+
def initialize(datasets:, x_axis:, y_axis:, block: nil, style: nil, legend_position: nil, hidden_legend_constraints: [])
|
|
154
|
+
super
|
|
164
155
|
end
|
|
156
|
+
end
|
|
165
157
|
|
|
166
158
|
# A complex chart widget. (Legacy/Alias for Chart)
|
|
167
159
|
#
|
|
@@ -180,11 +172,11 @@ module RatatuiRuby
|
|
|
180
172
|
# [block] Optional block widget to wrap the chart.
|
|
181
173
|
def initialize(datasets:, x_labels: [], y_labels: [], y_bounds: [0.0, 100.0], block: nil)
|
|
182
174
|
super(
|
|
183
|
-
datasets
|
|
184
|
-
x_labels
|
|
185
|
-
y_labels
|
|
175
|
+
datasets:,
|
|
176
|
+
x_labels:,
|
|
177
|
+
y_labels:,
|
|
186
178
|
y_bounds: [Float(y_bounds[0]), Float(y_bounds[1])],
|
|
187
|
-
block:
|
|
179
|
+
block:
|
|
188
180
|
)
|
|
189
181
|
end
|
|
190
182
|
end
|
|
@@ -4,49 +4,49 @@
|
|
|
4
4
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
|
|
6
6
|
module RatatuiRuby
|
|
7
|
-
|
|
7
|
+
# Resets the terminal buffer for a specific area.
|
|
8
|
+
#
|
|
9
|
+
# Painting in a terminal is additive. New content draws over old content. If the new content has transparency
|
|
10
|
+
# or empty spaces, the old content "bleeds" through. This ruins popups and modals.
|
|
11
|
+
#
|
|
12
|
+
# This widget wipes the slate clean. It resets all cells in its area to their default state (spaces with default background).
|
|
13
|
+
#
|
|
14
|
+
# Use it as the first layer in an Overlay stack when building popups. Ensure your floating windows are truly opaque.
|
|
15
|
+
#
|
|
16
|
+
# === Examples
|
|
17
|
+
#
|
|
18
|
+
# # Opaque Popup Construction
|
|
19
|
+
# Overlay.new(
|
|
20
|
+
# layers: [
|
|
21
|
+
# MainUI.new,
|
|
22
|
+
# Center.new(
|
|
23
|
+
# child: Overlay.new(
|
|
24
|
+
# layers: [
|
|
25
|
+
# Clear.new, # Wipe the area first
|
|
26
|
+
# Block.new(title: "Modal", borders: [:all])
|
|
27
|
+
# ]
|
|
28
|
+
# ),
|
|
29
|
+
# width_percent: 50,
|
|
30
|
+
# height_percent: 50
|
|
31
|
+
# )
|
|
32
|
+
# ]
|
|
33
|
+
# )
|
|
34
|
+
#
|
|
35
|
+
# # Shortcut: rendering a block directly
|
|
36
|
+
# Clear.new(block: Block.new(title: "Cleared area", borders: [:all]))
|
|
37
|
+
class Clear < Data.define(:block)
|
|
38
|
+
##
|
|
39
|
+
# :attr_reader: block
|
|
40
|
+
# Optional Block to render after clearing.
|
|
8
41
|
#
|
|
9
|
-
#
|
|
10
|
-
# or empty spaces, the old content "bleeds" through. This ruins popups and modals.
|
|
11
|
-
#
|
|
12
|
-
# This widget wipes the slate clean. It resets all cells in its area to their default state (spaces with default background).
|
|
13
|
-
#
|
|
14
|
-
# Use it as the first layer in an Overlay stack when building popups. Ensure your floating windows are truly opaque.
|
|
15
|
-
#
|
|
16
|
-
# === Examples
|
|
17
|
-
#
|
|
18
|
-
# # Opaque Popup Construction
|
|
19
|
-
# Overlay.new(
|
|
20
|
-
# layers: [
|
|
21
|
-
# MainUI.new,
|
|
22
|
-
# Center.new(
|
|
23
|
-
# child: Overlay.new(
|
|
24
|
-
# layers: [
|
|
25
|
-
# Clear.new, # Wipe the area first
|
|
26
|
-
# Block.new(title: "Modal", borders: [:all])
|
|
27
|
-
# ]
|
|
28
|
-
# ),
|
|
29
|
-
# width_percent: 50,
|
|
30
|
-
# height_percent: 50
|
|
31
|
-
# )
|
|
32
|
-
# ]
|
|
33
|
-
# )
|
|
34
|
-
#
|
|
35
|
-
# # Shortcut: rendering a block directly
|
|
36
|
-
# Clear.new(block: Block.new(title: "Cleared area", borders: [:all]))
|
|
37
|
-
class Clear < Data.define(:block)
|
|
38
|
-
##
|
|
39
|
-
# :attr_reader: block
|
|
40
|
-
# Optional Block to render after clearing.
|
|
41
|
-
#
|
|
42
|
-
# If provided, the borders/title of this block are drawn on top of the cleared area.
|
|
42
|
+
# If provided, the borders/title of this block are drawn on top of the cleared area.
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
end
|
|
44
|
+
# Creates a new Clear widget.
|
|
45
|
+
#
|
|
46
|
+
# [block]
|
|
47
|
+
# Block widget to render (optional).
|
|
48
|
+
def initialize(block: nil)
|
|
49
|
+
super
|
|
51
50
|
end
|
|
51
|
+
end
|
|
52
52
|
end
|