@@ -71,69 +71,6 @@ func handleRefresh(g *gocui.Gui, v *gocui.View) error {
7171 return refreshSidePanels (g )
7272}
7373
74- // Binding - a keybinding mapping a key and modifier to a handler. The keypress
75- // is only handled if the given view has focus, or handled globally if the view
76- // is ""
77- type Binding struct {
78- ViewName string
79- Handler func (* gocui.Gui , * gocui.View ) error
80- Key interface {} // FIXME: find out how to get `gocui.Key | rune`
81- Modifier gocui.Modifier
82- }
83-
84- func keybindings (g * gocui.Gui ) error {
85- bindings := []Binding {
86- Binding {ViewName : "" , Key : gocui .KeyArrowLeft , Modifier : gocui .ModNone , Handler : previousView },
87- Binding {ViewName : "" , Key : gocui .KeyArrowRight , Modifier : gocui .ModNone , Handler : nextView },
88- Binding {ViewName : "" , Key : gocui .KeyTab , Modifier : gocui .ModNone , Handler : nextView },
89- Binding {ViewName : "" , Key : 'q' , Modifier : gocui .ModNone , Handler : quit },
90- Binding {ViewName : "" , Key : gocui .KeyCtrlC , Modifier : gocui .ModNone , Handler : quit },
91- Binding {ViewName : "" , Key : gocui .KeyArrowDown , Modifier : gocui .ModNone , Handler : cursorDown },
92- Binding {ViewName : "" , Key : gocui .KeyArrowUp , Modifier : gocui .ModNone , Handler : cursorUp },
93- Binding {ViewName : "" , Key : gocui .KeyPgup , Modifier : gocui .ModNone , Handler : scrollUpMain },
94- Binding {ViewName : "" , Key : gocui .KeyPgdn , Modifier : gocui .ModNone , Handler : scrollDownMain },
95- Binding {ViewName : "" , Key : 'P' , Modifier : gocui .ModNone , Handler : pushFiles },
96- Binding {ViewName : "" , Key : 'p' , Modifier : gocui .ModNone , Handler : pullFiles },
97- Binding {ViewName : "" , Key : 'R' , Modifier : gocui .ModNone , Handler : handleRefresh },
98- Binding {ViewName : "files" , Key : 'c' , Modifier : gocui .ModNone , Handler : handleCommitPress },
99- Binding {ViewName : "files" , Key : gocui .KeySpace , Modifier : gocui .ModNone , Handler : handleFilePress },
100- Binding {ViewName : "files" , Key : 'd' , Modifier : gocui .ModNone , Handler : handleFileRemove },
101- Binding {ViewName : "files" , Key : 'm' , Modifier : gocui .ModNone , Handler : handleSwitchToMerge },
102- Binding {ViewName : "files" , Key : 'o' , Modifier : gocui .ModNone , Handler : handleFileOpen },
103- Binding {ViewName : "files" , Key : 's' , Modifier : gocui .ModNone , Handler : handleSublimeFileOpen },
104- Binding {ViewName : "files" , Key : 'v' , Modifier : gocui .ModNone , Handler : handleVsCodeFileOpen },
105- Binding {ViewName : "files" , Key : 'i' , Modifier : gocui .ModNone , Handler : handleIgnoreFile },
106- Binding {ViewName : "files" , Key : 'r' , Modifier : gocui .ModNone , Handler : handleRefreshFiles },
107- Binding {ViewName : "files" , Key : 'S' , Modifier : gocui .ModNone , Handler : handleStashSave },
108- Binding {ViewName : "files" , Key : 'a' , Modifier : gocui .ModNone , Handler : handleAbortMerge },
109- Binding {ViewName : "main" , Key : gocui .KeyArrowUp , Modifier : gocui .ModNone , Handler : handleSelectTop },
110- Binding {ViewName : "main" , Key : gocui .KeyArrowDown , Modifier : gocui .ModNone , Handler : handleSelectBottom },
111- Binding {ViewName : "main" , Key : gocui .KeyEsc , Modifier : gocui .ModNone , Handler : handleEscapeMerge },
112- Binding {ViewName : "main" , Key : gocui .KeySpace , Modifier : gocui .ModNone , Handler : handlePickHunk },
113- Binding {ViewName : "main" , Key : 'b' , Modifier : gocui .ModNone , Handler : handlePickBothHunks },
114- Binding {ViewName : "main" , Key : gocui .KeyArrowLeft , Modifier : gocui .ModNone , Handler : handleSelectPrevConflict },
115- Binding {ViewName : "main" , Key : gocui .KeyArrowRight , Modifier : gocui .ModNone , Handler : handleSelectNextConflict },
116- Binding {ViewName : "main" , Key : 'z' , Modifier : gocui .ModNone , Handler : handlePopFileSnapshot },
117- Binding {ViewName : "branches" , Key : gocui .KeySpace , Modifier : gocui .ModNone , Handler : handleBranchPress },
118- Binding {ViewName : "branches" , Key : 'c' , Modifier : gocui .ModNone , Handler : handleCheckoutByName },
119- Binding {ViewName : "branches" , Key : 'F' , Modifier : gocui .ModNone , Handler : handleForceCheckout },
120- Binding {ViewName : "branches" , Key : 'n' , Modifier : gocui .ModNone , Handler : handleNewBranch },
121- Binding {ViewName : "branches" , Key : 'm' , Modifier : gocui .ModNone , Handler : handleMerge },
122- Binding {ViewName : "commits" , Key : 's' , Modifier : gocui .ModNone , Handler : handleCommitSquashDown },
123- Binding {ViewName : "commits" , Key : 'r' , Modifier : gocui .ModNone , Handler : handleRenameCommit },
124- Binding {ViewName : "commits" , Key : 'g' , Modifier : gocui .ModNone , Handler : handleResetToCommit },
125- Binding {ViewName : "stash" , Key : gocui .KeySpace , Modifier : gocui .ModNone , Handler : handleStashApply },
126- Binding {ViewName : "stash" , Key : 'k' , Modifier : gocui .ModNone , Handler : handleStashPop },
127- Binding {ViewName : "stash" , Key : 'd' , Modifier : gocui .ModNone , Handler : handleStashDrop },
128- }
129- for _ , binding := range bindings {
130- if err := g .SetKeybinding (binding .ViewName , binding .Key , binding .Modifier , binding .Handler ); err != nil {
131- return err
132- }
133- }
134- return nil
135- }
136-
13774func layout (g * gocui.Gui ) error {
13875 g .Highlight = true
13976 g .SelFgColor = gocui .ColorWhite | gocui .AttrBold
0 commit comments