Class: Plushie::Command
- Inherits:
-
Object
- Object
- Plushie::Command
- Defined in:
- lib/plushie/command.rb
Overview
Commands describe side effects that update wants the runtime to perform.
They are pure data -- inspectable, testable, serializable. The runtime interprets them after update returns. Nothing executes inside update.
Defined Under Namespace
Classes: Cmd
Class Method Summary collapse
-
.advance_frame(timestamp) ⇒ Cmd
Advance the animation clock.
- .allow_automatic_tabbing(enabled) ⇒ Cmd
-
.announce(text) ⇒ Cmd
Screen reader announcement.
-
.async(callable, tag) ⇒ Cmd
Run a callable asynchronously.
-
.batch(commands) ⇒ Cmd
Combine multiple commands.
-
.cancel(tag) ⇒ Cmd
Cancel a running async or stream task by tag.
-
.clear_images ⇒ Cmd
Remove all image handles.
- .close_window(window_id) ⇒ Cmd
-
.create_image(handle, data = nil, width: nil, height: nil, pixels: nil) ⇒ Cmd
Create an image from encoded data (PNG/JPEG).
-
.delete_image(handle) ⇒ Cmd
Delete an image handle.
- .disable_mouse_passthrough(window_id) ⇒ Cmd
-
.done(value, mapper_fn) ⇒ Cmd
Lift an already-resolved value into the command pipeline.
- .drag_resize_window(window_id, direction) ⇒ Cmd
- .drag_window(window_id) ⇒ Cmd
- .enable_mouse_passthrough(window_id) ⇒ Cmd
-
.exit ⇒ Cmd
Terminate the application.
-
.extension_command(node_id, op, payload = {}) ⇒ Cmd
Send a command to a native extension widget.
-
.extension_commands(commands) ⇒ Cmd
Batch multiple extension commands.
-
.find_focused(tag) ⇒ Cmd
Find focused widget.
- .focus(widget_id) ⇒ Cmd
-
.focus_element(canvas_id, element_id) ⇒ Cmd
Focus a specific element within a canvas widget.
- .focus_next ⇒ Cmd
- .focus_previous ⇒ Cmd
- .gain_focus(window_id) ⇒ Cmd
- .get_mode(window_id, tag) ⇒ Cmd
- .get_scale_factor(window_id, tag) ⇒ Cmd
- .get_system_info(tag) ⇒ Cmd
- .get_system_theme(tag) ⇒ Cmd
- .get_window_position(window_id, tag) ⇒ Cmd
- .get_window_size(window_id, tag) ⇒ Cmd
- .is_maximized(window_id, tag) ⇒ Cmd
- .is_minimized(window_id, tag) ⇒ Cmd
-
.list_images(tag) ⇒ Cmd
List all image handles.
-
.load_font(data) ⇒ Cmd
Load a font at runtime from TTF/OTF data.
- .maximize_window(window_id, maximized = true) ⇒ Cmd
- .minimize_window(window_id, minimized = true) ⇒ Cmd
- .monitor_size(window_id, tag) ⇒ Cmd
- .move_cursor_to(widget_id, position) ⇒ Cmd
- .move_cursor_to_end(widget_id) ⇒ Cmd
- .move_cursor_to_front(widget_id) ⇒ Cmd
- .move_window(window_id, x, y) ⇒ Cmd
-
.none ⇒ Cmd
No-op command.
- .pane_close(grid_id, pane_id) ⇒ Cmd
- .pane_maximize(grid_id, pane_id) ⇒ Cmd
- .pane_restore(grid_id) ⇒ Cmd
- .pane_split(grid_id, pane_id, axis, new_pane_id) ⇒ Cmd
- .pane_swap(grid_id, pane_a, pane_b) ⇒ Cmd
- .raw_id(window_id, tag) ⇒ Cmd
- .request_user_attention(window_id, urgency) ⇒ Cmd
- .resize_window(window_id, width, height) ⇒ Cmd
- .screenshot(window_id, tag) ⇒ Cmd
- .scroll_by(widget_id, x, y) ⇒ Cmd
- .scroll_to(widget_id, offset_y) ⇒ Cmd
- .select_all(widget_id) ⇒ Cmd
- .select_range(widget_id, start_pos, end_pos) ⇒ Cmd
-
.send_after(delay_ms, event) ⇒ Cmd
Send an event to update after a delay.
- .set_icon(window_id, rgba_data, width, height) ⇒ Cmd
- .set_max_size(window_id, width, height) ⇒ Cmd
- .set_min_size(window_id, width, height) ⇒ Cmd
- .set_resizable(window_id, resizable) ⇒ Cmd
- .set_resize_increments(window_id, width, height) ⇒ Cmd
- .set_window_level(window_id, level) ⇒ Cmd
- .set_window_mode(window_id, mode) ⇒ Cmd
- .show_system_menu(window_id) ⇒ Cmd
- .snap_to(widget_id, x, y) ⇒ Cmd
- .snap_to_end(widget_id) ⇒ Cmd
-
.stream(callable, tag) ⇒ Cmd
Run a callable that emits multiple values via an emit callback.
- .toggle_decorations(window_id) ⇒ Cmd
- .toggle_maximize(window_id) ⇒ Cmd
-
.tree_hash(tag) ⇒ Cmd
Compute tree hash.
-
.update_image(handle, data = nil, width: nil, height: nil, pixels: nil) ⇒ Cmd
Update an existing image handle.
Class Method Details
.advance_frame(timestamp) ⇒ Cmd
Advance the animation clock. For deterministic testing.
446 |
# File 'lib/plushie/command.rb', line 446 def self.advance_frame() = Cmd.new(type: :advance_frame, payload: {timestamp:}) |
.allow_automatic_tabbing(enabled) ⇒ Cmd
250 |
# File 'lib/plushie/command.rb', line 250 def self.allow_automatic_tabbing(enabled) = Cmd.new(type: :window_op, payload: {op: :allow_automatic_tabbing, window_id: "_global", enabled:}) |
.announce(text) ⇒ Cmd
Screen reader announcement.
421 |
# File 'lib/plushie/command.rb', line 421 def self.announce(text) = Cmd.new(type: :widget_op, payload: {op: :announce, text:}) |
.async(callable, tag) ⇒ Cmd
Run a callable asynchronously. Result delivered as Event::Async.
34 |
# File 'lib/plushie/command.rb', line 34 def self.async(callable, tag) = Cmd.new(type: :async, payload: {callable:, tag:}) |
.batch(commands) ⇒ Cmd
Combine multiple commands. Executed sequentially.
67 |
# File 'lib/plushie/command.rb', line 67 def self.batch(commands) = Cmd.new(type: :batch, payload: {commands:}) |
.cancel(tag) ⇒ Cmd
Cancel a running async or stream task by tag.
46 |
# File 'lib/plushie/command.rb', line 46 def self.cancel(tag) = Cmd.new(type: :cancel, payload: {tag:}) |
.clear_images ⇒ Cmd
Remove all image handles.
389 |
# File 'lib/plushie/command.rb', line 389 def self.clear_images = Cmd.new(type: :widget_op, payload: {op: :clear_images}) |
.close_window(window_id) ⇒ Cmd
141 |
# File 'lib/plushie/command.rb', line 141 def self.close_window(window_id) = Cmd.new(type: :close_window, payload: {window_id:}) |
.create_image(handle, data = nil, width: nil, height: nil, pixels: nil) ⇒ Cmd
Create an image from encoded data (PNG/JPEG).
357 358 359 360 361 362 363 |
# File 'lib/plushie/command.rb', line 357 def self.create_image(handle, data = nil, width: nil, height: nil, pixels: nil) if pixels Cmd.new(type: :image_op, payload: {op: :create_image, handle:, pixels:, width:, height:}) else Cmd.new(type: :image_op, payload: {op: :create_image, handle:, data:}) end end |
.delete_image(handle) ⇒ Cmd
Delete an image handle.
380 |
# File 'lib/plushie/command.rb', line 380 def self.delete_image(handle) = Cmd.new(type: :image_op, payload: {op: :delete_image, handle:}) |
.disable_mouse_passthrough(window_id) ⇒ Cmd
229 |
# File 'lib/plushie/command.rb', line 229 def self.disable_mouse_passthrough(window_id) = Cmd.new(type: :window_op, payload: {op: :mouse_passthrough, window_id:, enabled: false}) |
.done(value, mapper_fn) ⇒ Cmd
Lift an already-resolved value into the command pipeline.
52 |
# File 'lib/plushie/command.rb', line 52 def self.done(value, mapper_fn) = Cmd.new(type: :done, payload: {value:, mapper: mapper_fn}) |
.drag_resize_window(window_id, direction) ⇒ Cmd
194 |
# File 'lib/plushie/command.rb', line 194 def self.drag_resize_window(window_id, direction) = Cmd.new(type: :window_op, payload: {op: :drag_resize, window_id:, direction: direction.to_s}) |
.drag_window(window_id) ⇒ Cmd
189 |
# File 'lib/plushie/command.rb', line 189 def self.drag_window(window_id) = Cmd.new(type: :window_op, payload: {op: :drag, window_id:}) |
.enable_mouse_passthrough(window_id) ⇒ Cmd
225 |
# File 'lib/plushie/command.rb', line 225 def self.enable_mouse_passthrough(window_id) = Cmd.new(type: :window_op, payload: {op: :mouse_passthrough, window_id:, enabled: true}) |
.exit ⇒ Cmd
Terminate the application.
62 |
# File 'lib/plushie/command.rb', line 62 def self.exit = Cmd.new(type: :exit, payload: {}) |
.extension_command(node_id, op, payload = {}) ⇒ Cmd
Send a command to a native extension widget.
432 |
# File 'lib/plushie/command.rb', line 432 def self.extension_command(node_id, op, payload = {}) = Cmd.new(type: :extension_command, payload: {node_id:, op:, data: payload}) |
.extension_commands(commands) ⇒ Cmd
Batch multiple extension commands.
437 |
# File 'lib/plushie/command.rb', line 437 def self.extension_commands(commands) = Cmd.new(type: :extension_commands, payload: {commands:}) |
.find_focused(tag) ⇒ Cmd
Find focused widget. Result via Event::System.
403 |
# File 'lib/plushie/command.rb', line 403 def self.find_focused(tag) = Cmd.new(type: :widget_op, payload: {op: :find_focused, tag: tag.to_s}) |
.focus(widget_id) ⇒ Cmd
75 |
# File 'lib/plushie/command.rb', line 75 def self.focus() = Cmd.new(type: :focus, payload: {target: }) |
.focus_element(canvas_id, element_id) ⇒ Cmd
Focus a specific element within a canvas widget.
316 |
# File 'lib/plushie/command.rb', line 316 def self.focus_element(canvas_id, element_id) = Cmd.new(type: :widget_op, payload: {op: "focus_element", target: canvas_id, element_id: element_id}) |
.focus_next ⇒ Cmd
78 |
# File 'lib/plushie/command.rb', line 78 def self.focus_next = Cmd.new(type: :focus_next, payload: {}) |
.focus_previous ⇒ Cmd
81 |
# File 'lib/plushie/command.rb', line 81 def self.focus_previous = Cmd.new(type: :focus_previous, payload: {}) |
.gain_focus(window_id) ⇒ Cmd
180 |
# File 'lib/plushie/command.rb', line 180 def self.gain_focus(window_id) = Cmd.new(type: :window_op, payload: {op: :gain_focus, window_id:}) |
.get_mode(window_id, tag) ⇒ Cmd
279 |
# File 'lib/plushie/command.rb', line 279 def self.get_mode(window_id, tag) = Cmd.new(type: :window_query, payload: {op: :get_mode, window_id:, tag: tag.to_s}) |
.get_scale_factor(window_id, tag) ⇒ Cmd
284 |
# File 'lib/plushie/command.rb', line 284 def self.get_scale_factor(window_id, tag) = Cmd.new(type: :window_query, payload: {op: :get_scale_factor, window_id:, tag: tag.to_s}) |
.get_system_info(tag) ⇒ Cmd
306 |
# File 'lib/plushie/command.rb', line 306 def self.get_system_info(tag) = Cmd.new(type: :window_query, payload: {op: :get_system_info, window_id: "_system", tag: tag.to_s}) |
.get_system_theme(tag) ⇒ Cmd
302 |
# File 'lib/plushie/command.rb', line 302 def self.get_system_theme(tag) = Cmd.new(type: :window_query, payload: {op: :get_system_theme, window_id: "_system", tag: tag.to_s}) |
.get_window_position(window_id, tag) ⇒ Cmd
264 |
# File 'lib/plushie/command.rb', line 264 def self.get_window_position(window_id, tag) = Cmd.new(type: :window_query, payload: {op: :get_position, window_id:, tag: tag.to_s}) |
.get_window_size(window_id, tag) ⇒ Cmd
259 |
# File 'lib/plushie/command.rb', line 259 def self.get_window_size(window_id, tag) = Cmd.new(type: :window_query, payload: {op: :get_size, window_id:, tag: tag.to_s}) |
.is_maximized(window_id, tag) ⇒ Cmd
269 |
# File 'lib/plushie/command.rb', line 269 def self.is_maximized(window_id, tag) = Cmd.new(type: :window_query, payload: {op: :is_maximized, window_id:, tag: tag.to_s}) |
.is_minimized(window_id, tag) ⇒ Cmd
274 |
# File 'lib/plushie/command.rb', line 274 def self.is_minimized(window_id, tag) = Cmd.new(type: :window_query, payload: {op: :is_minimized, window_id:, tag: tag.to_s}) |
.list_images(tag) ⇒ Cmd
List all image handles. Result via Event::System.
385 |
# File 'lib/plushie/command.rb', line 385 def self.list_images(tag) = Cmd.new(type: :widget_op, payload: {op: :list_images, tag: tag.to_s}) |
.load_font(data) ⇒ Cmd
Load a font at runtime from TTF/OTF data.
412 |
# File 'lib/plushie/command.rb', line 412 def self.load_font(data) = Cmd.new(type: :widget_op, payload: {op: :load_font, data:}) |
.maximize_window(window_id, maximized = true) ⇒ Cmd
158 |
# File 'lib/plushie/command.rb', line 158 def self.maximize_window(window_id, maximized = true) = Cmd.new(type: :window_op, payload: {op: :maximize, window_id:, maximized:}) |
.minimize_window(window_id, minimized = true) ⇒ Cmd
163 |
# File 'lib/plushie/command.rb', line 163 def self.minimize_window(window_id, minimized = true) = Cmd.new(type: :window_op, payload: {op: :minimize, window_id:, minimized:}) |
.monitor_size(window_id, tag) ⇒ Cmd
294 |
# File 'lib/plushie/command.rb', line 294 def self.monitor_size(window_id, tag) = Cmd.new(type: :window_query, payload: {op: :monitor_size, window_id:, tag: tag.to_s}) |
.move_cursor_to(widget_id, position) ⇒ Cmd
102 |
# File 'lib/plushie/command.rb', line 102 def self.move_cursor_to(, position) = Cmd.new(type: :move_cursor_to, payload: {target: , position:}) |
.move_cursor_to_end(widget_id) ⇒ Cmd
97 |
# File 'lib/plushie/command.rb', line 97 def self.move_cursor_to_end() = Cmd.new(type: :move_cursor_to_end, payload: {target: }) |
.move_cursor_to_front(widget_id) ⇒ Cmd
93 |
# File 'lib/plushie/command.rb', line 93 def self.move_cursor_to_front() = Cmd.new(type: :move_cursor_to_front, payload: {target: }) |
.move_window(window_id, x, y) ⇒ Cmd
153 |
# File 'lib/plushie/command.rb', line 153 def self.move_window(window_id, x, y) = Cmd.new(type: :window_op, payload: {op: :move, window_id:, x:, y:}) |
.none ⇒ Cmd
Returns no-op command.
28 |
# File 'lib/plushie/command.rb', line 28 def self.none = Cmd.new(type: :none, payload: {}) |
.pane_close(grid_id, pane_id) ⇒ Cmd
332 |
# File 'lib/plushie/command.rb', line 332 def self.pane_close(grid_id, pane_id) = Cmd.new(type: :widget_op, payload: {op: :pane_close, target: grid_id, pane: pane_id}) |
.pane_maximize(grid_id, pane_id) ⇒ Cmd
343 |
# File 'lib/plushie/command.rb', line 343 def self.pane_maximize(grid_id, pane_id) = Cmd.new(type: :widget_op, payload: {op: :pane_maximize, target: grid_id, pane: pane_id}) |
.pane_restore(grid_id) ⇒ Cmd
347 |
# File 'lib/plushie/command.rb', line 347 def self.pane_restore(grid_id) = Cmd.new(type: :widget_op, payload: {op: :pane_restore, target: grid_id}) |
.pane_split(grid_id, pane_id, axis, new_pane_id) ⇒ Cmd
327 |
# File 'lib/plushie/command.rb', line 327 def self.pane_split(grid_id, pane_id, axis, new_pane_id) = Cmd.new(type: :widget_op, payload: {op: :pane_split, target: grid_id, pane: pane_id, axis: axis.to_s, new_pane_id:}) |
.pane_swap(grid_id, pane_a, pane_b) ⇒ Cmd
338 |
# File 'lib/plushie/command.rb', line 338 def self.pane_swap(grid_id, pane_a, pane_b) = Cmd.new(type: :widget_op, payload: {op: :pane_swap, target: grid_id, a: pane_a, b: pane_b}) |
.raw_id(window_id, tag) ⇒ Cmd
289 |
# File 'lib/plushie/command.rb', line 289 def self.raw_id(window_id, tag) = Cmd.new(type: :window_query, payload: {op: :raw_id, window_id:, tag: tag.to_s}) |
.request_user_attention(window_id, urgency) ⇒ Cmd
199 |
# File 'lib/plushie/command.rb', line 199 def self.request_user_attention(window_id, urgency) = Cmd.new(type: :window_op, payload: {op: :request_attention, window_id:, urgency: urgency&.to_s}) |
.resize_window(window_id, width, height) ⇒ Cmd
147 |
# File 'lib/plushie/command.rb', line 147 def self.resize_window(window_id, width, height) = Cmd.new(type: :window_op, payload: {op: :resize, window_id:, width:, height:}) |
.screenshot(window_id, tag) ⇒ Cmd
204 |
# File 'lib/plushie/command.rb', line 204 def self.screenshot(window_id, tag) = Cmd.new(type: :window_query, payload: {op: :screenshot, window_id:, tag: tag.to_s}) |
.scroll_by(widget_id, x, y) ⇒ Cmd
133 |
# File 'lib/plushie/command.rb', line 133 def self.scroll_by(, x, y) = Cmd.new(type: :scroll_by, payload: {target: , x:, y:}) |
.scroll_to(widget_id, offset_y) ⇒ Cmd
117 |
# File 'lib/plushie/command.rb', line 117 def self.scroll_to(, offset_y) = Cmd.new(type: :scroll_to, payload: {target: , offset_y:}) |
.select_all(widget_id) ⇒ Cmd
89 |
# File 'lib/plushie/command.rb', line 89 def self.select_all() = Cmd.new(type: :select_all, payload: {target: }) |
.select_range(widget_id, start_pos, end_pos) ⇒ Cmd
108 |
# File 'lib/plushie/command.rb', line 108 def self.select_range(, start_pos, end_pos) = Cmd.new(type: :select_range, payload: {target: , start: start_pos, end: end_pos}) |
.send_after(delay_ms, event) ⇒ Cmd
Send an event to update after a delay.
58 |
# File 'lib/plushie/command.rb', line 58 def self.send_after(delay_ms, event) = Cmd.new(type: :send_after, payload: {delay: delay_ms, event:}) |
.set_icon(window_id, rgba_data, width, height) ⇒ Cmd
240 |
# File 'lib/plushie/command.rb', line 240 def self.set_icon(window_id, rgba_data, width, height) = Cmd.new(type: :window_op, payload: {op: :set_icon, window_id:, icon_data: rgba_data, width:, height:}) |
.set_max_size(window_id, width, height) ⇒ Cmd
221 |
# File 'lib/plushie/command.rb', line 221 def self.set_max_size(window_id, width, height) = Cmd.new(type: :window_op, payload: {op: :set_max_size, window_id:, width:, height:}) |
.set_min_size(window_id, width, height) ⇒ Cmd
215 |
# File 'lib/plushie/command.rb', line 215 def self.set_min_size(window_id, width, height) = Cmd.new(type: :window_op, payload: {op: :set_min_size, window_id:, width:, height:}) |
.set_resizable(window_id, resizable) ⇒ Cmd
209 |
# File 'lib/plushie/command.rb', line 209 def self.set_resizable(window_id, resizable) = Cmd.new(type: :window_op, payload: {op: :set_resizable, window_id:, resizable:}) |
.set_resize_increments(window_id, width, height) ⇒ Cmd
246 |
# File 'lib/plushie/command.rb', line 246 def self.set_resize_increments(window_id, width, height) = Cmd.new(type: :window_op, payload: {op: :set_resize_increments, window_id:, width:, height:}) |
.set_window_level(window_id, level) ⇒ Cmd
185 |
# File 'lib/plushie/command.rb', line 185 def self.set_window_level(window_id, level) = Cmd.new(type: :window_op, payload: {op: :set_level, window_id:, level: level.to_s}) |
.set_window_mode(window_id, mode) ⇒ Cmd
168 |
# File 'lib/plushie/command.rb', line 168 def self.set_window_mode(window_id, mode) = Cmd.new(type: :window_op, payload: {op: :set_mode, window_id:, mode: mode.to_s}) |
.show_system_menu(window_id) ⇒ Cmd
233 |
# File 'lib/plushie/command.rb', line 233 def self.(window_id) = Cmd.new(type: :window_op, payload: {op: :show_system_menu, window_id:}) |
.snap_to(widget_id, x, y) ⇒ Cmd
123 |
# File 'lib/plushie/command.rb', line 123 def self.snap_to(, x, y) = Cmd.new(type: :snap_to, payload: {target: , x:, y:}) |
.snap_to_end(widget_id) ⇒ Cmd
127 |
# File 'lib/plushie/command.rb', line 127 def self.snap_to_end() = Cmd.new(type: :snap_to_end, payload: {target: }) |
.stream(callable, tag) ⇒ Cmd
Run a callable that emits multiple values via an emit callback. Each emit delivers Event::Stream; the final return delivers Event::Async.
41 |
# File 'lib/plushie/command.rb', line 41 def self.stream(callable, tag) = Cmd.new(type: :stream, payload: {callable:, tag:}) |
.toggle_decorations(window_id) ⇒ Cmd
176 |
# File 'lib/plushie/command.rb', line 176 def self.toggle_decorations(window_id) = Cmd.new(type: :window_op, payload: {op: :toggle_decorations, window_id:}) |
.toggle_maximize(window_id) ⇒ Cmd
172 |
# File 'lib/plushie/command.rb', line 172 def self.toggle_maximize(window_id) = Cmd.new(type: :window_op, payload: {op: :toggle_maximize, window_id:}) |
.tree_hash(tag) ⇒ Cmd
Compute tree hash. Result via Event::System.
398 |
# File 'lib/plushie/command.rb', line 398 def self.tree_hash(tag) = Cmd.new(type: :widget_op, payload: {op: :tree_hash, tag: tag.to_s}) |
.update_image(handle, data = nil, width: nil, height: nil, pixels: nil) ⇒ Cmd
Update an existing image handle.
369 370 371 372 373 374 375 |
# File 'lib/plushie/command.rb', line 369 def self.update_image(handle, data = nil, width: nil, height: nil, pixels: nil) if pixels Cmd.new(type: :image_op, payload: {op: :update_image, handle:, pixels:, width:, height:}) else Cmd.new(type: :image_op, payload: {op: :update_image, handle:, data:}) end end |