Packages

A Gleam TUI (terminal user interface) framework targeting erlang

Current section

Files

Jump to
shore src shore@ui.erl
Raw

src/shore@ui.erl

-module(shore@ui).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-define(FILEPATH, "src/shore/ui.gleam").
-export([align/2, bar/1, bar2/2, box/2, br/0, button/3, col/1, debug/0, graph/3, hr/0, hr_styled/1, input/4, input_hidden/4, keybind/2, progress/4, row/1, table/2, table_kv/2, text/1, text_styled/3]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-file("src/shore/ui.gleam", 7).
?DOC(" Sets alignment of all child nodes\n").
-spec align(shore@style:align(), shore@internal:node_(GUN)) -> shore@internal:node_(GUN).
align(Alignment, Node) ->
{aligned, Alignment, Node}.
-file("src/shore/ui.gleam", 12).
?DOC(" A row with a background color\n").
-spec bar(shore@style:color()) -> shore@internal:node_(any()).
bar(Color) ->
{bar, Color}.
-file("src/shore/ui.gleam", 17).
?DOC(" A row with a background color, containing items\n").
-spec bar2(shore@style:color(), shore@internal:node_(GUS)) -> shore@internal:node_(GUS).
bar2(Color, Node) ->
{bar2, Color, Node}.
-file("src/shore/ui.gleam", 22).
?DOC(" A box container element for holding other nodes\n").
-spec box(list(shore@internal:node_(GUV)), gleam@option:option(binary())) -> shore@internal:node_(GUV).
box(Children, Title) ->
{box, Children, Title}.
-file("src/shore/ui.gleam", 27).
?DOC(" An empty line\n").
-spec br() -> shore@internal:node_(any()).
br() ->
b_r.
-file("src/shore/ui.gleam", 32).
?DOC(" A button assigned to a key press to execute an event\n").
-spec button(binary(), shore@key:key(), GVC) -> shore@internal:node_(GVC).
button(Text, Key, Event) ->
{button, Text, Key, Event}.
-file("src/shore/ui.gleam", 37).
?DOC(" A container element for holding other nodes over multiple lines\n").
-spec col(list(shore@internal:node_(GVE))) -> shore@internal:node_(GVE).
col(Children) ->
{col, Children}.
-file("src/shore/ui.gleam", 42).
?DOC(" Prints some positional information for developer debugging\n").
-spec debug() -> shore@internal:node_(any()).
debug() ->
debug.
-file("src/shore/ui.gleam", 47).
?DOC(" An extremely simple plot\n").
-spec graph(shore@style:size(), shore@style:size(), list(float())) -> shore@internal:node_(any()).
graph(Width, Height, Points) ->
{graph, Width, Height, Points}.
-file("src/shore/ui.gleam", 56).
?DOC(" A horizontal line\n").
-spec hr() -> shore@internal:node_(any()).
hr() ->
h_r.
-file("src/shore/ui.gleam", 61).
?DOC(" A colored horizontal line\n").
-spec hr_styled(shore@style:color()) -> shore@internal:node_(any()).
hr_styled(Color) ->
{h_r2, Color}.
-file("src/shore/ui.gleam", 66).
?DOC(" A field for text input\n").
-spec input(binary(), binary(), shore@style:size(), fun((binary()) -> GVR)) -> shore@internal:node_(GVR).
input(Label, Value, Width, Event) ->
{input, Label, Value, Width, Event, false}.
-file("src/shore/ui.gleam", 76).
?DOC(" A field for text input with the content display hidden, useful for password fields\n").
-spec input_hidden(
binary(),
binary(),
shore@style:size(),
fun((binary()) -> GVT)
) -> shore@internal:node_(GVT).
input_hidden(Label, Value, Width, Event) ->
{input, Label, Value, Width, Event, true}.
-file("src/shore/ui.gleam", 86).
?DOC(" A non-visible button assigned to a key press to execute an event\n").
-spec keybind(shore@key:key(), GVV) -> shore@internal:node_(GVV).
keybind(Key, Event) ->
{key_bind, Key, Event}.
-file("src/shore/ui.gleam", 91).
?DOC(" A progress bar, will automatically calculate fill percent based off max and current values\n").
-spec progress(shore@style:size(), integer(), integer(), shore@style:color()) -> shore@internal:node_(any()).
progress(Width, Max, Value, Color) ->
{progress, Width, Max, Value, Color}.
-file("src/shore/ui.gleam", 101).
?DOC(" A container element for holding other nodes in a single line\n").
-spec row(list(shore@internal:node_(GVZ))) -> shore@internal:node_(GVZ).
row(Children) ->
{row, Children}.
-file("src/shore/ui.gleam", 106).
?DOC(" A table layout\n").
-spec table(shore@style:size(), list(list(binary()))) -> shore@internal:node_(any()).
table(Width, Table) ->
{table, Width, Table}.
-file("src/shore/ui.gleam", 111).
?DOC(" A Key-Value style table layout\n").
-spec table_kv(shore@style:size(), list(list(binary()))) -> shore@internal:node_(any()).
table_kv(Width, Table) ->
{table_k_v, Width, Table}.
-file("src/shore/ui.gleam", 116).
?DOC(" A text string\n").
-spec text(binary()) -> shore@internal:node_(any()).
text(Text) ->
{text_multi, Text, none, none}.
-file("src/shore/ui.gleam", 121).
?DOC(" A text string with colored foreground and/or background\n").
-spec text_styled(
binary(),
gleam@option:option(shore@style:color()),
gleam@option:option(shore@style:color())
) -> shore@internal:node_(any()).
text_styled(Text, Fg, Bg) ->
{text_multi, Text, Fg, Bg}.