mirror of
https://github.com/pdxlocations/contact.git
synced 2026-05-06 05:22:13 +02:00
Replace window.clear() calls with window.erase()
https://lists.gnu.org/archive/html/bug-ncurses/2014-01/msg00007.html
This commit is contained in:
@@ -41,7 +41,7 @@ def get_user_input(prompt):
|
||||
curses.curs_set(0)
|
||||
|
||||
# Clear the input window
|
||||
input_win.clear()
|
||||
input_win.erase()
|
||||
input_win.refresh()
|
||||
return user_input
|
||||
|
||||
@@ -60,7 +60,7 @@ def get_bool_selection(message, current_value):
|
||||
bool_win.bkgd(get_color("background"))
|
||||
bool_win.attrset(get_color("window_frame"))
|
||||
bool_win.keypad(True)
|
||||
bool_win.clear()
|
||||
bool_win.erase()
|
||||
|
||||
bool_win.border()
|
||||
bool_win.addstr(1, 2, message, get_color("settings_default", bold=True))
|
||||
@@ -108,7 +108,7 @@ def get_repeated_input(current_value):
|
||||
user_input = ""
|
||||
|
||||
while True:
|
||||
repeated_win.clear()
|
||||
repeated_win.erase()
|
||||
repeated_win.border()
|
||||
repeated_win.addstr(1, 2, "Enter comma-separated values:", get_color("settings_default", bold=True))
|
||||
repeated_win.addstr(3, 2, f"Current: {', '.join(map(str, current_value))}", get_color("settings_default"))
|
||||
@@ -164,7 +164,7 @@ def get_enum_input(options, current_value):
|
||||
|
||||
enum_pad = curses.newpad(len(options) + 1, width - 8)
|
||||
|
||||
enum_win.clear()
|
||||
enum_win.erase()
|
||||
enum_win.border()
|
||||
enum_win.addstr(1, 2, "Select an option:", get_color("settings_default", bold=True))
|
||||
|
||||
@@ -214,7 +214,7 @@ def get_fixed32_input(current_value):
|
||||
user_input = ""
|
||||
|
||||
while True:
|
||||
fixed32_win.clear()
|
||||
fixed32_win.erase()
|
||||
fixed32_win.border()
|
||||
fixed32_win.addstr(1, 2, "Enter an IP address (xxx.xxx.xxx.xxx):", curses.A_BOLD)
|
||||
fixed32_win.addstr(3, 2, f"Current: {current_value}")
|
||||
|
||||
10
settings.py
10
settings.py
@@ -24,7 +24,7 @@ def display_menu(current_menu, menu_path, selected_index, show_save_option):
|
||||
|
||||
# Create a new curses window with dynamic dimensions
|
||||
menu_win = curses.newwin(height, width, start_y, start_x)
|
||||
menu_win.clear()
|
||||
menu_win.erase()
|
||||
menu_win.bkgd(get_color("background"))
|
||||
menu_win.attrset(get_color("window_frame"))
|
||||
menu_win.border()
|
||||
@@ -137,11 +137,11 @@ def settings_menu(stdscr, interface):
|
||||
|
||||
elif key == curses.KEY_RIGHT or key == ord('\n'):
|
||||
need_redraw = True
|
||||
menu_win.clear()
|
||||
menu_win.erase()
|
||||
menu_win.refresh()
|
||||
if show_save_option and selected_index == len(options):
|
||||
save_changes(interface, menu_path, modified_settings)
|
||||
modified_settings.clear()
|
||||
modified_settings.erase()
|
||||
logging.info("Changes Saved")
|
||||
|
||||
if len(menu_path) > 1:
|
||||
@@ -253,7 +253,7 @@ def settings_menu(stdscr, interface):
|
||||
elif key == curses.KEY_LEFT:
|
||||
need_redraw = True
|
||||
|
||||
menu_win.clear()
|
||||
menu_win.erase()
|
||||
menu_win.refresh()
|
||||
|
||||
modified_settings.clear()
|
||||
@@ -267,7 +267,7 @@ def settings_menu(stdscr, interface):
|
||||
selected_index = menu_index.pop()
|
||||
|
||||
elif key == 27: # Escape key
|
||||
menu_win.clear()
|
||||
menu_win.erase()
|
||||
menu_win.refresh()
|
||||
break
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ def draw_splash(stdscr):
|
||||
|
||||
|
||||
def draw_channel_list():
|
||||
channel_pad.clear()
|
||||
channel_pad.erase()
|
||||
win_height, win_width = channel_box.getmaxyx()
|
||||
start_index = max(0, globals.selected_channel - (win_height - 3)) # Leave room for borders
|
||||
|
||||
@@ -155,7 +155,7 @@ def draw_channel_list():
|
||||
|
||||
def draw_messages_window(scroll_to_bottom = False):
|
||||
"""Update the messages window based on the selected channel and scroll position."""
|
||||
messages_pad.clear()
|
||||
messages_pad.erase()
|
||||
|
||||
channel = globals.channel_list[globals.selected_channel]
|
||||
|
||||
@@ -197,7 +197,7 @@ def draw_messages_window(scroll_to_bottom = False):
|
||||
draw_packetlog_win()
|
||||
|
||||
def draw_node_list():
|
||||
nodes_pad.clear()
|
||||
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
|
||||
|
||||
@@ -272,7 +272,7 @@ def draw_packetlog_win():
|
||||
span = 0
|
||||
|
||||
if globals.display_log:
|
||||
packetlog_win.clear()
|
||||
packetlog_win.erase()
|
||||
height, width = packetlog_win.getmaxyx()
|
||||
|
||||
for column in columns[:-1]:
|
||||
@@ -527,8 +527,7 @@ def main_ui(stdscr):
|
||||
|
||||
# Clear entry window and reset input text
|
||||
input_text = ""
|
||||
entry_win.clear()
|
||||
# entry_win.refresh()
|
||||
entry_win.erase()
|
||||
|
||||
elif char in (curses.KEY_BACKSPACE, chr(127)):
|
||||
if input_text:
|
||||
@@ -552,7 +551,7 @@ def main_ui(stdscr):
|
||||
draw_messages_window(True)
|
||||
else:
|
||||
globals.display_log = False
|
||||
packetlog_win.clear()
|
||||
packetlog_win.erase()
|
||||
draw_messages_window(True)
|
||||
else:
|
||||
# Append typed character to input text
|
||||
|
||||
@@ -35,6 +35,6 @@ def dialog(stdscr, title, message):
|
||||
char = win.getch()
|
||||
# Close dialog with enter, space, or esc
|
||||
if char in(curses.KEY_ENTER, 10, 13, 32, 27):
|
||||
win.clear()
|
||||
win.erase()
|
||||
win.refresh()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user