ratatui_ruby 1.2.2 → 1.3.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 +54 -0
- data/.builds/ruby-3.3.yml +54 -0
- data/.builds/ruby-3.4.yml +54 -0
- data/.builds/ruby-4.0.0.yml +54 -0
- data/.pre-commit-config.yaml +16 -0
- data/.rubocop.yml +10 -0
- data/AGENTS.md +147 -0
- data/CHANGELOG.md +771 -0
- data/README.md +187 -0
- data/README.rdoc +302 -0
- data/Rakefile +11 -0
- data/Steepfile +50 -0
- data/doc/concepts/application_architecture.md +321 -0
- data/doc/concepts/application_testing.md +193 -0
- data/doc/concepts/async.md +190 -0
- data/doc/concepts/custom_widgets.md +247 -0
- data/doc/concepts/debugging.md +401 -0
- data/doc/concepts/event_handling.md +162 -0
- data/doc/concepts/interactive_design.md +146 -0
- data/doc/contributors/auditing/parity.md +239 -0
- data/doc/contributors/design/ruby_frontend.md +448 -0
- data/doc/contributors/design/rust_backend.md +434 -0
- data/doc/contributors/design.md +11 -0
- data/doc/contributors/developing_examples.md +400 -0
- data/doc/contributors/documentation_style.md +121 -0
- data/doc/contributors/index.md +21 -0
- data/doc/contributors/releasing.md +215 -0
- data/doc/contributors/todo/align/api_completeness_audit-finished.md +381 -0
- data/doc/contributors/todo/align/api_completeness_audit-unfinished.md +200 -0
- data/doc/contributors/todo/align/term.md +351 -0
- data/doc/contributors/todo/align/terminal.md +647 -0
- data/doc/contributors/todo/future_work.md +169 -0
- data/doc/contributors/upstream_requests/paragraph_span_rects.md +259 -0
- data/doc/contributors/upstream_requests/tab_rects.md +173 -0
- data/doc/contributors/upstream_requests/title_rects.md +132 -0
- data/doc/custom.css +22 -0
- data/doc/getting_started/quickstart.md +291 -0
- data/doc/getting_started/why.md +93 -0
- data/doc/images/app_all_events.png +0 -0
- data/doc/images/app_cli_rich_moments.gif +0 -0
- data/doc/images/app_color_picker.png +0 -0
- data/doc/images/app_debugging_showcase.gif +0 -0
- data/doc/images/app_debugging_showcase.png +0 -0
- data/doc/images/app_external_editor.gif +0 -0
- data/doc/images/app_login_form.png +0 -0
- data/doc/images/app_stateful_interaction.png +0 -0
- data/doc/images/verify_quickstart_dsl.png +0 -0
- data/doc/images/verify_quickstart_layout.png +0 -0
- data/doc/images/verify_quickstart_lifecycle.png +0 -0
- data/doc/images/verify_readme_usage.png +0 -0
- data/doc/images/widget_barchart.png +0 -0
- data/doc/images/widget_block.png +0 -0
- data/doc/images/widget_box.png +0 -0
- data/doc/images/widget_calendar.png +0 -0
- data/doc/images/widget_canvas.png +0 -0
- data/doc/images/widget_cell.png +0 -0
- data/doc/images/widget_center.png +0 -0
- data/doc/images/widget_chart.png +0 -0
- data/doc/images/widget_gauge.png +0 -0
- data/doc/images/widget_layout_split.png +0 -0
- data/doc/images/widget_line_gauge.png +0 -0
- data/doc/images/widget_list.png +0 -0
- data/doc/images/widget_map.png +0 -0
- data/doc/images/widget_overlay.png +0 -0
- data/doc/images/widget_popup.png +0 -0
- data/doc/images/widget_ratatui_logo.png +0 -0
- data/doc/images/widget_ratatui_mascot.png +0 -0
- data/doc/images/widget_rect.png +0 -0
- data/doc/images/widget_render.png +0 -0
- data/doc/images/widget_rich_text.png +0 -0
- data/doc/images/widget_scroll_text.png +0 -0
- data/doc/images/widget_scrollbar.png +0 -0
- data/doc/images/widget_sparkline.png +0 -0
- data/doc/images/widget_style_colors.png +0 -0
- data/doc/images/widget_table.png +0 -0
- data/doc/images/widget_tabs.png +0 -0
- data/doc/images/widget_text_width.png +0 -0
- data/doc/index.md +34 -0
- data/doc/troubleshooting/async.md +4 -0
- data/doc/troubleshooting/terminal_limitations.md +131 -0
- data/doc/troubleshooting/tui_output.md +197 -0
- data/examples/app_all_events/README.md +114 -0
- data/examples/app_all_events/app.rb +98 -0
- data/examples/app_all_events/model/app_model.rb +159 -0
- data/examples/app_all_events/model/event_color_cycle.rb +43 -0
- data/examples/app_all_events/model/event_entry.rb +94 -0
- data/examples/app_all_events/model/msg.rb +39 -0
- data/examples/app_all_events/model/timestamp.rb +56 -0
- data/examples/app_all_events/update.rb +75 -0
- data/examples/app_all_events/view/app_view.rb +80 -0
- data/examples/app_all_events/view/controls_view.rb +54 -0
- data/examples/app_all_events/view/counts_view.rb +61 -0
- data/examples/app_all_events/view/live_view.rb +72 -0
- data/examples/app_all_events/view/log_view.rb +57 -0
- data/examples/app_all_events/view.rb +9 -0
- data/examples/app_cli_rich_moments/README.md +81 -0
- data/examples/app_cli_rich_moments/app.rb +189 -0
- data/examples/app_color_picker/README.md +156 -0
- data/examples/app_color_picker/app.rb +76 -0
- data/examples/app_color_picker/clipboard.rb +86 -0
- data/examples/app_color_picker/color.rb +193 -0
- data/examples/app_color_picker/controls.rb +92 -0
- data/examples/app_color_picker/copy_dialog.rb +168 -0
- data/examples/app_color_picker/export_pane.rb +128 -0
- data/examples/app_color_picker/harmony.rb +58 -0
- data/examples/app_color_picker/input.rb +176 -0
- data/examples/app_color_picker/main_container.rb +180 -0
- data/examples/app_color_picker/palette.rb +111 -0
- data/examples/app_debugging_showcase/README.md +119 -0
- data/examples/app_debugging_showcase/app.rb +318 -0
- data/examples/app_external_editor/README.md +62 -0
- data/examples/app_external_editor/app.rb +344 -0
- data/examples/app_login_form/README.md +58 -0
- data/examples/app_login_form/app.rb +109 -0
- data/examples/app_stateful_interaction/README.md +35 -0
- data/examples/app_stateful_interaction/app.rb +328 -0
- data/examples/timeout_demo.rb +45 -0
- data/examples/verify_quickstart_dsl/README.md +55 -0
- data/examples/verify_quickstart_dsl/app.rb +49 -0
- data/examples/verify_quickstart_layout/README.md +77 -0
- data/examples/verify_quickstart_layout/app.rb +73 -0
- data/examples/verify_quickstart_lifecycle/README.md +68 -0
- data/examples/verify_quickstart_lifecycle/app.rb +62 -0
- data/examples/verify_readme_usage/README.md +49 -0
- data/examples/verify_readme_usage/app.rb +42 -0
- data/examples/verify_website_managed/README.md +48 -0
- data/examples/verify_website_managed/app.rb +36 -0
- data/examples/verify_website_menu/README.md +60 -0
- data/examples/verify_website_menu/app.rb +84 -0
- data/examples/verify_website_spinner/README.md +44 -0
- data/examples/verify_website_spinner/app.rb +34 -0
- data/examples/widget_barchart/README.md +58 -0
- data/examples/widget_barchart/app.rb +240 -0
- data/examples/widget_block/README.md +44 -0
- data/examples/widget_block/app.rb +258 -0
- data/examples/widget_box/README.md +54 -0
- data/examples/widget_box/app.rb +255 -0
- data/examples/widget_calendar/README.md +48 -0
- data/examples/widget_calendar/app.rb +115 -0
- data/examples/widget_canvas/README.md +31 -0
- data/examples/widget_canvas/app.rb +130 -0
- data/examples/widget_cell/README.md +45 -0
- data/examples/widget_cell/app.rb +112 -0
- data/examples/widget_center/README.md +33 -0
- data/examples/widget_center/app.rb +118 -0
- data/examples/widget_chart/README.md +50 -0
- data/examples/widget_chart/app.rb +220 -0
- data/examples/widget_gauge/README.md +50 -0
- data/examples/widget_gauge/app.rb +229 -0
- data/examples/widget_layout_split/README.md +53 -0
- data/examples/widget_layout_split/app.rb +260 -0
- data/examples/widget_line_gauge/README.md +50 -0
- data/examples/widget_line_gauge/app.rb +219 -0
- data/examples/widget_list/README.md +58 -0
- data/examples/widget_list/app.rb +382 -0
- data/examples/widget_map/README.md +48 -0
- data/examples/widget_map/app.rb +95 -0
- data/examples/widget_overlay/README.md +45 -0
- data/examples/widget_overlay/app.rb +250 -0
- data/examples/widget_popup/README.md +45 -0
- data/examples/widget_popup/app.rb +106 -0
- data/examples/widget_ratatui_logo/README.md +43 -0
- data/examples/widget_ratatui_logo/app.rb +104 -0
- data/examples/widget_ratatui_mascot/README.md +43 -0
- data/examples/widget_ratatui_mascot/app.rb +95 -0
- data/examples/widget_rect/README.md +53 -0
- data/examples/widget_rect/app.rb +222 -0
- data/examples/widget_render/README.md +46 -0
- data/examples/widget_render/app.rb +186 -0
- data/examples/widget_render/app.rbs +41 -0
- data/examples/widget_rich_text/README.md +44 -0
- data/examples/widget_rich_text/app.rb +193 -0
- data/examples/widget_scroll_text/README.md +46 -0
- data/examples/widget_scroll_text/app.rb +109 -0
- data/examples/widget_scrollbar/README.md +46 -0
- data/examples/widget_scrollbar/app.rb +155 -0
- data/examples/widget_sparkline/README.md +51 -0
- data/examples/widget_sparkline/app.rb +277 -0
- data/examples/widget_style_colors/README.md +43 -0
- data/examples/widget_style_colors/app.rb +83 -0
- data/examples/widget_table/README.md +57 -0
- data/examples/widget_table/app.rb +285 -0
- data/examples/widget_tabs/README.md +50 -0
- data/examples/widget_tabs/app.rb +183 -0
- data/examples/widget_text_width/README.md +44 -0
- data/examples/widget_text_width/app.rb +117 -0
- data/ext/ratatui_ruby/Cargo.lock +1 -2
- data/ext/ratatui_ruby/Cargo.toml +1 -2
- data/ext/ratatui_ruby/src/events.rs +18 -157
- data/lib/ratatui_ruby/event/focus_gained.rb +50 -0
- data/lib/ratatui_ruby/event/focus_lost.rb +51 -0
- data/lib/ratatui_ruby/event/key/dwim.rb +301 -0
- data/lib/ratatui_ruby/event/key/modifier.rb +2 -0
- data/lib/ratatui_ruby/event/key.rb +9 -0
- data/lib/ratatui_ruby/event/mouse.rb +33 -0
- data/lib/ratatui_ruby/event/paste.rb +25 -0
- data/lib/ratatui_ruby/event/resize.rb +65 -0
- data/lib/ratatui_ruby/version.rb +1 -1
- data/migrate_to_buffer.rb +145 -0
- data/mise.toml +8 -0
- data/sig/ratatui_ruby/event.rbs +97 -0
- data/tasks/autodoc/examples.rb +87 -0
- data/tasks/autodoc/member.rb +58 -0
- data/tasks/autodoc/name.rb +21 -0
- data/tasks/autodoc.rake +21 -0
- data/tasks/bump/bump_workflow.rb +49 -0
- data/tasks/bump/cargo_lockfile.rb +21 -0
- data/tasks/bump/changelog.rb +104 -0
- data/tasks/bump/header.rb +32 -0
- data/tasks/bump/history.rb +32 -0
- data/tasks/bump/links.rb +69 -0
- data/tasks/bump/manifest.rb +33 -0
- data/tasks/bump/patch_release.rb +19 -0
- data/tasks/bump/release_branch.rb +17 -0
- data/tasks/bump/release_from_trunk.rb +49 -0
- data/tasks/bump/repository.rb +54 -0
- data/tasks/bump/ruby_gem.rb +29 -0
- data/tasks/bump/sem_ver.rb +44 -0
- data/tasks/bump/unreleased_section.rb +73 -0
- data/tasks/bump.rake +61 -0
- data/tasks/doc/documentation.rb +59 -0
- data/tasks/doc/link/file_url.rb +30 -0
- data/tasks/doc/link/relative_path.rb +61 -0
- data/tasks/doc/link/web_url.rb +55 -0
- data/tasks/doc/link.rb +52 -0
- data/tasks/doc/link_audit.rb +116 -0
- data/tasks/doc/problem.rb +40 -0
- data/tasks/doc/source_file.rb +93 -0
- data/tasks/doc.rake +905 -0
- data/tasks/example_viewer.html.erb +172 -0
- data/tasks/extension.rake +14 -0
- data/tasks/license/headers_md.rb +223 -0
- data/tasks/license/headers_rb.rb +210 -0
- data/tasks/license/license_utils.rb +130 -0
- data/tasks/license/snippets_md.rb +315 -0
- data/tasks/license/snippets_rdoc.rb +150 -0
- data/tasks/license.rake +91 -0
- data/tasks/lint.rake +170 -0
- data/tasks/rbs_predicates/predicate_catalog.rb +52 -0
- data/tasks/rbs_predicates/predicate_tests.rb +124 -0
- data/tasks/rbs_predicates/rbs_signature.rb +63 -0
- data/tasks/rbs_predicates.rake +31 -0
- data/tasks/rdoc_config.rb +29 -0
- data/tasks/resources/build.yml.erb +60 -0
- data/tasks/resources/index.html.erb +141 -0
- data/tasks/resources/rubies.yml +7 -0
- data/tasks/sourcehut.rake +122 -0
- data/tasks/steep.rake +11 -0
- data/tasks/terminal_preview/app_screenshot.rb +45 -0
- data/tasks/terminal_preview/crash_report.rb +54 -0
- data/tasks/terminal_preview/example_app.rb +27 -0
- data/tasks/terminal_preview/launcher_script.rb +48 -0
- data/tasks/terminal_preview/preview_collection.rb +60 -0
- data/tasks/terminal_preview/preview_timing.rb +24 -0
- data/tasks/terminal_preview/safety_confirmation.rb +58 -0
- data/tasks/terminal_preview/saved_screenshot.rb +56 -0
- data/tasks/terminal_preview/system_appearance.rb +13 -0
- data/tasks/terminal_preview/terminal_window.rb +138 -0
- data/tasks/terminal_preview/window_id.rb +16 -0
- data/tasks/terminal_preview.rake +30 -0
- data/tasks/test.rake +36 -0
- data/tasks/website/index_page.rb +30 -0
- data/tasks/website/version.rb +122 -0
- data/tasks/website/version_menu.rb +68 -0
- data/tasks/website/versioned_documentation.rb +83 -0
- data/tasks/website/website.rb +53 -0
- data/tasks/website.rake +28 -0
- metadata +256 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
|
|
3
|
+
SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
|
+
%>
|
|
5
|
+
<!DOCTYPE html>
|
|
6
|
+
<html lang="en">
|
|
7
|
+
<head>
|
|
8
|
+
<meta charset="UTF-8">
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
10
|
+
<title><%= page_title %> - Example Viewer</title>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
var rdoc_rel_prefix = "<%= doc_root_link.sub('index.html', '') %>";
|
|
14
|
+
var index_rel_prefix = "<%= '../' * (relative_path.split('/').size - 1) %>";
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script src="<%= '../' * (relative_path.split('/').size - 1) %>js/search_navigation.js" defer></script>
|
|
18
|
+
<script src="<%= '../' * (relative_path.split('/').size - 1) %>js/search_data.js" defer></script>
|
|
19
|
+
<script src="<%= '../' * (relative_path.split('/').size - 1) %>js/search_ranker.js" defer></script>
|
|
20
|
+
<script src="<%= '../' * (relative_path.split('/').size - 1) %>js/search_controller.js" defer></script>
|
|
21
|
+
<script src="<%= '../' * (relative_path.split('/').size - 1) %>js/aliki.js" defer></script>
|
|
22
|
+
|
|
23
|
+
<link href="<%= doc_root_link.sub('index.html', '') %>css/rdoc.css" rel="stylesheet">
|
|
24
|
+
<link href="<%= doc_root_link.sub('index.html', '') %>custom.css" rel="stylesheet">
|
|
25
|
+
</head>
|
|
26
|
+
<body class="file<%= ' has-toc' unless toc_items.empty? %>">
|
|
27
|
+
<%= icons_svg %>
|
|
28
|
+
<header class="top-navbar">
|
|
29
|
+
<div class="navbar-brand">
|
|
30
|
+
Example Viewer
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<!-- Desktop search bar -->
|
|
34
|
+
<div class="navbar-search navbar-search-desktop" role="search">
|
|
35
|
+
<form action="#" method="get" accept-charset="utf-8">
|
|
36
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
|
37
|
+
aria-autocomplete="list" aria-controls="search-results-desktop"
|
|
38
|
+
type="text" name="search" placeholder="Search (/) examples..."
|
|
39
|
+
spellcheck="false" autocomplete="off"
|
|
40
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
|
41
|
+
<ul id="search-results-desktop" aria-label="Search Results"
|
|
42
|
+
aria-busy="false" aria-expanded="false"
|
|
43
|
+
aria-atomic="false" class="initially-hidden search-results"></ul>
|
|
44
|
+
</form>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<!-- Mobile search icon button -->
|
|
48
|
+
<button id="search-toggle" class="navbar-search-mobile" aria-label="Open search" type="button">
|
|
49
|
+
<span aria-hidden="true">🔍</span>
|
|
50
|
+
</button>
|
|
51
|
+
|
|
52
|
+
<button id="theme-toggle" class="theme-toggle" aria-label="Switch to dark mode" type="button" onclick="cycleColorMode()">
|
|
53
|
+
<span class="theme-toggle-icon" aria-hidden="true">🌙</span>
|
|
54
|
+
</button>
|
|
55
|
+
</header>
|
|
56
|
+
|
|
57
|
+
<!-- Search Modal (Mobile) -->
|
|
58
|
+
<div id="search-modal" class="search-modal" hidden aria-modal="true" role="dialog" aria-label="Search">
|
|
59
|
+
<div class="search-modal-backdrop"></div>
|
|
60
|
+
<div class="search-modal-content">
|
|
61
|
+
<div class="search-modal-header">
|
|
62
|
+
<form class="search-modal-form" action="#" method="get" accept-charset="utf-8">
|
|
63
|
+
<span class="search-modal-icon" aria-hidden="true">🔍</span>
|
|
64
|
+
<input id="search-field-mobile" role="combobox" aria-label="Search"
|
|
65
|
+
aria-autocomplete="list" aria-controls="search-results-mobile"
|
|
66
|
+
type="text" name="search" placeholder="Search examples"
|
|
67
|
+
spellcheck="false" autocomplete="off">
|
|
68
|
+
<button type="button" class="search-modal-close" aria-label="Close search" id="search-modal-close">
|
|
69
|
+
<span aria-hidden="true">esc</span>
|
|
70
|
+
</button>
|
|
71
|
+
</form>
|
|
72
|
+
</div>
|
|
73
|
+
<div class="search-modal-body">
|
|
74
|
+
<ul id="search-results-mobile" aria-label="Search Results"
|
|
75
|
+
aria-busy="false" aria-expanded="false"
|
|
76
|
+
aria-atomic="false" class="search-results search-modal-results initially-hidden"></ul>
|
|
77
|
+
<div class="search-modal-empty">
|
|
78
|
+
<p>No recent searches</p>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
<nav id="navigation" role="navigation">
|
|
85
|
+
<div id="fileindex-section" class="nav-section">
|
|
86
|
+
<details class="nav-section-collapsible" open>
|
|
87
|
+
<summary class="nav-section-header">
|
|
88
|
+
<span class="nav-section-icon">
|
|
89
|
+
<svg><use href="#icon-file"></use></svg>
|
|
90
|
+
</span>
|
|
91
|
+
<span class="nav-section-title">Examples</span>
|
|
92
|
+
<span class="nav-section-chevron">
|
|
93
|
+
<svg><use href="#icon-chevron"></use></svg>
|
|
94
|
+
</span>
|
|
95
|
+
</summary>
|
|
96
|
+
<ul class="nav-list">
|
|
97
|
+
<li><a href="<%= doc_root_link %>">← Back to Docs</a></li>
|
|
98
|
+
</ul>
|
|
99
|
+
</details>
|
|
100
|
+
</div>
|
|
101
|
+
<div class="nav-section">
|
|
102
|
+
<details class="nav-section-collapsible" open>
|
|
103
|
+
<summary class="nav-section-header">
|
|
104
|
+
<span class="nav-section-icon">
|
|
105
|
+
<svg><use href="#icon-layers"></use></svg>
|
|
106
|
+
</span>
|
|
107
|
+
<span class="nav-section-title">Files</span>
|
|
108
|
+
<span class="nav-section-chevron">
|
|
109
|
+
<svg><use href="#icon-chevron"></use></svg>
|
|
110
|
+
</span>
|
|
111
|
+
</summary>
|
|
112
|
+
<ul class="link-list nav-list">
|
|
113
|
+
<%= render_tree(tree_data, relative_path, current_file_html) %>
|
|
114
|
+
</ul>
|
|
115
|
+
</details>
|
|
116
|
+
</div>
|
|
117
|
+
</nav>
|
|
118
|
+
|
|
119
|
+
<main role="main">
|
|
120
|
+
<div class="breadcrumb">
|
|
121
|
+
<%= breadcrumb_path %>
|
|
122
|
+
</div>
|
|
123
|
+
<%= file_header_html %>
|
|
124
|
+
<div class="content">
|
|
125
|
+
<%= file_content_html %>
|
|
126
|
+
</div>
|
|
127
|
+
</main>
|
|
128
|
+
|
|
129
|
+
<% unless toc_items.empty? %>
|
|
130
|
+
<aside class="table-of-contents" role="complementary" aria-label="Table of Contents">
|
|
131
|
+
<div class="toc-sticky">
|
|
132
|
+
<div class="toc-list">
|
|
133
|
+
<h3>On This Page</h3>
|
|
134
|
+
<%= render_toc(toc_items) %>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
</aside>
|
|
138
|
+
<% end %>
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
<script>
|
|
142
|
+
const modes = ['auto', 'light', 'dark'];
|
|
143
|
+
const icons = { auto: '🌓', light: '☀️', dark: '🌙' };
|
|
144
|
+
|
|
145
|
+
function setColorMode(mode) {
|
|
146
|
+
if (mode === 'auto') {
|
|
147
|
+
document.documentElement.removeAttribute('data-theme');
|
|
148
|
+
const systemTheme = (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) ? 'dark' : 'light';
|
|
149
|
+
document.documentElement.setAttribute('data-theme', systemTheme);
|
|
150
|
+
} else {
|
|
151
|
+
document.documentElement.setAttribute('data-theme', mode);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const icon = icons[mode];
|
|
155
|
+
const toggle = document.getElementById('theme-toggle');
|
|
156
|
+
toggle.querySelector('.theme-toggle-icon').textContent = icon;
|
|
157
|
+
|
|
158
|
+
localStorage.setItem('rdoc-theme', mode);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function cycleColorMode() {
|
|
162
|
+
const current = localStorage.getItem('rdoc-theme') || 'auto';
|
|
163
|
+
const currentIndex = modes.indexOf(current);
|
|
164
|
+
const nextMode = modes[(currentIndex + 1) % modes.length];
|
|
165
|
+
setColorMode(nextMode);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const savedMode = localStorage.getItem('rdoc-theme') || 'auto';
|
|
169
|
+
setColorMode(savedMode);
|
|
170
|
+
</script>
|
|
171
|
+
</body>
|
|
172
|
+
</html>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
|
|
5
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
+
#++
|
|
7
|
+
|
|
8
|
+
require "rake/extensiontask"
|
|
9
|
+
|
|
10
|
+
spec = Gem::Specification.load("ratatui_ruby.gemspec")
|
|
11
|
+
Rake::ExtensionTask.new("ratatui_ruby", spec) do |ext|
|
|
12
|
+
ext.lib_dir = "lib/ratatui_ruby"
|
|
13
|
+
ext.ext_dir = "ext/ratatui_ruby"
|
|
14
|
+
end
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
+
#++
|
|
7
|
+
|
|
8
|
+
# Script to ensure markdown files have correct SPDX file headers (CC-BY-SA-4.0).
|
|
9
|
+
#
|
|
10
|
+
# Usage: ruby tasks/license/headers_md.rb [path...]
|
|
11
|
+
#
|
|
12
|
+
# If no paths are given, processes all .md files via git ls-files.
|
|
13
|
+
#
|
|
14
|
+
# Rules:
|
|
15
|
+
# - Ensures file has CC-BY-SA-4.0 license header with YOUR copyright
|
|
16
|
+
# - Updates years for EXISTING contributors based on git blame + Co-Authored-By
|
|
17
|
+
# - Does NOT add new contributors from git history - only updates existing ones
|
|
18
|
+
# - Uses non-code-block lines for year calculation
|
|
19
|
+
# - Adds header with YOUR copyright if missing
|
|
20
|
+
|
|
21
|
+
require_relative "license_utils"
|
|
22
|
+
|
|
23
|
+
YOUR_NAME = "Kerrick Long"
|
|
24
|
+
YOUR_EMAIL = "me@kerricklong.com"
|
|
25
|
+
YOUR_IDENTIFIERS = [YOUR_NAME, YOUR_EMAIL].freeze
|
|
26
|
+
YOUR_COPYRIGHT = "#{YOUR_NAME} <#{YOUR_EMAIL}>"
|
|
27
|
+
LICENSE = "CC-BY-SA-4.0"
|
|
28
|
+
|
|
29
|
+
def find_code_blocks(lines)
|
|
30
|
+
blocks = []
|
|
31
|
+
i = 0
|
|
32
|
+
|
|
33
|
+
while i < lines.length
|
|
34
|
+
line = lines[i]
|
|
35
|
+
|
|
36
|
+
if line =~ /^(````*)(\w*)$/
|
|
37
|
+
fence_marker = $1
|
|
38
|
+
fence_start = i
|
|
39
|
+
re_end = /^#{Regexp.escape(fence_marker)}$/
|
|
40
|
+
|
|
41
|
+
j = i + 1
|
|
42
|
+
while j < lines.length
|
|
43
|
+
if lines[j] =~ re_end
|
|
44
|
+
blocks << { start: fence_start, end: j }
|
|
45
|
+
i = j
|
|
46
|
+
break
|
|
47
|
+
end
|
|
48
|
+
j += 1
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
i += 1
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
blocks
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def get_non_code_line_ranges(lines)
|
|
59
|
+
header_end = 0
|
|
60
|
+
if lines[0]&.include?("<!--")
|
|
61
|
+
(0...(lines.length)).each do |i|
|
|
62
|
+
if lines[i].include?("-->")
|
|
63
|
+
header_end = i + 1
|
|
64
|
+
break
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
code_blocks = find_code_blocks(lines)
|
|
70
|
+
non_code_ranges = []
|
|
71
|
+
current_line = header_end
|
|
72
|
+
|
|
73
|
+
code_blocks.each do |block|
|
|
74
|
+
if current_line < block[:start]
|
|
75
|
+
non_code_ranges << [current_line + 1, block[:start]]
|
|
76
|
+
end
|
|
77
|
+
current_line = block[:end] + 1
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
if current_line < lines.length
|
|
81
|
+
non_code_ranges << [current_line + 1, lines.length]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
non_code_ranges
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def parse_existing_header(lines)
|
|
88
|
+
return nil unless lines[0]&.include?("<!--")
|
|
89
|
+
|
|
90
|
+
header_end = nil
|
|
91
|
+
copyrights = []
|
|
92
|
+
license = nil
|
|
93
|
+
|
|
94
|
+
(0...(lines.length)).each do |i|
|
|
95
|
+
line = lines[i]
|
|
96
|
+
|
|
97
|
+
if line =~ /SPDX-FileCopyrightText:\s*(\d{4})\s+(.+)$/
|
|
98
|
+
copyrights << { year: $1.to_i, holder: $2.strip }
|
|
99
|
+
# REUSE-IgnoreStart
|
|
100
|
+
elsif line =~ /SPDX-License-Identifier:\s*(.+)$/
|
|
101
|
+
# REUSE-IgnoreEnd
|
|
102
|
+
license = $1.strip
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
if line.include?("-->")
|
|
106
|
+
header_end = i
|
|
107
|
+
break
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
return nil if header_end.nil?
|
|
112
|
+
return nil if copyrights.empty? && license.nil?
|
|
113
|
+
|
|
114
|
+
{ end_line: header_end, copyrights:, license: }
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def process_file(filepath)
|
|
118
|
+
content = File.read(filepath)
|
|
119
|
+
lines = content.lines
|
|
120
|
+
|
|
121
|
+
non_code_ranges = get_non_code_line_ranges(lines)
|
|
122
|
+
|
|
123
|
+
# Get contributors from non-code lines for year lookups
|
|
124
|
+
all_contributors = {}
|
|
125
|
+
non_code_ranges.each do |start_line, end_line|
|
|
126
|
+
range_contributors = LicenseUtils.get_contributors_for_lines(filepath, start_line, end_line)
|
|
127
|
+
range_contributors.each do |contributor, year|
|
|
128
|
+
all_contributors[contributor] = [all_contributors[contributor] || 0, year].max
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
your_year = nil
|
|
133
|
+
all_contributors.each do |contributor, year|
|
|
134
|
+
if YOUR_IDENTIFIERS.any? { |id| contributor.include?(id) }
|
|
135
|
+
your_year = [your_year || 0, year].max
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
your_year ||= Date.today.year
|
|
139
|
+
|
|
140
|
+
existing = parse_existing_header(lines)
|
|
141
|
+
|
|
142
|
+
if existing
|
|
143
|
+
# Only update years for EXISTING contributors
|
|
144
|
+
needs_update = false
|
|
145
|
+
updated_copyrights = []
|
|
146
|
+
|
|
147
|
+
existing[:copyrights].each do |c|
|
|
148
|
+
git_year = nil
|
|
149
|
+
all_contributors.each do |contributor, year|
|
|
150
|
+
if c[:holder].split.any? { |word| contributor.include?(word) }
|
|
151
|
+
git_year = [git_year || 0, year].max
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
if git_year && git_year != c[:year]
|
|
156
|
+
puts " Updated #{c[:holder].split.first}'s copyright year: #{c[:year]} -> #{git_year}"
|
|
157
|
+
updated_copyrights << { year: git_year, holder: c[:holder] }
|
|
158
|
+
needs_update = true
|
|
159
|
+
else
|
|
160
|
+
updated_copyrights << c
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Check if YOUR year needs updating
|
|
165
|
+
your_existing = updated_copyrights.find { |c| YOUR_IDENTIFIERS.any? { |id| c[:holder].include?(id) } }
|
|
166
|
+
if your_existing.nil?
|
|
167
|
+
puts " Adding your copyright"
|
|
168
|
+
updated_copyrights << { year: your_year, holder: YOUR_COPYRIGHT }
|
|
169
|
+
needs_update = true
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
if existing[:license] != LICENSE
|
|
173
|
+
puts " Fixing license: #{existing[:license]} -> #{LICENSE}"
|
|
174
|
+
needs_update = true
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
if needs_update
|
|
178
|
+
# REUSE-IgnoreStart
|
|
179
|
+
header_lines = ["<!--\n"]
|
|
180
|
+
updated_copyrights.each do |c|
|
|
181
|
+
header_lines << " SPDX-FileCopyrightText: #{c[:year]} #{c[:holder]}\n"
|
|
182
|
+
end
|
|
183
|
+
header_lines << " SPDX-License-Identifier: #{LICENSE}\n"
|
|
184
|
+
header_lines << "-->\n"
|
|
185
|
+
# REUSE-IgnoreEnd
|
|
186
|
+
|
|
187
|
+
remaining = lines[(existing[:end_line] + 1)..]
|
|
188
|
+
File.write(filepath, header_lines.join + remaining.join)
|
|
189
|
+
puts "Updated: #{filepath}"
|
|
190
|
+
end
|
|
191
|
+
else
|
|
192
|
+
# No header - add one with YOUR copyright only
|
|
193
|
+
# REUSE-IgnoreStart
|
|
194
|
+
header = "<!--\n SPDX-FileCopyrightText: #{your_year} #{YOUR_COPYRIGHT}\n SPDX-License-Identifier: #{LICENSE}\n-->\n"
|
|
195
|
+
# REUSE-IgnoreEnd
|
|
196
|
+
|
|
197
|
+
File.write(filepath, header + content)
|
|
198
|
+
puts "Added header: #{filepath}"
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def find_md_files(paths)
|
|
203
|
+
if paths.empty?
|
|
204
|
+
`git ls-files '*.md'`.split("\n")
|
|
205
|
+
else
|
|
206
|
+
paths.flat_map do |path|
|
|
207
|
+
if File.directory?(path)
|
|
208
|
+
`git ls-files '#{path}/**/*.md'`.split("\n")
|
|
209
|
+
else
|
|
210
|
+
path
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
if __FILE__ == $0
|
|
217
|
+
paths = ARGV.empty? ? [] : ARGV
|
|
218
|
+
files = find_md_files(paths)
|
|
219
|
+
|
|
220
|
+
files.each do |file|
|
|
221
|
+
process_file(file)
|
|
222
|
+
end
|
|
223
|
+
end
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
5
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
+
#++
|
|
7
|
+
|
|
8
|
+
# Script to ensure Ruby files have correct SPDX file headers.
|
|
9
|
+
#
|
|
10
|
+
# Usage: ruby tasks/license/headers_rb.rb [path...]
|
|
11
|
+
#
|
|
12
|
+
# If no paths are given, processes lib/, ext/, test/, examples/, tasks/, bin/.
|
|
13
|
+
#
|
|
14
|
+
# License selection by directory:
|
|
15
|
+
# - lib/, ext/, test/ → LGPL-3.0-or-later
|
|
16
|
+
# - examples/widget_*, examples/verify_* → MIT-0
|
|
17
|
+
# - examples/app_*, tasks/, bin/ → AGPL-3.0-or-later
|
|
18
|
+
|
|
19
|
+
require_relative "license_utils"
|
|
20
|
+
|
|
21
|
+
YOUR_NAME = "Kerrick Long"
|
|
22
|
+
YOUR_EMAIL = "me@kerricklong.com"
|
|
23
|
+
YOUR_IDENTIFIERS = [YOUR_NAME, YOUR_EMAIL].freeze
|
|
24
|
+
YOUR_COPYRIGHT = "#{YOUR_NAME} <#{YOUR_EMAIL}>"
|
|
25
|
+
|
|
26
|
+
def license_for_file(filepath)
|
|
27
|
+
case filepath
|
|
28
|
+
when %r{^(lib|sig/ratatui_ruby|ext|test)/}
|
|
29
|
+
"LGPL-3.0-or-later"
|
|
30
|
+
when %r{^(examples|sig/examples)/(widget_|verify_)}
|
|
31
|
+
"MIT-0"
|
|
32
|
+
else
|
|
33
|
+
"AGPL-3.0-or-later"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def parse_existing_header(lines)
|
|
38
|
+
# Returns { end_line:, copyrights: [{year:, holder:}], license: }
|
|
39
|
+
# REUSE-IgnoreStart
|
|
40
|
+
# Ruby files typically have:
|
|
41
|
+
# # frozen_string_literal: true
|
|
42
|
+
# (blank line)
|
|
43
|
+
# #--
|
|
44
|
+
# # SPDX-FileCopyrightText: YYYY Name
|
|
45
|
+
# # SPDX-License-Identifier: LICENSE
|
|
46
|
+
# #++
|
|
47
|
+
# REUSE-IgnoreEnd
|
|
48
|
+
|
|
49
|
+
copyrights = []
|
|
50
|
+
license = nil
|
|
51
|
+
header_end = nil
|
|
52
|
+
found_spdx = false
|
|
53
|
+
|
|
54
|
+
lines.each_with_index do |line, i|
|
|
55
|
+
if line =~ /^#\s*SPDX-FileCopyrightText:\s*(\d{4})\s+(.+)$/
|
|
56
|
+
copyrights << { year: $1.to_i, holder: $2.strip }
|
|
57
|
+
found_spdx = true
|
|
58
|
+
# REUSE-IgnoreStart
|
|
59
|
+
elsif line =~ /^#\s*SPDX-License-Identifier:\s*(.+)$/
|
|
60
|
+
# REUSE-IgnoreEnd
|
|
61
|
+
license = $1.strip
|
|
62
|
+
found_spdx = true
|
|
63
|
+
elsif line =~ /^#\+\+\s*$/ && found_spdx
|
|
64
|
+
header_end = i
|
|
65
|
+
break
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
return nil if copyrights.empty? && license.nil?
|
|
70
|
+
|
|
71
|
+
{ end_line: header_end || 0, copyrights:, license: }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def process_file(filepath)
|
|
75
|
+
content = File.read(filepath)
|
|
76
|
+
lines = content.lines
|
|
77
|
+
|
|
78
|
+
target_license = license_for_file(filepath)
|
|
79
|
+
|
|
80
|
+
# Get contributors from git for year lookups
|
|
81
|
+
all_contributors = LicenseUtils.get_contributors_for_lines(filepath)
|
|
82
|
+
your_year = LicenseUtils.get_your_latest_year(filepath, YOUR_IDENTIFIERS)
|
|
83
|
+
|
|
84
|
+
existing = parse_existing_header(lines)
|
|
85
|
+
|
|
86
|
+
if existing
|
|
87
|
+
# File has existing header - only update years for EXISTING contributors
|
|
88
|
+
needs_update = false
|
|
89
|
+
updated_copyrights = []
|
|
90
|
+
|
|
91
|
+
existing[:copyrights].each do |c|
|
|
92
|
+
# Find this contributor's latest year from git
|
|
93
|
+
git_year = nil
|
|
94
|
+
all_contributors.each do |contributor, year|
|
|
95
|
+
if c[:holder].split.any? { |word| contributor.include?(word) }
|
|
96
|
+
git_year = [git_year || 0, year].max
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
if git_year && git_year != c[:year]
|
|
101
|
+
puts " Updated #{c[:holder].split.first}'s copyright year: #{c[:year]} -> #{git_year}"
|
|
102
|
+
updated_copyrights << { year: git_year, holder: c[:holder] }
|
|
103
|
+
needs_update = true
|
|
104
|
+
else
|
|
105
|
+
updated_copyrights << c
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Check if YOUR year needs updating (if you're a contributor)
|
|
110
|
+
your_existing = updated_copyrights.find { |c| YOUR_IDENTIFIERS.any? { |id| c[:holder].include?(id) } }
|
|
111
|
+
if your_existing.nil?
|
|
112
|
+
puts " Adding your copyright"
|
|
113
|
+
updated_copyrights << { year: your_year, holder: YOUR_COPYRIGHT }
|
|
114
|
+
needs_update = true
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Check license
|
|
118
|
+
if existing[:license] != target_license
|
|
119
|
+
puts " Fixing license: #{existing[:license]} -> #{target_license}"
|
|
120
|
+
needs_update = true
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
if needs_update
|
|
124
|
+
frozen_string = lines[0].include?("frozen_string_literal") ? lines[0] : nil
|
|
125
|
+
|
|
126
|
+
header_lines = []
|
|
127
|
+
header_lines << "# frozen_string_literal: true\n" unless frozen_string
|
|
128
|
+
header_lines << "\n" if frozen_string.nil? && !lines[0].strip.empty?
|
|
129
|
+
header_lines << "#--\n"
|
|
130
|
+
|
|
131
|
+
# REUSE-IgnoreStart
|
|
132
|
+
updated_copyrights.each do |c|
|
|
133
|
+
header_lines << "# SPDX-FileCopyrightText: #{c[:year]} #{c[:holder]}\n"
|
|
134
|
+
end
|
|
135
|
+
header_lines << "# SPDX-License-Identifier: #{target_license}\n"
|
|
136
|
+
# REUSE-IgnoreEnd
|
|
137
|
+
header_lines << "#++\n"
|
|
138
|
+
|
|
139
|
+
content_start = existing[:end_line] + 1
|
|
140
|
+
while content_start < lines.length && lines[content_start].strip.empty?
|
|
141
|
+
content_start += 1
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
remaining = lines[content_start..]
|
|
145
|
+
|
|
146
|
+
new_content = if frozen_string
|
|
147
|
+
"#{frozen_string}\n#{header_lines.join}\n#{remaining.join}"
|
|
148
|
+
else
|
|
149
|
+
"#{header_lines.join}\n#{remaining.join}"
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
File.write(filepath, new_content)
|
|
153
|
+
puts "Updated: #{filepath}"
|
|
154
|
+
end
|
|
155
|
+
else
|
|
156
|
+
# No header - add one with YOUR copyright only
|
|
157
|
+
frozen_line = lines[0]&.include?("frozen_string_literal") ? lines.shift : nil
|
|
158
|
+
|
|
159
|
+
header = []
|
|
160
|
+
header << "# frozen_string_literal: true\n\n" unless frozen_line
|
|
161
|
+
header << "#--\n"
|
|
162
|
+
# REUSE-IgnoreStart
|
|
163
|
+
header << "# SPDX-FileCopyrightText: #{your_year} #{YOUR_COPYRIGHT}\n"
|
|
164
|
+
header << "# SPDX-License-Identifier: #{target_license}\n"
|
|
165
|
+
# REUSE-IgnoreEnd
|
|
166
|
+
header << "#++\n\n"
|
|
167
|
+
|
|
168
|
+
if frozen_line
|
|
169
|
+
File.write(filepath, "#{frozen_line}\n#{header.join}#{lines.join}")
|
|
170
|
+
else
|
|
171
|
+
File.write(filepath, header.join + lines.join)
|
|
172
|
+
end
|
|
173
|
+
puts "Added header: #{filepath}"
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def find_rb_files(paths)
|
|
178
|
+
if paths.empty?
|
|
179
|
+
# Process all relevant directories
|
|
180
|
+
dirs = %w[lib ext test examples tasks bin sig]
|
|
181
|
+
files = dirs.flat_map do |dir|
|
|
182
|
+
# Include both root files and subdirectory files, for both .rb and .rbs
|
|
183
|
+
%w[rb rbs].flat_map do |ext|
|
|
184
|
+
root_files = `git ls-files '#{dir}/*.#{ext}' 2>/dev/null`.split("\n")
|
|
185
|
+
sub_files = `git ls-files '#{dir}/**/*.#{ext}' 2>/dev/null`.split("\n")
|
|
186
|
+
root_files + sub_files
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
files.uniq
|
|
190
|
+
else
|
|
191
|
+
paths.flat_map do |path|
|
|
192
|
+
if File.directory?(path)
|
|
193
|
+
rb_files = `git ls-files '#{path}/**/*.rb'`.split("\n")
|
|
194
|
+
rbs_files = `git ls-files '#{path}/**/*.rbs'`.split("\n")
|
|
195
|
+
rb_files + rbs_files
|
|
196
|
+
else
|
|
197
|
+
path
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
if __FILE__ == $0
|
|
204
|
+
paths = ARGV.empty? ? [] : ARGV
|
|
205
|
+
files = find_rb_files(paths)
|
|
206
|
+
|
|
207
|
+
files.each do |file|
|
|
208
|
+
process_file(file)
|
|
209
|
+
end
|
|
210
|
+
end
|