summaryrefslogtreecommitdiffstats
path: root/pkg/gui/keybindings.go
diff options
context:
space:
mode:
authorJesse Duffield Duffield <jesseduffieldduffield@Jesses-MacBook-Pro-3.local>2019-02-25 22:11:35 +1100
committerJesse Duffield <jessedduffield@gmail.com>2019-03-02 17:49:30 +1100
commit8c0ea8f45fde1dfddd23198fcb06ae77468e3a3a (patch)
treeba923f1b86c26327ceec9f12de619265229bf642 /pkg/gui/keybindings.go
parentafbc028ad6f2b8a580f6b22d13f3313ba5c44cf6 (diff)
mouse support
Diffstat (limited to 'pkg/gui/keybindings.go')
-rw-r--r--pkg/gui/keybindings.go43
1 files changed, 36 insertions, 7 deletions
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go
index 3c5862569..3e0e3b1d1 100644
--- a/pkg/gui/keybindings.go
+++ b/pkg/gui/keybindings.go
@@ -400,7 +400,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Handler: gui.handleStashApply,
Description: gui.Tr.SLocalize("apply"),
}, {
-
ViewName: "stash",
Key: 'g',
Modifier: gocui.ModNone,
@@ -442,6 +441,11 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Key: 'q',
Modifier: gocui.ModNone,
Handler: gui.handleMenuClose,
+ }, {
+ ViewName: "version",
+ Key: gocui.MouseLeft,
+ Modifier: gocui.ModNone,
+ Handler: gui.handleDonate,
},
}
@@ -458,20 +462,25 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
listPanelMap := map[string]struct {
prevLine func(*gocui.Gui, *gocui.View) error
nextLine func(*gocui.Gui, *gocui.View) error
+ focus func(*gocui.Gui, *gocui.View) error
}{
- "menu": {prevLine: gui.handleMenuPrevLine, nextLine: gui.handleMenuNextLine},
- "files": {prevLine: gui.handleFilesPrevLine, nextLine: gui.handleFilesNextLine},
- "branches": {prevLine: gui.handleBranchesPrevLine, nextLine: gui.handleBranchesNextLine},
- "commits": {prevLine: gui.handleCommitsPrevLine, nextLine: gui.handleCommitsNextLine},
- "stash": {prevLine: gui.handleStashPrevLine, nextLine: gui.handleStashNextLine},
+ "menu": {prevLine: gui.handleMenuPrevLine, nextLine: gui.handleMenuNextLine, focus: gui.handleMenuSelect},
+ "files": {prevLine: gui.handleFilesPrevLine, nextLine: gui.handleFilesNextLine, focus: gui.handleFilesFocus},
+ "branches": {prevLine: gui.handleBranchesPrevLine, nextLine: gui.handleBranchesNextLine, focus: gui.handleBranchSelect},
+ "commits": {prevLine: gui.handleCommitsPrevLine, nextLine: gui.handleCommitsNextLine, focus: gui.handleCommitSelect},
+ "stash": {prevLine: gui.handleStashPrevLine, nextLine: gui.handleStashNextLine, focus: gui.handleStashEntrySelect},
+ "status": {focus: gui.handleStatusSelect},
}
for viewName, functions := range listPanelMap {
bindings = append(bindings, []*Binding{
{ViewName: viewName, Key: 'k', Modifier: gocui.ModNone, Handler: functions.prevLine},
{ViewName: viewName, Key: gocui.KeyArrowUp, Modifier: gocui.ModNone, Handler: functions.prevLine},
+ {ViewName: viewName, Key: gocui.MouseWheelUp, Modifier: gocui.ModNone, Handler: functions.prevLine},
{ViewName: viewName, Key: 'j', Modifier: gocui.ModNone, Handler: functions.nextLine},
{ViewName: viewName, Key: gocui.KeyArrowDown, Modifier: gocui.ModNone, Handler: functions.nextLine},
+ {ViewName: viewName, Key: gocui.MouseWheelDown, Modifier: gocui.ModNone, Handler: functions.nextLine},
+ {ViewName: viewName, Key: gocui.MouseLeft, Modifier: gocui.ModNone, Handler: functions.focus},
}...)
}
@@ -481,7 +490,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
// GetCurrentKeybindings gets the list of keybindings given the current context
func (gui *Gui) GetCurrentKeybindings() []*Binding {
bindings := gui.GetInitialKeybindings()
- viewName := gui.currentViewName(gui.g)
+ viewName := gui.currentViewName()
currentContext := gui.State.Contexts[viewName]
contextBindings := gui.GetContextMap()[viewName][currentContext]
@@ -560,6 +569,16 @@ func (gui *Gui) GetContextMap() map[string]map[string][]*Binding {
Modifier: gocui.ModNone,
Handler: gui.handleStagingNextLine,
}, {
+ ViewName: "main",
+ Key: gocui.KeyArrowLeft,
+ Modifier: gocui.ModNone,
+ Handler: gui.handleStagingPrevLine,
+ }, {
+ ViewName: "main",
+ Key: gocui.MouseWheelDown,
+ Modifier: gocui.ModNone,
+ Handler: gui.handleStagingNextLine,
+ }, {
ViewName: "main",
Key: gocui.KeyArrowLeft,
Modifier: gocui.ModNone,
@@ -642,6 +661,16 @@ func (gui *Gui) GetContextMap() map[string]map[string][]*Binding {
Description: gui.Tr.SLocalize("SelectBottom"),
}, {
ViewName: "main",
+ Key: gocui.MouseWheelUp,
+ Modifier: gocui.ModNone,
+ Handler: gui.handleSelectTop,
+ }, {
+ ViewName: "main",
+ Key: gocui.MouseWheelDown,
+ Modifier: gocui.ModNone,
+ Handler: gui.handleSelectBottom,
+ }, {
+ ViewName: "main",
Key: 'h',
Modifier: gocui.ModNone,
Handler: gui.handleSelectPrevConflict,