1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-31 03:11:14 +02:00

allow showing, hiding, and scrolling the extras panel

This commit is contained in:
Jesse Duffield 2021-04-11 12:12:54 +10:00
parent e3a14d546a
commit 4f03d7733a
7 changed files with 40 additions and 9 deletions

View File

@ -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",

View File

@ -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,

15
pkg/gui/extras_panel.go Normal file
View File

@ -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})
}

View File

@ -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
}

View File

@ -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{

View File

@ -1111,6 +1111,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Description: gui.Tr.LcOpenDiffingMenu,
OpensMenu: true,
},
{
ViewName: "",
Key: gui.getKey(config.Universal.ExtrasMenu),
Handler: gui.handleCreateExtrasMenuPanel,
Description: gui.Tr.LcOpenExtrasMenu,
OpensMenu: true,
},
{
ViewName: "secondary",
Key: gocui.MouseWheelUp,

View File

@ -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",