diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-03-02 15:11:53 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-03-02 17:46:56 +1100 |
commit | e331dfcaf845df42580b171ac29380e707844858 (patch) | |
tree | 12584a122f625ad6f20b0d293810dcdf6a34e2e6 /pkg | |
parent | 1337f6e76ad5a9293b2d32fd29cbe91e750814c6 (diff) |
update i18n
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/context.go | 4 | ||||
-rw-r--r-- | pkg/gui/keybindings.go | 110 | ||||
-rw-r--r-- | pkg/i18n/english.go | 45 |
3 files changed, 129 insertions, 30 deletions
diff --git a/pkg/gui/context.go b/pkg/gui/context.go index d349286cf..861ffc0be 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -38,7 +38,7 @@ func (gui *Gui) changeContext(viewName, context string) error { return nil } - contextMap := gui.getContextMap() + contextMap := gui.GetContextMap() gui.g.DeleteKeybindings(viewName) @@ -53,7 +53,7 @@ func (gui *Gui) changeContext(viewName, context string) error { } func (gui *Gui) setInitialContexts() error { - contextMap := gui.getContextMap() + contextMap := gui.GetContextMap() initialContexts := map[string]string{ "main": "merging", diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 3992513ef..6084d26e7 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -13,6 +13,7 @@ type Binding struct { Key interface{} // FIXME: find out how to get `gocui.Key | rune` Modifier gocui.Modifier Description string + panic bool } // GetDisplayStrings returns the display string of a file @@ -31,6 +32,10 @@ func (b *Binding) GetKey() string { key = int(b.Key.(gocui.Key)) } + if b.panic { + panic(key) + } + // special keys switch key { case 27: @@ -39,6 +44,18 @@ func (b *Binding) GetKey() string { return "enter" case 32: return "space" + case 65514: + return "►" + case 65515: + return "◄" + case 65517: + return "▲" + case 65516: + return "▼" + case 65508: + return "PgUp" + case 65507: + return "PgDn" } return string(key) @@ -461,11 +478,12 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { return bindings } +// GetCurrentKeybindings gets the list of keybindings given the current context func (gui *Gui) GetCurrentKeybindings() []*Binding { bindings := gui.GetInitialKeybindings() viewName := gui.currentViewName(gui.g) currentContext := gui.State.Contexts[viewName] - contextBindings := gui.getContextMap()[viewName][currentContext] + contextBindings := gui.GetContextMap()[viewName][currentContext] return append(bindings, contextBindings...) } @@ -484,9 +502,24 @@ func (gui *Gui) keybindings(g *gocui.Gui) error { return nil } -func (gui *Gui) getContextMap() map[string]map[string][]*Binding { +func (gui *Gui) GetContextMap() map[string]map[string][]*Binding { return map[string]map[string][]*Binding{ "main": { + "normal": { + { + ViewName: "main", + Key: gocui.MouseWheelDown, + Modifier: gocui.ModNone, + Handler: gui.scrollDownMain, + Description: gui.Tr.SLocalize("ScrollDown"), + }, { + ViewName: "main", + Key: gocui.MouseWheelUp, + Modifier: gocui.ModNone, + Handler: gui.scrollUpMain, + Description: gui.Tr.SLocalize("ScrollUp"), + }, + }, "staging": { { ViewName: "main", @@ -495,15 +528,17 @@ func (gui *Gui) getContextMap() map[string]map[string][]*Binding { Handler: gui.handleStagingEscape, Description: gui.Tr.SLocalize("EscapeStaging"), }, { - ViewName: "main", - Key: gocui.KeyArrowUp, - Modifier: gocui.ModNone, - Handler: gui.handleStagingPrevLine, + ViewName: "main", + Key: gocui.KeyArrowUp, + Modifier: gocui.ModNone, + Handler: gui.handleStagingPrevLine, + Description: gui.Tr.SLocalize("PrevLine"), }, { - ViewName: "main", - Key: gocui.KeyArrowDown, - Modifier: gocui.ModNone, - Handler: gui.handleStagingNextLine, + ViewName: "main", + Key: gocui.KeyArrowDown, + Modifier: gocui.ModNone, + Handler: gui.handleStagingNextLine, + Description: gui.Tr.SLocalize("NextLine"), }, { ViewName: "main", Key: 'k', @@ -516,14 +551,26 @@ func (gui *Gui) getContextMap() map[string]map[string][]*Binding { Handler: gui.handleStagingNextLine, }, { ViewName: "main", - Key: gocui.KeyArrowLeft, + Key: gocui.MouseWheelUp, Modifier: gocui.ModNone, - Handler: gui.handleStagingPrevHunk, + Handler: gui.handleStagingPrevLine, }, { ViewName: "main", - Key: gocui.KeyArrowRight, + Key: gocui.MouseWheelDown, Modifier: gocui.ModNone, - Handler: gui.handleStagingNextHunk, + Handler: gui.handleStagingNextLine, + }, { + ViewName: "main", + Key: gocui.KeyArrowLeft, + Modifier: gocui.ModNone, + Handler: gui.handleStagingPrevHunk, + Description: gui.Tr.SLocalize("PrevHunk"), + }, { + ViewName: "main", + Key: gocui.KeyArrowRight, + Modifier: gocui.ModNone, + Handler: gui.handleStagingNextHunk, + Description: gui.Tr.SLocalize("NextHunk"), }, { ViewName: "main", Key: 'h', @@ -550,10 +597,11 @@ func (gui *Gui) getContextMap() map[string]map[string][]*Binding { }, "merging": { { - ViewName: "main", - Key: gocui.KeyEsc, - Modifier: gocui.ModNone, - Handler: gui.handleEscapeMerge, + ViewName: "main", + Key: gocui.KeyEsc, + Modifier: gocui.ModNone, + Handler: gui.handleEscapeMerge, + Description: gui.Tr.SLocalize("EscapeStaging"), }, { ViewName: "main", Key: gocui.KeySpace, @@ -567,25 +615,31 @@ func (gui *Gui) getContextMap() map[string]map[string][]*Binding { Handler: gui.handlePickBothHunks, Description: gui.Tr.SLocalize("PickBothHunks"), }, { - ViewName: "main", - Key: gocui.KeyArrowLeft, - Modifier: gocui.ModNone, - Handler: gui.handleSelectPrevConflict, + ViewName: "main", + Key: gocui.KeyArrowLeft, + Modifier: gocui.ModNone, + Handler: gui.handleSelectPrevConflict, + Description: gui.Tr.SLocalize("PrevConflict"), }, { ViewName: "main", Key: gocui.KeyArrowRight, Modifier: gocui.ModNone, Handler: gui.handleSelectNextConflict, + + Description: gui.Tr.SLocalize("NextConflict"), }, { ViewName: "main", Key: gocui.KeyArrowUp, - Modifier: gocui.ModNone, - Handler: gui.handleSelectTop, + + Modifier: gocui.ModNone, + Handler: gui.handleSelectTop, + Description: gui.Tr.SLocalize("SelectTop"), }, { - ViewName: "main", - Key: gocui.KeyArrowDown, - Modifier: gocui.ModNone, - Handler: gui.handleSelectBottom, + ViewName: "main", + Key: gocui.KeyArrowDown, + Modifier: gocui.ModNone, + Handler: gui.handleSelectBottom, + Description: gui.Tr.SLocalize("SelectBottom"), }, { ViewName: "main", Key: 'h', diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 74d9bfb7d..7195c5f0d 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -46,6 +46,18 @@ func addEnglish(i18nObject *i18n.Bundle) error { ID: "MergingMainTitle", Other: "Resolve merge conflicts", }, &i18n.Message{ + ID: "MainTitle", + Other: "Main", + }, &i18n.Message{ + ID: "StagingTitle", + Other: "Staging", + }, &i18n.Message{ + ID: "MergingTitle", + Other: "Merging", + }, &i18n.Message{ + ID: "NormalTitle", + Other: "Normal", + }, &i18n.Message{ ID: "CommitMessage", Other: "Commit message", }, &i18n.Message{ @@ -588,6 +600,39 @@ func addEnglish(i18nObject *i18n.Bundle) error { }, &i18n.Message{ ID: "CannotRebaseOntoFirstCommit", Other: "You cannot interactive rebase onto the first commit", + }, &i18n.Message{ + ID: "Donate", + Other: "Donate", + }, &i18n.Message{ + ID: "PrevLine", + Other: "select previous line", + }, &i18n.Message{ + ID: "NextLine", + Other: "select next line", + }, &i18n.Message{ + ID: "PrevHunk", + Other: "select previous hunk", + }, &i18n.Message{ + ID: "NextHunk", + Other: "select next hunk", + }, &i18n.Message{ + ID: "PrevConflict", + Other: "select previous conflict", + }, &i18n.Message{ + ID: "NextConflict", + Other: "select next conflict", + }, &i18n.Message{ + ID: "SelectTop", + Other: "select top hunk", + }, &i18n.Message{ + ID: "SelectBottom", + Other: "select bottom hunk", + }, &i18n.Message{ + ID: "ScrollDown", + Other: "scroll down", + }, &i18n.Message{ + ID: "ScrollUp", + Other: "scroll up", }, ) } |