ratatui_ruby 1.4.0-x86_64-linux
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 +7 -0
- data/LICENSE +15 -0
- data/LICENSES/AGPL-3.0-or-later.txt +661 -0
- data/LICENSES/CC-BY-SA-4.0.txt +427 -0
- data/LICENSES/CC0-1.0.txt +121 -0
- data/LICENSES/LGPL-3.0-or-later.txt +304 -0
- data/LICENSES/MIT-0.txt +16 -0
- data/LICENSES/MIT.txt +21 -0
- data/REUSE.toml +42 -0
- data/exe/.gitkeep +0 -0
- data/ext/ratatui_ruby/.cargo/config.toml +13 -0
- data/ext/ratatui_ruby/.gitignore +4 -0
- data/ext/ratatui_ruby/Cargo.lock +1737 -0
- data/ext/ratatui_ruby/Cargo.toml +24 -0
- data/ext/ratatui_ruby/clippy.toml +7 -0
- data/ext/ratatui_ruby/extconf.rb +21 -0
- data/ext/ratatui_ruby/src/color.rs +82 -0
- data/ext/ratatui_ruby/src/errors.rs +28 -0
- data/ext/ratatui_ruby/src/events.rs +700 -0
- data/ext/ratatui_ruby/src/frame.rs +241 -0
- data/ext/ratatui_ruby/src/lib.rs +343 -0
- data/ext/ratatui_ruby/src/lib_header.rs +11 -0
- data/ext/ratatui_ruby/src/rendering.rs +158 -0
- data/ext/ratatui_ruby/src/string_width.rs +101 -0
- data/ext/ratatui_ruby/src/style.rs +469 -0
- data/ext/ratatui_ruby/src/terminal/capabilities.rs +46 -0
- data/ext/ratatui_ruby/src/terminal/init.rs +233 -0
- data/ext/ratatui_ruby/src/terminal/mod.rs +42 -0
- data/ext/ratatui_ruby/src/terminal/mutations.rs +158 -0
- data/ext/ratatui_ruby/src/terminal/queries.rs +231 -0
- data/ext/ratatui_ruby/src/terminal/query.rs +400 -0
- data/ext/ratatui_ruby/src/terminal/storage.rs +109 -0
- data/ext/ratatui_ruby/src/terminal/wrapper.rs +16 -0
- data/ext/ratatui_ruby/src/text.rs +225 -0
- data/ext/ratatui_ruby/src/widgets/barchart.rs +169 -0
- data/ext/ratatui_ruby/src/widgets/block.rs +41 -0
- data/ext/ratatui_ruby/src/widgets/calendar.rs +84 -0
- data/ext/ratatui_ruby/src/widgets/canvas.rs +183 -0
- data/ext/ratatui_ruby/src/widgets/center.rs +79 -0
- data/ext/ratatui_ruby/src/widgets/chart.rs +222 -0
- data/ext/ratatui_ruby/src/widgets/clear.rs +39 -0
- data/ext/ratatui_ruby/src/widgets/cursor.rs +32 -0
- data/ext/ratatui_ruby/src/widgets/gauge.rs +65 -0
- data/ext/ratatui_ruby/src/widgets/layout.rs +379 -0
- data/ext/ratatui_ruby/src/widgets/line_gauge.rs +100 -0
- data/ext/ratatui_ruby/src/widgets/list.rs +378 -0
- data/ext/ratatui_ruby/src/widgets/list_state.rs +173 -0
- data/ext/ratatui_ruby/src/widgets/mod.rs +26 -0
- data/ext/ratatui_ruby/src/widgets/overlay.rs +24 -0
- data/ext/ratatui_ruby/src/widgets/paragraph.rs +87 -0
- data/ext/ratatui_ruby/src/widgets/ratatui_logo.rs +40 -0
- data/ext/ratatui_ruby/src/widgets/ratatui_mascot.rs +55 -0
- data/ext/ratatui_ruby/src/widgets/scrollbar.rs +214 -0
- data/ext/ratatui_ruby/src/widgets/scrollbar_state.rs +169 -0
- data/ext/ratatui_ruby/src/widgets/sparkline.rs +127 -0
- data/ext/ratatui_ruby/src/widgets/table.rs +415 -0
- data/ext/ratatui_ruby/src/widgets/table_state.rs +203 -0
- data/ext/ratatui_ruby/src/widgets/tabs.rs +194 -0
- data/lib/ratatui_ruby/backend/window_size.rb +50 -0
- data/lib/ratatui_ruby/backend.rb +59 -0
- data/lib/ratatui_ruby/buffer/cell.rb +212 -0
- data/lib/ratatui_ruby/buffer.rb +149 -0
- data/lib/ratatui_ruby/cell.rb +208 -0
- data/lib/ratatui_ruby/debug.rb +215 -0
- data/lib/ratatui_ruby/draw.rb +63 -0
- data/lib/ratatui_ruby/event/focus_gained.rb +125 -0
- data/lib/ratatui_ruby/event/focus_lost.rb +127 -0
- data/lib/ratatui_ruby/event/key/character.rb +53 -0
- data/lib/ratatui_ruby/event/key/dwim.rb +301 -0
- data/lib/ratatui_ruby/event/key/media.rb +46 -0
- data/lib/ratatui_ruby/event/key/modifier.rb +107 -0
- data/lib/ratatui_ruby/event/key/navigation.rb +72 -0
- data/lib/ratatui_ruby/event/key/system.rb +47 -0
- data/lib/ratatui_ruby/event/key.rb +479 -0
- data/lib/ratatui_ruby/event/mouse.rb +291 -0
- data/lib/ratatui_ruby/event/none.rb +53 -0
- data/lib/ratatui_ruby/event/paste.rb +130 -0
- data/lib/ratatui_ruby/event/resize.rb +221 -0
- data/lib/ratatui_ruby/event/sync.rb +52 -0
- data/lib/ratatui_ruby/event.rb +163 -0
- data/lib/ratatui_ruby/frame.rb +257 -0
- data/lib/ratatui_ruby/labs/a11y.rb +182 -0
- data/lib/ratatui_ruby/labs/frame_a11y_capture.rb +50 -0
- data/lib/ratatui_ruby/labs.rb +47 -0
- data/lib/ratatui_ruby/layout/alignment.rb +91 -0
- data/lib/ratatui_ruby/layout/constraint.rb +337 -0
- data/lib/ratatui_ruby/layout/layout.rb +258 -0
- data/lib/ratatui_ruby/layout/position.rb +81 -0
- data/lib/ratatui_ruby/layout/rect.rb +733 -0
- data/lib/ratatui_ruby/layout/size.rb +62 -0
- data/lib/ratatui_ruby/layout.rb +29 -0
- data/lib/ratatui_ruby/list_state.rb +201 -0
- data/lib/ratatui_ruby/output_guard.rb +171 -0
- data/lib/ratatui_ruby/ratatui_ruby.so +0 -0
- data/lib/ratatui_ruby/scrollbar_state.rb +122 -0
- data/lib/ratatui_ruby/style/color.rb +149 -0
- data/lib/ratatui_ruby/style/style.rb +147 -0
- data/lib/ratatui_ruby/style.rb +19 -0
- data/lib/ratatui_ruby/symbols.rb +435 -0
- data/lib/ratatui_ruby/synthetic_events.rb +106 -0
- data/lib/ratatui_ruby/table_state.rb +251 -0
- data/lib/ratatui_ruby/terminal/capabilities.rb +316 -0
- data/lib/ratatui_ruby/terminal/viewport.rb +80 -0
- data/lib/ratatui_ruby/terminal.rb +66 -0
- data/lib/ratatui_ruby/terminal_lifecycle.rb +303 -0
- data/lib/ratatui_ruby/terminal_lifecycle.rb.bak +197 -0
- data/lib/ratatui_ruby/test_helper/event_injection.rb +241 -0
- data/lib/ratatui_ruby/test_helper/global_state.rb +111 -0
- data/lib/ratatui_ruby/test_helper/snapshot.rb +568 -0
- data/lib/ratatui_ruby/test_helper/snapshots/axis_labels_alignment.ansi +24 -0
- data/lib/ratatui_ruby/test_helper/snapshots/axis_labels_alignment.txt +24 -0
- data/lib/ratatui_ruby/test_helper/snapshots/barchart_styled_label.ansi +5 -0
- data/lib/ratatui_ruby/test_helper/snapshots/barchart_styled_label.txt +5 -0
- data/lib/ratatui_ruby/test_helper/snapshots/chart_rendering.ansi +24 -0
- data/lib/ratatui_ruby/test_helper/snapshots/chart_rendering.txt +24 -0
- data/lib/ratatui_ruby/test_helper/snapshots/half_block_marker.ansi +12 -0
- data/lib/ratatui_ruby/test_helper/snapshots/half_block_marker.txt +12 -0
- data/lib/ratatui_ruby/test_helper/snapshots/legend_position_bottom.ansi +12 -0
- data/lib/ratatui_ruby/test_helper/snapshots/legend_position_bottom.txt +12 -0
- data/lib/ratatui_ruby/test_helper/snapshots/legend_position_left.ansi +12 -0
- data/lib/ratatui_ruby/test_helper/snapshots/legend_position_left.txt +12 -0
- data/lib/ratatui_ruby/test_helper/snapshots/legend_position_right.ansi +12 -0
- data/lib/ratatui_ruby/test_helper/snapshots/legend_position_right.txt +12 -0
- data/lib/ratatui_ruby/test_helper/snapshots/legend_position_top.ansi +12 -0
- data/lib/ratatui_ruby/test_helper/snapshots/legend_position_top.txt +12 -0
- data/lib/ratatui_ruby/test_helper/snapshots/my_snapshot.txt +1 -0
- data/lib/ratatui_ruby/test_helper/snapshots/styled_axis_title.ansi +10 -0
- data/lib/ratatui_ruby/test_helper/snapshots/styled_axis_title.txt +10 -0
- data/lib/ratatui_ruby/test_helper/snapshots/styled_dataset_name.ansi +10 -0
- data/lib/ratatui_ruby/test_helper/snapshots/styled_dataset_name.txt +10 -0
- data/lib/ratatui_ruby/test_helper/style_assertions.rb +449 -0
- data/lib/ratatui_ruby/test_helper/subprocess_timeout.rb +35 -0
- data/lib/ratatui_ruby/test_helper/terminal.rb +187 -0
- data/lib/ratatui_ruby/test_helper/test_doubles.rb +86 -0
- data/lib/ratatui_ruby/test_helper.rb +115 -0
- data/lib/ratatui_ruby/text/line.rb +245 -0
- data/lib/ratatui_ruby/text/span.rb +158 -0
- data/lib/ratatui_ruby/text.rb +99 -0
- data/lib/ratatui_ruby/tui/buffer_factories.rb +22 -0
- data/lib/ratatui_ruby/tui/canvas_factories.rb +149 -0
- data/lib/ratatui_ruby/tui/core.rb +67 -0
- data/lib/ratatui_ruby/tui/layout_factories.rb +153 -0
- data/lib/ratatui_ruby/tui/state_factories.rb +77 -0
- data/lib/ratatui_ruby/tui/style_factories.rb +22 -0
- data/lib/ratatui_ruby/tui/text_factories.rb +86 -0
- data/lib/ratatui_ruby/tui/widget_factories.rb +272 -0
- data/lib/ratatui_ruby/tui.rb +106 -0
- data/lib/ratatui_ruby/version.rb +12 -0
- data/lib/ratatui_ruby/widgets/bar_chart/bar.rb +51 -0
- data/lib/ratatui_ruby/widgets/bar_chart/bar_group.rb +29 -0
- data/lib/ratatui_ruby/widgets/bar_chart.rb +308 -0
- data/lib/ratatui_ruby/widgets/block.rb +266 -0
- data/lib/ratatui_ruby/widgets/calendar.rb +88 -0
- data/lib/ratatui_ruby/widgets/canvas.rb +297 -0
- data/lib/ratatui_ruby/widgets/cell.rb +59 -0
- data/lib/ratatui_ruby/widgets/center.rb +71 -0
- data/lib/ratatui_ruby/widgets/chart.rb +172 -0
- data/lib/ratatui_ruby/widgets/clear.rb +66 -0
- data/lib/ratatui_ruby/widgets/coerceable_widget.rb +77 -0
- data/lib/ratatui_ruby/widgets/cursor.rb +54 -0
- data/lib/ratatui_ruby/widgets/gauge.rb +146 -0
- data/lib/ratatui_ruby/widgets/line_gauge.rb +158 -0
- data/lib/ratatui_ruby/widgets/list.rb +252 -0
- data/lib/ratatui_ruby/widgets/list_item.rb +55 -0
- data/lib/ratatui_ruby/widgets/overlay.rb +55 -0
- data/lib/ratatui_ruby/widgets/paragraph.rb +113 -0
- data/lib/ratatui_ruby/widgets/ratatui_logo.rb +35 -0
- data/lib/ratatui_ruby/widgets/ratatui_mascot.rb +40 -0
- data/lib/ratatui_ruby/widgets/row.rb +123 -0
- data/lib/ratatui_ruby/widgets/scrollbar.rb +147 -0
- data/lib/ratatui_ruby/widgets/shape/label.rb +80 -0
- data/lib/ratatui_ruby/widgets/sparkline.rb +153 -0
- data/lib/ratatui_ruby/widgets/table.rb +213 -0
- data/lib/ratatui_ruby/widgets/tabs.rb +91 -0
- data/lib/ratatui_ruby/widgets.rb +43 -0
- data/lib/ratatui_ruby.rb +555 -0
- data/sig/examples/app_all_events/app.rbs +11 -0
- data/sig/examples/app_all_events/model/app_model.rbs +23 -0
- data/sig/examples/app_all_events/model/event_entry.rbs +23 -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 +14 -0
- data/sig/examples/app_cli_rich_moments/app.rbs +12 -0
- data/sig/examples/app_color_picker/app.rbs +17 -0
- data/sig/examples/app_external_editor/app.rbs +12 -0
- data/sig/examples/app_login_form/app.rbs +11 -0
- data/sig/examples/app_stateful_interaction/app.rbs +39 -0
- data/sig/examples/verify_quickstart_dsl/app.rbs +17 -0
- data/sig/examples/verify_quickstart_lifecycle/app.rbs +17 -0
- data/sig/examples/verify_readme_usage/app.rbs +17 -0
- data/sig/examples/widget_block_demo/app.rbs +38 -0
- data/sig/examples/widget_box_demo/app.rbs +17 -0
- data/sig/examples/widget_calendar_demo/app.rbs +17 -0
- data/sig/examples/widget_cell_demo/app.rbs +17 -0
- data/sig/examples/widget_chart_demo/app.rbs +17 -0
- data/sig/examples/widget_gauge_demo/app.rbs +17 -0
- data/sig/examples/widget_layout_split/app.rbs +16 -0
- data/sig/examples/widget_line_gauge_demo/app.rbs +17 -0
- data/sig/examples/widget_list_demo/app.rbs +17 -0
- data/sig/examples/widget_map_demo/app.rbs +17 -0
- data/sig/examples/widget_popup_demo/app.rbs +17 -0
- data/sig/examples/widget_ratatui_logo_demo/app.rbs +17 -0
- data/sig/examples/widget_ratatui_mascot_demo/app.rbs +17 -0
- data/sig/examples/widget_rect/app.rbs +18 -0
- data/sig/examples/widget_render/app.rbs +16 -0
- data/sig/examples/widget_rich_text/app.rbs +17 -0
- data/sig/examples/widget_scroll_text/app.rbs +17 -0
- data/sig/examples/widget_scrollbar_demo/app.rbs +17 -0
- data/sig/examples/widget_sparkline_demo/app.rbs +16 -0
- data/sig/examples/widget_style_colors/app.rbs +20 -0
- data/sig/examples/widget_table_demo/app.rbs +17 -0
- data/sig/examples/widget_text_width/app.rbs +16 -0
- data/sig/generated/event_key_predicates.rbs +1348 -0
- data/sig/manifest.yaml +5 -0
- data/sig/patches/data.rbs +26 -0
- data/sig/patches/debugger__.rbs +8 -0
- data/sig/ratatui_ruby/backend/window_size.rbs +17 -0
- data/sig/ratatui_ruby/backend.rbs +12 -0
- data/sig/ratatui_ruby/buffer/cell.rbs +46 -0
- data/sig/ratatui_ruby/buffer.rbs +18 -0
- data/sig/ratatui_ruby/cell.rbs +44 -0
- data/sig/ratatui_ruby/clear.rbs +18 -0
- data/sig/ratatui_ruby/constraint.rbs +26 -0
- data/sig/ratatui_ruby/debug.rbs +45 -0
- data/sig/ratatui_ruby/draw.rbs +30 -0
- data/sig/ratatui_ruby/event.rbs +249 -0
- data/sig/ratatui_ruby/frame.rbs +23 -0
- data/sig/ratatui_ruby/interfaces.rbs +25 -0
- data/sig/ratatui_ruby/labs.rbs +90 -0
- data/sig/ratatui_ruby/layout/alignment.rbs +26 -0
- data/sig/ratatui_ruby/layout/constraint.rbs +39 -0
- data/sig/ratatui_ruby/layout/layout.rbs +45 -0
- data/sig/ratatui_ruby/layout/position.rbs +18 -0
- data/sig/ratatui_ruby/layout/rect.rbs +64 -0
- data/sig/ratatui_ruby/layout/size.rbs +18 -0
- data/sig/ratatui_ruby/list_state.rbs +23 -0
- data/sig/ratatui_ruby/output_guard.rbs +23 -0
- data/sig/ratatui_ruby/ratatui_ruby.rbs +113 -0
- data/sig/ratatui_ruby/rect.rbs +17 -0
- data/sig/ratatui_ruby/scrollbar_state.rbs +24 -0
- data/sig/ratatui_ruby/session.rbs +93 -0
- data/sig/ratatui_ruby/style/color.rbs +22 -0
- data/sig/ratatui_ruby/style/style.rbs +29 -0
- data/sig/ratatui_ruby/symbols.rbs +141 -0
- data/sig/ratatui_ruby/synthetic_events.rbs +24 -0
- data/sig/ratatui_ruby/table_state.rbs +27 -0
- data/sig/ratatui_ruby/terminal/capabilities.rbs +38 -0
- data/sig/ratatui_ruby/terminal/viewport.rbs +33 -0
- data/sig/ratatui_ruby/terminal_lifecycle.rbs +39 -0
- data/sig/ratatui_ruby/test_helper/event_injection.rbs +22 -0
- data/sig/ratatui_ruby/test_helper/snapshot.rbs +37 -0
- data/sig/ratatui_ruby/test_helper/style_assertions.rbs +77 -0
- data/sig/ratatui_ruby/test_helper/terminal.rbs +20 -0
- data/sig/ratatui_ruby/test_helper/test_doubles.rbs +32 -0
- data/sig/ratatui_ruby/test_helper.rbs +18 -0
- data/sig/ratatui_ruby/text/line.rbs +27 -0
- data/sig/ratatui_ruby/text/span.rbs +23 -0
- data/sig/ratatui_ruby/text.rbs +12 -0
- data/sig/ratatui_ruby/tui/buffer_factories.rbs +16 -0
- data/sig/ratatui_ruby/tui/canvas_factories.rbs +38 -0
- data/sig/ratatui_ruby/tui/core.rbs +23 -0
- data/sig/ratatui_ruby/tui/layout_factories.rbs +39 -0
- data/sig/ratatui_ruby/tui/state_factories.rbs +23 -0
- data/sig/ratatui_ruby/tui/style_factories.rbs +18 -0
- data/sig/ratatui_ruby/tui/text_factories.rbs +23 -0
- data/sig/ratatui_ruby/tui/widget_factories.rbs +138 -0
- data/sig/ratatui_ruby/tui.rbs +25 -0
- data/sig/ratatui_ruby/version.rbs +12 -0
- data/sig/ratatui_ruby/widgets/bar_chart.rbs +95 -0
- data/sig/ratatui_ruby/widgets/block.rbs +51 -0
- data/sig/ratatui_ruby/widgets/calendar.rbs +45 -0
- data/sig/ratatui_ruby/widgets/canvas.rbs +95 -0
- data/sig/ratatui_ruby/widgets/chart.rbs +91 -0
- data/sig/ratatui_ruby/widgets/coerceable_widget.rbs +26 -0
- data/sig/ratatui_ruby/widgets/gauge.rbs +44 -0
- data/sig/ratatui_ruby/widgets/line_gauge.rbs +48 -0
- data/sig/ratatui_ruby/widgets/list.rbs +63 -0
- data/sig/ratatui_ruby/widgets/misc.rbs +158 -0
- data/sig/ratatui_ruby/widgets/paragraph.rbs +45 -0
- data/sig/ratatui_ruby/widgets/row.rbs +43 -0
- data/sig/ratatui_ruby/widgets/scrollbar.rbs +53 -0
- data/sig/ratatui_ruby/widgets/shape/label.rbs +37 -0
- data/sig/ratatui_ruby/widgets/sparkline.rbs +45 -0
- data/sig/ratatui_ruby/widgets/table.rbs +78 -0
- data/sig/ratatui_ruby/widgets/tabs.rbs +44 -0
- data/sig/ratatui_ruby/widgets.rbs +16 -0
- data/vendor/goodcop/base.yml +1047 -0
- metadata +729 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
6
|
+
#++
|
|
7
|
+
|
|
8
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
9
|
+
|
|
10
|
+
module RatatuiRuby
|
|
11
|
+
class TUI
|
|
12
|
+
module LayoutFactories
|
|
13
|
+
def rect: (?x: Integer, ?y: Integer, ?width: Integer, ?height: Integer) -> Layout::Rect
|
|
14
|
+
|
|
15
|
+
# Constraint dispatcher (TIMTOWTDI pattern)
|
|
16
|
+
def constraint: (?type: Symbol, ?value: (Integer | Array[Integer])) -> Layout::Constraint
|
|
17
|
+
| (:length | :fixed, Integer) -> Layout::Constraint
|
|
18
|
+
| (:percentage | :percent, Integer) -> Layout::Constraint
|
|
19
|
+
| (:min, Integer) -> Layout::Constraint
|
|
20
|
+
| (:max, Integer) -> Layout::Constraint
|
|
21
|
+
| (:fill | :flex | :fr, ?Integer) -> Layout::Constraint
|
|
22
|
+
| (:ratio | :aspect, Integer, Integer) -> Layout::Constraint
|
|
23
|
+
|
|
24
|
+
def constraint_length: (Integer n) -> Layout::Constraint
|
|
25
|
+
def constraint_percentage: (Integer n) -> Layout::Constraint
|
|
26
|
+
def constraint_min: (Integer n) -> Layout::Constraint
|
|
27
|
+
def constraint_max: (Integer n) -> Layout::Constraint
|
|
28
|
+
def constraint_fill: (?Integer n) -> Layout::Constraint
|
|
29
|
+
def constraint_ratio: (Integer numerator, Integer denominator) -> Layout::Constraint
|
|
30
|
+
def layout: (?direction: Symbol, ?constraints: Array[Layout::Constraint], ?children: Array[widget], ?flex: Layout::flex_mode) -> Layout::Layout
|
|
31
|
+
def layout_split: (Layout::Rect area, ?direction: Symbol, constraints: Array[Layout::Constraint], ?flex: Symbol) -> Array[Layout::Rect]
|
|
32
|
+
def split: (Layout::Rect area, ?direction: Symbol, constraints: Array[Layout::Constraint], ?flex: Symbol) -> Array[Layout::Rect]
|
|
33
|
+
def fixed: (Integer n) -> Layout::Constraint
|
|
34
|
+
def percent: (Integer n) -> Layout::Constraint
|
|
35
|
+
def flex: (?Integer n) -> Layout::Constraint
|
|
36
|
+
def fr: (?Integer n) -> Layout::Constraint
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
6
|
+
#++
|
|
7
|
+
|
|
8
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
9
|
+
|
|
10
|
+
module RatatuiRuby
|
|
11
|
+
class TUI
|
|
12
|
+
module StateFactories
|
|
13
|
+
def list_state: (?Integer? selected) -> ListState
|
|
14
|
+
def table_state: (?Integer? selected) -> TableState
|
|
15
|
+
def scrollbar_state: (?Integer content_length) -> ScrollbarState
|
|
16
|
+
|
|
17
|
+
# State dispatcher (TIMTOWTDI pattern)
|
|
18
|
+
def state: (:list, ?Integer? arg) -> ListState
|
|
19
|
+
| (:table, ?Integer? arg) -> TableState
|
|
20
|
+
| (:scrollbar, ?Integer arg) -> ScrollbarState
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
6
|
+
#++
|
|
7
|
+
|
|
8
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
9
|
+
|
|
10
|
+
module RatatuiRuby
|
|
11
|
+
class TUI
|
|
12
|
+
module StyleFactories
|
|
13
|
+
type color = String | Symbol | Integer
|
|
14
|
+
|
|
15
|
+
def style: (?fg: color?, ?bg: color?, ?underline_color: color?, ?modifiers: Array[Symbol], ?remove_modifiers: Array[Symbol]) -> Style::Style
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
6
|
+
#++
|
|
7
|
+
|
|
8
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
9
|
+
|
|
10
|
+
module RatatuiRuby
|
|
11
|
+
class TUI
|
|
12
|
+
module TextFactories
|
|
13
|
+
def text_span: (content: String, ?style: Style::Style?) -> Text::Span
|
|
14
|
+
def span: (content: String, ?style: Style::Style?) -> Text::Span
|
|
15
|
+
def text_line: (?spans: Array[Text::Span], ?alignment: Symbol?, ?style: Style::Style?) -> Text::Line
|
|
16
|
+
def line: (?spans: Array[Text::Span], ?alignment: Symbol?, ?style: Style::Style?) -> Text::Line
|
|
17
|
+
def text_width: (String string) -> Integer
|
|
18
|
+
|
|
19
|
+
# Text dispatcher (TIMTOWTDI pattern)
|
|
20
|
+
def text: (Symbol, **untyped) -> (Text::Span | Text::Line)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
6
|
+
#++
|
|
7
|
+
|
|
8
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
9
|
+
|
|
10
|
+
module RatatuiRuby
|
|
11
|
+
class TUI
|
|
12
|
+
# Widget factory methods for TUI.
|
|
13
|
+
#
|
|
14
|
+
# All factory methods support DWIM hash coercion: both `tui.table(hash)` and
|
|
15
|
+
# `tui.table(**hash)` work identically.
|
|
16
|
+
module WidgetFactories
|
|
17
|
+
# Widgets::Block
|
|
18
|
+
def block: (Widgets::block_options) -> Widgets::Block
|
|
19
|
+
| (?title: String?, ?titles: Array[title_entry], ?title_alignment: alignment?, ?title_style: style_input?, ?borders: Array[border_side], ?border_style: style_input?, ?border_type: border_type?, ?border_set: border_set_hash?, ?style: style_input?, ?padding: (_ToI | Array[_ToI]), ?children: Array[widget]) -> Widgets::Block
|
|
20
|
+
|
|
21
|
+
# Widgets::Paragraph
|
|
22
|
+
def paragraph: (Widgets::paragraph_options) -> Widgets::Paragraph
|
|
23
|
+
| (text: String, ?style: Style::Style?, ?fg: (String | Symbol)?, ?bg: (String | Symbol)?, ?block: Widgets::Block?, ?wrap: bool, ?alignment: Symbol, ?scroll: [_ToI, _ToI]) -> Widgets::Paragraph
|
|
24
|
+
|
|
25
|
+
# Widgets::List
|
|
26
|
+
def list: (Widgets::list_options) -> Widgets::List
|
|
27
|
+
| (?items: Array[String | Text::Span | Text::Line | Widgets::ListItem], ?selected_index: _ToI?, ?offset: _ToI?, ?style: Style::Style?, ?highlight_style: Style::Style?, ?highlight_symbol: String?, ?repeat_highlight_symbol: bool, ?highlight_spacing: Symbol, ?direction: Symbol, ?scroll_padding: _ToI?, ?block: Widgets::Block?) -> Widgets::List
|
|
28
|
+
|
|
29
|
+
# Widgets::ListItem
|
|
30
|
+
def list_item: (Widgets::list_item_options) -> Widgets::ListItem
|
|
31
|
+
| (content: String | Text::Span | Text::Line, ?style: Style::Style?) -> Widgets::ListItem
|
|
32
|
+
|
|
33
|
+
# DWIM alias for list_item (terse form for use in list context)
|
|
34
|
+
alias item list_item
|
|
35
|
+
|
|
36
|
+
# Widgets::Table
|
|
37
|
+
def table: (Widgets::table_options) -> Widgets::Table
|
|
38
|
+
| (?header: Array[String | Widgets::Paragraph]?, ?rows: Array[Array[String | Widgets::Paragraph | Style | _ToS]], ?widths: Array[Layout::Constraint | Integer], ?row_highlight_style: Style::Style?, ?highlight_symbol: String?, ?highlight_spacing: Symbol, ?column_highlight_style: Style::Style?, ?cell_highlight_style: Style::Style?, ?selected_row: _ToI?, ?selected_column: _ToI?, ?offset: _ToI?, ?block: Widgets::Block?, ?footer: Array[String | Widgets::Paragraph]?, ?flex: Symbol, ?style: style_input?, ?column_spacing: _ToI) -> Widgets::Table
|
|
39
|
+
|
|
40
|
+
# Widgets::Row
|
|
41
|
+
def row: (Widgets::row_options) -> Widgets::Row
|
|
42
|
+
| (cells: Array[String | Text::Span | Text::Line | Widgets::Paragraph | Widgets::Cell], ?style: Style::Style?, ?height: Integer?, ?top_margin: Integer?, ?bottom_margin: Integer?) -> Widgets::Row
|
|
43
|
+
def table_row: (Widgets::row_options) -> Widgets::Row
|
|
44
|
+
| (cells: Array[String | Text::Span | Text::Line | Widgets::Paragraph | Widgets::Cell], ?style: Style::Style?, ?height: Integer?, ?top_margin: Integer?, ?bottom_margin: Integer?) -> Widgets::Row
|
|
45
|
+
|
|
46
|
+
# Widgets::Cell
|
|
47
|
+
def table_cell: (Widgets::cell_options) -> Widgets::Cell
|
|
48
|
+
| (content: String | Text::Span | Text::Line | Widgets::Paragraph, ?style: Style::Style?) -> Widgets::Cell
|
|
49
|
+
|
|
50
|
+
# Widgets::Tabs
|
|
51
|
+
def tabs: (Widgets::tabs_options) -> Widgets::Tabs
|
|
52
|
+
| (?titles: Array[String | _ToS], ?selected_index: _ToI, ?block: Widgets::Block?, ?divider: String?, ?highlight_style: Style::Style?, ?style: Style::Style?, ?padding_left: (String | Text::Line | _ToI), ?padding_right: (String | Text::Line | _ToI)) -> Widgets::Tabs
|
|
53
|
+
|
|
54
|
+
# Widgets::Gauge
|
|
55
|
+
def gauge: (Widgets::gauge_options) -> Widgets::Gauge
|
|
56
|
+
| (?ratio: _ToF?, ?percent: _ToF?, ?label: String | Text::Span | nil, ?style: Style::Style?, ?gauge_style: Style::Style?, ?block: Widgets::Block?, ?use_unicode: bool) -> Widgets::Gauge
|
|
57
|
+
|
|
58
|
+
# Widgets::LineGauge
|
|
59
|
+
def line_gauge: (Widgets::line_gauge_options) -> Widgets::LineGauge
|
|
60
|
+
| (?ratio: _ToF, ?label: String | Text::Span | nil, ?style: Style::Style?, ?filled_style: Style::Style?, ?unfilled_style: Style::Style?, ?block: Widgets::Block?, ?filled_symbol: String, ?unfilled_symbol: String) -> Widgets::LineGauge
|
|
61
|
+
|
|
62
|
+
# Widgets::Sparkline
|
|
63
|
+
def sparkline: (Widgets::sparkline_options) -> Widgets::Sparkline
|
|
64
|
+
| (data: Array[_ToI?], ?max: _ToI?, ?style: Style::Style?, ?block: Widgets::Block?, ?direction: (:left_to_right | :right_to_left)?, ?absent_value_symbol: String?, ?absent_value_style: Style::Style?, ?bar_set: Hash[Symbol, String]?) -> Widgets::Sparkline
|
|
65
|
+
|
|
66
|
+
# Widgets::BarChart
|
|
67
|
+
def bar_chart: (Widgets::bar_chart_options) -> Widgets::BarChart
|
|
68
|
+
| (data: Hash[String | Symbol | _ToS, _ToI] | Array[Array[String | Symbol | _ToS | _ToI]] | Array[Widgets::BarChart::BarGroup], ?bar_width: _ToI, ?bar_gap: _ToI, ?group_gap: _ToI, ?max: _ToI?, ?style: Style::Style?, ?block: Widgets::Block?, ?direction: (:vertical | :horizontal), ?label_style: Style::Style?, ?value_style: Style::Style?, ?bar_set: Hash[Symbol, String]?) -> Widgets::BarChart
|
|
69
|
+
|
|
70
|
+
# Widgets::BarChart::Bar
|
|
71
|
+
def bar: (Widgets::bar_options) -> Widgets::BarChart::Bar
|
|
72
|
+
| (value: _ToI, ?label: String | Text::Span | Text::Line | nil, ?style: Style::Style?, ?value_style: Style::Style?, ?text_value: String | Text::Span | Text::Line | nil) -> Widgets::BarChart::Bar
|
|
73
|
+
def bar_chart_bar: (Widgets::bar_options) -> Widgets::BarChart::Bar
|
|
74
|
+
| (value: _ToI, ?label: String | Text::Span | Text::Line | nil, ?style: Style::Style?, ?value_style: Style::Style?, ?text_value: String | Text::Span | Text::Line | nil) -> Widgets::BarChart::Bar
|
|
75
|
+
|
|
76
|
+
# Widgets::BarChart::BarGroup
|
|
77
|
+
def bar_group: (Widgets::bar_group_options) -> Widgets::BarChart::BarGroup
|
|
78
|
+
| (label: String, bars: Array[Widgets::BarChart::Bar]) -> Widgets::BarChart::BarGroup
|
|
79
|
+
def bar_chart_bar_group: (Widgets::bar_group_options) -> Widgets::BarChart::BarGroup
|
|
80
|
+
| (label: String, bars: Array[Widgets::BarChart::Bar]) -> Widgets::BarChart::BarGroup
|
|
81
|
+
|
|
82
|
+
# Widgets::Chart
|
|
83
|
+
def chart: (Widgets::chart_options) -> Widgets::Chart
|
|
84
|
+
| (datasets: Array[Widgets::Dataset], x_axis: Widgets::Axis, y_axis: Widgets::Axis, ?block: Widgets::Block?, ?style: Style::Style?, ?legend_position: Symbol?, ?hidden_legend_constraints: Array[Layout::Constraint]) -> Widgets::Chart
|
|
85
|
+
|
|
86
|
+
# Widgets::Dataset
|
|
87
|
+
def dataset: (Widgets::dataset_options) -> Widgets::Dataset
|
|
88
|
+
| (name: String | Symbol, data: Array[[_ToF, _ToF]], ?style: Style::Style?, ?marker: Symbol, ?graph_type: Symbol) -> Widgets::Dataset
|
|
89
|
+
|
|
90
|
+
# Widgets::Axis
|
|
91
|
+
def axis: (Widgets::axis_options) -> Widgets::Axis
|
|
92
|
+
| (?title: String, ?bounds: [_ToF, _ToF], ?labels: Array[String], ?style: Style::Style?, ?labels_alignment: Symbol?) -> Widgets::Axis
|
|
93
|
+
|
|
94
|
+
# Widgets::Scrollbar
|
|
95
|
+
def scrollbar: (Widgets::scrollbar_options) -> Widgets::Scrollbar
|
|
96
|
+
| (content_length: _ToI, position: _ToI, ?orientation: Symbol, ?thumb_symbol: String, ?thumb_style: Style::Style?, ?track_symbol: String?, ?track_style: Style::Style?, ?begin_symbol: String?, ?begin_style: Style::Style?, ?end_symbol: String?, ?end_style: Style::Style?, ?style: Style::Style?, ?block: Widgets::Block?) -> Widgets::Scrollbar
|
|
97
|
+
|
|
98
|
+
# Widgets::Calendar
|
|
99
|
+
def calendar: (Widgets::calendar_options) -> Widgets::Calendar
|
|
100
|
+
| (year: _ToI, month: _ToI, ?events: Hash[date_key, Style], ?default_style: Style::Style?, ?header_style: Style::Style?, ?block: Widgets::Block?, ?show_weekdays_header: bool, ?show_surrounding: Style::Style?, ?show_month_header: bool) -> Widgets::Calendar
|
|
101
|
+
|
|
102
|
+
# Widgets::Canvas
|
|
103
|
+
def canvas: (Widgets::canvas_options) -> Widgets::Canvas
|
|
104
|
+
| (?shapes: Array[Widgets::Shape::Line | Widgets::Shape::Rectangle | Widgets::Shape::Circle | Widgets::Shape::Map | Widgets::Shape::Label | Widgets::Shape::Point], ?x_bounds: Array[_ToF], ?y_bounds: Array[_ToF], ?marker: Symbol, ?block: Widgets::Block?, ?background_color: (String | Symbol)?) -> Widgets::Canvas
|
|
105
|
+
|
|
106
|
+
# Widgets::Clear
|
|
107
|
+
def clear: (Widgets::clear_options) -> Widgets::Clear
|
|
108
|
+
| (?block: Widgets::Block?) -> Widgets::Clear
|
|
109
|
+
|
|
110
|
+
# Widgets::Cursor
|
|
111
|
+
def cursor: (Widgets::cursor_options) -> Widgets::Cursor
|
|
112
|
+
| (x: _ToI, y: _ToI) -> Widgets::Cursor
|
|
113
|
+
|
|
114
|
+
# Widgets::Overlay
|
|
115
|
+
def overlay: (Widgets::overlay_options) -> Widgets::Overlay
|
|
116
|
+
| (?layers: Array[widget]) -> Widgets::Overlay
|
|
117
|
+
|
|
118
|
+
# Widgets::Center
|
|
119
|
+
def center: (Widgets::center_options) -> Widgets::Center
|
|
120
|
+
| (child: widget, ?width_percent: _ToF, ?height_percent: _ToF) -> Widgets::Center
|
|
121
|
+
|
|
122
|
+
# Widgets::RatatuiLogo
|
|
123
|
+
def ratatui_logo: (Widgets::ratatui_logo_options) -> Widgets::RatatuiLogo
|
|
124
|
+
| () -> Widgets::RatatuiLogo
|
|
125
|
+
|
|
126
|
+
# Widgets::RatatuiMascot
|
|
127
|
+
def ratatui_mascot: (Widgets::ratatui_mascot_options) -> Widgets::RatatuiMascot
|
|
128
|
+
| (?block: Widgets::Block?) -> Widgets::RatatuiMascot
|
|
129
|
+
|
|
130
|
+
# Widgets::Shape::Label
|
|
131
|
+
def shape_label: (Widgets::Shape::label_options) -> Widgets::Shape::Label
|
|
132
|
+
| (x: _ToF, y: _ToF, text: String | Text::Line, ?style: Style::Style?) -> Widgets::Shape::Label
|
|
133
|
+
|
|
134
|
+
# Widget dispatcher (TIMTOWTDI pattern)
|
|
135
|
+
def widget: (Symbol, ?untyped, **untyped) -> untyped
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
6
|
+
#++
|
|
7
|
+
|
|
8
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
9
|
+
|
|
10
|
+
module RatatuiRuby
|
|
11
|
+
# Terminal User Interface facade providing a concise DSL for building TUI applications.
|
|
12
|
+
#
|
|
13
|
+
# Combines all factory mixins to provide convenient access to widgets, layouts,
|
|
14
|
+
# styles, and terminal operations without verbose class name qualification.
|
|
15
|
+
class TUI
|
|
16
|
+
include Core
|
|
17
|
+
include LayoutFactories
|
|
18
|
+
include StyleFactories
|
|
19
|
+
include WidgetFactories
|
|
20
|
+
include TextFactories
|
|
21
|
+
include StateFactories
|
|
22
|
+
include CanvasFactories
|
|
23
|
+
include BufferFactories
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
6
|
+
#++
|
|
7
|
+
|
|
8
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
9
|
+
|
|
10
|
+
module RatatuiRuby
|
|
11
|
+
module Widgets
|
|
12
|
+
# Options hash type for BarChart constructor arguments.
|
|
13
|
+
type bar_chart_options = {
|
|
14
|
+
?data: Hash[String | Symbol | _ToS, _ToI] | Array[Array[String | Symbol | _ToS | _ToI]] | Array[BarChart::BarGroup],
|
|
15
|
+
?bar_width: _ToI,
|
|
16
|
+
?bar_gap: _ToI,
|
|
17
|
+
?group_gap: _ToI,
|
|
18
|
+
?max: _ToI?,
|
|
19
|
+
?style: Style::Style?,
|
|
20
|
+
?block: Widgets::Block?,
|
|
21
|
+
?direction: (:vertical | :horizontal),
|
|
22
|
+
?label_style: Style::Style?,
|
|
23
|
+
?value_style: Style::Style?,
|
|
24
|
+
?bar_set: Hash[Symbol, String]?
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# Options hash type for BarChart::Bar constructor arguments.
|
|
28
|
+
type bar_options = {
|
|
29
|
+
?value: _ToI,
|
|
30
|
+
?label: String | Text::Span | Text::Line | nil,
|
|
31
|
+
?style: Style::Style?,
|
|
32
|
+
?value_style: Style::Style?,
|
|
33
|
+
?text_value: String | Text::Span | Text::Line | nil
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# Options hash type for BarChart::BarGroup constructor arguments.
|
|
37
|
+
type bar_group_options = {
|
|
38
|
+
?label: String,
|
|
39
|
+
?bars: Array[BarChart::Bar]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
class BarChart < Data
|
|
43
|
+
BAR_KEYS: Array[Symbol]
|
|
44
|
+
|
|
45
|
+
attr_reader data: Array[BarChart::BarGroup]
|
|
46
|
+
attr_reader bar_width: Integer
|
|
47
|
+
attr_reader bar_gap: Integer
|
|
48
|
+
attr_reader group_gap: Integer
|
|
49
|
+
attr_reader max: Integer?
|
|
50
|
+
attr_reader style: Style::Style?
|
|
51
|
+
attr_reader block: Widgets::Block?
|
|
52
|
+
attr_reader direction: (:vertical | :horizontal)
|
|
53
|
+
attr_reader label_style: Style::Style?
|
|
54
|
+
attr_reader value_style: Style::Style?
|
|
55
|
+
attr_reader bar_set: Hash[Symbol, String]?
|
|
56
|
+
|
|
57
|
+
include CoerceableWidget
|
|
58
|
+
|
|
59
|
+
def self.coerce_args: (bar_chart_options first, ?bar_chart_options kwargs) -> BarChart
|
|
60
|
+
| (nil first, bar_chart_options kwargs) -> BarChart
|
|
61
|
+
|
|
62
|
+
def self.new: (data: Hash[String | Symbol | _ToS, _ToI] | Array[Array[String | Symbol | _ToS | _ToI]] | Array[BarChart::BarGroup], ?bar_width: _ToI, ?bar_gap: _ToI, ?group_gap: _ToI, ?max: _ToI?, ?style: Style::Style?, ?block: Widgets::Block?, ?direction: (:vertical | :horizontal), ?label_style: Style::Style?, ?value_style: Style::Style?, ?bar_set: Hash[Symbol, String]?) -> BarChart
|
|
63
|
+
def initialize: (data: Hash[String | Symbol | _ToS, _ToI] | Array[Array[String | Symbol | _ToS | _ToI]] | Array[BarChart::BarGroup], ?bar_width: _ToI, ?bar_gap: _ToI, ?group_gap: _ToI, ?max: _ToI?, ?style: Style::Style?, ?block: Widgets::Block?, ?direction: (:vertical | :horizontal), ?label_style: Style::Style?, ?value_style: Style::Style?, ?bar_set: Hash[Symbol, String]?) -> void
|
|
64
|
+
|
|
65
|
+
class Bar < Data
|
|
66
|
+
attr_reader value: Integer
|
|
67
|
+
attr_reader label: (String | Text::Span | Text::Line)?
|
|
68
|
+
attr_reader style: Style::Style?
|
|
69
|
+
attr_reader value_style: Style::Style?
|
|
70
|
+
attr_reader text_value: (String | Text::Span | Text::Line)?
|
|
71
|
+
|
|
72
|
+
include CoerceableWidget
|
|
73
|
+
|
|
74
|
+
def self.coerce_args: (bar_options first, ?bar_options kwargs) -> Bar
|
|
75
|
+
| (nil first, bar_options kwargs) -> Bar
|
|
76
|
+
|
|
77
|
+
def self.new: (value: _ToI, ?label: String | Text::Span | Text::Line | nil, ?style: Style::Style?, ?value_style: Style::Style?, ?text_value: String | Text::Span | Text::Line | nil) -> Bar
|
|
78
|
+
def initialize: (value: _ToI, ?label: String | Text::Span | Text::Line | nil, ?style: Style::Style?, ?value_style: Style::Style?, ?text_value: String | Text::Span | Text::Line | nil) -> void
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
class BarGroup < Data
|
|
82
|
+
attr_reader label: String
|
|
83
|
+
attr_reader bars: Array[BarChart::Bar]
|
|
84
|
+
|
|
85
|
+
include CoerceableWidget
|
|
86
|
+
|
|
87
|
+
def self.coerce_args: (bar_group_options first, ?bar_group_options kwargs) -> BarGroup
|
|
88
|
+
| (nil first, bar_group_options kwargs) -> BarGroup
|
|
89
|
+
|
|
90
|
+
def self.new: (label: String, bars: Array[BarChart::Bar]) -> BarGroup
|
|
91
|
+
def initialize: (label: String, bars: Array[BarChart::Bar]) -> void
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
6
|
+
#++
|
|
7
|
+
|
|
8
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
9
|
+
|
|
10
|
+
module RatatuiRuby
|
|
11
|
+
module Widgets
|
|
12
|
+
# Options hash type for Block constructor arguments.
|
|
13
|
+
type block_options = {
|
|
14
|
+
?title: String?,
|
|
15
|
+
?titles: Array[title_entry],
|
|
16
|
+
?title_alignment: alignment?,
|
|
17
|
+
?title_style: style_input?,
|
|
18
|
+
?borders: Array[border_side],
|
|
19
|
+
?border_style: style_input?,
|
|
20
|
+
?border_type: border_type?,
|
|
21
|
+
?border_set: border_set_hash?,
|
|
22
|
+
?style: style_input?,
|
|
23
|
+
?padding: (_ToI | Array[_ToI]),
|
|
24
|
+
?children: Array[widget]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
class Block < Data
|
|
28
|
+
attr_reader title: String?
|
|
29
|
+
attr_reader titles: Array[title_entry]
|
|
30
|
+
attr_reader title_alignment: alignment?
|
|
31
|
+
attr_reader title_style: style_input?
|
|
32
|
+
attr_reader borders: Array[border_side]
|
|
33
|
+
attr_reader border_style: style_input?
|
|
34
|
+
attr_reader border_type: border_type?
|
|
35
|
+
attr_reader border_set: border_set_hash?
|
|
36
|
+
attr_reader style: style_input?
|
|
37
|
+
attr_reader padding: (Integer | Array[Integer])
|
|
38
|
+
attr_reader children: Array[widget]
|
|
39
|
+
|
|
40
|
+
include CoerceableWidget
|
|
41
|
+
|
|
42
|
+
def self.coerce_args: (block_options first, ?block_options kwargs) -> Block
|
|
43
|
+
| (nil first, block_options kwargs) -> Block
|
|
44
|
+
|
|
45
|
+
def self.new: (?title: String?, ?titles: Array[title_entry], ?title_alignment: alignment?, ?title_style: style_input?, ?borders: Array[border_side], ?border_style: style_input?, ?border_type: border_type?, ?border_set: border_set_hash?, ?style: style_input?, ?padding: (_ToI | Array[_ToI]), ?children: Array[widget]) -> Block
|
|
46
|
+
def initialize: (?title: String?, ?titles: Array[title_entry], ?title_alignment: alignment?, ?title_style: style_input?, ?borders: Array[border_side], ?border_style: style_input?, ?border_type: border_type?, ?border_set: border_set_hash?, ?style: style_input?, ?padding: (_ToI | Array[_ToI]), ?children: Array[widget]) -> void
|
|
47
|
+
|
|
48
|
+
def inner: (Layout::Rect area) -> Layout::Rect
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
6
|
+
#++
|
|
7
|
+
|
|
8
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
9
|
+
|
|
10
|
+
module RatatuiRuby
|
|
11
|
+
module Widgets
|
|
12
|
+
# Options hash type for Calendar constructor arguments.
|
|
13
|
+
type calendar_options = {
|
|
14
|
+
?year: _ToI,
|
|
15
|
+
?month: _ToI,
|
|
16
|
+
?events: Hash[date_key, Style],
|
|
17
|
+
?default_style: Style::Style?,
|
|
18
|
+
?header_style: Style::Style?,
|
|
19
|
+
?block: Widgets::Block?,
|
|
20
|
+
?show_weekdays_header: bool,
|
|
21
|
+
?show_surrounding: Style::Style?,
|
|
22
|
+
?show_month_header: bool
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
class Calendar < Data
|
|
26
|
+
attr_reader year: Integer
|
|
27
|
+
attr_reader month: Integer
|
|
28
|
+
attr_reader events: Hash[date_key, Style]
|
|
29
|
+
attr_reader default_style: Style::Style?
|
|
30
|
+
attr_reader header_style: Style::Style?
|
|
31
|
+
attr_reader block: Widgets::Block?
|
|
32
|
+
attr_reader show_weekdays_header: bool
|
|
33
|
+
attr_reader show_surrounding: Style::Style?
|
|
34
|
+
attr_reader show_month_header: bool
|
|
35
|
+
|
|
36
|
+
include CoerceableWidget
|
|
37
|
+
|
|
38
|
+
def self.coerce_args: (calendar_options first, ?calendar_options kwargs) -> Calendar
|
|
39
|
+
| (nil first, calendar_options kwargs) -> Calendar
|
|
40
|
+
|
|
41
|
+
def self.new: (year: _ToI, month: _ToI, ?events: Hash[date_key, Style], ?default_style: Style::Style?, ?header_style: Style::Style?, ?block: Widgets::Block?, ?show_weekdays_header: bool, ?show_surrounding: Style::Style?, ?show_month_header: bool) -> Calendar
|
|
42
|
+
def initialize: (year: _ToI, month: _ToI, ?events: Hash[date_key, Style], ?default_style: Style::Style?, ?header_style: Style::Style?, ?block: Widgets::Block?, ?show_weekdays_header: bool, ?show_surrounding: Style::Style?, ?show_month_header: bool) -> void
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
6
|
+
#++
|
|
7
|
+
|
|
8
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
9
|
+
|
|
10
|
+
module RatatuiRuby
|
|
11
|
+
module Widgets
|
|
12
|
+
# Options hash type for Canvas constructor arguments.
|
|
13
|
+
type canvas_options = {
|
|
14
|
+
?shapes: Array[Shape::Line | Shape::Rectangle | Shape::Circle | Shape::Map | Shape::Label | Shape::Point],
|
|
15
|
+
?x_bounds: Array[_ToF],
|
|
16
|
+
?y_bounds: Array[_ToF],
|
|
17
|
+
?marker: Symbol,
|
|
18
|
+
?block: Widgets::Block?,
|
|
19
|
+
?background_color: (String | Symbol)?
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class Canvas < Data
|
|
23
|
+
attr_reader shapes: Array[Shape::Line | Shape::Rectangle | Shape::Circle | Shape::Map | Shape::Label | Shape::Point]
|
|
24
|
+
attr_reader x_bounds: Array[Float]
|
|
25
|
+
attr_reader y_bounds: Array[Float]
|
|
26
|
+
attr_reader marker: Symbol
|
|
27
|
+
attr_reader block: Widgets::Block?
|
|
28
|
+
attr_reader background_color: (String | Symbol)?
|
|
29
|
+
|
|
30
|
+
include CoerceableWidget
|
|
31
|
+
|
|
32
|
+
def self.coerce_args: (canvas_options first, ?canvas_options kwargs) -> Canvas
|
|
33
|
+
| (nil first, canvas_options kwargs) -> Canvas
|
|
34
|
+
|
|
35
|
+
def self.new: (?shapes: Array[Shape::Line | Shape::Rectangle | Shape::Circle | Shape::Map | Shape::Label | Shape::Point], ?x_bounds: Array[_ToF], ?y_bounds: Array[_ToF], ?marker: Symbol, ?block: Widgets::Block?, ?background_color: (String | Symbol)?) -> Canvas
|
|
36
|
+
def initialize: (?shapes: Array[Shape::Line | Shape::Rectangle | Shape::Circle | Shape::Map | Shape::Label | Shape::Point], ?x_bounds: Array[_ToF], ?y_bounds: Array[_ToF], ?marker: Symbol, ?block: Widgets::Block?, ?background_color: (String | Symbol)?) -> void
|
|
37
|
+
|
|
38
|
+
# Converts canvas coordinates to normalized grid coordinates.
|
|
39
|
+
# Returns [normalized_x, normalized_y] or nil if out of bounds.
|
|
40
|
+
def get_point: (_ToF x, _ToF y) -> Array[Float]?
|
|
41
|
+
alias point get_point
|
|
42
|
+
alias [] get_point
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
module Shape
|
|
46
|
+
class Point < Data
|
|
47
|
+
attr_reader x: Float
|
|
48
|
+
attr_reader y: Float
|
|
49
|
+
|
|
50
|
+
def self.new: (x: _ToF, y: _ToF) -> Point
|
|
51
|
+
def initialize: (x: _ToF, y: _ToF) -> void
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class Line < Data
|
|
55
|
+
attr_reader x1: Float
|
|
56
|
+
attr_reader y1: Float
|
|
57
|
+
attr_reader x2: Float
|
|
58
|
+
attr_reader y2: Float
|
|
59
|
+
attr_reader color: (String | Symbol)
|
|
60
|
+
|
|
61
|
+
def self.new: (x1: _ToF, y1: _ToF, x2: _ToF, y2: _ToF, color: (String | Symbol)) -> Line
|
|
62
|
+
def initialize: (x1: _ToF, y1: _ToF, x2: _ToF, y2: _ToF, color: (String | Symbol)) -> void
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
class Rectangle < Data
|
|
66
|
+
attr_reader x: Float
|
|
67
|
+
attr_reader y: Float
|
|
68
|
+
attr_reader width: Float
|
|
69
|
+
attr_reader height: Float
|
|
70
|
+
attr_reader color: (String | Symbol)
|
|
71
|
+
|
|
72
|
+
def self.new: (x: _ToF, y: _ToF, width: _ToF, height: _ToF, color: (String | Symbol)) -> Rectangle
|
|
73
|
+
def initialize: (x: _ToF, y: _ToF, width: _ToF, height: _ToF, color: (String | Symbol)) -> void
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
class Circle < Data
|
|
77
|
+
attr_reader x: Float
|
|
78
|
+
attr_reader y: Float
|
|
79
|
+
attr_reader radius: Float
|
|
80
|
+
attr_reader color: (String | Symbol)
|
|
81
|
+
|
|
82
|
+
def self.new: (x: _ToF, y: _ToF, radius: _ToF, color: (String | Symbol)) -> Circle
|
|
83
|
+
def initialize: (x: _ToF, y: _ToF, radius: _ToF, color: (String | Symbol)) -> void
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
class Map < Data
|
|
87
|
+
attr_reader color: (String | Symbol)
|
|
88
|
+
attr_reader resolution: Symbol
|
|
89
|
+
|
|
90
|
+
def self.new: (?color: (String | Symbol), ?resolution: Symbol) -> Map
|
|
91
|
+
def initialize: (?color: (String | Symbol), ?resolution: Symbol) -> void
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
6
|
+
#++
|
|
7
|
+
|
|
8
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
9
|
+
|
|
10
|
+
module RatatuiRuby
|
|
11
|
+
module Widgets
|
|
12
|
+
# Options hash type for Chart constructor arguments.
|
|
13
|
+
type chart_options = {
|
|
14
|
+
?datasets: Array[Dataset],
|
|
15
|
+
?x_axis: Axis,
|
|
16
|
+
?y_axis: Axis,
|
|
17
|
+
?block: Widgets::Block?,
|
|
18
|
+
?style: Style::Style?,
|
|
19
|
+
?legend_position: Symbol?,
|
|
20
|
+
?hidden_legend_constraints: Array[Layout::Constraint]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
# Options hash type for Dataset constructor arguments.
|
|
24
|
+
type dataset_options = {
|
|
25
|
+
?name: String | Symbol,
|
|
26
|
+
?data: Array[[_ToF, _ToF]],
|
|
27
|
+
?style: Style::Style?,
|
|
28
|
+
?marker: Symbol,
|
|
29
|
+
?graph_type: Symbol
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# Options hash type for Axis constructor arguments.
|
|
33
|
+
type axis_options = {
|
|
34
|
+
?title: String,
|
|
35
|
+
?bounds: [_ToF, _ToF],
|
|
36
|
+
?labels: Array[String],
|
|
37
|
+
?style: Style::Style?,
|
|
38
|
+
?labels_alignment: Symbol?
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
class Chart < Data
|
|
42
|
+
attr_reader datasets: Array[Dataset]
|
|
43
|
+
attr_reader x_axis: Axis
|
|
44
|
+
attr_reader y_axis: Axis
|
|
45
|
+
attr_reader block: Widgets::Block?
|
|
46
|
+
attr_reader style: Style::Style?
|
|
47
|
+
attr_reader legend_position: Symbol?
|
|
48
|
+
attr_reader hidden_legend_constraints: Array[Layout::Constraint]
|
|
49
|
+
|
|
50
|
+
include CoerceableWidget
|
|
51
|
+
|
|
52
|
+
def self.coerce_args: (chart_options first, ?chart_options kwargs) -> Chart
|
|
53
|
+
| (nil first, chart_options kwargs) -> Chart
|
|
54
|
+
|
|
55
|
+
def self.new: (datasets: Array[Dataset], x_axis: Axis, y_axis: Axis, ?block: Widgets::Block?, ?style: Style::Style?, ?legend_position: Symbol?, ?hidden_legend_constraints: Array[Layout::Constraint]) -> Chart
|
|
56
|
+
def initialize: (datasets: Array[Dataset], x_axis: Axis, y_axis: Axis, ?block: Widgets::Block?, ?style: Style::Style?, ?legend_position: Symbol?, ?hidden_legend_constraints: Array[Layout::Constraint]) -> void
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
class Dataset < Data
|
|
60
|
+
attr_reader name: String | Symbol
|
|
61
|
+
attr_reader data: Array[[Float, Float]]
|
|
62
|
+
attr_reader style: Style::Style?
|
|
63
|
+
attr_reader marker: Symbol
|
|
64
|
+
attr_reader graph_type: Symbol
|
|
65
|
+
|
|
66
|
+
include CoerceableWidget
|
|
67
|
+
|
|
68
|
+
def self.coerce_args: (dataset_options first, ?dataset_options kwargs) -> Dataset
|
|
69
|
+
| (nil first, dataset_options kwargs) -> Dataset
|
|
70
|
+
|
|
71
|
+
def self.new: (name: String | Symbol, data: Array[[_ToF, _ToF]], ?style: Style::Style?, ?marker: Symbol, ?graph_type: Symbol) -> Dataset
|
|
72
|
+
def initialize: (name: String | Symbol, data: Array[[_ToF, _ToF]], ?style: Style::Style?, ?marker: Symbol, ?graph_type: Symbol) -> void
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
class Axis < Data
|
|
76
|
+
attr_reader title: String
|
|
77
|
+
attr_reader bounds: [Float, Float]
|
|
78
|
+
attr_reader labels: Array[String]
|
|
79
|
+
attr_reader style: Style::Style?
|
|
80
|
+
attr_reader labels_alignment: Symbol?
|
|
81
|
+
|
|
82
|
+
include CoerceableWidget
|
|
83
|
+
|
|
84
|
+
def self.coerce_args: (axis_options first, ?axis_options kwargs) -> Axis
|
|
85
|
+
| (nil first, axis_options kwargs) -> Axis
|
|
86
|
+
|
|
87
|
+
def self.new: (?title: String, ?bounds: [_ToF, _ToF], ?labels: Array[String], ?style: Style::Style?, ?labels_alignment: Symbol?) -> Axis
|
|
88
|
+
def initialize: (?title: String, ?bounds: [_ToF, _ToF], ?labels: Array[String], ?style: Style::Style?, ?labels_alignment: Symbol?) -> void
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|