mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-05 00:59:19 +02:00
allow focusing on command log view
This commit is contained in:
@ -41,6 +41,7 @@ For old installations (slightly embarrassing: I didn't realise at the time that
|
|||||||
skipUnstageLineWarning: false
|
skipUnstageLineWarning: false
|
||||||
skipStashWarning: true
|
skipStashWarning: true
|
||||||
showFileTree: false # for rendering changes files in a tree format
|
showFileTree: false # for rendering changes files in a tree format
|
||||||
|
showCommandLog: false
|
||||||
git:
|
git:
|
||||||
paging:
|
paging:
|
||||||
colorArg: always
|
colorArg: always
|
||||||
|
@ -36,6 +36,7 @@ type GuiConfig struct {
|
|||||||
CommitLength CommitLengthConfig `yaml:"commitLength"`
|
CommitLength CommitLengthConfig `yaml:"commitLength"`
|
||||||
SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"`
|
SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"`
|
||||||
ShowFileTree bool `yaml:"showFileTree"`
|
ShowFileTree bool `yaml:"showFileTree"`
|
||||||
|
ShowCommandLog bool `yaml:"showCommandLog"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ThemeConfig struct {
|
type ThemeConfig struct {
|
||||||
|
@ -148,7 +148,10 @@ func (gui *Gui) getWindowDimensions(informationStr string, appStatus string) map
|
|||||||
|
|
||||||
extrasWindowSize := 0
|
extrasWindowSize := 0
|
||||||
if gui.ShowExtrasWindow {
|
if gui.ShowExtrasWindow {
|
||||||
extrasWindowSize = 40 // TODO: make configurable
|
extrasWindowSize = 10
|
||||||
|
if gui.currentStaticContext().GetKey() == COMMAND_LOG_CONTEXT_KEY {
|
||||||
|
extrasWindowSize = 40
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
root := &boxlayout.Box{
|
root := &boxlayout.Box{
|
||||||
|
@ -313,6 +313,29 @@ func (gui *Gui) currentSideContext() Context {
|
|||||||
return gui.defaultSideContext()
|
return gui.defaultSideContext()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static as opposed to popup
|
||||||
|
func (gui *Gui) currentStaticContext() Context {
|
||||||
|
gui.State.ContextManager.RLock()
|
||||||
|
defer gui.State.ContextManager.RUnlock()
|
||||||
|
|
||||||
|
stack := gui.State.ContextManager.ContextStack
|
||||||
|
|
||||||
|
if len(stack) == 0 {
|
||||||
|
return gui.defaultSideContext()
|
||||||
|
}
|
||||||
|
|
||||||
|
// find the first context in the stack without a popup type
|
||||||
|
for i := range stack {
|
||||||
|
context := stack[len(stack)-1-i]
|
||||||
|
|
||||||
|
if context.GetKind() != TEMPORARY_POPUP && context.GetKind() != PERSISTENT_POPUP {
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return gui.defaultSideContext()
|
||||||
|
}
|
||||||
|
|
||||||
func (gui *Gui) defaultSideContext() Context {
|
func (gui *Gui) defaultSideContext() Context {
|
||||||
if gui.State.Modes.Filtering.Active() {
|
if gui.State.Modes.Filtering.Active() {
|
||||||
return gui.State.Contexts.BranchCommits
|
return gui.State.Contexts.BranchCommits
|
||||||
@ -362,7 +385,7 @@ func (gui *Gui) onViewFocusChange() error {
|
|||||||
|
|
||||||
currentView := gui.g.CurrentView()
|
currentView := gui.g.CurrentView()
|
||||||
for _, view := range gui.g.Views() {
|
for _, view := range gui.g.Views() {
|
||||||
view.Highlight = view.Name() != "main" && view == currentView
|
view.Highlight = view.Name() != "main" && view.Name() != "extras" && view == currentView
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -188,10 +188,15 @@ func (gui *Gui) contextTree() ContextTree {
|
|||||||
Key: SEARCH_CONTEXT_KEY,
|
Key: SEARCH_CONTEXT_KEY,
|
||||||
},
|
},
|
||||||
CommandLog: &BasicContext{
|
CommandLog: &BasicContext{
|
||||||
OnFocus: func() error { return nil },
|
OnFocus: func() error { return nil },
|
||||||
Kind: EXTRAS_CONTEXT,
|
Kind: EXTRAS_CONTEXT,
|
||||||
ViewName: "extras",
|
ViewName: "extras",
|
||||||
Key: COMMAND_LOG_CONTEXT_KEY,
|
Key: COMMAND_LOG_CONTEXT_KEY,
|
||||||
|
OnGetOptionsMap: gui.getMergingOptions,
|
||||||
|
OnFocusLost: func() error {
|
||||||
|
gui.Views.Extras.Autoscroll = true
|
||||||
|
return nil
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,12 @@ func (gui *Gui) handleCreateExtrasMenuPanel() error {
|
|||||||
{
|
{
|
||||||
displayString: gui.Tr.ToggleShowCommandLog,
|
displayString: gui.Tr.ToggleShowCommandLog,
|
||||||
onPress: func() error {
|
onPress: func() error {
|
||||||
|
currentContext := gui.currentStaticContext()
|
||||||
|
if gui.ShowExtrasWindow && currentContext.GetKey() == COMMAND_LOG_CONTEXT_KEY {
|
||||||
|
if err := gui.returnFromContext(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
gui.ShowExtrasWindow = !gui.ShowExtrasWindow
|
gui.ShowExtrasWindow = !gui.ShowExtrasWindow
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
@ -12,12 +18,32 @@ func (gui *Gui) handleCreateExtrasMenuPanel() error {
|
|||||||
{
|
{
|
||||||
displayString: gui.Tr.FocusCommandLog,
|
displayString: gui.Tr.FocusCommandLog,
|
||||||
onPress: func() error {
|
onPress: func() error {
|
||||||
gui.ShowExtrasWindow = true
|
return gui.handleFocusCommandLog()
|
||||||
gui.State.Contexts.CommandLog.SetParentContext(gui.currentSideContext())
|
|
||||||
return gui.pushContext(gui.State.Contexts.CommandLog)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return gui.createMenu(gui.Tr.DiffingMenuTitle, menuItems, createMenuOptions{showCancel: true})
|
return gui.createMenu(gui.Tr.CommandLog, menuItems, createMenuOptions{showCancel: true})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) handleFocusCommandLog() error {
|
||||||
|
gui.ShowExtrasWindow = true
|
||||||
|
gui.State.Contexts.CommandLog.SetParentContext(gui.currentSideContext())
|
||||||
|
return gui.pushContext(gui.State.Contexts.CommandLog)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) scrollUpExtra() error {
|
||||||
|
gui.Views.Extras.Autoscroll = false
|
||||||
|
|
||||||
|
return gui.scrollUpView(gui.Views.Extras)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) scrollDownExtra() error {
|
||||||
|
gui.Views.Extras.Autoscroll = false
|
||||||
|
|
||||||
|
if err := gui.scrollDownView(gui.Views.Extras); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -140,24 +140,6 @@ func (gui *Gui) scrollDownSecondary() error {
|
|||||||
return gui.scrollDownView(gui.Views.Secondary)
|
return gui.scrollDownView(gui.Views.Secondary)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) scrollUpExtra() error {
|
|
||||||
gui.Views.Extras.Autoscroll = false
|
|
||||||
|
|
||||||
return gui.scrollUpView(gui.Views.Extras)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (gui *Gui) scrollDownExtra() error {
|
|
||||||
if gui.atScrollBottom(gui.Views.Extras) {
|
|
||||||
gui.Views.Extras.Autoscroll = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := gui.scrollDownView(gui.Views.Extras); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (gui *Gui) scrollUpConfirmationPanel() error {
|
func (gui *Gui) scrollUpConfirmationPanel() error {
|
||||||
if gui.Views.Confirmation.Editable {
|
if gui.Views.Confirmation.Editable {
|
||||||
return nil
|
return nil
|
||||||
@ -183,13 +165,13 @@ func (gui *Gui) handleMouseDownMain() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
switch gui.g.CurrentView() {
|
switch gui.currentSideContext() {
|
||||||
case gui.Views.Files:
|
case gui.State.Contexts.Files:
|
||||||
// set filename, set primary/secondary selected, set line number, then switch context
|
// set filename, set primary/secondary selected, set line number, then switch context
|
||||||
// I'll need to know it was changed though.
|
// I'll need to know it was changed though.
|
||||||
// Could I pass something along to the context change?
|
// Could I pass something along to the context change?
|
||||||
return gui.enterFile(false, gui.Views.Main.SelectedLineIdx())
|
return gui.enterFile(false, gui.Views.Main.SelectedLineIdx())
|
||||||
case gui.Views.CommitFiles:
|
case gui.State.Contexts.CommitFiles:
|
||||||
return gui.enterCommitFile(gui.Views.Main.SelectedLineIdx())
|
return gui.enterCommitFile(gui.Views.Main.SelectedLineIdx())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,6 +466,7 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *oscom
|
|||||||
RepoPathStack: []string{},
|
RepoPathStack: []string{},
|
||||||
RepoStateMap: map[Repo]*guiState{},
|
RepoStateMap: map[Repo]*guiState{},
|
||||||
CmdLog: []string{},
|
CmdLog: []string{},
|
||||||
|
ShowExtrasWindow: config.GetUserConfig().Gui.ShowCommandLog,
|
||||||
}
|
}
|
||||||
|
|
||||||
gui.resetState(filterPath, false)
|
gui.resetState(filterPath, false)
|
||||||
@ -480,6 +481,8 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *oscom
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gui.Views.Extras.Autoscroll = true
|
||||||
|
|
||||||
if entry.GetSpan() != currentSpan {
|
if entry.GetSpan() != currentSpan {
|
||||||
fmt.Fprintln(gui.Views.Extras, utils.ColoredString(entry.GetSpan(), color.FgYellow))
|
fmt.Fprintln(gui.Views.Extras, utils.ColoredString(entry.GetSpan(), color.FgYellow))
|
||||||
currentSpan = entry.GetSpan()
|
currentSpan = entry.GetSpan()
|
||||||
|
@ -1719,6 +1719,52 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||||||
Key: gocui.MouseWheelDown,
|
Key: gocui.MouseWheelDown,
|
||||||
Handler: gui.scrollDownExtra,
|
Handler: gui.scrollDownExtra,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ViewName: "extras",
|
||||||
|
Key: gui.getKey(config.Universal.ExtrasMenu),
|
||||||
|
Handler: gui.handleCreateExtrasMenuPanel,
|
||||||
|
Description: gui.Tr.LcOpenExtrasMenu,
|
||||||
|
OpensMenu: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ViewName: "extras",
|
||||||
|
Tag: "navigation",
|
||||||
|
Contexts: []string{string(COMMAND_LOG_CONTEXT_KEY)},
|
||||||
|
Key: gui.getKey(config.Universal.PrevItemAlt),
|
||||||
|
Modifier: gocui.ModNone,
|
||||||
|
Handler: gui.scrollUpExtra,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ViewName: "extras",
|
||||||
|
Tag: "navigation",
|
||||||
|
Contexts: []string{string(COMMAND_LOG_CONTEXT_KEY)},
|
||||||
|
Key: gui.getKey(config.Universal.PrevItem),
|
||||||
|
Modifier: gocui.ModNone,
|
||||||
|
Handler: gui.scrollUpExtra,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ViewName: "extras",
|
||||||
|
Tag: "navigation",
|
||||||
|
Contexts: []string{string(COMMAND_LOG_CONTEXT_KEY)},
|
||||||
|
Key: gui.getKey(config.Universal.NextItem),
|
||||||
|
Modifier: gocui.ModNone,
|
||||||
|
Handler: gui.scrollDownExtra,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ViewName: "extras",
|
||||||
|
Tag: "navigation",
|
||||||
|
Contexts: []string{string(COMMAND_LOG_CONTEXT_KEY)},
|
||||||
|
Key: gui.getKey(config.Universal.NextItemAlt),
|
||||||
|
Modifier: gocui.ModNone,
|
||||||
|
Handler: gui.scrollDownExtra,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ViewName: "extras",
|
||||||
|
Tag: "navigation",
|
||||||
|
Key: gocui.MouseLeft,
|
||||||
|
Modifier: gocui.ModNone,
|
||||||
|
Handler: gui.handleFocusCommandLog,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, viewName := range []string{"status", "branches", "files", "commits", "commitFiles", "stash", "menu"} {
|
for _, viewName := range []string{"status", "branches", "files", "commits", "commitFiles", "stash", "menu"} {
|
||||||
|
Reference in New Issue
Block a user