diff options
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 |