Refactor Input Handlers (#108)

* bool is just a list

* working changes

* enum is a list too

* spacing
This commit is contained in:
pdxlocations
2025-02-02 16:52:16 -08:00
committed by GitHub
parent 40c2ef62b4
commit 07ce9dfbac
3 changed files with 56 additions and 167 deletions
+5 -5
View File
@@ -3,7 +3,7 @@ import json
import curses
from ui.colors import get_color, setup_colors, COLOR_MAP
from default_config import format_json_single_line_arrays, loaded_config
from input_handlers import select_from_list
from input_handlers import get_list_input
width = 60
save_option_text = "Save Changes"
@@ -14,8 +14,8 @@ def edit_color_pair(key, current_value):
Allows the user to select a foreground and background color for a key.
"""
color_list = [" "] + list(COLOR_MAP.keys())
fg_color = select_from_list(f"Select Foreground Color for {key}", current_value[0], color_list)
bg_color = select_from_list(f"Select Background Color for {key}", current_value[1], color_list)
fg_color = get_list_input(f"Select Foreground Color for {key}", current_value[0], color_list)
bg_color = get_list_input(f"Select Background Color for {key}", current_value[1], color_list)
return [fg_color, bg_color]
@@ -48,10 +48,10 @@ def edit_value(key, current_value):
if key == "theme":
# Load theme names dynamically from the JSON
theme_options = [k.split("_", 2)[2].lower() for k in loaded_config.keys() if k.startswith("COLOR_CONFIG")]
return select_from_list("Select Theme", current_value, theme_options)
return get_list_input("Select Theme", current_value, theme_options)
elif key == "node_sort":
sort_options = ['lastHeard', 'name', 'hops']
return select_from_list("Sort By", current_value, sort_options)
return get_list_input("Sort By", current_value, sort_options)
# Standard Input Mode (Scrollable)
edit_win.addstr(7, 2, "New Value: ", get_color("settings_default"))