diff --git a/input_handlers.py b/input_handlers.py index 86a18d8..36b71fb 100644 --- a/input_handlers.py +++ b/input_handlers.py @@ -26,8 +26,10 @@ def get_user_input(prompt): curses.curs_set(1) user_input = "" + input_position = (3, 15) # Tuple for row and column + row, col = input_position # Unpack tuple while True: - key = input_win.get_wch(3, 15 + len(user_input)) # Adjust cursor position dynamically + key = input_win.get_wch(row, col + len(user_input)) # Adjust cursor position dynamically if key == chr(27) or key == curses.KEY_LEFT: # ESC or Left Arrow curses.curs_set(0) return None # Exit without returning a value @@ -35,8 +37,8 @@ def get_user_input(prompt): break elif key in (curses.KEY_BACKSPACE, chr(127)): # Backspace user_input = user_input[:-1] - input_win.addstr(3, 15, " " * (len(user_input) + 1), get_color("settings_default")) # Clear the line - input_win.addstr(3, 15, user_input, get_color("settings_default")) + input_win.addstr(row, col, " " * (len(user_input) + 1), get_color("settings_default")) # Clear the line + input_win.addstr(row, col, user_input, get_color("settings_default")) elif max_length is None or len(user_input) < max_length: # Enforce max length if applicable # Append typed character to input text if(isinstance(key, str)): diff --git a/ui/curses_ui.py b/ui/curses_ui.py index 3293088..276873e 100644 --- a/ui/curses_ui.py +++ b/ui/curses_ui.py @@ -239,9 +239,6 @@ def draw_messages_window(scroll_to_bottom = False): def draw_node_list(): nodes_pad.erase() - win_height = nodes_box.getmaxyx()[0] - start_index = max(0, globals.selected_node - (win_height - 3)) # Calculate starting index based on selected node and window height - nodes_pad.resize(len(globals.node_list), nodes_box.getmaxyx()[1]) for i, node in enumerate(globals.node_list): diff --git a/user_config.py b/user_config.py index 78fc541..613c199 100644 --- a/user_config.py +++ b/user_config.py @@ -1,7 +1,7 @@ import os import json import curses -from ui.colors import get_color, setup_colors +from ui.colors import get_color, setup_colors, COLOR_MAP from default_config import format_json_single_line_arrays, loaded_config width = 60 @@ -12,9 +12,9 @@ def edit_color_pair(key, current_value): """ Allows the user to select a foreground and background color for a key. """ - colors = [" ", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] - fg_color = select_from_list(f"Select Foreground Color for {key}", current_value[0], colors) - bg_color = select_from_list(f"Select Background Color for {key}", current_value[1], colors) + 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) return [fg_color, bg_color] @@ -122,16 +122,17 @@ def edit_value(key, current_value): edit_win.addstr(7, 2, "New Value: ", get_color("settings_default")) curses.curs_set(1) - user_input = "" scroll_offset = 0 # Determines which part of the text is visible - + user_input = "" + input_position = (7, 13) # Tuple for row and column + row, col = input_position # Unpack tuple while True: visible_text = user_input[scroll_offset:scroll_offset + input_width] # Only show what fits - edit_win.addstr(7, 13, " " * input_width, get_color("settings_default")) # Clear previous text - edit_win.addstr(7, 13, visible_text, get_color("settings_default")) # Display text + edit_win.addstr(row, col, " " * input_width, get_color("settings_default")) # Clear previous text + edit_win.addstr(row, col, visible_text, get_color("settings_default")) # Display text edit_win.refresh() - edit_win.move(7, 13 + min(len(user_input) - scroll_offset, input_width)) # Adjust cursor position + edit_win.move(row, col + min(len(user_input) - scroll_offset, input_width)) # Adjust cursor position key = edit_win.get_wch() if key in (chr(27), curses.KEY_LEFT): # ESC or Left Arrow