summaryrefslogtreecommitdiff
path: root/lib/chessh/ssh/screens/board.ex
diff options
context:
space:
mode:
authorLogan Hunt <logan.hunt@usu.edu>2023-01-04 15:22:28 -0700
committerLogan Hunt <logan.hunt@usu.edu>2023-01-04 15:22:28 -0700
commit1536d0192f9bb0490d64d58b4da22d12076a25af (patch)
tree5cc09ab0fa621efeb8a36c317eb5e53103846f18 /lib/chessh/ssh/screens/board.ex
parent93ae544684b29db30c6c65a5ba5e7cb51972123c (diff)
downloadchessh-1536d0192f9bb0490d64d58b4da22d12076a25af.tar.gz
chessh-1536d0192f9bb0490d64d58b4da22d12076a25af.zip
Move to a new state when menu option selected
Diffstat (limited to 'lib/chessh/ssh/screens/board.ex')
-rw-r--r--lib/chessh/ssh/screens/board.ex26
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/chessh/ssh/screens/board.ex b/lib/chessh/ssh/screens/board.ex
index 7b22052..c95049f 100644
--- a/lib/chessh/ssh/screens/board.ex
+++ b/lib/chessh/ssh/screens/board.ex
@@ -1,14 +1,30 @@
defmodule Chessh.SSH.Client.Board do
+ alias Chessh.SSH.Client
+ alias IO.ANSI
+
+ require Logger
+
+ defmodule State do
+ defstruct cursor_x: 0,
+ cursor_y: 0
+ end
+
use Chessh.SSH.Client.Screen
- alias Chessh.SSH.Client.State
- def render(%State{} = _state) do
- @ascii_chars["pieces"]["white"]["knight"]
+ def render(%Client.State{} = _state) do
+ knight = @ascii_chars["pieces"]["white"]["knight"]
+
+ [ANSI.home()] ++
+ Enum.map(
+ Enum.zip(0..(length(knight) - 1), knight),
+ fn {i, line} ->
+ [ANSI.cursor(i, 0), line]
+ end
+ )
end
- def handle_input(action, state) do
+ def handle_input(action, %Client.State{} = state) do
case action do
- "q" -> state
_ -> state
end
end