diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-11 12:12:54 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-11 17:07:49 +1000 |
commit | 4f03d7733ab186d357064f343915ac48ca059940 (patch) | |
tree | 258437fad6568feaafe1c4a19e2a47c66fc92c5c | |
parent | e3a14d546aa31851e6ab26dcdb21336ad94365c7 (diff) |
allow showing, hiding, and scrolling the extras panel
-rw-r--r-- | pkg/config/user_config.go | 2 | ||||
-rw-r--r-- | pkg/gui/arrangement.go | 5 | ||||
-rw-r--r-- | pkg/gui/extras_panel.go | 15 | ||||
-rw-r--r-- | pkg/gui/global_handlers.go | 10 | ||||
-rw-r--r-- | pkg/gui/gui.go | 7 | ||||
-rw-r--r-- | pkg/gui/keybindings.go | 7 | ||||
-rw-r--r-- | pkg/i18n/english.go | 3 |
7 files changed, 40 insertions, 9 deletions
diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 22a31f02d..28c194574 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -156,6 +156,7 @@ type KeybindingUniversalConfig struct { CopyToClipboard string `yaml:"copyToClipboard"` SubmitEditorText string `yaml:"submitEditorText"` AppendNewline string `yaml:"appendNewline"` + ExtrasMenu string `yaml:"extrasMenu"` } type KeybindingStatusConfig struct { @@ -383,6 +384,7 @@ func GetDefaultConfig() *UserConfig { CopyToClipboard: "<c-o>", SubmitEditorText: "<enter>", AppendNewline: "<a-enter>", + ExtrasMenu: "@", }, Status: KeybindingStatusConfig{ CheckForUpdate: "u", diff --git a/pkg/gui/arrangement.go b/pkg/gui/arrangement.go index 4cd9610f9..8f35ad86d 100644 --- a/pkg/gui/arrangement.go +++ b/pkg/gui/arrangement.go @@ -146,7 +146,10 @@ func (gui *Gui) getWindowDimensions(informationStr string, appStatus string) map mainPanelsDirection = boxlayout.COLUMN } - extrasWindowSize := 40 // TODO: make configurable + extrasWindowSize := 0 + if gui.ShowExtrasWindow { + extrasWindowSize = 40 // TODO: make configurable + } root := &boxlayout.Box{ Direction: boxlayout.ROW, diff --git a/pkg/gui/extras_panel.go b/pkg/gui/extras_panel.go new file mode 100644 index 000000000..976cf5b43 --- /dev/null +++ b/pkg/gui/extras_panel.go @@ -0,0 +1,15 @@ +package gui + +func (gui *Gui) handleCreateExtrasMenuPanel() error { + menuItems := []*menuItem{ + { + displayString: "Toggle show/hide command log", + onPress: func() error { + gui.ShowExtrasWindow = !gui.ShowExtrasWindow + return nil + }, + }, + } + + return gui.createMenu(gui.Tr.DiffingMenuTitle, menuItems, createMenuOptions{showCancel: true}) +} diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go index cea8be8b0..92bb1fee4 100644 --- a/pkg/gui/global_handlers.go +++ b/pkg/gui/global_handlers.go @@ -113,7 +113,7 @@ func (gui *Gui) linesToScrollDown(view *gocui.View) int { } func (gui *Gui) atScrollBottom(view *gocui.View) bool { - return gui.linesToScrollDown(view) > 0 + return gui.linesToScrollDown(view) == 0 } func (gui *Gui) scrollUpMain() error { @@ -147,14 +147,14 @@ func (gui *Gui) scrollUpExtra() error { } func (gui *Gui) scrollDownExtra() error { - if err := gui.scrollDownView(gui.Views.Extras); err != nil { - return err - } - if gui.atScrollBottom(gui.Views.Extras) { gui.Views.Extras.Autoscroll = true } + if err := gui.scrollDownView(gui.Views.Extras); err != nil { + return err + } + return nil } diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 4d104faf2..fa8329991 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -113,6 +113,9 @@ type Gui struct { // Log of the commands that get run, to be displayed to the user. CmdLog []string OnRunCommand func(entry oscommands.CmdLogEntry) + + // the extras window contains things like the command log + ShowExtrasWindow bool } type listPanelState struct { @@ -338,7 +341,6 @@ type guiState struct { IsRefreshingFiles bool Searching searchingState ScreenMode WindowMaximisation - SideView *gocui.View Ptmx *os.File PrevMainWidth int PrevMainHeight int @@ -428,8 +430,7 @@ func (gui *Gui) resetState(filterPath string, reuseState bool) { ConflictsMutex: sync.Mutex{}, }, }, - SideView: nil, - Ptmx: nil, + Ptmx: nil, Modes: Modes{ Filtering: filtering.NewFiltering(filterPath), CherryPicking: CherryPicking{ diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index c2a420e8a..a31b47446 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -1112,6 +1112,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { OpensMenu: true, }, { + ViewName: "", + Key: gui.getKey(config.Universal.ExtrasMenu), + Handler: gui.handleCreateExtrasMenuPanel, + Description: gui.Tr.LcOpenExtrasMenu, + OpensMenu: true, + }, + { ViewName: "secondary", Key: gocui.MouseWheelUp, Modifier: gocui.ModNone, diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 7507744b2..0b991bcfa 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -386,6 +386,7 @@ type TranslationSet struct { DiffingMenuTitle string LcSwapDiff string LcOpenDiffingMenu string + LcOpenExtrasMenu string LcShowingGitDiff string LcCopyCommitShaToClipboard string LcCopyCommitMessageToClipboard string @@ -1038,6 +1039,8 @@ func englishTranslationSet() TranslationSet { DiffingMenuTitle: "Diffing", LcSwapDiff: "reverse diff direction", LcOpenDiffingMenu: "open diff menu", + // the actual view is the extras view which I intend to give more tabs in future but for now we'll only mention the command log part + LcOpenExtrasMenu: "open command log menu", LcShowingGitDiff: "showing output for:", LcCopyCommitShaToClipboard: "copy commit SHA to clipboard", LcCopyCommitMessageToClipboard: "copy commit message to clipboard", |