diff --git a/.gitignore b/.gitignore index b0f7d02..3afd689 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ __pycache__/ venv3/ *.log cvarlist.txt +curztest.py diff --git a/main.py b/main.py index a2ca385..22032cb 100644 --- a/main.py +++ b/main.py @@ -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 diff --git a/parser.py b/parser.py index cde25bc..361be2b 100644 --- a/parser.py +++ b/parser.py @@ -193,7 +193,7 @@ class EventParser: warmup = " ^0^3(Warmup)^7^9" if data.get('WARMUP', False) else "" 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): """Handle MATCH_STARTED event""" diff --git a/ui.py b/ui.py index 7e2e356..1f7993a 100644 --- a/ui.py +++ b/ui.py @@ -170,6 +170,7 @@ class UIManager: cursor_pos = 0 temp_history_index = -1 temp_input = "" # Temp storage when navigating history + quit_confirm = False while True: try: @@ -227,6 +228,28 @@ class UIManager: window.addstr(0, 0, current_input) 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 elif key in (curses.KEY_BACKSPACE, 127, 8): if cursor_pos > 0: