-module(examples@hello_world). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/examples/hello_world.gleam"). -export([main/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(false). -file("src/examples/hello_world.gleam", 32). ?DOC(false). -spec draw_centered_text(integer(), integer()) -> nil. draw_centered_text(X, Y) -> S = <<" Hello from Etch! "/utf8>>, Len = string:length(S), S@1 = begin _pipe = etch@style:with_on(S, black, {ansi_value, 40}), etch@style:reset_color(_pipe) end, Red = begin _pipe@1 = <<"█"/utf8>>, _pipe@2 = gleam@string:repeat(_pipe@1, Len), etch@style:with(_pipe@2, {rgb, 233, 51, 35}) end, Orange = begin _pipe@3 = <<"█"/utf8>>, _pipe@4 = gleam@string:repeat(_pipe@3, Len), etch@style:with(_pipe@4, {rgb, 241, 161, 57}) end, Yellow = begin _pipe@5 = <<"█"/utf8>>, _pipe@6 = gleam@string:repeat(_pipe@5, Len), etch@style:with(_pipe@6, {ansi_value, 226}) end, Light_blue = begin _pipe@7 = <<"█"/utf8>>, _pipe@8 = gleam@string:repeat(_pipe@7, Len), etch@style:with(_pipe@8, {rgb, 74, 163, 228}) end, Blue = begin _pipe@9 = <<"█"/utf8>>, _pipe@10 = gleam@string:repeat(_pipe@9, Len), etch@style:blue(_pipe@10) end, Purple = begin _pipe@11 = <<"█"/utf8>>, _pipe@12 = gleam@string:repeat(_pipe@11, Len), etch@style:magenta(_pipe@12) end, X_offset = Len div 2, X@1 = (X div 2) - X_offset, etch@stdout:execute( [{clear, all}, {move_to, X@1, (Y div 2) - 3}, {print, Red}, {move_to, X@1, (Y div 2) - 2}, {print, Orange}, {move_to, X@1, (Y div 2) - 1}, {print, Yellow}, {move_to, X@1, Y div 2}, {print, S@1}, {move_to, X@1, (Y div 2) + 1}, {print, Light_blue}, {move_to, X@1, (Y div 2) + 2}, {print, Blue}, {move_to, X@1, (Y div 2) + 3}, {print, Purple}] ). -file("src/examples/hello_world.gleam", 22). ?DOC(false). -spec handle_input() -> nil. handle_input() -> case event_ffi:read() of {some, {ok, {resize, X, Y}}} -> draw_centered_text(X, Y); {some, _} -> nil; none -> nil end. -file("src/examples/hello_world.gleam", 17). ?DOC(false). -spec loop() -> any(). loop() -> handle_input(), loop(). -file("src/examples/hello_world.gleam", 9). ?DOC(false). -spec main() -> any(). main() -> etch@stdout:execute([hide_cursor]), {X, Y} = terminal_ffi:window_size(), draw_centered_text(X, Y), etch@event:init_event_server(), loop().