From eec32aa38a8762eccc8575a37a628bd5ae2cc1d0 Mon Sep 17 00:00:00 2001 From: "Elizabeth (Lizzy) Hunt" Date: Mon, 29 May 2023 16:28:27 -0700 Subject: Bots (#23) * squash all the things for bots * fix warnings * change colors a bit and README updates * fix frontend warnings --- .../ssh/client/menus/select_paginate_poller.ex | 83 ++++++++++++---------- 1 file changed, 44 insertions(+), 39 deletions(-) (limited to 'lib/chessh/ssh/client/menus/select_paginate_poller.ex') diff --git a/lib/chessh/ssh/client/menus/select_paginate_poller.ex b/lib/chessh/ssh/client/menus/select_paginate_poller.ex index adca697..23808b5 100644 --- a/lib/chessh/ssh/client/menus/select_paginate_poller.ex +++ b/lib/chessh/ssh/client/menus/select_paginate_poller.ex @@ -26,7 +26,8 @@ defmodule Chessh.SSH.Client.SelectPaginatePoller do player_session: nil, options: [], tick: 0, - cursor: nil + cursor: nil, + extra_info: %{} end defmacro __using__(_) do @@ -127,51 +128,55 @@ defmodule Chessh.SSH.Client.SelectPaginatePoller do max_item = min(length(options), max_displayed_options()) new_state = - if(max_item > 0, - do: - case action do - :up -> - %State{ - state - | selected_option_idx: Utils.wrap_around(selected_option_idx, -1, max_item), - tick: 0 - } - - :down -> - %State{ - state - | selected_option_idx: Utils.wrap_around(selected_option_idx, 1, max_item), - tick: 0 - } - - :left -> - if dynamic_options(), - do: %State{ + if max_item > 0 do + if action == :return do + {_, selected} = Enum.at(options, selected_option_idx) + {module, state} = make_process_tuple(selected, state) + send(client_pid, {:set_screen_process, module, state}) + state + else + if(max_item > 1) do + case action do + :up -> + %State{ state - | options: previous_page_options(state), - selected_option_idx: 0, + | selected_option_idx: Utils.wrap_around(selected_option_idx, -1, max_item), tick: 0 } - :right -> - if dynamic_options(), - do: %State{ + :down -> + %State{ state - | options: next_page_options(state), - selected_option_idx: 0, + | selected_option_idx: Utils.wrap_around(selected_option_idx, 1, max_item), tick: 0 } - :return -> - {_, selected} = Enum.at(options, selected_option_idx) - {module, state} = make_process_tuple(selected, state) - send(client_pid, {:set_screen_process, module, state}) - state - - _ -> - nil + :left -> + if dynamic_options(), + do: %State{ + state + | options: previous_page_options(state), + selected_option_idx: 0, + tick: 0 + } + + :right -> + if dynamic_options(), + do: %State{ + state + | options: next_page_options(state), + selected_option_idx: 0, + tick: 0 + } + + _ -> + state + end + else + state end - ) || state + end + end if !(action == :return) do render(width, height, new_state) @@ -229,7 +234,7 @@ defmodule Chessh.SSH.Client.SelectPaginatePoller do if i == selected_option_idx do ANSI.format_fragment( - [:light_cyan, :bright, "> #{line} <", :reset], + [:light_cyan, :bright, "♜ #{line} ♜", :reset], true ) else @@ -238,7 +243,7 @@ defmodule Chessh.SSH.Client.SelectPaginatePoller do end ) else - ["Looks like there's nothing here.", "Use Ctrl+b to go back."] + ["Looks like there's nothing here.", "Use Ctrl+b return to the menu."] end end -- cgit v1.2.3-70-g09d2