Skip to content

Commit ca17bbe

Browse files
committed
color fixes
1 parent 659dad4 commit ca17bbe

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

default_config.py

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def initialize_config():
5050
"ack_unknown_str": "[…]",
5151
"COLOR_CONFIG": {
5252
"default": ["white", "black"],
53+
"background": [" ", "black"],
5354
"splash_logo": ["green", "black"],
5455
"splash_text": ["white", "black"],
5556
"input": ["white", "black"],

input_handlers.py

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import curses
22
import ipaddress
3+
from ui.colors import get_color
34

45
def get_user_input(prompt):
56
# Calculate the dynamic height and width for the input window
@@ -10,6 +11,8 @@ def get_user_input(prompt):
1011

1112
# Create a new window for user input
1213
input_win = curses.newwin(height, width, start_y, start_x)
14+
input_win.bkgd(get_color("background"))
15+
input_win.attrset(get_color("window_frame"))
1316
input_win.border()
1417

1518
# Display the prompt
@@ -54,6 +57,8 @@ def get_bool_selection(message, current_value):
5457
start_x = (curses.COLS - width) // 2
5558

5659
bool_win = curses.newwin(height, width, start_y, start_x)
60+
bool_win.bkgd(get_color("background"))
61+
bool_win.attrset(get_color("window_frame"))
5762
bool_win.keypad(True)
5863

5964
while True:
@@ -63,9 +68,9 @@ def get_bool_selection(message, current_value):
6368

6469
for idx, option in enumerate(options):
6570
if idx == selected_index:
66-
bool_win.addstr(idx + 3, 4, option, curses.A_REVERSE)
71+
bool_win.addstr(idx + 3, 4, option, get_color("settings_default", reverse=True))
6772
else:
68-
bool_win.addstr(idx + 3, 4, option)
73+
bool_win.addstr(idx + 3, 4, option, get_color("settings_default"))
6974

7075
bool_win.refresh()
7176
key = bool_win.getch()
@@ -87,6 +92,8 @@ def get_repeated_input(current_value):
8792
start_x = (curses.COLS - width) // 2
8893

8994
repeated_win = curses.newwin(height, width, start_y, start_x)
95+
repeated_win.bkgd(get_color("background"))
96+
repeated_win.attrset(get_color("window_frame"))
9097
repeated_win.keypad(True) # Enable keypad for special keys
9198

9299
curses.echo()
@@ -128,18 +135,20 @@ def get_enum_input(options, current_value):
128135
start_x = (curses.COLS - width) // 2
129136

130137
enum_win = curses.newwin(height, width, start_y, start_x)
138+
enum_win.bkgd(get_color("background"))
139+
enum_win.attrset(get_color("window_frame"))
131140
enum_win.keypad(True)
132141

133142
while True:
134143
enum_win.clear()
135144
enum_win.border()
136-
enum_win.addstr(1, 2, "Select an option:", curses.A_BOLD)
145+
enum_win.addstr(1, 2, "Select an option:", get_color("settings_default", bold=True))
137146

138147
for idx, option in enumerate(options):
139148
if idx == selected_index:
140-
enum_win.addstr(idx + 2, 4, option, curses.A_REVERSE)
149+
enum_win.addstr(idx + 2, 4, option, get_color("settings_default", reverse=True))
141150
else:
142-
enum_win.addstr(idx + 2, 4, option)
151+
enum_win.addstr(idx + 2, 4, option, get_color("settings_default"))
143152

144153
enum_win.refresh()
145154
key = enum_win.getch()
@@ -163,6 +172,8 @@ def get_fixed32_input(current_value):
163172
start_x = (curses.COLS - width) // 2
164173

165174
fixed32_win = curses.newwin(height, width, start_y, start_x)
175+
fixed32_win.bkgd(get_color("background"))
176+
fixed32_win.attrset(get_color("window_frame"))
166177
fixed32_win.keypad(True)
167178

168179
curses.echo()

settings.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def display_menu(current_menu, menu_path, selected_index, show_save_option):
2626
menu_win = curses.newwin(height, width, start_y, start_x)
2727
menu_win.clear()
2828
menu_win.attrset((get_color("window_frame")))
29+
menu_win.bkgd(get_color("background"))
30+
menu_win.attrset(get_color("window_frame"))
2931
menu_win.border()
3032
menu_win.keypad(True)
3133

@@ -66,12 +68,12 @@ def move_highlight(old_idx, new_idx, options, show_save_option, menu_win):
6668
if show_save_option and old_idx == max_index: # special case un-highlight "Save" option
6769
menu_win.chgat(max_index + 4, (width - len(save_option)) // 2, len(save_option), get_color("settings_save"))
6870
else:
69-
menu_win.chgat(old_idx + 3, 4, width - 8, get_color("settings_sensitive" if options[old_idx] in sensitive_settings else "default"))
71+
menu_win.chgat(old_idx + 3, 4, width - 8, get_color("settings_sensitive" if options[old_idx] in sensitive_settings else "settings_default"))
7072

7173
if show_save_option and new_idx == max_index: # special case highlight "Save" option
7274
menu_win.chgat(max_index + 4, (width - len(save_option)) // 2, len(save_option), get_color("settings_save", reverse = True))
7375
else:
74-
menu_win.chgat(new_idx + 3, 4, width - 8, get_color("settings_sensitive" if options[new_idx] in sensitive_settings else "default", reverse = True))
76+
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))
7577

7678
menu_win.refresh()
7779

ui/curses_ui.py

+13
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def draw_splash(stdscr):
105105
stdscr.addstr(start_y+2, start_x-2, message_3, get_color("splash_logo", bold=True))
106106
stdscr.addstr(start_y+4, start_x2, message_4, get_color("splash_text"))
107107
stdscr.attrset(get_color("window_frame"))
108+
stdscr.bkgd(get_color("background"))
108109
stdscr.box()
109110
stdscr.refresh()
110111
curses.napms(500)
@@ -318,14 +319,26 @@ def main_ui(stdscr):
318319
messages_box = curses.newwin(height - 6, messages_width, 3, channel_width)
319320
nodes_box = curses.newwin(height - 6, nodes_width, 3, channel_width + messages_width)
320321

322+
entry_win.bkgd(get_color("background"))
323+
channel_box.bkgd(get_color("background"))
324+
messages_box.bkgd(get_color("background"))
325+
nodes_box.bkgd(get_color("background"))
326+
321327
# Will be resized to what we need when drawn
322328
messages_pad = curses.newpad(1, 1)
323329
nodes_pad = curses.newpad(1,1)
324330
channel_pad = curses.newpad(1,1)
325331

332+
messages_pad.bkgd(get_color("background"))
333+
nodes_pad.bkgd(get_color("background"))
334+
channel_pad.bkgd(get_color("background"))
335+
326336
function_win = curses.newwin(3, width, height - 3, 0)
327337
packetlog_win = curses.newwin(int(height / 3), messages_width, height - int(height / 3) - 3, channel_width)
328338

339+
function_win.bkgd(get_color("background"))
340+
packetlog_win.bkgd(get_color("background"))
341+
329342
draw_centered_text_field(function_win, f"↑→↓← = Select ENTER = Send ` = Settings ^P = Packet Log ESC = Quit",0 ,get_color("commands"))
330343

331344
# Draw boxes around windows

0 commit comments

Comments
 (0)