color fixes

This commit is contained in:
pdxlocations
2025-01-24 22:12:25 -08:00
parent 659dad493c
commit ca17bbee31
4 changed files with 34 additions and 7 deletions
+1
View File
@@ -50,6 +50,7 @@ def initialize_config():
"ack_unknown_str": "[…]",
"COLOR_CONFIG": {
"default": ["white", "black"],
"background": [" ", "black"],
"splash_logo": ["green", "black"],
"splash_text": ["white", "black"],
"input": ["white", "black"],
+16 -5
View File
@@ -1,5 +1,6 @@
import curses
import ipaddress
from ui.colors import get_color
def get_user_input(prompt):
# Calculate the dynamic height and width for the input window
@@ -10,6 +11,8 @@ def get_user_input(prompt):
# Create a new window for user input
input_win = curses.newwin(height, width, start_y, start_x)
input_win.bkgd(get_color("background"))
input_win.attrset(get_color("window_frame"))
input_win.border()
# Display the prompt
@@ -54,6 +57,8 @@ def get_bool_selection(message, current_value):
start_x = (curses.COLS - width) // 2
bool_win = curses.newwin(height, width, start_y, start_x)
bool_win.bkgd(get_color("background"))
bool_win.attrset(get_color("window_frame"))
bool_win.keypad(True)
while True:
@@ -63,9 +68,9 @@ def get_bool_selection(message, current_value):
for idx, option in enumerate(options):
if idx == selected_index:
bool_win.addstr(idx + 3, 4, option, curses.A_REVERSE)
bool_win.addstr(idx + 3, 4, option, get_color("settings_default", reverse=True))
else:
bool_win.addstr(idx + 3, 4, option)
bool_win.addstr(idx + 3, 4, option, get_color("settings_default"))
bool_win.refresh()
key = bool_win.getch()
@@ -87,6 +92,8 @@ def get_repeated_input(current_value):
start_x = (curses.COLS - width) // 2
repeated_win = curses.newwin(height, width, start_y, start_x)
repeated_win.bkgd(get_color("background"))
repeated_win.attrset(get_color("window_frame"))
repeated_win.keypad(True) # Enable keypad for special keys
curses.echo()
@@ -128,18 +135,20 @@ def get_enum_input(options, current_value):
start_x = (curses.COLS - width) // 2
enum_win = curses.newwin(height, width, start_y, start_x)
enum_win.bkgd(get_color("background"))
enum_win.attrset(get_color("window_frame"))
enum_win.keypad(True)
while True:
enum_win.clear()
enum_win.border()
enum_win.addstr(1, 2, "Select an option:", curses.A_BOLD)
enum_win.addstr(1, 2, "Select an option:", get_color("settings_default", bold=True))
for idx, option in enumerate(options):
if idx == selected_index:
enum_win.addstr(idx + 2, 4, option, curses.A_REVERSE)
enum_win.addstr(idx + 2, 4, option, get_color("settings_default", reverse=True))
else:
enum_win.addstr(idx + 2, 4, option)
enum_win.addstr(idx + 2, 4, option, get_color("settings_default"))
enum_win.refresh()
key = enum_win.getch()
@@ -163,6 +172,8 @@ def get_fixed32_input(current_value):
start_x = (curses.COLS - width) // 2
fixed32_win = curses.newwin(height, width, start_y, start_x)
fixed32_win.bkgd(get_color("background"))
fixed32_win.attrset(get_color("window_frame"))
fixed32_win.keypad(True)
curses.echo()
+4 -2
View File
@@ -26,6 +26,8 @@ def display_menu(current_menu, menu_path, selected_index, show_save_option):
menu_win = curses.newwin(height, width, start_y, start_x)
menu_win.clear()
menu_win.attrset((get_color("window_frame")))
menu_win.bkgd(get_color("background"))
menu_win.attrset(get_color("window_frame"))
menu_win.border()
menu_win.keypad(True)
@@ -66,12 +68,12 @@ def move_highlight(old_idx, new_idx, options, show_save_option, menu_win):
if show_save_option and old_idx == max_index: # special case un-highlight "Save" option
menu_win.chgat(max_index + 4, (width - len(save_option)) // 2, len(save_option), get_color("settings_save"))
else:
menu_win.chgat(old_idx + 3, 4, width - 8, get_color("settings_sensitive" if options[old_idx] in sensitive_settings else "default"))
menu_win.chgat(old_idx + 3, 4, width - 8, get_color("settings_sensitive" if options[old_idx] in sensitive_settings else "settings_default"))
if show_save_option and new_idx == max_index: # special case highlight "Save" option
menu_win.chgat(max_index + 4, (width - len(save_option)) // 2, len(save_option), get_color("settings_save", reverse = True))
else:
menu_win.chgat(new_idx + 3, 4, width - 8, get_color("settings_sensitive" if options[new_idx] in sensitive_settings else "default", reverse = True))
menu_win.chgat(new_idx + 3, 4, width - 8, get_color("settings_sensitive" if options[new_idx] in sensitive_settings else "settings_default", reverse = True))
menu_win.refresh()
+13
View File
@@ -105,6 +105,7 @@ def draw_splash(stdscr):
stdscr.addstr(start_y+2, start_x-2, message_3, get_color("splash_logo", bold=True))
stdscr.addstr(start_y+4, start_x2, message_4, get_color("splash_text"))
stdscr.attrset(get_color("window_frame"))
stdscr.bkgd(get_color("background"))
stdscr.box()
stdscr.refresh()
curses.napms(500)
@@ -318,14 +319,26 @@ def main_ui(stdscr):
messages_box = curses.newwin(height - 6, messages_width, 3, channel_width)
nodes_box = curses.newwin(height - 6, nodes_width, 3, channel_width + messages_width)
entry_win.bkgd(get_color("background"))
channel_box.bkgd(get_color("background"))
messages_box.bkgd(get_color("background"))
nodes_box.bkgd(get_color("background"))
# Will be resized to what we need when drawn
messages_pad = curses.newpad(1, 1)
nodes_pad = curses.newpad(1,1)
channel_pad = curses.newpad(1,1)
messages_pad.bkgd(get_color("background"))
nodes_pad.bkgd(get_color("background"))
channel_pad.bkgd(get_color("background"))
function_win = curses.newwin(3, width, height - 3, 0)
packetlog_win = curses.newwin(int(height / 3), messages_width, height - int(height / 3) - 3, channel_width)
function_win.bkgd(get_color("background"))
packetlog_win.bkgd(get_color("background"))
draw_centered_text_field(function_win, f"↑→↓← = Select ENTER = Send ` = Settings ^P = Packet Log ESC = Quit",0 ,get_color("commands"))
# Draw boxes around windows