summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author <>2018-12-14 02:25:50 +0300
committer <>2018-12-14 02:25:50 +0300
commit734514a61c00b325137b0242adbfc8c788ae66c5 (patch)
tree11dc60cd823c6be3131531ff719c5f3716833a79
parentimproved commit feature (diff)
downloadgitbatch-734514a61c00b325137b0242adbfc8c788ae66c5.tar.gz
reorganize keybindings
-rw-r--r--pkg/gui/gui-util.go22
-rw-r--r--pkg/gui/keybindings.go96
2 files changed, 53 insertions, 65 deletions
diff --git a/pkg/gui/gui-util.go b/pkg/gui/gui-util.go
index 343e293..f203bbf 100644
--- a/pkg/gui/gui-util.go
+++ b/pkg/gui/gui-util.go
@@ -78,7 +78,6 @@ func (gui *Gui) previousViewOfGroup(g *gocui.Gui, v *gocui.View, group []viewFea
}
// siwtch the app mode
-// TODO: switching can be made with conventional iteration
func (gui *Gui) switchMode(g *gocui.Gui, v *gocui.View) error {
for i, mode := range modes {
if mode == gui.State.Mode {
@@ -94,6 +93,27 @@ func (gui *Gui) switchMode(g *gocui.Gui, v *gocui.View) error {
return nil
}
+// siwtch the app's mode to fetch
+func (gui *Gui) switchToFetchMode(g *gocui.Gui, v *gocui.View) error {
+ gui.State.Mode = fetchMode
+ gui.updateKeyBindingsView(g, mainViewFeature.Name)
+ return nil
+}
+
+// siwtch the app's mode to pull
+func (gui *Gui) switchToPullMode(g *gocui.Gui, v *gocui.View) error {
+ gui.State.Mode = pullMode
+ gui.updateKeyBindingsView(g, mainViewFeature.Name)
+ return nil
+}
+
+// siwtch the app's mode to merge
+func (gui *Gui) switchToMergeMode(g *gocui.Gui, v *gocui.View) error {
+ gui.State.Mode = mergeMode
+ gui.updateKeyBindingsView(g, mainViewFeature.Name)
+ return nil
+}
+
// bring the view on the top by its name
func (gui *Gui) setCurrentViewOnTop(g *gocui.Gui, name string) (*gocui.View, error) {
if _, err := g.SetCurrentView(name); err != nil {
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go
index 4917cd4..53acf60 100644
--- a/pkg/gui/keybindings.go
+++ b/pkg/gui/keybindings.go
@@ -33,42 +33,34 @@ func (gui *Gui) generateKeybindings() error {
Vital: true,
}, {
View: view.Name,
- Key: gocui.KeyTab,
- Modifier: gocui.ModNone,
- Handler: gui.switchMode,
- Display: "tab",
- Description: "Switch mode",
- Vital: true,
- }, {
- View: view.Name,
- Key: gocui.KeyArrowLeft,
+ Key: 'f',
Modifier: gocui.ModNone,
- Handler: gui.previousMainView,
- Display: "←",
- Description: "Previous Panel",
+ Handler: gui.switchToFetchMode,
+ Display: "f",
+ Description: "Fetch mode",
Vital: false,
}, {
View: view.Name,
- Key: gocui.KeyArrowRight,
+ Key: 'p',
Modifier: gocui.ModNone,
- Handler: gui.nextMainView,
- Display: "→",
- Description: "Next Panel",
+ Handler: gui.switchToPullMode,
+ Display: "p",
+ Description: "Pull mode",
Vital: false,
}, {
View: view.Name,
- Key: 'l',
+ Key: 'm',
Modifier: gocui.ModNone,
- Handler: gui.nextMainView,
- Display: "l",
- Description: "Previous Panel",
+ Handler: gui.switchToMergeMode,
+ Display: "m",
+ Description: "Merge mode",
Vital: false,
}, {
View: view.Name,
- Key: 'h',
+ Key: gocui.KeyTab,
Modifier: gocui.ModNone,
- Handler: gui.previousMainView,
- Display: "h",
+ Handler: gui.nextMainView,
+ Display: "tab",
Description: "Next Panel",
Vital: false,
},
@@ -82,44 +74,20 @@ func (gui *Gui) generateKeybindings() error {
statusKeybindings := []*KeyBinding{
{
View: view.Name,
- Key: 'c',
+ Key: gocui.KeyEsc,
Modifier: gocui.ModNone,
Handler: gui.closeStatusView,
- Display: "c",
+ Display: "esc",
Description: "Close/Cancel",
Vital: true,
}, {
View: view.Name,
- Key: gocui.KeyArrowLeft,
- Modifier: gocui.ModNone,
- Handler: gui.previousStatusView,
- Display: "←",
- Description: "Previous Panel",
- Vital: false,
- }, {
- View: view.Name,
- Key: gocui.KeyArrowRight,
- Modifier: gocui.ModNone,
- Handler: gui.nextStatusView,
- Display: "→",
- Description: "Next Panel",
- Vital: false,
- }, {
- View: view.Name,
- Key: 'l',
+ Key: gocui.KeyTab,
Modifier: gocui.ModNone,
Handler: gui.nextStatusView,
- Display: "l",
- Description: "Previous Panel",
- Vital: false,
- }, {
- View: view.Name,
- Key: 'h',
- Modifier: gocui.ModNone,
- Handler: gui.previousStatusView,
- Display: "h",
+ Display: "tab",
Description: "Next Panel",
- Vital: false,
+ Vital: true,
}, {
View: view.Name,
Key: gocui.KeyArrowUp,
@@ -348,7 +316,7 @@ func (gui *Gui) generateKeybindings() error {
Modifier: gocui.ModNone,
Handler: gui.markRepository,
Display: "space",
- Description: "Add to queue",
+ Description: "Select",
Vital: true,
}, {
View: mainViewFeature.Name,
@@ -356,7 +324,7 @@ func (gui *Gui) generateKeybindings() error {
Modifier: gocui.ModNone,
Handler: gui.startQueue,
Display: "enter",
- Description: "Start queue",
+ Description: "Start",
Vital: true,
}, {
View: mainViewFeature.Name,
@@ -364,7 +332,7 @@ func (gui *Gui) generateKeybindings() error {
Modifier: gocui.ModNone,
Handler: gui.markAllRepositories,
Display: "ctrl + space",
- Description: "Add all to queue",
+ Description: "Select All",
Vital: false,
}, {
View: mainViewFeature.Name,
@@ -372,7 +340,7 @@ func (gui *Gui) generateKeybindings() error {
Modifier: gocui.ModNone,
Handler: gui.unmarkAllRepositories,
Display: "backspace",
- Description: "Remove all from queue",
+ Description: "Deselect All",
Vital: false,
}, {
View: mainViewFeature.Name,
@@ -392,10 +360,10 @@ func (gui *Gui) generateKeybindings() error {
Vital: false,
}, {
View: mainViewFeature.Name,
- Key: 'm',
+ Key: 'r',
Modifier: gocui.ModNone,
Handler: gui.sortByMod,
- Display: "m",
+ Display: "r",
Description: "Sort repositories by Modification date",
Vital: false,
}, {
@@ -570,10 +538,10 @@ func (gui *Gui) generateKeybindings() error {
// Diff View Controls
{
View: diffViewFeature.Name,
- Key: 'c',
+ Key: gocui.KeyEsc,
Modifier: gocui.ModNone,
Handler: gui.closeCommitDiffView,
- Display: "c",
+ Display: "esc",
Description: "close/cancel",
Vital: true,
}, {
@@ -612,10 +580,10 @@ func (gui *Gui) generateKeybindings() error {
// Application Controls
{
View: cheatSheetViewFeature.Name,
- Key: 'c',
+ Key: gocui.KeyEsc,
Modifier: gocui.ModNone,
Handler: gui.closeCheatSheetView,
- Display: "c",
+ Display: "esc",
Description: "close/cancel",
Vital: true,
}, {
@@ -654,10 +622,10 @@ func (gui *Gui) generateKeybindings() error {
// Error View
{
View: errorViewFeature.Name,
- Key: 'c',
+ Key: gocui.KeyEsc,
Modifier: gocui.ModNone,
Handler: gui.closeErrorView,
- Display: "c",
+ Display: "esc",
Description: "close/cancel",
Vital: true,
}, {