ratatui_ruby 0.5.0 β 0.6.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 +6 -0
- data/CHANGELOG.md +44 -7
- data/README.md +11 -4
- data/REUSE.toml +2 -7
- data/doc/application_architecture.md +84 -10
- data/doc/application_testing.md +75 -29
- data/doc/contributors/design/ruby_frontend.md +39 -3
- data/doc/contributors/design/rust_backend.md +1 -0
- data/doc/contributors/developing_examples.md +129 -44
- data/doc/contributors/examples_audit/p1_high.md +21 -0
- data/doc/contributors/examples_audit/p2_moderate.md +81 -0
- data/doc/contributors/examples_audit.md +41 -0
- data/doc/event_handling.md +11 -3
- data/doc/images/app_all_events.png +0 -0
- data/doc/images/app_color_picker.png +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_demo.png +0 -0
- data/doc/images/widget_block_demo.png +0 -0
- data/doc/images/widget_canvas_demo.png +0 -0
- data/doc/images/widget_cell_demo.png +0 -0
- data/doc/images/widget_center_demo.png +0 -0
- data/doc/images/widget_chart_demo.png +0 -0
- data/doc/images/widget_list_demo.png +0 -0
- data/doc/images/widget_overlay_demo.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_sparkline_demo.png +0 -0
- data/doc/images/widget_table_demo.png +0 -0
- data/doc/images/widget_tabs_demo.png +0 -0
- data/doc/images/widget_text_width.png +0 -0
- data/doc/quickstart.md +69 -76
- data/doc/terminal_limitations.md +92 -0
- data/examples/app_all_events/README.md +45 -27
- data/examples/app_all_events/app.rb +38 -35
- data/examples/app_all_events/model/app_model.rb +157 -0
- data/examples/app_all_events/model/event_entry.rb +17 -0
- data/examples/app_all_events/model/msg.rb +37 -0
- data/examples/app_all_events/update.rb +73 -0
- data/examples/app_all_events/view/app_view.rb +8 -8
- data/examples/app_all_events/view/controls_view.rb +8 -6
- data/examples/app_all_events/view/counts_view.rb +12 -8
- data/examples/app_all_events/view/live_view.rb +8 -7
- data/examples/app_all_events/view/log_view.rb +10 -15
- data/examples/app_color_picker/README.md +84 -44
- data/examples/app_color_picker/app.rb +24 -62
- data/examples/app_color_picker/controls.rb +90 -0
- data/examples/app_color_picker/copy_dialog.rb +45 -49
- data/examples/app_color_picker/export_pane.rb +126 -0
- data/examples/app_color_picker/input.rb +99 -67
- data/examples/app_color_picker/main_container.rb +178 -0
- data/examples/app_color_picker/palette.rb +55 -26
- data/examples/app_login_form/README.md +47 -0
- data/examples/app_login_form/app.rb +2 -3
- data/examples/app_stateful_interaction/README.md +31 -0
- data/examples/app_stateful_interaction/app.rb +272 -0
- data/examples/timeout_demo.rb +43 -0
- data/examples/verify_quickstart_dsl/README.md +48 -0
- data/examples/verify_quickstart_dsl/app.rb +2 -0
- data/examples/verify_quickstart_layout/README.md +71 -0
- data/examples/verify_quickstart_layout/app.rb +2 -0
- data/examples/verify_quickstart_lifecycle/README.md +56 -0
- data/examples/verify_quickstart_lifecycle/app.rb +8 -2
- data/examples/verify_readme_usage/README.md +43 -0
- data/examples/verify_readme_usage/app.rb +8 -2
- data/examples/widget_barchart_demo/README.md +49 -0
- data/examples/widget_barchart_demo/app.rb +5 -5
- data/examples/widget_block_demo/README.md +34 -0
- data/examples/widget_block_demo/app.rb +256 -0
- data/examples/widget_box_demo/README.md +45 -0
- data/examples/widget_calendar_demo/README.md +39 -0
- data/examples/widget_canvas_demo/README.md +27 -0
- data/examples/widget_canvas_demo/app.rb +123 -0
- data/examples/widget_cell_demo/README.md +36 -0
- data/examples/widget_cell_demo/app.rb +31 -24
- data/examples/widget_center_demo/README.md +29 -0
- data/examples/widget_center_demo/app.rb +116 -0
- data/examples/widget_chart_demo/README.md +41 -0
- data/examples/widget_chart_demo/app.rb +7 -2
- data/examples/widget_gauge_demo/README.md +41 -0
- data/examples/widget_layout_split/README.md +44 -0
- data/examples/widget_line_gauge_demo/README.md +41 -0
- data/examples/widget_list_demo/README.md +49 -0
- data/examples/widget_list_demo/app.rb +91 -107
- data/examples/widget_map_demo/README.md +39 -0
- data/examples/{app_map_demo β widget_map_demo}/app.rb +2 -2
- data/examples/widget_overlay_demo/app.rb +248 -0
- data/examples/widget_popup_demo/README.md +36 -0
- data/examples/widget_ratatui_logo_demo/README.md +34 -0
- data/examples/widget_ratatui_mascot_demo/README.md +34 -0
- data/examples/widget_rect/README.md +38 -0
- data/examples/widget_render/README.md +37 -0
- data/examples/widget_rich_text/README.md +35 -0
- data/examples/widget_rich_text/app.rb +62 -33
- data/examples/widget_scroll_text/README.md +37 -0
- data/examples/widget_scroll_text/app.rb +0 -1
- data/examples/widget_scrollbar_demo/README.md +37 -0
- data/examples/widget_sparkline_demo/README.md +42 -0
- data/examples/widget_sparkline_demo/app.rb +4 -3
- data/examples/widget_style_colors/README.md +34 -0
- data/examples/widget_table_demo/README.md +48 -0
- data/examples/{app_table_select β widget_table_demo}/app.rb +46 -8
- data/examples/widget_tabs_demo/README.md +41 -0
- data/examples/widget_tabs_demo/app.rb +15 -1
- data/examples/widget_text_width/README.md +35 -0
- data/examples/widget_text_width/app.rb +106 -0
- data/exe/.gitkeep +0 -0
- data/ext/ratatui_ruby/Cargo.lock +11 -4
- data/ext/ratatui_ruby/Cargo.toml +2 -1
- data/ext/ratatui_ruby/src/events.rs +238 -26
- data/ext/ratatui_ruby/src/frame.rs +113 -1
- data/ext/ratatui_ruby/src/lib.rs +34 -4
- data/ext/ratatui_ruby/src/string_width.rs +101 -0
- data/ext/ratatui_ruby/src/terminal.rs +39 -15
- data/ext/ratatui_ruby/src/text.rs +1 -1
- data/ext/ratatui_ruby/src/widgets/barchart.rs +24 -6
- data/ext/ratatui_ruby/src/widgets/gauge.rs +9 -2
- data/ext/ratatui_ruby/src/widgets/line_gauge.rs +9 -2
- data/ext/ratatui_ruby/src/widgets/list.rs +179 -3
- data/ext/ratatui_ruby/src/widgets/list_state.rs +137 -0
- data/ext/ratatui_ruby/src/widgets/mod.rs +3 -0
- data/ext/ratatui_ruby/src/widgets/scrollbar.rs +93 -1
- data/ext/ratatui_ruby/src/widgets/scrollbar_state.rs +169 -0
- data/ext/ratatui_ruby/src/widgets/table.rs +113 -1
- data/ext/ratatui_ruby/src/widgets/table_state.rs +121 -0
- data/lib/ratatui_ruby/cell.rb +4 -4
- data/lib/ratatui_ruby/event/key/character.rb +35 -0
- data/lib/ratatui_ruby/event/key/media.rb +44 -0
- data/lib/ratatui_ruby/event/key/modifier.rb +95 -0
- data/lib/ratatui_ruby/event/key/navigation.rb +55 -0
- data/lib/ratatui_ruby/event/key/system.rb +45 -0
- data/lib/ratatui_ruby/event/key.rb +111 -51
- data/lib/ratatui_ruby/event/mouse.rb +3 -3
- data/lib/ratatui_ruby/event/paste.rb +1 -1
- data/lib/ratatui_ruby/frame.rb +96 -0
- data/lib/ratatui_ruby/list_state.rb +88 -0
- data/lib/ratatui_ruby/schema/bar_chart/bar.rb +2 -2
- data/lib/ratatui_ruby/schema/cursor.rb +5 -0
- data/lib/ratatui_ruby/schema/gauge.rb +3 -1
- data/lib/ratatui_ruby/schema/line_gauge.rb +2 -2
- data/lib/ratatui_ruby/schema/list.rb +25 -4
- data/lib/ratatui_ruby/schema/list_item.rb +41 -0
- data/lib/ratatui_ruby/schema/rect.rb +43 -0
- data/lib/ratatui_ruby/schema/style.rb +24 -4
- data/lib/ratatui_ruby/schema/table.rb +21 -3
- data/lib/ratatui_ruby/schema/text.rb +69 -1
- data/lib/ratatui_ruby/scrollbar_state.rb +112 -0
- data/lib/ratatui_ruby/session/autodoc.rb +65 -0
- data/lib/ratatui_ruby/session.rb +22 -7
- data/lib/ratatui_ruby/table_state.rb +90 -0
- data/lib/ratatui_ruby/test_helper/event_injection.rb +169 -0
- data/lib/ratatui_ruby/test_helper/snapshot.rb +390 -0
- data/lib/ratatui_ruby/test_helper/style_assertions.rb +351 -0
- data/lib/ratatui_ruby/test_helper/terminal.rb +127 -0
- data/lib/ratatui_ruby/test_helper/test_doubles.rb +68 -0
- data/lib/ratatui_ruby/test_helper.rb +65 -358
- data/lib/ratatui_ruby/version.rb +1 -1
- data/lib/ratatui_ruby.rb +42 -19
- data/sig/examples/app_stateful_interaction/app.rbs +33 -0
- data/sig/examples/widget_block_demo/app.rbs +32 -0
- data/sig/examples/{app_map_demo β widget_map_demo}/app.rbs +2 -2
- data/sig/examples/{app_table_select β widget_table_demo}/app.rbs +2 -2
- data/sig/examples/{widget_table_flex β widget_text_width}/app.rbs +2 -3
- data/sig/ratatui_ruby/event.rbs +11 -1
- data/sig/ratatui_ruby/frame.rbs +2 -0
- data/sig/ratatui_ruby/list_state.rbs +13 -0
- data/sig/ratatui_ruby/ratatui_ruby.rbs +2 -2
- data/sig/ratatui_ruby/schema/bar_chart/bar.rbs +3 -3
- data/sig/ratatui_ruby/schema/gauge.rbs +2 -2
- data/sig/ratatui_ruby/schema/line_gauge.rbs +2 -2
- data/sig/ratatui_ruby/schema/list.rbs +4 -2
- data/sig/ratatui_ruby/schema/list_item.rbs +10 -0
- data/sig/ratatui_ruby/schema/rect.rbs +3 -0
- data/sig/ratatui_ruby/schema/style.rbs +3 -3
- data/sig/ratatui_ruby/schema/table.rbs +3 -1
- data/sig/ratatui_ruby/schema/text.rbs +8 -6
- data/sig/ratatui_ruby/scrollbar_state.rbs +18 -0
- data/sig/ratatui_ruby/session.rbs +13 -0
- data/sig/ratatui_ruby/table_state.rbs +15 -0
- data/sig/ratatui_ruby/test_helper/event_injection.rbs +16 -0
- data/sig/ratatui_ruby/test_helper/snapshot.rbs +12 -0
- data/sig/ratatui_ruby/test_helper/style_assertions.rbs +64 -0
- data/sig/ratatui_ruby/test_helper/terminal.rbs +14 -0
- data/sig/ratatui_ruby/test_helper/test_doubles.rbs +22 -0
- data/sig/ratatui_ruby/test_helper.rbs +5 -4
- data/tasks/autodoc/examples.rb +79 -0
- data/tasks/autodoc/inventory.rb +9 -7
- data/tasks/autodoc.rake +11 -5
- data/tasks/bump/changelog.rb +3 -3
- data/tasks/bump/links.rb +67 -0
- data/tasks/sourcehut.rake +61 -21
- data/tasks/terminal_preview/app_screenshot.rb +13 -3
- data/tasks/terminal_preview/saved_screenshot.rb +4 -3
- metadata +111 -37
- data/doc/images/app_table_select.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_list_styles.png +0 -0
- data/examples/app_all_events/model/events.rb +0 -180
- data/examples/app_all_events/model/highlight.rb +0 -57
- data/examples/app_all_events/test/snapshots/after_focus_lost.txt +0 -24
- data/examples/app_all_events/test/snapshots/after_focus_regained.txt +0 -24
- data/examples/app_all_events/test/snapshots/after_horizontal_resize.txt +0 -24
- data/examples/app_all_events/test/snapshots/after_key_a.txt +0 -24
- data/examples/app_all_events/test/snapshots/after_key_ctrl_x.txt +0 -24
- data/examples/app_all_events/test/snapshots/after_mouse_click.txt +0 -24
- data/examples/app_all_events/test/snapshots/after_mouse_drag.txt +0 -24
- data/examples/app_all_events/test/snapshots/after_multiple_events.txt +0 -24
- data/examples/app_all_events/test/snapshots/after_paste.txt +0 -24
- data/examples/app_all_events/test/snapshots/after_resize.txt +0 -24
- data/examples/app_all_events/test/snapshots/after_right_click.txt +0 -24
- data/examples/app_all_events/test/snapshots/after_vertical_resize.txt +0 -24
- data/examples/app_all_events/test/snapshots/initial_state.txt +0 -24
- data/examples/app_all_events/view_state.rb +0 -42
- data/examples/app_color_picker/scene.rb +0 -201
- data/examples/widget_block_padding/app.rb +0 -67
- data/examples/widget_block_titles/app.rb +0 -69
- data/examples/widget_list_styles/app.rb +0 -141
- data/examples/widget_table_flex/app.rb +0 -95
- data/sig/examples/widget_block_padding/app.rbs +0 -11
- data/sig/examples/widget_block_titles/app.rbs +0 -11
- data/sig/examples/widget_list_styles/app.rbs +0 -11
- data/tasks/bump/comparison_links.rb +0 -41
- /data/doc/images/{app_map_demo.png β widget_map_demo.png} +0 -0
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
|
|
4
|
-
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
|
-
|
|
6
|
-
require_relative "timestamp"
|
|
7
|
-
require_relative "event_color_cycle"
|
|
8
|
-
require_relative "event_entry"
|
|
9
|
-
|
|
10
|
-
# Manages the history and state of all application events.
|
|
11
|
-
#
|
|
12
|
-
# Applications need to track, count, and display event history for debugging and feedback.
|
|
13
|
-
# Direct management of event arrays and counters across the app leads to scattered state.
|
|
14
|
-
#
|
|
15
|
-
# This class centralizes event storage. It records new events, maintains counts, and manages temporary highlights.
|
|
16
|
-
#
|
|
17
|
-
# Use it to store key presses, mouse clicks, and window resizes for display in a log or counter.
|
|
18
|
-
#
|
|
19
|
-
# === Examples
|
|
20
|
-
#
|
|
21
|
-
# events = Events.new
|
|
22
|
-
# events.record(key_event)
|
|
23
|
-
# puts events.count(:key) #=> 1
|
|
24
|
-
#
|
|
25
|
-
# if events.lit?(:key)
|
|
26
|
-
# puts "Key event just happened!"
|
|
27
|
-
# end
|
|
28
|
-
class Events
|
|
29
|
-
# Duration in milliseconds for an event to remain highlighted in the UI.
|
|
30
|
-
HIGHLIGHT_DURATION_MS = 300
|
|
31
|
-
|
|
32
|
-
# Creates a new Events manager.
|
|
33
|
-
def initialize
|
|
34
|
-
@entries = []
|
|
35
|
-
@color_cycle = EventColorCycle.new
|
|
36
|
-
@none_count = 0
|
|
37
|
-
@lit_type = nil
|
|
38
|
-
@lit_until = Timestamp.now
|
|
39
|
-
@live = {}
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Records a new event.
|
|
43
|
-
#
|
|
44
|
-
# [event] RatatuiRuby::Event object.
|
|
45
|
-
# [context] Hash of additional context (e.g., last_dimensions).
|
|
46
|
-
#
|
|
47
|
-
# === Example
|
|
48
|
-
#
|
|
49
|
-
# events.record(mouse_event)
|
|
50
|
-
def record(event, context: {})
|
|
51
|
-
if event.is_a?(RatatuiRuby::Event::None) || event == :none
|
|
52
|
-
@none_count += 1
|
|
53
|
-
return
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
color = @color_cycle.next_color
|
|
57
|
-
timestamp = Timestamp.now
|
|
58
|
-
entry = EventEntry.create(event, color, timestamp)
|
|
59
|
-
@entries << entry
|
|
60
|
-
update_lit_type(entry)
|
|
61
|
-
|
|
62
|
-
display_type = live_type_for(entry.type)
|
|
63
|
-
@live[display_type] = { time: Time.now, description: entry.description }
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
private def live_type_for(type)
|
|
67
|
-
case type
|
|
68
|
-
when :focus_gained, :focus_lost
|
|
69
|
-
:focus
|
|
70
|
-
else
|
|
71
|
-
type
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# Returns the most recent live event data for a type.
|
|
76
|
-
#
|
|
77
|
-
# [type] Symbol event type to look up.
|
|
78
|
-
#
|
|
79
|
-
# === Example
|
|
80
|
-
#
|
|
81
|
-
# events.live_event(:key) #=> { time: ..., description: "..." }
|
|
82
|
-
def live_event(type)
|
|
83
|
-
@live[type]
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
# Returns all recorded live event data.
|
|
87
|
-
#
|
|
88
|
-
# === Example
|
|
89
|
-
#
|
|
90
|
-
# events.live_events #=> { key: { ... }, mouse: { ... } }
|
|
91
|
-
def live_events
|
|
92
|
-
@live
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
# Returns the most recent entries up to the given limit.
|
|
96
|
-
#
|
|
97
|
-
# [max_entries] Integer maximum number of entries to return.
|
|
98
|
-
#
|
|
99
|
-
# === Example
|
|
100
|
-
#
|
|
101
|
-
# events.visible(10) #=> [#<EventEntry ...>, ...]
|
|
102
|
-
def visible(max_entries)
|
|
103
|
-
@entries.last(max_entries)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
# Checks if any events have been recorded.
|
|
107
|
-
#
|
|
108
|
-
# === Example
|
|
109
|
-
#
|
|
110
|
-
# events.empty? #=> true
|
|
111
|
-
def empty?
|
|
112
|
-
@entries.empty?
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
# Returns the count of events for a type.
|
|
116
|
-
#
|
|
117
|
-
# [type] Symbol event type.
|
|
118
|
-
#
|
|
119
|
-
# === Example
|
|
120
|
-
#
|
|
121
|
-
# events.count(:key) #=> 5
|
|
122
|
-
def count(type)
|
|
123
|
-
return @none_count if type == :none
|
|
124
|
-
|
|
125
|
-
@entries.count { |e| e.matches_type?(type) }
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
# Returns counts grouped by subtype (kind or modifier status).
|
|
129
|
-
#
|
|
130
|
-
# [type] Symbol event type.
|
|
131
|
-
#
|
|
132
|
-
# === Example
|
|
133
|
-
#
|
|
134
|
-
# events.sub_counts(:mouse) #=> { "down" => 1, "up" => 2 }
|
|
135
|
-
def sub_counts(type)
|
|
136
|
-
return {} if type == :none
|
|
137
|
-
|
|
138
|
-
entries = @entries.select { |e| e.matches_type?(type) }
|
|
139
|
-
|
|
140
|
-
defaults = { key: %w[unmodified modified], focus: %w[gained lost], mouse: %w[down up drag moved scroll_up scroll_down] }
|
|
141
|
-
entries.each_with_object(defaults.fetch(type, []).to_h { |k| [k, 0] }) do |entry, counts|
|
|
142
|
-
group = if entry.event.respond_to?(:kind)
|
|
143
|
-
entry.event.kind.to_s
|
|
144
|
-
elsif entry.event.respond_to?(:modifiers)
|
|
145
|
-
entry.event.modifiers.empty? ? "unmodified" : "modified"
|
|
146
|
-
elsif type == :focus
|
|
147
|
-
entry.type.to_s.sub("focus_", "")
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
counts[group] += 1 if group
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
# Checks if a type should be highlighted.
|
|
155
|
-
#
|
|
156
|
-
# [type] Symbol event type.
|
|
157
|
-
#
|
|
158
|
-
# === Example
|
|
159
|
-
#
|
|
160
|
-
# events.lit?(:key) #=> true
|
|
161
|
-
def lit?(type)
|
|
162
|
-
return false if Timestamp.now.milliseconds >= @lit_until.milliseconds
|
|
163
|
-
|
|
164
|
-
@lit_type == type
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
# Returns all event entries.
|
|
168
|
-
#
|
|
169
|
-
# === Example
|
|
170
|
-
#
|
|
171
|
-
# events.entries #=> [#<EventEntry ...>, ...]
|
|
172
|
-
def entries
|
|
173
|
-
@entries
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
private def update_lit_type(entry)
|
|
177
|
-
@lit_type = live_type_for(entry.type)
|
|
178
|
-
@lit_until = Timestamp.new(milliseconds: Timestamp.now.milliseconds + HIGHLIGHT_DURATION_MS)
|
|
179
|
-
end
|
|
180
|
-
end
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
|
|
4
|
-
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
|
-
|
|
6
|
-
require_relative "timestamp"
|
|
7
|
-
|
|
8
|
-
# Manages temporary visual highlights for different event types.
|
|
9
|
-
#
|
|
10
|
-
# Users need visual feedback when an event occurs, but highlights should fade.
|
|
11
|
-
# Manually tracking timers for every highlightable element is complex.
|
|
12
|
-
#
|
|
13
|
-
# This class manages the "lit" state of multiple keys with a consistent duration.
|
|
14
|
-
#
|
|
15
|
-
# Use it to trigger and check for temporary UI highlights.
|
|
16
|
-
#
|
|
17
|
-
# === Examples
|
|
18
|
-
#
|
|
19
|
-
# highlight = Highlight.new
|
|
20
|
-
# highlight.light_up(:key)
|
|
21
|
-
# highlight.lit?(:key) #=> true
|
|
22
|
-
# sleep(0.4)
|
|
23
|
-
# highlight.lit?(:key) #=> false
|
|
24
|
-
class Highlight
|
|
25
|
-
# Duration in milliseconds that a highlight remains active.
|
|
26
|
-
DURATION_MS = 300
|
|
27
|
-
|
|
28
|
-
# Creates a new Highlight manager.
|
|
29
|
-
def initialize
|
|
30
|
-
@lit_types = {}
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Triggers a highlight for the given type.
|
|
34
|
-
#
|
|
35
|
-
# [type] Symbol to highlight.
|
|
36
|
-
#
|
|
37
|
-
# === Example
|
|
38
|
-
#
|
|
39
|
-
# highlight.light_up(:mouse)
|
|
40
|
-
def light_up(type)
|
|
41
|
-
@lit_types[type] = Timestamp.now
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
# Checks if a highlight is currently active for the given type.
|
|
45
|
-
#
|
|
46
|
-
# [type] Symbol to check.
|
|
47
|
-
#
|
|
48
|
-
# === Example
|
|
49
|
-
#
|
|
50
|
-
# highlight.lit?(:mouse) #=> true
|
|
51
|
-
def lit?(type)
|
|
52
|
-
timestamp = @lit_types[type]
|
|
53
|
-
return false unless timestamp
|
|
54
|
-
|
|
55
|
-
!timestamp.elapsed?(DURATION_MS)
|
|
56
|
-
end
|
|
57
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
βEvent Countsβββββββ βLive Displayββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2
|
-
βKey: 0 β βType Time Description β
|
|
3
|
-
β Unmodified: 0 β βKey β β β
|
|
4
|
-
β Modified: 0 β βMouse β β β
|
|
5
|
-
βMouse: 0 β βResize β β β
|
|
6
|
-
β Down: 0 β βPaste β β β
|
|
7
|
-
β Up: 0 β βFocus XX:XX:XX #<RatatuiRuby::Event::FocusLost:0xXXXXXXβ
|
|
8
|
-
β Drag: 0 β β β
|
|
9
|
-
β Moved: 0 β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
10
|
-
β Scroll_up: 0 β βEvent Logβββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
11
|
-
β Scroll_down: 0 β β#<RatatuiRuby::Event::FocusLost:0xXXXXXX> β
|
|
12
|
-
βResize: 0 β β β
|
|
13
|
-
βPaste: 0 β β β
|
|
14
|
-
βFocus: 1 β β β
|
|
15
|
-
β Gained: 0 β β β
|
|
16
|
-
β Lost: 1 β β β
|
|
17
|
-
βNone: 0 β β β
|
|
18
|
-
β β β β
|
|
19
|
-
β β β β
|
|
20
|
-
β β β β
|
|
21
|
-
ββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
22
|
-
βControlsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
23
|
-
βq: Quit Ctrl+C: Quit β
|
|
24
|
-
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
βEvent Countsβββββββ βLive Displayββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2
|
-
βKey: 0 β βType Time Description β
|
|
3
|
-
β Unmodified: 0 β βKey β β β
|
|
4
|
-
β Modified: 0 β βMouse β β β
|
|
5
|
-
βMouse: 0 β βResize β β β
|
|
6
|
-
β Down: 0 β βPaste β β β
|
|
7
|
-
β Up: 0 β βFocus XX:XX:XX #<RatatuiRuby::Event::FocusGained:0xXXXXXXβ
|
|
8
|
-
β Drag: 0 β β β
|
|
9
|
-
β Moved: 0 β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
10
|
-
β Scroll_up: 0 β βEvent Logβββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
11
|
-
β Scroll_down: 0 β β#<RatatuiRuby::Event::FocusLost:0xXXXXXX> β
|
|
12
|
-
βResize: 0 β β β
|
|
13
|
-
βPaste: 0 β β#<RatatuiRuby::Event::FocusGained:0xXXXXXX> β
|
|
14
|
-
βFocus: 2 β β β
|
|
15
|
-
β Gained: 1 β β β
|
|
16
|
-
β Lost: 1 β β β
|
|
17
|
-
βNone: 0 β β β
|
|
18
|
-
β β β β
|
|
19
|
-
β β β β
|
|
20
|
-
β β β β
|
|
21
|
-
ββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
22
|
-
βControlsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
23
|
-
βq: Quit Ctrl+C: Quit β
|
|
24
|
-
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
βEvent Countsβββββββ βLive Displayββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2
|
-
βKey: 0 β βType Time Description β
|
|
3
|
-
β Unmodified: 0 β βKey β β β
|
|
4
|
-
β Modified: 0 β βMouse β β β
|
|
5
|
-
βMouse: 0 β βResize XX:XX:XX #<RatatuiRuby::Event::Resize:0xXXXXXXβ
|
|
6
|
-
β Down: 0 β βPaste β β β
|
|
7
|
-
β Up: 0 β βFocus β β β
|
|
8
|
-
β Drag: 0 β β β
|
|
9
|
-
β Moved: 0 β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
10
|
-
β Scroll_up: 0 β βEvent Logβββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
11
|
-
β Scroll_down: 0 β β#<RatatuiRuby::Event::Resize:0xXXXXXX β
|
|
12
|
-
βResize: 1 β β@width=100, @height=24> β
|
|
13
|
-
βPaste: 0 β β β
|
|
14
|
-
βFocus: 0 β β β
|
|
15
|
-
β Gained: 0 β β β
|
|
16
|
-
β Lost: 0 β β β
|
|
17
|
-
βNone: 0 β β β
|
|
18
|
-
β β β β
|
|
19
|
-
β β β β
|
|
20
|
-
β β β β
|
|
21
|
-
ββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
22
|
-
βControlsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
23
|
-
βq: Quit Ctrl+C: Quit β
|
|
24
|
-
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
βEvent Countsβββββββ βLive Displayββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2
|
-
βKey: 1 β βType Time Description β
|
|
3
|
-
β Unmodified: 1 β βKey XX:XX:XX #<RatatuiRuby::Event::Key code="a" modβ
|
|
4
|
-
β Modified: 0 β βMouse β β β
|
|
5
|
-
βMouse: 0 β βResize β β β
|
|
6
|
-
β Down: 0 β βPaste β β β
|
|
7
|
-
β Up: 0 β βFocus β β β
|
|
8
|
-
β Drag: 0 β β β
|
|
9
|
-
β Moved: 0 β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
10
|
-
β Scroll_up: 0 β βEvent Logβββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
11
|
-
β Scroll_down: 0 β β#<RatatuiRuby::Event::Key code="a" modifiers=[]> β
|
|
12
|
-
βResize: 0 β β β
|
|
13
|
-
βPaste: 0 β β β
|
|
14
|
-
βFocus: 0 β β β
|
|
15
|
-
β Gained: 0 β β β
|
|
16
|
-
β Lost: 0 β β β
|
|
17
|
-
βNone: 0 β β β
|
|
18
|
-
β β β β
|
|
19
|
-
β β β β
|
|
20
|
-
β β β β
|
|
21
|
-
ββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
22
|
-
βControlsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
23
|
-
βq: Quit Ctrl+C: Quit β
|
|
24
|
-
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
βEvent Countsβββββββ βLive Displayββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2
|
-
βKey: 1 β βType Time Description β
|
|
3
|
-
β Unmodified: 0 β βKey XX:XX:XX #<RatatuiRuby::Event::Key code="x" modβ
|
|
4
|
-
β Modified: 1 β βMouse β β β
|
|
5
|
-
βMouse: 0 β βResize β β β
|
|
6
|
-
β Down: 0 β βPaste β β β
|
|
7
|
-
β Up: 0 β βFocus β β β
|
|
8
|
-
β Drag: 0 β β β
|
|
9
|
-
β Moved: 0 β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
10
|
-
β Scroll_up: 0 β βEvent Logβββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
11
|
-
β Scroll_down: 0 β β#<RatatuiRuby::Event::Key code="x" modifiers=["ctrl"]> β
|
|
12
|
-
βResize: 0 β β β
|
|
13
|
-
βPaste: 0 β β β
|
|
14
|
-
βFocus: 0 β β β
|
|
15
|
-
β Gained: 0 β β β
|
|
16
|
-
β Lost: 0 β β β
|
|
17
|
-
βNone: 0 β β β
|
|
18
|
-
β β β β
|
|
19
|
-
β β β β
|
|
20
|
-
β β β β
|
|
21
|
-
ββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
22
|
-
βControlsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
23
|
-
βq: Quit Ctrl+C: Quit β
|
|
24
|
-
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
βEvent Countsβββββββ βLive Displayββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2
|
-
βKey: 0 β βType Time Description β
|
|
3
|
-
β Unmodified: 0 β βKey β β β
|
|
4
|
-
β Modified: 0 β βMouse XX:XX:XX #<RatatuiRuby::Event::Mouse:0xXXXXXXβ
|
|
5
|
-
βMouse: 1 β βResize β β β
|
|
6
|
-
β Down: 1 β βPaste β β β
|
|
7
|
-
β Up: 0 β βFocus β β β
|
|
8
|
-
β Drag: 0 β β β
|
|
9
|
-
β Moved: 0 β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
10
|
-
β Scroll_up: 0 β βEvent Logβββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
11
|
-
β Scroll_down: 0 β β#<RatatuiRuby::Event::Mouse:0xXXXXXX β
|
|
12
|
-
βResize: 0 β β@kind="down", @x=40, @y=12, @button="left", β
|
|
13
|
-
βPaste: 0 β β@modifiers=[]> β
|
|
14
|
-
βFocus: 0 β β β
|
|
15
|
-
β Gained: 0 β β β
|
|
16
|
-
β Lost: 0 β β β
|
|
17
|
-
βNone: 0 β β β
|
|
18
|
-
β β β β
|
|
19
|
-
β β β β
|
|
20
|
-
β β β β
|
|
21
|
-
ββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
22
|
-
βControlsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
23
|
-
βq: Quit Ctrl+C: Quit β
|
|
24
|
-
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
βEvent Countsβββββββ βLive Displayββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2
|
-
βKey: 0 β βType Time Description β
|
|
3
|
-
β Unmodified: 0 β βKey β β β
|
|
4
|
-
β Modified: 0 β βMouse XX:XX:XX #<RatatuiRuby::Event::Mouse:0xXXXXXXβ
|
|
5
|
-
βMouse: 1 β βResize β β β
|
|
6
|
-
β Down: 0 β βPaste β β β
|
|
7
|
-
β Up: 0 β βFocus β β β
|
|
8
|
-
β Drag: 1 β β β
|
|
9
|
-
β Moved: 0 β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
10
|
-
β Scroll_up: 0 β βEvent Logβββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
11
|
-
β Scroll_down: 0 β β#<RatatuiRuby::Event::Mouse:0xXXXXXX β
|
|
12
|
-
βResize: 0 β β@kind="drag", @x=25, @y=8, @button="left", @modifiers=[]>β
|
|
13
|
-
βPaste: 0 β β β
|
|
14
|
-
βFocus: 0 β β β
|
|
15
|
-
β Gained: 0 β β β
|
|
16
|
-
β Lost: 0 β β β
|
|
17
|
-
βNone: 0 β β β
|
|
18
|
-
β β β β
|
|
19
|
-
β β β β
|
|
20
|
-
β β β β
|
|
21
|
-
ββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
22
|
-
βControlsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
23
|
-
βq: Quit Ctrl+C: Quit β
|
|
24
|
-
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
βEvent Countsβββββββ βLive Displayββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2
|
-
βKey: 3 β βType Time Description β
|
|
3
|
-
β Unmodified: 3 β βKey XX:XX:XX #<RatatuiRuby::Event::Key code="c" modβ
|
|
4
|
-
β Modified: 0 β βMouse XX:XX:XX #<RatatuiRuby::Event::Mouse:0xXXXXXXβ
|
|
5
|
-
βMouse: 1 β βResize β β β
|
|
6
|
-
β Down: 1 β βPaste β β β
|
|
7
|
-
β Up: 0 β βFocus β β β
|
|
8
|
-
β Drag: 0 β β β
|
|
9
|
-
β Moved: 0 β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
10
|
-
β Scroll_up: 0 β βEvent Logβββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
11
|
-
β Scroll_down: 0 β β#<RatatuiRuby::Event::Key code="a" modifiers=[]> β
|
|
12
|
-
βResize: 0 β β β
|
|
13
|
-
βPaste: 0 β β#<RatatuiRuby::Event::Key code="b" modifiers=[]> β
|
|
14
|
-
βFocus: 0 β β β
|
|
15
|
-
β Gained: 0 β β#<RatatuiRuby::Event::Key code="c" modifiers=[]> β
|
|
16
|
-
β Lost: 0 β β β
|
|
17
|
-
βNone: 0 β β#<RatatuiRuby::Event::Mouse:0xXXXXXX β
|
|
18
|
-
β β β@kind="down", @x=10, @y=5, @button="left", @modifiers=[]>β
|
|
19
|
-
β β β β
|
|
20
|
-
β β β β
|
|
21
|
-
ββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
22
|
-
βControlsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
23
|
-
βq: Quit Ctrl+C: Quit β
|
|
24
|
-
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
βEvent Countsβββββββ βLive Displayββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2
|
-
βKey: 0 β βType Time Description β
|
|
3
|
-
β Unmodified: 0 β βKey β β β
|
|
4
|
-
β Modified: 0 β βMouse β β β
|
|
5
|
-
βMouse: 0 β βResize β β β
|
|
6
|
-
β Down: 0 β βPaste XX:XX:XX #<RatatuiRuby::Event::Paste:0xXXXXXXβ
|
|
7
|
-
β Up: 0 β βFocus β β β
|
|
8
|
-
β Drag: 0 β β β
|
|
9
|
-
β Moved: 0 β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
10
|
-
β Scroll_up: 0 β βEvent Logβββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
11
|
-
β Scroll_down: 0 β β#<RatatuiRuby::Event::Paste:0xXXXXXX β
|
|
12
|
-
βResize: 0 β β@content="Hello World"> β
|
|
13
|
-
βPaste: 1 β β β
|
|
14
|
-
βFocus: 0 β β β
|
|
15
|
-
β Gained: 0 β β β
|
|
16
|
-
β Lost: 0 β β β
|
|
17
|
-
βNone: 0 β β β
|
|
18
|
-
β β β β
|
|
19
|
-
β β β β
|
|
20
|
-
β β β β
|
|
21
|
-
ββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
22
|
-
βControlsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
23
|
-
βq: Quit Ctrl+C: Quit β
|
|
24
|
-
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
βEvent Countsβββββββ βLive Displayββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2
|
-
βKey: 0 β βType Time Description β
|
|
3
|
-
β Unmodified: 0 β βKey β β β
|
|
4
|
-
β Modified: 0 β βMouse β β β
|
|
5
|
-
βMouse: 0 β βResize XX:XX:XX #<RatatuiRuby::Event::Resize:0xXXXXXXβ
|
|
6
|
-
β Down: 0 β βPaste β β β
|
|
7
|
-
β Up: 0 β βFocus β β β
|
|
8
|
-
β Drag: 0 β β β
|
|
9
|
-
β Moved: 0 β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
10
|
-
β Scroll_up: 0 β βEvent Logβββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
11
|
-
β Scroll_down: 0 β β#<RatatuiRuby::Event::Resize:0xXXXXXX β
|
|
12
|
-
βResize: 1 β β@width=100, @height=30> β
|
|
13
|
-
βPaste: 0 β β β
|
|
14
|
-
βFocus: 0 β β β
|
|
15
|
-
β Gained: 0 β β β
|
|
16
|
-
β Lost: 0 β β β
|
|
17
|
-
βNone: 0 β β β
|
|
18
|
-
β β β β
|
|
19
|
-
β β β β
|
|
20
|
-
β β β β
|
|
21
|
-
ββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
22
|
-
βControlsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
23
|
-
βq: Quit Ctrl+C: Quit β
|
|
24
|
-
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
βEvent Countsβββββββ βLive Displayββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2
|
-
βKey: 0 β βType Time Description β
|
|
3
|
-
β Unmodified: 0 β βKey β β β
|
|
4
|
-
β Modified: 0 β βMouse XX:XX:XX #<RatatuiRuby::Event::Mouse:0xXXXXXXβ
|
|
5
|
-
βMouse: 1 β βResize β β β
|
|
6
|
-
β Down: 1 β βPaste β β β
|
|
7
|
-
β Up: 0 β βFocus β β β
|
|
8
|
-
β Drag: 0 β β β
|
|
9
|
-
β Moved: 0 β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
10
|
-
β Scroll_up: 0 β βEvent Logβββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
11
|
-
β Scroll_down: 0 β β#<RatatuiRuby::Event::Mouse:0xXXXXXX β
|
|
12
|
-
βResize: 0 β β@kind="down", @x=50, @y=10, @button="right", β
|
|
13
|
-
βPaste: 0 β β@modifiers=[]> β
|
|
14
|
-
βFocus: 0 β β β
|
|
15
|
-
β Gained: 0 β β β
|
|
16
|
-
β Lost: 0 β β β
|
|
17
|
-
βNone: 0 β β β
|
|
18
|
-
β β β β
|
|
19
|
-
β β β β
|
|
20
|
-
β β β β
|
|
21
|
-
ββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
22
|
-
βControlsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
23
|
-
βq: Quit Ctrl+C: Quit β
|
|
24
|
-
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
βEvent Countsβββββββ βLive Displayββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2
|
-
βKey: 0 β βType Time Description β
|
|
3
|
-
β Unmodified: 0 β βKey β β β
|
|
4
|
-
β Modified: 0 β βMouse β β β
|
|
5
|
-
βMouse: 0 β βResize XX:XX:XX #<RatatuiRuby::Event::Resize:0xXXXXXXβ
|
|
6
|
-
β Down: 0 β βPaste β β β
|
|
7
|
-
β Up: 0 β βFocus β β β
|
|
8
|
-
β Drag: 0 β β β
|
|
9
|
-
β Moved: 0 β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
10
|
-
β Scroll_up: 0 β βEvent Logβββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
11
|
-
β Scroll_down: 0 β β#<RatatuiRuby::Event::Resize:0xXXXXXX β
|
|
12
|
-
βResize: 1 β β@width=80, @height=30> β
|
|
13
|
-
βPaste: 0 β β β
|
|
14
|
-
βFocus: 0 β β β
|
|
15
|
-
β Gained: 0 β β β
|
|
16
|
-
β Lost: 0 β β β
|
|
17
|
-
βNone: 0 β β β
|
|
18
|
-
β β β β
|
|
19
|
-
β β β β
|
|
20
|
-
β β β β
|
|
21
|
-
ββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
22
|
-
βControlsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
23
|
-
βq: Quit Ctrl+C: Quit β
|
|
24
|
-
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
βEvent Countsβββββββ βLive Displayββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2
|
-
βKey: 0 β βType Time Description β
|
|
3
|
-
β Unmodified: 0 β βKey β β β
|
|
4
|
-
β Modified: 0 β βMouse β β β
|
|
5
|
-
βMouse: 0 β βResize β β β
|
|
6
|
-
β Down: 0 β βPaste β β β
|
|
7
|
-
β Up: 0 β βFocus β β β
|
|
8
|
-
β Drag: 0 β β β
|
|
9
|
-
β Moved: 0 β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
10
|
-
β Scroll_up: 0 β βEvent Logβββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
11
|
-
β Scroll_down: 0 β βNo events yet... β
|
|
12
|
-
βResize: 0 β β β
|
|
13
|
-
βPaste: 0 β β β
|
|
14
|
-
βFocus: 0 β β β
|
|
15
|
-
β Gained: 0 β β β
|
|
16
|
-
β Lost: 0 β β β
|
|
17
|
-
βNone: 0 β β β
|
|
18
|
-
β β β β
|
|
19
|
-
β β β β
|
|
20
|
-
β β β β
|
|
21
|
-
ββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
22
|
-
βControlsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
23
|
-
βq: Quit Ctrl+C: Quit β
|
|
24
|
-
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
|
|
4
|
-
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
|
-
|
|
6
|
-
# Encapsulates all data required to render the application view.
|
|
7
|
-
#
|
|
8
|
-
# Views need access to models, global settings, and calculated styles.
|
|
9
|
-
# Passing dozens of individual parameters to view components is messy and unmaintainable.
|
|
10
|
-
#
|
|
11
|
-
# This class provides a single, structured object containing all state necessary for rendering.
|
|
12
|
-
#
|
|
13
|
-
# Use it to shuttle data from the main application to the various view components.
|
|
14
|
-
#
|
|
15
|
-
# === Examples
|
|
16
|
-
#
|
|
17
|
-
# state = ViewState.build(events, true, tui, nil)
|
|
18
|
-
# puts state.focused #=> true
|
|
19
|
-
# app_view.call(state, tui, frame, area)
|
|
20
|
-
class ViewState < Data.define(:events, :focused, :hotkey_style, :dimmed_style, :lit_style, :border_color, :area)
|
|
21
|
-
# Builds a new ViewState with calculated styles.
|
|
22
|
-
#
|
|
23
|
-
# [events] Events model instance.
|
|
24
|
-
# [focused] Boolean indicating if the app has focus.
|
|
25
|
-
# [tui] RatatuiRuby instance for style creation.
|
|
26
|
-
# [_resize_sub_counter] Unused parameter (reserved for future use).
|
|
27
|
-
#
|
|
28
|
-
# === Example
|
|
29
|
-
#
|
|
30
|
-
# ViewState.build(events, true, tui, nil) #=> #<ViewState ...>
|
|
31
|
-
def self.build(events, focused, tui, _resize_sub_counter)
|
|
32
|
-
new(
|
|
33
|
-
events:,
|
|
34
|
-
focused:,
|
|
35
|
-
hotkey_style: tui.style(modifiers: [:bold, :underlined]),
|
|
36
|
-
dimmed_style: tui.style(fg: :dark_gray),
|
|
37
|
-
lit_style: tui.style(fg: :green, modifiers: [:bold]),
|
|
38
|
-
border_color: focused ? :green : :gray,
|
|
39
|
-
area: nil
|
|
40
|
-
)
|
|
41
|
-
end
|
|
42
|
-
end
|