improoove

This commit is contained in:
xbl
2025-12-24 09:23:26 +01:00
parent 6ef29d83cb
commit 53c0b3af55
4 changed files with 43 additions and 7 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ __pycache__/
venv3/ venv3/
*.log *.log
cvarlist.txt cvarlist.txt
curztest.py

20
main.py
View File

@ -31,12 +31,24 @@ all_json_logger.setLevel(logging.DEBUG)
unknown_json_logger = logging.getLogger('unknown_json') unknown_json_logger = logging.getLogger('unknown_json')
unknown_json_logger.setLevel(logging.DEBUG) unknown_json_logger.setLevel(logging.DEBUG)
# Global flag for quit confirmation
quit_confirm_time = None
def signal_handler(sig, frame): def signal_handler(sig, frame):
"""Handle Ctrl+C for immediate shutdown""" """Handle Ctrl+C with confirmation"""
# Don't call curses.endwin() here - let curses.wrapper handle it global quit_confirm_time
sys.exit(0) import time
current_time = time.time()
if quit_confirm_time is None or (current_time - quit_confirm_time) > 3:
# First Ctrl-C or timeout expired
logger.warning("^1^0Press Ctrl-C again within 3 seconds to quit^0")
quit_confirm_time = current_time
else:
# Second Ctrl-C within 3 seconds
logger.warning("^1^0Quittin'^9")
sys.exit(0)
def parse_cvar_response(message, game_state, ui): def parse_cvar_response(message, game_state, ui):
""" """
@ -221,7 +233,7 @@ def parse_player_events(message, game_state, ui):
def main_loop(screen): def main_loop(screen):
"""Main application loop""" """Main application loop"""
# Setup signal handler for Ctrl+C # Setup signal handler for Ctrl+C with confirmation
signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGINT, signal_handler)
# Parse arguments # Parse arguments

View File

@ -193,7 +193,7 @@ class EventParser:
warmup = " ^0^3(Warmup)^7^9" if data.get('WARMUP', False) else "" warmup = " ^0^3(Warmup)^7^9" if data.get('WARMUP', False) else ""
team_prefix = get_team_prefix(name, self.game_state.player_tracker) team_prefix = get_team_prefix(name, self.game_state.player_tracker)
return f"{team_prefix}^0{name}^9 ^7got a medal: ^6{medal}{warmup}\n" return f"{team_prefix}^0{name}^9 ^7got a medal: ^0^6{medal}{warmup}\n"
def _handle_match_started(self, data): def _handle_match_started(self, data):
"""Handle MATCH_STARTED event""" """Handle MATCH_STARTED event"""

23
ui.py
View File

@ -170,6 +170,7 @@ class UIManager:
cursor_pos = 0 cursor_pos = 0
temp_history_index = -1 temp_history_index = -1
temp_input = "" # Temp storage when navigating history temp_input = "" # Temp storage when navigating history
quit_confirm = False
while True: while True:
try: try:
@ -227,6 +228,28 @@ class UIManager:
window.addstr(0, 0, current_input) window.addstr(0, 0, current_input)
window.refresh() window.refresh()
# Arrow LEFT - move cursor left
elif key == curses.KEY_LEFT:
if cursor_pos > 0:
cursor_pos -= 1
window.move(0, cursor_pos)
window.refresh()
# Arrow RIGHT - move cursor right
elif key == curses.KEY_RIGHT:
if cursor_pos < len(current_input):
cursor_pos += 1
window.move(0, cursor_pos)
window.refresh()
# ESC - cancel quit confirmation
elif key == 27:
if quit_confirm:
quit_confirm = False
window.clear()
window.refresh()
# Backspace # Backspace
elif key in (curses.KEY_BACKSPACE, 127, 8): elif key in (curses.KEY_BACKSPACE, 127, 8):
if cursor_pos > 0: if cursor_pos > 0: