Packages

Native desktop GUI framework for Gleam, powered by Iced

Current section

Files

Jump to
plushie_gleam src plushie@command.erl
Raw

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, done/2, async/2, stream/2, cancel/1, send_after/2, exit/0, focus/1, focus_next/0, focus_previous/0, select_all/1, close_window/1, resize_window/3, move_window/3, maximize_window/1, minimize_window/1, toggle_maximize/1, toggle_decorations/1, gain_focus/1, screenshot/2, announce/1, create_image/2, delete_image/1, clear_images/0, tree_hash/1, find_focused/1, advance_frame/1]).
-export_type([command/1]).
-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(FYX) :: none |
{batch, list(command(FYX))} |
{done, gleam@dynamic:dynamic_(), fun((gleam@dynamic:dynamic_()) -> FYX)} |
{async, fun(() -> gleam@dynamic:dynamic_()), binary()} |
{stream,
fun((fun((gleam@dynamic:dynamic_()) -> nil)) -> gleam@dynamic:dynamic_()),
binary()} |
{cancel, binary()} |
{send_after, integer(), FYX} |
exit |
{focus, binary()} |
focus_next |
focus_previous |
{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(), gleam@dynamic:dynamic_()} |
{snap_to, binary(), float(), float()} |
{snap_to_end, binary()} |
{scroll_by, binary(), float(), float()} |
{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()} |
{gain_focus, 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())} |
{allow_automatic_tabbing, boolean()} |
{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()} |
{get_system_theme, binary()} |
{get_system_info, binary()} |
{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 |
{announce, binary()} |
{pane_split,
binary(),
gleam@dynamic:dynamic_(),
binary(),
gleam@dynamic:dynamic_()} |
{pane_close, binary(), gleam@dynamic:dynamic_()} |
{pane_swap, binary(), gleam@dynamic:dynamic_(), gleam@dynamic:dynamic_()} |
{pane_maximize, binary(), gleam@dynamic:dynamic_()} |
{pane_restore, binary()} |
{tree_hash_query, binary()} |
{find_focused, binary()} |
{load_font, bitstring()} |
{effect,
binary(),
binary(),
gleam@dict:dict(binary(), plushie@node:prop_value())} |
{extension_command,
binary(),
binary(),
gleam@dict:dict(binary(), plushie@node:prop_value())} |
{extension_commands,
list({binary(),
binary(),
gleam@dict:dict(binary(), plushie@node:prop_value())})} |
{advance_frame, integer()}.
-file("src/plushie/command.gleam", 219).
?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", 224).
?DOC(" Execute multiple commands in list order.\n").
-spec batch(list(command(FZA))) -> command(FZA).
batch(Commands) ->
{batch, Commands}.
-file("src/plushie/command.gleam", 231).
?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"
).
-spec done(gleam@dynamic:dynamic_(), fun((gleam@dynamic:dynamic_()) -> FZE)) -> command(FZE).
done(Value, Mapper) ->
{done, Value, Mapper}.
-file("src/plushie/command.gleam", 237).
?DOC(
" Run a function asynchronously on a background process. The result\n"
" is delivered as an AsyncResult event identified by the tag.\n"
).
-spec async(fun(() -> gleam@dynamic:dynamic_()), binary()) -> command(any()).
async(Work, Tag) ->
{async, Work, Tag}.
-file("src/plushie/command.gleam", 243).
?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"
).
-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", 251).
?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", 258).
?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(), FZM) -> command(FZM).
send_after(Delay_ms, Msg) ->
{send_after, Delay_ms, Msg}.
-file("src/plushie/command.gleam", 263).
?DOC(" Shut down the runtime and close all windows.\n").
-spec exit() -> command(any()).
exit() ->
exit.
-file("src/plushie/command.gleam", 268).
?DOC(" Move keyboard focus to the given widget.\n").
-spec focus(binary()) -> command(any()).
focus(Widget_id) ->
{focus, Widget_id}.
-file("src/plushie/command.gleam", 273).
?DOC(" Move focus to the next focusable widget.\n").
-spec focus_next() -> command(any()).
focus_next() ->
focus_next.
-file("src/plushie/command.gleam", 278).
?DOC(" Move focus to the previous focusable widget.\n").
-spec focus_previous() -> command(any()).
focus_previous() ->
focus_previous.
-file("src/plushie/command.gleam", 283).
?DOC(" Select all text in the given text input widget.\n").
-spec select_all(binary()) -> command(any()).
select_all(Widget_id) ->
{select_all, Widget_id}.
-file("src/plushie/command.gleam", 288).
?DOC(" Close the window with the given ID.\n").
-spec close_window(binary()) -> command(any()).
close_window(Window_id) ->
{close_window, Window_id}.
-file("src/plushie/command.gleam", 293).
?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) ->
{resize_window, Window_id, Width, Height}.
-file("src/plushie/command.gleam", 302).
?DOC(" Move a window to the given screen position.\n").
-spec move_window(binary(), float(), float()) -> command(any()).
move_window(Window_id, X, Y) ->
{move_window, Window_id, X, Y}.
-file("src/plushie/command.gleam", 307).
?DOC(" Maximize a window.\n").
-spec maximize_window(binary()) -> command(any()).
maximize_window(Window_id) ->
{maximize_window, Window_id, true}.
-file("src/plushie/command.gleam", 312).
?DOC(" Minimize a window.\n").
-spec minimize_window(binary()) -> command(any()).
minimize_window(Window_id) ->
{minimize_window, Window_id, true}.
-file("src/plushie/command.gleam", 317).
?DOC(" Toggle a window between maximized and restored state.\n").
-spec toggle_maximize(binary()) -> command(any()).
toggle_maximize(Window_id) ->
{toggle_maximize, Window_id}.
-file("src/plushie/command.gleam", 322).
?DOC(" Toggle window decorations (title bar, borders).\n").
-spec toggle_decorations(binary()) -> command(any()).
toggle_decorations(Window_id) ->
{toggle_decorations, Window_id}.
-file("src/plushie/command.gleam", 327).
?DOC(" Give focus to a window, bringing it to the front.\n").
-spec gain_focus(binary()) -> command(any()).
gain_focus(Window_id) ->
{gain_focus, Window_id}.
-file("src/plushie/command.gleam", 332).
?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) ->
{screenshot, Window_id, Tag}.
-file("src/plushie/command.gleam", 337).
?DOC(" Announce text to screen readers via the accessibility system.\n").
-spec announce(binary()) -> command(any()).
announce(Text) ->
{announce, Text}.
-file("src/plushie/command.gleam", 343).
?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) ->
{create_image, Handle, Data}.
-file("src/plushie/command.gleam", 348).
?DOC(" Delete a previously registered image by its handle.\n").
-spec delete_image(binary()) -> command(any()).
delete_image(Handle) ->
{delete_image, Handle}.
-file("src/plushie/command.gleam", 353).
?DOC(" Delete all registered images.\n").
-spec clear_images() -> command(any()).
clear_images() ->
clear_images.
-file("src/plushie/command.gleam", 359).
?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) ->
{tree_hash_query, Tag}.
-file("src/plushie/command.gleam", 365).
?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) ->
{find_focused, Tag}.
-file("src/plushie/command.gleam", 370).
?DOC(" Advance the renderer by one frame in test/headless mode.\n").
-spec advance_frame(integer()) -> command(any()).
advance_frame(Timestamp) ->
{advance_frame, Timestamp}.