Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,14 @@ If you want the exact delta configuration I'm using - [it can be found here](htt
| <kbd>i</kbd> | Cycle icon style |
| <kbd>o</kbd> | Open file in $EDITOR |
| <kbd>s</kbd> | Toggle side-by-side/unified view |
| <kbd>v</kbd> | Visual select mode (release mouse for native text selection / copy) |
| <kbd>Tab</kbd> | Switch focus between the panes |
| <kbd>q</kbd> | Quit |

While mouse capture is on, your terminal can't do its native click-and-drag selection. Press <kbd>v</kbd> to enter visual select mode — this releases the mouse so you can select and copy lines from the diff (the footer shows `visual select`); press <kbd>v</kbd> again to restore mouse scroll/click. Tip: in side-by-side mode the selection spans both columns — switch to unified with <kbd>s</kbd> first, or use your terminal's block-select modifier (Option+drag in iTerm2 / Terminal.app, Alt+drag in many Linux terminals).

Most terminals (iTerm2, Terminal.app, Alacritty, kitty, WezTerm, GNOME Terminal) also let you hold <kbd>Shift</kbd> while dragging to bypass mouse capture without toggling.

## Discord

Have questions? Join our [Discord community](https://discord.gg/SXNXp9NctV)!
Expand Down
6 changes: 6 additions & 0 deletions pkg/ui/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type KeyMap struct {
ToggleIconStyle key.Binding
ToggleHelp key.Binding
ToggleMessage key.Binding
ToggleMouse key.Binding
}

var keys = &KeyMap{
Expand Down Expand Up @@ -111,6 +112,10 @@ var keys = &KeyMap{
key.WithKeys("m"),
key.WithHelp("m", "commit info"),
),
ToggleMouse: key.NewBinding(
key.WithKeys("v"),
key.WithHelp("v", "visual select"),
),
}

func KeyGroups() [][]key.Binding {
Expand All @@ -133,6 +138,7 @@ func KeyGroups() [][]key.Binding {
keys.ToggleIconStyle,
}, {
keys.ToggleMessage,
keys.ToggleMouse,
keys.ToggleHelp,
keys.Quit,
}}
Expand Down
17 changes: 16 additions & 1 deletion pkg/ui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type mainModel struct {
pendingCursorPath string
watchInFlight bool
repoRoot string
mouseDisabled bool
}

func New(input string, cfg config.Config) mainModel {
Expand Down Expand Up @@ -255,6 +256,10 @@ func (m mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.search.SetWidth(m.searchWidth())
dfCmd := m.diffViewer.SetSize(m.width-sidebarWidth, h)
cmds = append(cmds, dfCmd)
case key.Matches(msg, keys.ToggleMouse):
m.mouseDisabled = !m.mouseDisabled
m.draggingSidebar = false
return m, tea.Batch(cmds...)
case key.Matches(msg, keys.ToggleIconStyle):
m.cycleIconStyle()
case key.Matches(msg, keys.ToggleDiffView):
Expand Down Expand Up @@ -488,7 +493,11 @@ func (m mainModel) searchUpdate(msg tea.Msg) (mainModel, []tea.Cmd) {
func (m mainModel) View() tea.View {
var view tea.View
view.AltScreen = true
view.MouseMode = tea.MouseModeAllMotion
if m.mouseDisabled {
view.MouseMode = tea.MouseModeNone
} else {
view.MouseMode = tea.MouseModeAllMotion
}

view.KeyboardEnhancements.ReportEventTypes = true
// Determine colors based on active panel.
Expand Down Expand Up @@ -826,6 +835,12 @@ func (m mainModel) footerView() string {
usedWidth += lipgloss.Width(sep) + lipgloss.Width(watchLabel)
}

if m.mouseDisabled {
mouseLabel := base.Foreground(lipgloss.Yellow).Render("visual select")
parts = append(parts, sep, mouseLabel)
usedWidth += lipgloss.Width(sep) + lipgloss.Width(mouseLabel)
}

spacing := base.Render(strings.Repeat(" ", max(0, m.width-usedWidth)))
parts = append(parts, spacing, help)
return base.
Expand Down
Loading