diff --git a/gtm2.py b/gtm2.py index a640f80..00602a9 100755 --- a/gtm2.py +++ b/gtm2.py @@ -542,7 +542,10 @@ def handle_keyboard_input(key, state): # --- Main Application --- def main(stdscr, filename, show_diff, show_add, show_del, mouse): - curses.curs_set(0) + try: + curses.curs_set(0) + except: + pass stdscr.keypad(True) stdscr.timeout(50) # Less aggressive timeout (50ms instead of 10ms) @@ -559,7 +562,10 @@ def main(stdscr, filename, show_diff, show_add, show_del, mouse): if state.enable_mouse: curses.mousemask(curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION) # Enable mouse motion events for better drag tracking - print("\033[?1003h", end="", flush=True) + try: + print("\033[?1003h", end="", flush=True) + except: + pass state.load_commit_content() @@ -586,11 +592,17 @@ def main(stdscr, filename, show_diff, show_add, show_del, mouse): draw_ui(stdscr, state) except Exception as e: # Prevent crashes by catching exceptions + # Uncomment for debugging: + # with open("/tmp/gtm_error.log", "a") as f: + # f.write(f"{str(e)}\n") pass # Disable mouse motion events when exiting if state.enable_mouse: - print("\033[?1003l", end="", flush=True) + try: + print("\033[?1003l", end="", flush=True) + except: + pass if __name__ == "__main__": parser = argparse.ArgumentParser(description="A \"Git Time Machine\" for viewing file history")