diff options
author | David Chen <weichen2000121@gmail.com> | 2019-12-07 09:19:43 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-07 09:19:43 -0800 |
commit | c507e5f562f6753110e5dc582b5cab9bda76b6ee (patch) | |
tree | 527c520534d230fd5951c5729e0b54dee7c02a7c | |
parent | 63e353ad6a86c04b7b02100ff2ddc7337369b1ea (diff) | |
parent | 3f4613feb010fbafa405e8caa6b48e7e6bca3000 (diff) |
Merge branch 'master' into custom-keybindings
-rw-r--r-- | pkg/commands/git.go | 4 | ||||
-rw-r--r-- | pkg/gui/commit_message_panel.go | 35 | ||||
-rw-r--r-- | pkg/gui/gui.go | 1 | ||||
-rw-r--r-- | pkg/gui/keybindings.go | 8 | ||||
-rw-r--r-- | pkg/gui/remotes_panel.go | 15 | ||||
-rw-r--r-- | pkg/i18n/english.go | 6 |
6 files changed, 69 insertions, 0 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 3464215c7..7bcc651cb 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -1109,3 +1109,7 @@ func (c *GitCommand) DeleteTag(tagName string) error { func (c *GitCommand) PushTag(remoteName string, tagName string) error { return c.OSCommand.RunCommand("git push %s %s", remoteName, tagName) } + +func (c *GitCommand) FetchRemote(remoteName string) error { + return c.OSCommand.RunCommand("git fetch %s", remoteName) +} diff --git a/pkg/gui/commit_message_panel.go b/pkg/gui/commit_message_panel.go index b087f5904..8d2d02524 100644 --- a/pkg/gui/commit_message_panel.go +++ b/pkg/gui/commit_message_panel.go @@ -83,3 +83,38 @@ func (gui *Gui) RenderCommitLength() { v := gui.getCommitMessageView() v.Subtitle = gui.getBufferLength(v) } + +// we've just copy+pasted the editor from gocui to here so that we can also re- +// render the commit message length on each keypress +func (gui *Gui) commitMessageEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) { + switch { + case key == gocui.KeyBackspace || key == gocui.KeyBackspace2: + v.EditDelete(true) + case key == gocui.KeyDelete: + v.EditDelete(false) + case key == gocui.KeyArrowDown: + v.MoveCursor(0, 1, false) + case key == gocui.KeyArrowUp: + v.MoveCursor(0, -1, false) + case key == gocui.KeyArrowLeft: + v.MoveCursor(-1, 0, false) + case key == gocui.KeyArrowRight: + v.MoveCursor(1, 0, false) + case key == gocui.KeyTab: + v.EditNewLine() + case key == gocui.KeySpace: + v.EditWrite(' ') + case key == gocui.KeyInsert: + v.Overwrite = !v.Overwrite + case key == gocui.KeyCtrlU: + v.EditDeleteToStartOfLine() + case key == gocui.KeyCtrlA: + v.EditGotoToStartOfLine() + case key == gocui.KeyCtrlE: + v.EditGotoToEndOfLine() + default: + v.EditWrite(ch) + } + + gui.RenderCommitLength() +} diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 3b6f2fb11..ba379fc56 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -553,6 +553,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { commitMessageView.Title = gui.Tr.SLocalize("CommitMessage") commitMessageView.FgColor = textColor commitMessageView.Editable = true + commitMessageView.Editor = gocui.EditorFunc(gui.commitMessageEditor) } } diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 2b0719189..0d9607574 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -738,6 +738,14 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { Description: gui.Tr.SLocalize("ReturnToRemotesList"), }, { + ViewName: "branches", + Contexts: []string{"remotes"}, + Key: 'f', + Modifier: gocui.ModNone, + Handler: gui.handleFetchRemote, + Description: gui.Tr.SLocalize("fetchRemote"), + }, + { ViewName: "commits", Key: gui.getKey("commits.squashDown"), Modifier: gocui.ModNone, diff --git a/pkg/gui/remotes_panel.go b/pkg/gui/remotes_panel.go index 90c2c8d59..6964bf108 100644 --- a/pkg/gui/remotes_panel.go +++ b/pkg/gui/remotes_panel.go @@ -176,3 +176,18 @@ func (gui *Gui) handleEditRemote(g *gocui.Gui, v *gocui.View) error { }) }) } + +func (gui *Gui) handleFetchRemote(g *gocui.Gui, v *gocui.View) error { + remote := gui.getSelectedRemote() + if remote == nil { + return nil + } + + return gui.WithWaitingStatus(gui.Tr.SLocalize("FetchingRemoteStatus"), func() error { + if err := gui.GitCommand.FetchRemote(remote.Name); err != nil { + return err + } + + return gui.refreshRemotes() + }) +} diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 10e4d209d..849594872 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -912,6 +912,12 @@ func addEnglish(i18nObject *i18n.Bundle) error { }, &i18n.Message{ ID: "CreateTagTitle", Other: "Tag name:", + }, &i18n.Message{ + ID: "fetchRemote", + Other: "fetch remote", + }, &i18n.Message{ + ID: "FetchingRemoteStatus", + Other: "fetching remote", }, ) } |