feat(tui): copy-on-select, configurable copy key, clearer Select label#510
feat(tui): copy-on-select, configurable copy key, clearer Select label#510saada wants to merge 1 commit into
Conversation
- Copy a mouse selection to the clipboard automatically on drag release (copy-on-select), no Enter required. - Add a configurable `log_copy` shortcut (default Enter) so the keyboard copy key can be remapped (e.g. `y` for a Vim-style yank). It was the only TUI binding not covered by shortcuts.yaml. - Relabel the selection toggle from 'Select On'/'Select Off' to the action it performs: 'Enable Select'/'Disable Select'. - Document the copy-to-clipboard flow (incl. the OSC 52 fallback) in www/docs/tui.md. - Ignore empty selections so a stray click/key press never clobbers the clipboard.
|
F1bonacc1
left a comment
There was a problem hiding this comment.
Hi @saada,
Thank you for the PR!
I accept that log copy should be a configurable shortcut.
And this is exactly what this PR provides, which is great.
I think "copy on selection" to the main clipboard is unexpected and should be behind a configuration or not at all.
There are also a 2 critical issues that should be addressed.
- nil dereference
process-compose/src/tui/actions.go
Line 236 in 1057510
is not wired. Setting a custom shortcut, I reproduced it withypanics here:
process-compose/src/tui/actions.go
Line 251 in 1057510
SinceactionFnisnil.
Since it was missed, it's worth adding a test to catch this before fixing.
ActionLogCopyis missing from the help screen
TheActionLogCopyaction should be added here:
process-compose/src/tui/actions.go
Line 105 in 1057510
| Toggle **selection mode** with `Ctrl+S` (`Enable Select` in the footer). The log pane then becomes selectable and there are two ways to copy: | ||
|
|
||
| - **Mouse:** drag to highlight — releasing the mouse copies the selection automatically (copy-on-select), no key press required. | ||
| - **Keyboard:** highlight with `Shift`+arrows and press `Enter` to copy. |
There was a problem hiding this comment.
Keyboard selection doesn't work.
Sounds like a documentation fix, not a bug.
|
|
||
| Press `Esc` to leave selection mode. | ||
|
|
||
| Process Compose copies through your system clipboard when available and falls back to the [OSC 52](https://www.reddit.com/r/vim/comments/k1ydpn/a_guide_on_how_to_copy_text_from_anywhere/) terminal escape sequence otherwise (your terminal must allow OSC 52). A status message confirms which method was used. |
There was a problem hiding this comment.
The OSC 52 fallback is documented in my other repo: https://github.com/F1bonacc1/glippy#osc-52-fallback
I wouldn't add it, especially with a Reddit link.



What
Makes copying logs out of the TUI ergonomic and configurable:
Enterneeded.log_copyshortcut, defaultEnter(fully backward compatible), so it can be rebound — e.g.yfor a Vim-style yank.Enable Select/Disable Select(the action) instead ofSelect On/Select Off(which read as current state).www/docs/tui.md, including the OSC 52 fallback — previously undocumented.Why
The copy key (
Enter) and exit key (Esc) in selection mode were the only TUI bindings not covered by the configurable shortcuts system, and "turn Select on → highlight → nothing's in my clipboard until I press Enter" is a recurring point of confusion.Ctrl+Ccan't simply be adopted for copy because it's already the global quit binding (and forwardsSIGINTto a focused interactive process), so copy-on-select plus a configurable copy key is the pragmatic fix.How
src/tui/actions.go— newActionLogCopy(log_copy), defaulttcell.KeyCRindefaultShortcuts, and aShortCutKeysentry. RelabelsActionLogSelection'sToggleDescription.log_copyis intentionally left out of the footer/help order arrays, so the footer layout is unchanged.src/tui/log-operations.go— copy logic extracted intocopyLogSelection(collapse bool)(ignores empty selections so a stray click/press never clobbers the clipboard). The keyboard path matches the configured key viaisLogCopyEvent(special key or rune); the title hint useslogCopyShortcut. ASetMouseCaptureon the text area copies onMouseLeftUp.Escstill exits.src/tui/actions_test.go— unit tests for the default (Enter) and overrides (yrune,Ctrl-Ykey).www/docs/tui.md— new docs section.Behavior notes
Enterstill copies,Escstill exits.Testing
go build ./...— cleango test ./...— pass (incl. new tests)gofmt -l/go vet ./src/tui/— cleanCloses #509