summaryrefslogtreecommitdiff
path: root/lib/chessh/ssh/client/screen.ex
diff options
context:
space:
mode:
authorSimponic <loganhunt@simponic.xyz>2023-01-11 09:54:05 -0700
committerSimponic <loganhunt@simponic.xyz>2023-01-11 09:54:05 -0700
commit2ce03d4796ad54f332c70ff88f0a9f3a164bbc4a (patch)
treecb434c2ca105490a3954298c6b69dea3dc576427 /lib/chessh/ssh/client/screen.ex
parent779c75dbe44516c0e1911cf8a56698a1508466b7 (diff)
downloadchessh-2ce03d4796ad54f332c70ff88f0a9f3a164bbc4a.tar.gz
chessh-2ce03d4796ad54f332c70ff88f0a9f3a164bbc4a.zip
Checkpoint\?
Diffstat (limited to 'lib/chessh/ssh/client/screen.ex')
-rw-r--r--lib/chessh/ssh/client/screen.ex31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/chessh/ssh/client/screen.ex b/lib/chessh/ssh/client/screen.ex
new file mode 100644
index 0000000..2dd9f9c
--- /dev/null
+++ b/lib/chessh/ssh/client/screen.ex
@@ -0,0 +1,31 @@
+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()
+
+ defmacro __using__(_) do
+ quote do
+ @behaviour Chessh.SSH.Client.Screen
+ use GenServer
+
+ @ascii_chars Application.compile_env!(:chessh, :ascii_chars_json_file)
+ |> File.read!()
+ |> Jason.decode!()
+
+ def center_rect({rect_width, rect_height}, {parent_width, parent_height}) do
+ {
+ div(parent_height - rect_height, 2),
+ div(parent_width - rect_width, 2)
+ }
+ end
+ end
+ end
+end