diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-02 14:33:20 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-06 19:34:32 +1000 |
commit | 3ea5e4d4b2b0fa3f555a1562acce5fb729b6ca02 (patch) | |
tree | 51498d4a92a5ba0844e256ca788483592150502f | |
parent | 5f77ac8d6f1b1de0af59ca839f2773f34f441c4d (diff) |
allow scrolling when staging lines or building patch
-rw-r--r-- | go.mod | 4 | ||||
-rw-r--r-- | go.sum | 4 | ||||
-rw-r--r-- | pkg/gui/global_handlers.go | 4 | ||||
-rw-r--r-- | pkg/gui/keybindings.go | 24 | ||||
-rw-r--r-- | pkg/gui/line_by_line_panel.go | 24 | ||||
-rw-r--r-- | vendor/github.com/jesseduffield/gocui/tcell_driver.go | 24 | ||||
-rw-r--r-- | vendor/modules.txt | 4 |
7 files changed, 36 insertions, 52 deletions
@@ -20,7 +20,7 @@ require ( github.com/imdario/mergo v0.3.11 github.com/integrii/flaggy v1.4.0 github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4 - github.com/jesseduffield/gocui v0.3.1-0.20210329131148-bcc4dcd991ff + github.com/jesseduffield/gocui v0.3.1-0.20210402033412-1238f910f001 github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe // indirect github.com/jesseduffield/yaml v2.1.0+incompatible github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 @@ -41,7 +41,7 @@ require ( golang.org/x/net v0.0.0-20201002202402-0a1ea396d57c // indirect golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54 // indirect golang.org/x/term v0.0.0-20210317153231-de623e64d2a6 // indirect - golang.org/x/text v0.3.5 // indirect + golang.org/x/text v0.3.6 // indirect ) replace github.com/go-git/go-git/v5 => github.com/jesseduffield/go-git/v5 v5.1.1 @@ -90,6 +90,8 @@ github.com/jesseduffield/gocui v0.3.1-0.20210329130738-e026850021e3 h1:UDiArPlzk github.com/jesseduffield/gocui v0.3.1-0.20210329130738-e026850021e3/go.mod h1:2RtZznzYKt8RLRwvFiSkXjU0Ei8WwHdubgnlaYH47dw= github.com/jesseduffield/gocui v0.3.1-0.20210329131148-bcc4dcd991ff h1:fTt3EzLtpsc7OA7A6Vd6JVnlxvcAy7cY9lmN9yzDwSs= github.com/jesseduffield/gocui v0.3.1-0.20210329131148-bcc4dcd991ff/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg= +github.com/jesseduffield/gocui v0.3.1-0.20210402033412-1238f910f001 h1:1WH+lTSK5YMr8emISHPA+VqYDDcLei6djuSxBCLIaiI= +github.com/jesseduffield/gocui v0.3.1-0.20210402033412-1238f910f001/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg= github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe h1:qsVhCf2RFyyKIUe/+gJblbCpXMUki9rZrHuEctg6M/E= github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe/go.mod h1:anMibpZtqNxjDbxrcDEAwSdaJ37vyUeM1f/M4uekib4= github.com/jesseduffield/yaml v2.1.0+incompatible h1:HWQJ1gIv2zHKbDYNp0Jwjlj24K8aqpFHnMCynY1EpmE= @@ -215,6 +217,8 @@ golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go index 2db37e5d4..a4526d46e 100644 --- a/pkg/gui/global_handlers.go +++ b/pkg/gui/global_handlers.go @@ -93,7 +93,7 @@ func (gui *Gui) scrollDownView(viewName string) error { return nil } -func (gui *Gui) scrollUpMain(g *gocui.Gui, v *gocui.View) error { +func (gui *Gui) scrollUpMain() error { if gui.canScrollMergePanel() { gui.State.Panels.Merging.UserScrolling = true } @@ -101,7 +101,7 @@ func (gui *Gui) scrollUpMain(g *gocui.Gui, v *gocui.View) error { return gui.scrollUpView("main") } -func (gui *Gui) scrollDownMain(g *gocui.Gui, v *gocui.View) error { +func (gui *Gui) scrollDownMain() error { if gui.canScrollMergePanel() { gui.State.Panels.Merging.UserScrolling = true } diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index d5e7154da..272d63a88 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -229,14 +229,14 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "", Key: gui.getKey(config.Universal.ScrollUpMain), - Handler: gui.scrollUpMain, + Handler: gui.wrappedHandler(gui.scrollUpMain), Alternative: "fn+up", Description: gui.Tr.LcScrollUpMainPanel, }, { ViewName: "", Key: gui.getKey(config.Universal.ScrollDownMain), - Handler: gui.scrollDownMain, + Handler: gui.wrappedHandler(gui.scrollDownMain), Alternative: "fn+down", Description: gui.Tr.LcScrollDownMainPanel, }, @@ -244,25 +244,25 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "", Key: gui.getKey(config.Universal.ScrollUpMainAlt1), Modifier: gocui.ModNone, - Handler: gui.scrollUpMain, + Handler: gui.wrappedHandler(gui.scrollUpMain), }, { ViewName: "", Key: gui.getKey(config.Universal.ScrollDownMainAlt1), Modifier: gocui.ModNone, - Handler: gui.scrollDownMain, + Handler: gui.wrappedHandler(gui.scrollDownMain), }, { ViewName: "", Key: gui.getKey(config.Universal.ScrollUpMainAlt2), Modifier: gocui.ModNone, - Handler: gui.scrollUpMain, + Handler: gui.wrappedHandler(gui.scrollUpMain), }, { ViewName: "", Key: gui.getKey(config.Universal.ScrollDownMainAlt2), Modifier: gocui.ModNone, - Handler: gui.scrollDownMain, + Handler: gui.wrappedHandler(gui.scrollDownMain), }, { ViewName: "", @@ -1125,7 +1125,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{MAIN_NORMAL_CONTEXT_KEY}, Key: gocui.MouseWheelDown, - Handler: gui.scrollDownMain, + Handler: gui.wrappedHandler(gui.scrollDownMain), Description: gui.Tr.ScrollDown, Alternative: "fn+up", }, @@ -1133,7 +1133,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{MAIN_NORMAL_CONTEXT_KEY}, Key: gocui.MouseWheelUp, - Handler: gui.scrollUpMain, + Handler: gui.wrappedHandler(gui.scrollUpMain), Description: gui.Tr.ScrollUp, Alternative: "fn+down", }, @@ -1226,14 +1226,14 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY}, Key: gocui.MouseWheelUp, Modifier: gocui.ModNone, - Handler: gui.wrappedHandler(gui.handleSelectPrevLine), + Handler: gui.wrappedHandler(gui.scrollUpMain), }, { ViewName: "main", Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY}, Key: gocui.MouseWheelDown, Modifier: gocui.ModNone, - Handler: gui.wrappedHandler(gui.handleSelectNextLine), + Handler: gui.wrappedHandler(gui.scrollDownMain), }, { ViewName: "main", @@ -1369,14 +1369,14 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY}, Key: gocui.MouseWheelUp, Modifier: gocui.ModNone, - Handler: gui.handleMouseScrollUp, + Handler: gui.wrappedHandler(gui.scrollUpMain), }, { ViewName: "main", Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY}, Key: gocui.MouseWheelDown, Modifier: gocui.ModNone, - Handler: gui.handleMouseScrollDown, + Handler: gui.wrappedHandler(gui.scrollDownMain), }, { ViewName: "main", diff --git a/pkg/gui/line_by_line_panel.go b/pkg/gui/line_by_line_panel.go index 4f35aa499..d92e099bb 100644 --- a/pkg/gui/line_by_line_panel.go +++ b/pkg/gui/line_by_line_panel.go @@ -204,30 +204,6 @@ func (gui *Gui) handleMouseDrag(g *gocui.Gui, v *gocui.View) error { }) } -func (gui *Gui) handleMouseScrollUp(g *gocui.Gui, v *gocui.View) error { - return gui.withLBLActiveCheck(func(state *lBlPanelState) error { - if gui.popupPanelFocused() { - return nil - } - - state.SelectMode = LINE - - return gui.LBLCycleLine(-1, state) - }) -} - -func (gui *Gui) handleMouseScrollDown(g *gocui.Gui, v *gocui.View) error { - return gui.withLBLActiveCheck(func(state *lBlPanelState) error { - if gui.popupPanelFocused() { - return nil - } - - state.SelectMode = LINE - - return gui.LBLCycleLine(1, state) - }) -} - func (gui *Gui) getSelectedCommitFileName() string { idx := gui.State.Panels.CommitFiles.SelectedLineIdx diff --git a/vendor/github.com/jesseduffield/gocui/tcell_driver.go b/vendor/github.com/jesseduffield/gocui/tcell_driver.go index 2f992e838..a7faed903 100644 --- a/vendor/github.com/jesseduffield/gocui/tcell_driver.go +++ b/vendor/github.com/jesseduffield/gocui/tcell_driver.go @@ -177,6 +177,8 @@ func pollEvent() GocuiEvent { mouseKey = MouseWheelRight } + wheeling := mouseKey == MouseWheelUp || mouseKey == MouseWheelDown || mouseKey == MouseWheelLeft || mouseKey == MouseWheelRight + // process button events (not wheel events) button &= tcell.ButtonMask(0xff) if button != tcell.ButtonNone && lastMouseKey == tcell.ButtonNone { @@ -210,17 +212,19 @@ func pollEvent() GocuiEvent { } } - switch dragState { - case NOT_DRAGGING: - return GocuiEvent{Type: eventNone} - // if we haven't released the left mouse button and we've moved the cursor then we're dragging - case MAYBE_DRAGGING: - if x != lastX || y != lastY { - dragState = DRAGGING + if !wheeling { + switch dragState { + case NOT_DRAGGING: + return GocuiEvent{Type: eventNone} + // if we haven't released the left mouse button and we've moved the cursor then we're dragging + case MAYBE_DRAGGING: + if x != lastX || y != lastY { + dragState = DRAGGING + } + case DRAGGING: + mouseMod = ModMotion + mouseKey = MouseLeft } - case DRAGGING: - mouseMod = ModMotion - mouseKey = MouseLeft } return GocuiEvent{ diff --git a/vendor/modules.txt b/vendor/modules.txt index c2ce6610a..23dfa0005 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -149,7 +149,7 @@ github.com/jesseduffield/go-git/v5/utils/merkletrie/filesystem github.com/jesseduffield/go-git/v5/utils/merkletrie/index github.com/jesseduffield/go-git/v5/utils/merkletrie/internal/frame github.com/jesseduffield/go-git/v5/utils/merkletrie/noder -# github.com/jesseduffield/gocui v0.3.1-0.20210329131148-bcc4dcd991ff +# github.com/jesseduffield/gocui v0.3.1-0.20210402033412-1238f910f001 ## explicit github.com/jesseduffield/gocui # github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe @@ -245,7 +245,7 @@ golang.org/x/sys/windows # golang.org/x/term v0.0.0-20210317153231-de623e64d2a6 ## explicit golang.org/x/term -# golang.org/x/text v0.3.5 +# golang.org/x/text v0.3.6 ## explicit golang.org/x/text/encoding golang.org/x/text/encoding/internal/identifier |