Skip to content

feat: hide cursor when process loses focus #227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Schniz
Copy link

@Schniz Schniz commented Jun 11, 2025

Implement ANSI focus tracking cursor control to reduce visual distraction when switching panes. The cursor now automatically hides when the OpenCode pane is not focused and reappears when returning to it.

Key changes:

  • Use ANSI focus tracking (like in Support xterm focus tracking vim/vim#609)
  • Control cursor visibility in textarea component using cursor.CursorHide/CursorBlink modes
  • Add FocusMsg for communicating focus changes between components

🤖 Generated with opencode

Implement tmux focus-aware cursor control to reduce visual distraction when switching between tmux panes. The cursor now automatically hides when the OpenCode pane is not focused and reappears when returning to it.

Key changes:
- Add tmux detection utilities using $TMUX and $TMUX_PANE environment variables
- Implement real-time focus monitoring with 500ms polling interval
- Control cursor visibility in textarea component using cursor.CursorHide/CursorBlink modes
- Add TmuxFocusMsg for communicating focus changes between components
- Set initial cursor state based on current tmux focus status

The implementation gracefully falls back to normal behavior when not running in tmux.

🤖 Generated with opencode
Co-Authored-By: opencode <[email protected]>
@Schniz
Copy link
Author

Schniz commented Jun 11, 2025

most of it was actually generated which makes me happy

@Schniz Schniz changed the title feat: hide cursor when tmux pane loses focus feat: hide cursor when process loses focus Jun 11, 2025
@Schniz
Copy link
Author

Schniz commented Jun 11, 2025

:til: there's a standard escape code which is how vim does that.

i asked opencode to use it, and it one shotted the implementation :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant