Repository navigation
feature/close by clicking outside #23
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9ef058e
build: add Makefile with test target
cboone def3ef4
feat: close popup on click outside content area
cboone 93e1271
Merge branch 'main' into feature/close-by-clicking-outside
cboone be2bad0
docs: add Copilot instruction for POPUP_WIDTH - 2 column calculation
cboone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
docs/plans/done/2026-02-08-close-popup-on-outside-click.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # Close Popup by Clicking Outside | ||
|
|
||
| ## Context | ||
|
|
||
| The tmux-binding-help popup currently only closes via keyboard (`q` or `Escape`). Users expect to be able to click outside the popup to dismiss it, as is standard for overlay/popup UIs. In tmux 3.4+, the popup may already close on outside click at the tmux level, but for tmux 3.2-3.3 the click may be forwarded to the viewer's PTY with out-of-bounds coordinates. Adding viewer-level detection of these out-of-bounds coordinates provides coverage across tmux versions. | ||
|
|
||
| ## Changes | ||
|
|
||
| All changes are in **`scripts/viewer.sh`** (3 edits, ~10 lines changed). | ||
|
|
||
| ### 1. Include column in the MOUSE_LEFT token (line 523) | ||
|
|
||
|
cboone marked this conversation as resolved.
|
||
| ```bash | ||
| # Before: | ||
| 0) printf 'MOUSE_LEFT:%d' "$mouse_row" ;; | ||
|
|
||
| # After: | ||
| 0) printf 'MOUSE_LEFT:%d:%d' "$mouse_row" "$mouse_col" ;; | ||
| ``` | ||
|
|
||
| The column is already parsed and validated at line 510-518 but currently discarded. This makes it available to the main loop. | ||
|
|
||
| ### 2. Extract both row and column in the main loop (lines 589-594) | ||
|
|
||
|
cboone marked this conversation as resolved.
|
||
| ```bash | ||
| # Before: | ||
| # Extract mouse row from MOUSE_LEFT:ROW token | ||
| local mouse_row=0 | ||
| if [[ "$key" == MOUSE_LEFT:* ]]; then | ||
| mouse_row="${key#MOUSE_LEFT:}" | ||
| key="MOUSE_LEFT" | ||
| fi | ||
|
|
||
| # After: | ||
| # Extract mouse row and column from MOUSE_LEFT:ROW:COL token | ||
| local mouse_row=0 mouse_col=0 | ||
| if [[ "$key" == MOUSE_LEFT:* ]]; then | ||
| local mouse_coords="${key#MOUSE_LEFT:}" | ||
| mouse_row="${mouse_coords%%:*}" | ||
| mouse_col="${mouse_coords#*:}" | ||
| key="MOUSE_LEFT" | ||
| fi | ||
| ``` | ||
|
|
||
| ### 3. Add boundary check before mode dispatch (insert after line 594, before line 596) | ||
|
|
||
| ```bash | ||
| # Close popup on click outside content area | ||
| if [[ "$key" == "MOUSE_LEFT" ]] && ((mouse_row > TERM_ROWS || mouse_col > TERM_COLS)); then | ||
| break | ||
| fi | ||
| ``` | ||
|
|
||
| Placed before the search-mode/normal-mode `if`, so it applies regardless of current mode. The `break` exits the main loop, triggering `cleanup()` via the EXIT trap, and the popup closes via `-E`. | ||
|
|
||
| Coordinates < 1 are already rejected as `MOUSE_OTHER` in `read_key()` (line 516), so only the upper-bound check is needed here. | ||
|
|
||
| ## What does not change | ||
|
|
||
| - `click_select()`, scroll events, `popup.sh`, `cleanup()`, release/other mouse events | ||
| - No new dependencies or version requirements | ||
|
|
||
| ## Verification | ||
|
|
||
| 1. Open the popup, click outside it -- popup should close | ||
| 2. Click inside on bindings, group headers, search bar, footer, empty area -- all should work as before | ||
| 3. Enter search mode, click outside -- popup should close | ||
| 4. Scroll inside popup -- should work as before | ||
| 5. `make test` -- existing parser tests should pass | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.