diff options
author | Simponic <loganhunt@simponic.xyz> | 2023-01-11 14:21:48 -0700 |
---|---|---|
committer | Simponic <loganhunt@simponic.xyz> | 2023-01-11 14:21:48 -0700 |
commit | 628c6d95a32ba0dea67ab046a480ddfca7432c9b (patch) | |
tree | 4405ecd2fbee6027897706884d70ac5dd5de418b /lib/chessh/ssh/client/screen.ex | |
parent | 2ce03d4796ad54f332c70ff88f0a9f3a164bbc4a (diff) | |
download | chessh-628c6d95a32ba0dea67ab046a480ddfca7432c9b.tar.gz chessh-628c6d95a32ba0dea67ab046a480ddfca7432c9b.zip |
Done moving menu to genserver architecture
Diffstat (limited to 'lib/chessh/ssh/client/screen.ex')
-rw-r--r-- | lib/chessh/ssh/client/screen.ex | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/chessh/ssh/client/screen.ex b/lib/chessh/ssh/client/screen.ex index 2dd9f9c..8eb9f21 100644 --- a/lib/chessh/ssh/client/screen.ex +++ b/lib/chessh/ssh/client/screen.ex @@ -1,21 +1,18 @@ defmodule Chessh.SSH.Client.Screen do - @callback handle_info( - {:render, width :: integer(), height :: integer()}, - state :: any() - ) :: - {:noreply, any()} - @callback handle_info({:input, width :: integer(), height :: integer(), action :: any()}) :: - {:noreply, any()} - - # @callback render(state :: Chessh.SSH.Client.State.t() | any()) :: any() - # @callback handle_input(action :: any(), state :: Chessh.SSH.Client.State.t()) :: - # Chessh.SSH.Client.State.t() + @callback render(width :: integer(), height :: integer(), state :: any()) :: any() + @callback input(width :: integer(), height :: integer(), action :: any(), state :: any()) :: + any() defmacro __using__(_) do quote do @behaviour Chessh.SSH.Client.Screen use GenServer + @clear_codes [ + IO.ANSI.clear(), + IO.ANSI.home() + ] + @ascii_chars Application.compile_env!(:chessh, :ascii_chars_json_file) |> File.read!() |> Jason.decode!() @@ -26,6 +23,12 @@ defmodule Chessh.SSH.Client.Screen do div(parent_width - rect_width, 2) } end + + def handle_info({:render, width, height}, state), + do: {:noreply, render(width, height, state)} + + def handle_info({:input, width, height, action}, state), + do: {:noreply, input(width, height, action, state)} end end end |