diff --git a/gtm2.py b/gtm2.py index 0643196..a111ffb 100755 --- a/gtm2.py +++ b/gtm2.py @@ -523,23 +523,27 @@ def main(stdscr, filename, show_diff, show_add, show_del, mouse): curses.mousemask(curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION) state.load_commit_content() + + # Initial draw before the main loop starts + draw_ui(stdscr, state) while not state.should_exit: - draw_ui(stdscr, state) - key = stdscr.getch() if key == -1: continue + # Process input and update the application state if key == curses.KEY_RESIZE: h, w = stdscr.getmaxyx() state.update_dimensions(h, w) - continue - - if state.enable_mouse and key == curses.KEY_MOUSE: + elif state.enable_mouse and key == curses.KEY_MOUSE: handle_mouse_input(stdscr, state) else: handle_keyboard_input(key, state) + + # After every action, redraw the UI to reflect changes immediately. + # This is crucial for real-time feedback during mouse drags. + draw_ui(stdscr, state) if __name__ == "__main__": parser = argparse.ArgumentParser(description="A \"Git Time Machine\" for viewing file history")