Current section
Files
Jump to
Current section
Files
src/plushie@command.erl
-module(plushie@command).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/plushie/command.gleam").
-export([none/0, batch/1, dispatch/2, task/2, stream/2, cancel/1, send_after/2, exit/0, focus/1, focus_next/0, focus_previous/0, focus_next_within/1, focus_previous_within/1, select_all/1, close_window/1, resize_window/3, move_window/3, maximize_window/1, minimize_window/1, toggle_maximize/1, toggle_decorations/1, focus_window/1, screenshot/2, announce/1, announce_with/2, announce_assertive/1, create_image/2, create_image_rgba/4, update_image_rgba/4, delete_image/1, clear_images/0, tree_hash/1, find_focused/1, advance_frame/1, move_cursor_to_front/1, move_cursor_to_end/1, move_cursor_to/2, select_range/3, scroll_to/3, snap_to/3, snap_to_end/1, scroll_by/3, pane_split/4, pane_close/2, pane_swap/3, pane_maximize/2, pane_restore/1, set_window_mode/2, set_window_level/2, drag_window/1, drag_resize_window/2, request_attention/2, set_resizable/2, set_min_size/3, set_max_size/3, enable_mouse_passthrough/1, disable_mouse_passthrough/1, show_system_menu/1, set_resize_increments/3, set_icon/4, window_size/2, window_position/2, is_maximized/2, is_minimized/2, window_mode/2, scale_factor/2, raw_window_id/2, monitor_size/2, allow_automatic_tabbing/1, system_theme/1, system_info/1, update_image/2, list_images/1, load_font/2, native_command/3, widget_batch/1, is_valid_native_op/1]).
-export_type([command/1, politeness/0, renderer_command/0, window_command/0, system_command/0, image_command/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" Command types returned from update.\n"
"\n"
" Commands describe side effects that the runtime executes after\n"
" `update` returns. The lifecycle is: `update` returns\n"
" `#(model, command)`, the runtime executes the command, and then\n"
" calls `view` with the new model. Batched commands execute in\n"
" list order. For no side effects, return `command.none()`.\n"
).
-type command(FZB) :: none |
{batch, list(command(FZB))} |
{done, gleam@dynamic:dynamic_(), fun((gleam@dynamic:dynamic_()) -> FZB)} |
{async, fun(() -> gleam@dynamic:dynamic_()), binary()} |
{stream,
fun((fun((gleam@dynamic:dynamic_()) -> nil)) -> gleam@dynamic:dynamic_()),
binary()} |
{cancel, binary()} |
{send_after, integer(), FZB} |
exit |
{renderer, renderer_command()}.
-type politeness() :: polite | assertive.
-type renderer_command() :: {focus, binary()} |
focus_next |
focus_previous |
{focus_next_within, binary()} |
{focus_previous_within, binary()} |
{select_all, binary()} |
{move_cursor_to_front, binary()} |
{move_cursor_to_end, binary()} |
{move_cursor_to, binary(), integer()} |
{select_range, binary(), integer(), integer()} |
{scroll_to, binary(), float(), float()} |
{snap_to, binary(), float(), float()} |
{snap_to_end, binary()} |
{scroll_by, binary(), float(), float()} |
{pane_split, binary(), binary(), binary(), binary()} |
{pane_close, binary(), binary()} |
{pane_swap, binary(), binary(), binary()} |
{pane_maximize, binary(), binary()} |
{pane_restore, binary()} |
{window, window_command()} |
{system, system_command()} |
{image, image_command()} |
{native_command,
binary(),
binary(),
gleam@dict:dict(binary(), plushie@node:prop_value())} |
{native_commands,
list({binary(),
binary(),
gleam@dict:dict(binary(), plushie@node:prop_value())})} |
{effect,
binary(),
binary(),
binary(),
gleam@dict:dict(binary(), plushie@node:prop_value())} |
{announce, binary(), politeness()} |
{load_font, binary(), bitstring()} |
{tree_hash_query, binary()} |
{find_focused, binary()} |
{advance_frame, integer()}.
-type window_command() :: {close_window, binary()} |
{resize_window, binary(), float(), float()} |
{move_window, binary(), float(), float()} |
{maximize_window, binary(), boolean()} |
{minimize_window, binary(), boolean()} |
{set_window_mode, binary(), binary()} |
{toggle_maximize, binary()} |
{toggle_decorations, binary()} |
{focus_window, binary()} |
{set_window_level, binary(), binary()} |
{drag_window, binary()} |
{drag_resize_window, binary(), binary()} |
{request_user_attention, binary(), gleam@option:option(binary())} |
{screenshot, binary(), binary()} |
{set_resizable, binary(), boolean()} |
{set_min_size, binary(), float(), float()} |
{set_max_size, binary(), float(), float()} |
{enable_mouse_passthrough, binary()} |
{disable_mouse_passthrough, binary()} |
{show_system_menu, binary()} |
{set_resize_increments,
binary(),
gleam@option:option(float()),
gleam@option:option(float())} |
{set_icon, binary(), bitstring(), integer(), integer()} |
{get_window_size, binary(), binary()} |
{get_window_position, binary(), binary()} |
{is_maximized, binary(), binary()} |
{is_minimized, binary(), binary()} |
{get_mode, binary(), binary()} |
{get_scale_factor, binary(), binary()} |
{raw_window_id, binary(), binary()} |
{monitor_size, binary(), binary()}.
-type system_command() :: {allow_automatic_tabbing, boolean()} |
{get_system_theme, binary()} |
{get_system_info, binary()}.
-type image_command() :: {create_image, binary(), bitstring()} |
{create_image_rgba, binary(), integer(), integer(), bitstring()} |
{update_image, binary(), bitstring()} |
{update_image_rgba, binary(), integer(), integer(), bitstring()} |
{delete_image, binary()} |
{list_images, binary()} |
clear_images.
-file("src/plushie/command.gleam", 274).
?DOC(" No side effect. Return this from update when no command is needed.\n").
-spec none() -> command(any()).
none() ->
none.
-file("src/plushie/command.gleam", 279).
?DOC(" Execute multiple commands in list order.\n").
-spec batch(list(command(FZE))) -> command(FZE).
batch(Commands) ->
{batch, Commands}.
-file("src/plushie/command.gleam", 291).
?DOC(
" Wrap an already-resolved value and deliver it through update via\n"
" the mapper function. Useful for lifting pure values into the\n"
" command pipeline.\n"
"\n"
" Note: the mapper function runs when the event is processed, which\n"
" may be after further state changes. Do not capture the current\n"
" model in the closure; use the model available in your update\n"
" function instead.\n"
).
-spec dispatch(gleam@dynamic:dynamic_(), fun((gleam@dynamic:dynamic_()) -> FZI)) -> command(FZI).
dispatch(Value, Mapper) ->
{done, Value, Mapper}.
-file("src/plushie/command.gleam", 298).
?DOC(
" Run a function asynchronously on a background process. The result\n"
" is delivered as an AsyncResult event identified by the tag.\n"
" Starting a new task with the same tag cancels the running one.\n"
).
-spec task(fun(() -> gleam@dynamic:dynamic_()), binary()) -> command(any()).
task(Work, Tag) ->
{async, Work, Tag}.
-file("src/plushie/command.gleam", 305).
?DOC(
" Run a function that can emit multiple values over time. Each value\n"
" is delivered as a StreamValue event identified by the tag.\n"
" Starting a new stream with the same tag cancels the running one.\n"
).
-spec stream(
fun((fun((gleam@dynamic:dynamic_()) -> nil)) -> gleam@dynamic:dynamic_()),
binary()
) -> command(any()).
stream(Work, Tag) ->
{stream, Work, Tag}.
-file("src/plushie/command.gleam", 313).
?DOC(" Cancel a running async or stream task by its tag.\n").
-spec cancel(binary()) -> command(any()).
cancel(Tag) ->
{cancel, Tag}.
-file("src/plushie/command.gleam", 320).
?DOC(
" Deliver a message back to update after a delay in milliseconds.\n"
" Sending another SendAfter with an identical msg replaces the\n"
" previous timer.\n"
).
-spec send_after(integer(), FZQ) -> command(FZQ).
send_after(Delay_ms, Msg) ->
{send_after, Delay_ms, Msg}.
-file("src/plushie/command.gleam", 325).
?DOC(" Shut down the runtime and close all windows.\n").
-spec exit() -> command(any()).
exit() ->
exit.
-file("src/plushie/command.gleam", 330).
?DOC(" Move keyboard focus to the given widget.\n").
-spec focus(binary()) -> command(any()).
focus(Widget_id) ->
{renderer, {focus, Widget_id}}.
-file("src/plushie/command.gleam", 335).
?DOC(" Move focus to the next focusable widget.\n").
-spec focus_next() -> command(any()).
focus_next() ->
{renderer, focus_next}.
-file("src/plushie/command.gleam", 340).
?DOC(" Move focus to the previous focusable widget.\n").
-spec focus_previous() -> command(any()).
focus_previous() ->
{renderer, focus_previous}.
-file("src/plushie/command.gleam", 347).
?DOC(
" Move focus to the next focusable widget within the subtree rooted\n"
" at `scope`. Useful for menus, pane grids, and other keyboard\n"
" containers that want a bounded Tab cycle.\n"
).
-spec focus_next_within(binary()) -> command(any()).
focus_next_within(Scope) ->
{renderer, {focus_next_within, Scope}}.
-file("src/plushie/command.gleam", 353).
?DOC(
" Move focus to the previous focusable widget within the subtree\n"
" rooted at `scope`. See `focus_next_within` for semantics.\n"
).
-spec focus_previous_within(binary()) -> command(any()).
focus_previous_within(Scope) ->
{renderer, {focus_previous_within, Scope}}.
-file("src/plushie/command.gleam", 358).
?DOC(" Select all text in the given text input widget.\n").
-spec select_all(binary()) -> command(any()).
select_all(Widget_id) ->
{renderer, {select_all, Widget_id}}.
-file("src/plushie/command.gleam", 363).
?DOC(" Close the window with the given ID.\n").
-spec close_window(binary()) -> command(any()).
close_window(Window_id) ->
{renderer, {window, {close_window, Window_id}}}.
-file("src/plushie/command.gleam", 368).
?DOC(" Resize a window to the given dimensions in logical pixels.\n").
-spec resize_window(binary(), float(), float()) -> command(any()).
resize_window(Window_id, Width, Height) ->
{renderer, {window, {resize_window, Window_id, Width, Height}}}.
-file("src/plushie/command.gleam", 377).
?DOC(" Move a window to the given screen position.\n").
-spec move_window(binary(), float(), float()) -> command(any()).
move_window(Window_id, X, Y) ->
{renderer, {window, {move_window, Window_id, X, Y}}}.
-file("src/plushie/command.gleam", 382).
?DOC(" Maximize a window.\n").
-spec maximize_window(binary()) -> command(any()).
maximize_window(Window_id) ->
{renderer, {window, {maximize_window, Window_id, true}}}.
-file("src/plushie/command.gleam", 387).
?DOC(" Minimize a window.\n").
-spec minimize_window(binary()) -> command(any()).
minimize_window(Window_id) ->
{renderer, {window, {minimize_window, Window_id, true}}}.
-file("src/plushie/command.gleam", 392).
?DOC(" Toggle a window between maximized and restored state.\n").
-spec toggle_maximize(binary()) -> command(any()).
toggle_maximize(Window_id) ->
{renderer, {window, {toggle_maximize, Window_id}}}.
-file("src/plushie/command.gleam", 397).
?DOC(" Toggle window decorations (title bar, borders).\n").
-spec toggle_decorations(binary()) -> command(any()).
toggle_decorations(Window_id) ->
{renderer, {window, {toggle_decorations, Window_id}}}.
-file("src/plushie/command.gleam", 402).
?DOC(" Give focus to a window, bringing it to the front.\n").
-spec focus_window(binary()) -> command(any()).
focus_window(Window_id) ->
{renderer, {window, {focus_window, Window_id}}}.
-file("src/plushie/command.gleam", 407).
?DOC(" Take a screenshot of a window. The result arrives as a tagged event.\n").
-spec screenshot(binary(), binary()) -> command(any()).
screenshot(Window_id, Tag) ->
{renderer, {window, {screenshot, Window_id, Tag}}}.
-file("src/plushie/command.gleam", 416).
?DOC(
" Announce text to screen readers at polite politeness.\n"
"\n"
" Polite is the correct choice for most toast-style feedback (saves,\n"
" confirmations, counts). Use `announce_assertive` for urgent context\n"
" that must interrupt whatever the user is currently hearing.\n"
).
-spec announce(binary()) -> command(any()).
announce(Text) ->
{renderer, {announce, Text, polite}}.
-file("src/plushie/command.gleam", 421).
?DOC(" Announce text to screen readers at the given politeness level.\n").
-spec announce_with(binary(), politeness()) -> command(any()).
announce_with(Text, Politeness) ->
{renderer, {announce, Text, Politeness}}.
-file("src/plushie/command.gleam", 427).
?DOC(
" Announce text to screen readers at assertive politeness, interrupting\n"
" the current announcement. Reserve for urgent context.\n"
).
-spec announce_assertive(binary()) -> command(any()).
announce_assertive(Text) ->
{renderer, {announce, Text, assertive}}.
-file("src/plushie/command.gleam", 433).
?DOC(
" Register an image from encoded data (PNG, JPEG, etc.) under the\n"
" given handle for use in image widgets.\n"
).
-spec create_image(binary(), bitstring()) -> command(any()).
create_image(Handle, Data) ->
{renderer, {image, {create_image, Handle, Data}}}.
-file("src/plushie/command.gleam", 463).
-spec validate_rgba_buffer(bitstring(), integer(), integer()) -> nil.
validate_rgba_buffer(Pixels, Width, Height) ->
Expected = (Width * Height) * 4,
Actual = erlang:byte_size(Pixels),
case Actual =:= Expected of
true ->
nil;
false ->
erlang:error(#{gleam_error => panic,
message => (<<<<<<<<<<<<<<"RGBA pixel buffer size mismatch: expected "/utf8,
(erlang:integer_to_binary(
Expected
))/binary>>/binary,
" bytes ("/utf8>>/binary,
(erlang:integer_to_binary(Width))/binary>>/binary,
"x"/utf8>>/binary,
(erlang:integer_to_binary(Height))/binary>>/binary,
"x4) but got "/utf8>>/binary,
(erlang:integer_to_binary(Actual))/binary>>),
file => <<?FILEPATH/utf8>>,
module => <<"plushie/command"/utf8>>,
function => <<"validate_rgba_buffer"/utf8>>,
line => 469})
end.
-file("src/plushie/command.gleam", 440).
?DOC(
" Register an image from raw RGBA pixel data under the given handle.\n"
" The pixel buffer must be exactly `width * height * 4` bytes\n"
" (R, G, B, A per pixel, row-major).\n"
).
-spec create_image_rgba(binary(), integer(), integer(), bitstring()) -> command(any()).
create_image_rgba(Handle, Width, Height, Pixels) ->
validate_rgba_buffer(Pixels, Width, Height),
{renderer, {image, {create_image_rgba, Handle, Width, Height, Pixels}}}.
-file("src/plushie/command.gleam", 453).
?DOC(
" Update an existing image handle with new raw RGBA pixel data.\n"
" The pixel buffer must be exactly `width * height * 4` bytes\n"
" (R, G, B, A per pixel, row-major).\n"
).
-spec update_image_rgba(binary(), integer(), integer(), bitstring()) -> command(any()).
update_image_rgba(Handle, Width, Height, Pixels) ->
validate_rgba_buffer(Pixels, Width, Height),
{renderer, {image, {update_image_rgba, Handle, Width, Height, Pixels}}}.
-file("src/plushie/command.gleam", 483).
?DOC(" Delete a previously registered image by its handle.\n").
-spec delete_image(binary()) -> command(any()).
delete_image(Handle) ->
{renderer, {image, {delete_image, Handle}}}.
-file("src/plushie/command.gleam", 488).
?DOC(" Delete all registered images.\n").
-spec clear_images() -> command(any()).
clear_images() ->
{renderer, {image, clear_images}}.
-file("src/plushie/command.gleam", 494).
?DOC(
" Query the current tree hash from the renderer. The result arrives\n"
" as a tagged event.\n"
).
-spec tree_hash(binary()) -> command(any()).
tree_hash(Tag) ->
{renderer, {tree_hash_query, Tag}}.
-file("src/plushie/command.gleam", 500).
?DOC(
" Query which widget currently has focus. The result arrives as a\n"
" tagged event.\n"
).
-spec find_focused(binary()) -> command(any()).
find_focused(Tag) ->
{renderer, {find_focused, Tag}}.
-file("src/plushie/command.gleam", 505).
?DOC(" Advance the renderer by one frame in test/headless mode.\n").
-spec advance_frame(integer()) -> command(any()).
advance_frame(Timestamp) ->
{renderer, {advance_frame, Timestamp}}.
-file("src/plushie/command.gleam", 512).
?DOC(" Move the text cursor to the beginning of the input.\n").
-spec move_cursor_to_front(binary()) -> command(any()).
move_cursor_to_front(Widget_id) ->
{renderer, {move_cursor_to_front, Widget_id}}.
-file("src/plushie/command.gleam", 517).
?DOC(" Move the text cursor to the end of the input.\n").
-spec move_cursor_to_end(binary()) -> command(any()).
move_cursor_to_end(Widget_id) ->
{renderer, {move_cursor_to_end, Widget_id}}.
-file("src/plushie/command.gleam", 522).
?DOC(" Move the text cursor to a specific character position.\n").
-spec move_cursor_to(binary(), integer()) -> command(any()).
move_cursor_to(Widget_id, Position) ->
{renderer, {move_cursor_to, Widget_id, Position}}.
-file("src/plushie/command.gleam", 527).
?DOC(" Select a range of text between start_pos and end_pos character positions.\n").
-spec select_range(binary(), integer(), integer()) -> command(any()).
select_range(Widget_id, Start_pos, End_pos) ->
{renderer, {select_range, Widget_id, Start_pos, End_pos}}.
-file("src/plushie/command.gleam", 538).
?DOC(" Scroll a scrollable widget to an absolute x/y offset.\n").
-spec scroll_to(binary(), float(), float()) -> command(any()).
scroll_to(Widget_id, X, Y) ->
{renderer, {scroll_to, Widget_id, X, Y}}.
-file("src/plushie/command.gleam", 544).
?DOC(
" Snap a scrollable widget to an absolute x/y offset instantly\n"
" (no smooth scrolling).\n"
).
-spec snap_to(binary(), float(), float()) -> command(any()).
snap_to(Widget_id, X, Y) ->
{renderer, {snap_to, Widget_id, X, Y}}.
-file("src/plushie/command.gleam", 549).
?DOC(" Snap a scrollable widget to the end of its content.\n").
-spec snap_to_end(binary()) -> command(any()).
snap_to_end(Widget_id) ->
{renderer, {snap_to_end, Widget_id}}.
-file("src/plushie/command.gleam", 554).
?DOC(" Scroll a scrollable widget by a relative x/y delta.\n").
-spec scroll_by(binary(), float(), float()) -> command(any()).
scroll_by(Widget_id, X, Y) ->
{renderer, {scroll_by, Widget_id, X, Y}}.
-file("src/plushie/command.gleam", 562).
?DOC(
" Split a pane in a pane_grid widget along the given axis\n"
" (\"horizontal\" or \"vertical\"), creating a new pane.\n"
).
-spec pane_split(binary(), binary(), binary(), binary()) -> command(any()).
pane_split(Pane_grid_id, Pane_id, Axis, New_pane_id) ->
{renderer, {pane_split, Pane_grid_id, Pane_id, Axis, New_pane_id}}.
-file("src/plushie/command.gleam", 572).
?DOC(" Close a pane in a pane_grid widget.\n").
-spec pane_close(binary(), binary()) -> command(any()).
pane_close(Pane_grid_id, Pane_id) ->
{renderer, {pane_close, Pane_grid_id, Pane_id}}.
-file("src/plushie/command.gleam", 577).
?DOC(" Swap two panes in a pane_grid widget.\n").
-spec pane_swap(binary(), binary(), binary()) -> command(any()).
pane_swap(Pane_grid_id, Pane_a, Pane_b) ->
{renderer, {pane_swap, Pane_grid_id, Pane_a, Pane_b}}.
-file("src/plushie/command.gleam", 586).
?DOC(" Maximize a single pane to fill the entire pane_grid.\n").
-spec pane_maximize(binary(), binary()) -> command(any()).
pane_maximize(Pane_grid_id, Pane_id) ->
{renderer, {pane_maximize, Pane_grid_id, Pane_id}}.
-file("src/plushie/command.gleam", 591).
?DOC(" Restore all panes from maximized state in a pane_grid.\n").
-spec pane_restore(binary()) -> command(any()).
pane_restore(Pane_grid_id) ->
{renderer, {pane_restore, Pane_grid_id}}.
-file("src/plushie/command.gleam", 598).
?DOC(" Set the window mode (e.g. \"windowed\", \"fullscreen\").\n").
-spec set_window_mode(binary(), binary()) -> command(any()).
set_window_mode(Window_id, Mode) ->
{renderer, {window, {set_window_mode, Window_id, Mode}}}.
-file("src/plushie/command.gleam", 604).
?DOC(
" Set window stacking level (\"normal\", \"always_on_top\",\n"
" \"always_on_bottom\"). May be ignored on Wayland.\n"
).
-spec set_window_level(binary(), binary()) -> command(any()).
set_window_level(Window_id, Level) ->
{renderer, {window, {set_window_level, Window_id, Level}}}.
-file("src/plushie/command.gleam", 609).
?DOC(" Initiate a window drag operation (user moves the window).\n").
-spec drag_window(binary()) -> command(any()).
drag_window(Window_id) ->
{renderer, {window, {drag_window, Window_id}}}.
-file("src/plushie/command.gleam", 614).
?DOC(" Initiate a drag-resize from the given edge/corner direction.\n").
-spec drag_resize_window(binary(), binary()) -> command(any()).
drag_resize_window(Window_id, Direction) ->
{renderer, {window, {drag_resize_window, Window_id, Direction}}}.
-file("src/plushie/command.gleam", 620).
?DOC(
" Flash the taskbar/dock icon to request user attention. Urgency\n"
" is \"informational\" or \"critical\"; None clears the request.\n"
).
-spec request_attention(binary(), gleam@option:option(binary())) -> command(any()).
request_attention(Window_id, Urgency) ->
{renderer, {window, {request_user_attention, Window_id, Urgency}}}.
-file("src/plushie/command.gleam", 628).
?DOC(" Set whether a window can be resized by the user.\n").
-spec set_resizable(binary(), boolean()) -> command(any()).
set_resizable(Window_id, Resizable) ->
{renderer, {window, {set_resizable, Window_id, Resizable}}}.
-file("src/plushie/command.gleam", 633).
?DOC(" Set the minimum allowed size for a window in logical pixels.\n").
-spec set_min_size(binary(), float(), float()) -> command(any()).
set_min_size(Window_id, Width, Height) ->
{renderer, {window, {set_min_size, Window_id, Width, Height}}}.
-file("src/plushie/command.gleam", 642).
?DOC(" Set the maximum allowed size for a window in logical pixels.\n").
-spec set_max_size(binary(), float(), float()) -> command(any()).
set_max_size(Window_id, Width, Height) ->
{renderer, {window, {set_max_size, Window_id, Width, Height}}}.
-file("src/plushie/command.gleam", 651).
?DOC(" Enable mouse passthrough so clicks pass through to windows below.\n").
-spec enable_mouse_passthrough(binary()) -> command(any()).
enable_mouse_passthrough(Window_id) ->
{renderer, {window, {enable_mouse_passthrough, Window_id}}}.
-file("src/plushie/command.gleam", 656).
?DOC(" Disable mouse passthrough, restoring normal click handling.\n").
-spec disable_mouse_passthrough(binary()) -> command(any()).
disable_mouse_passthrough(Window_id) ->
{renderer, {window, {disable_mouse_passthrough, Window_id}}}.
-file("src/plushie/command.gleam", 661).
?DOC(" Show the native system menu (window controls) for a window.\n").
-spec show_system_menu(binary()) -> command(any()).
show_system_menu(Window_id) ->
{renderer, {window, {show_system_menu, Window_id}}}.
-file("src/plushie/command.gleam", 667).
?DOC(
" Set the resize increment size. The window will only resize in\n"
" multiples of the given width/height. Pass None to clear.\n"
).
-spec set_resize_increments(
binary(),
gleam@option:option(float()),
gleam@option:option(float())
) -> command(any()).
set_resize_increments(Window_id, Width, Height) ->
{renderer, {window, {set_resize_increments, Window_id, Width, Height}}}.
-file("src/plushie/command.gleam", 677).
?DOC(
" Set the window icon from raw RGBA pixel data. The BitArray must\n"
" be width * height * 4 bytes (R, G, B, A per pixel, row-major).\n"
).
-spec set_icon(binary(), bitstring(), integer(), integer()) -> command(any()).
set_icon(Window_id, Rgba_data, Width, Height) ->
validate_rgba_buffer(Rgba_data, Width, Height),
{renderer, {window, {set_icon, Window_id, Rgba_data, Width, Height}}}.
-file("src/plushie/command.gleam", 690).
?DOC(" Query the size of a window. Result arrives as a SystemInfo event.\n").
-spec window_size(binary(), binary()) -> command(any()).
window_size(Window_id, Tag) ->
{renderer, {window, {get_window_size, Window_id, Tag}}}.
-file("src/plushie/command.gleam", 695).
?DOC(" Query the position of a window. Result arrives as a SystemInfo event.\n").
-spec window_position(binary(), binary()) -> command(any()).
window_position(Window_id, Tag) ->
{renderer, {window, {get_window_position, Window_id, Tag}}}.
-file("src/plushie/command.gleam", 700).
?DOC(" Query whether a window is maximized. Result arrives as a SystemInfo event.\n").
-spec is_maximized(binary(), binary()) -> command(any()).
is_maximized(Window_id, Tag) ->
{renderer, {window, {is_maximized, Window_id, Tag}}}.
-file("src/plushie/command.gleam", 705).
?DOC(" Query whether a window is minimized. Result arrives as a SystemInfo event.\n").
-spec is_minimized(binary(), binary()) -> command(any()).
is_minimized(Window_id, Tag) ->
{renderer, {window, {is_minimized, Window_id, Tag}}}.
-file("src/plushie/command.gleam", 711).
?DOC(
" Query the current window mode (windowed, fullscreen, hidden).\n"
" Result arrives as a SystemInfo event.\n"
).
-spec window_mode(binary(), binary()) -> command(any()).
window_mode(Window_id, Tag) ->
{renderer, {window, {get_mode, Window_id, Tag}}}.
-file("src/plushie/command.gleam", 716).
?DOC(" Query the window's DPI scale factor. Result arrives as a SystemInfo event.\n").
-spec scale_factor(binary(), binary()) -> command(any()).
scale_factor(Window_id, Tag) ->
{renderer, {window, {get_scale_factor, Window_id, Tag}}}.
-file("src/plushie/command.gleam", 722).
?DOC(
" Query the raw platform window ID (e.g. X11 window ID, HWND).\n"
" Result arrives as a SystemInfo event.\n"
).
-spec raw_window_id(binary(), binary()) -> command(any()).
raw_window_id(Window_id, Tag) ->
{renderer, {window, {raw_window_id, Window_id, Tag}}}.
-file("src/plushie/command.gleam", 728).
?DOC(
" Query the monitor size for the display containing a window.\n"
" Result arrives as a SystemInfo event.\n"
).
-spec monitor_size(binary(), binary()) -> command(any()).
monitor_size(Window_id, Tag) ->
{renderer, {window, {monitor_size, Window_id, Tag}}}.
-file("src/plushie/command.gleam", 736).
?DOC(
" Set whether the system can automatically organize windows into\n"
" tabs. macOS-specific; no-op on other platforms.\n"
).
-spec allow_automatic_tabbing(boolean()) -> command(any()).
allow_automatic_tabbing(Enabled) ->
{renderer, {system, {allow_automatic_tabbing, Enabled}}}.
-file("src/plushie/command.gleam", 743).
?DOC(
" Query the OS light/dark theme preference. Result arrives as a\n"
" SystemTheme event with \"light\", \"dark\", or \"none\". Use\n"
" theme.system_theme_from_string to convert concrete preferences.\n"
).
-spec system_theme(binary()) -> command(any()).
system_theme(Tag) ->
{renderer, {system, {get_system_theme, Tag}}}.
-file("src/plushie/command.gleam", 749).
?DOC(
" Query system information (OS, CPU, memory, graphics). Result\n"
" arrives as a SystemInfo event with a map of system fields.\n"
).
-spec system_info(binary()) -> command(any()).
system_info(Tag) ->
{renderer, {system, {get_system_info, Tag}}}.
-file("src/plushie/command.gleam", 756).
?DOC(" Update an existing image handle with new encoded data.\n").
-spec update_image(binary(), bitstring()) -> command(any()).
update_image(Handle, Data) ->
{renderer, {image, {update_image, Handle, Data}}}.
-file("src/plushie/command.gleam", 762).
?DOC(
" List all registered image handles. Result arrives as an\n"
" ImageList event.\n"
).
-spec list_images(binary()) -> command(any()).
list_images(Tag) ->
{renderer, {image, {list_images, Tag}}}.
-file("src/plushie/command.gleam", 771).
?DOC(
" Load a font at runtime from raw TrueType or OpenType binary data.\n"
" `family` is the name the app uses to reference the font in\n"
" `default_font` and widget font props.\n"
).
-spec load_font(binary(), bitstring()) -> command(any()).
load_font(Family, Data) ->
{renderer, {load_font, Family, Data}}.
-file("src/plushie/command.gleam", 780).
?DOC(
" Send a command directly to a native widget, bypassing the\n"
" normal tree diff/patch cycle. Operation names must start with\n"
" lowercase ASCII and may contain lowercase ASCII, digits, `_`, or `:`.\n"
" Prefer `native_widget.command` when you have a `NativeDef`; it also\n"
" checks the operation against the widget's declared commands.\n"
).
-spec native_command(
binary(),
binary(),
gleam@dict:dict(binary(), plushie@node:prop_value())
) -> command(any()).
native_command(Node_id, Op, Payload) ->
{renderer, {native_command, Node_id, Op, Payload}}.
-file("src/plushie/command.gleam", 792).
?DOC(
" Send a batch of native widget commands processed in one cycle.\n"
" Each tuple is `#(node_id, op, payload)`. The same operation-name\n"
" rule as `native_command` applies. A batch with any invalid operation\n"
" is dropped by the encoder.\n"
).
-spec widget_batch(
list({binary(),
binary(),
gleam@dict:dict(binary(), plushie@node:prop_value())})
) -> command(any()).
widget_batch(Commands) ->
{renderer, {native_commands, Commands}}.
-file("src/plushie/command.gleam", 808).
-spec is_native_op_start(binary()) -> boolean().
is_native_op_start(Char) ->
gleam@list:contains(
[<<"a"/utf8>>,
<<"b"/utf8>>,
<<"c"/utf8>>,
<<"d"/utf8>>,
<<"e"/utf8>>,
<<"f"/utf8>>,
<<"g"/utf8>>,
<<"h"/utf8>>,
<<"i"/utf8>>,
<<"j"/utf8>>,
<<"k"/utf8>>,
<<"l"/utf8>>,
<<"m"/utf8>>,
<<"n"/utf8>>,
<<"o"/utf8>>,
<<"p"/utf8>>,
<<"q"/utf8>>,
<<"r"/utf8>>,
<<"s"/utf8>>,
<<"t"/utf8>>,
<<"u"/utf8>>,
<<"v"/utf8>>,
<<"w"/utf8>>,
<<"x"/utf8>>,
<<"y"/utf8>>,
<<"z"/utf8>>],
Char
).
-file("src/plushie/command.gleam", 812).
-spec is_native_op_rest(binary()) -> boolean().
is_native_op_rest(Char) ->
(is_native_op_start(Char) orelse gleam@list:contains(
[<<"0"/utf8>>,
<<"1"/utf8>>,
<<"2"/utf8>>,
<<"3"/utf8>>,
<<"4"/utf8>>,
<<"5"/utf8>>,
<<"6"/utf8>>,
<<"7"/utf8>>,
<<"8"/utf8>>,
<<"9"/utf8>>],
Char
))
orelse gleam@list:contains([<<"_"/utf8>>, <<":"/utf8>>], Char).
-file("src/plushie/command.gleam", 800).
?DOC(
" Returns whether a native widget operation name is safe for the wire\n"
" protocol. Widget-specific allowlists live in `native_widget.NativeDef`.\n"
).
-spec is_valid_native_op(binary()) -> boolean().
is_valid_native_op(Op) ->
case gleam@string:to_graphemes(Op) of
[] ->
false;
[First | Rest] ->
is_native_op_start(First) andalso gleam@list:all(
Rest,
fun is_native_op_rest/1
)
end.