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
+18 -6
View File
@@ -31,12 +31,24 @@ all_json_logger.setLevel(logging.DEBUG)
unknown_json_logger = logging.getLogger('unknown_json')
unknown_json_logger.setLevel(logging.DEBUG)
# Global flag for quit confirmation
quit_confirm_time = None
def signal_handler(sig, frame):
"""Handle Ctrl+C for immediate shutdown"""
# Don't call curses.endwin() here - let curses.wrapper handle it
sys.exit(0)
"""Handle Ctrl+C with confirmation"""
global quit_confirm_time
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):
"""
@@ -220,8 +232,8 @@ def parse_player_events(message, game_state, ui):
def main_loop(screen):
"""Main application loop"""
# Setup signal handler for Ctrl+C
# Setup signal handler for Ctrl+C with confirmation
signal.signal(signal.SIGINT, signal_handler)
# Parse arguments