1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-02 23:27:32 +02:00
lazygit/pkg/gui/controllers/switch_to_focused_main_view_controller.go
Stefan Haller 1a93b2324b Allow focussing the main view
In this commit this is only possible by pressing '0' in a side panel; we'll add
mouse clicking later in the branch.

Also, you can't really do anything in the focused view except press escape to
leave it again. We'll add some more functionality in a following commit.
2025-04-21 18:03:19 +02:00

50 lines
1.3 KiB
Go

package controllers
import (
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
// This controller is for all contexts that can focus their main view.
var _ types.IController = &SwitchToFocusedMainViewController{}
type SwitchToFocusedMainViewController struct {
baseController
c *ControllerCommon
context types.Context
}
func NewSwitchToFocusedMainViewController(
c *ControllerCommon,
context types.Context,
) *SwitchToFocusedMainViewController {
return &SwitchToFocusedMainViewController{
baseController: baseController{},
c: c,
context: context,
}
}
func (self *SwitchToFocusedMainViewController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding {
bindings := []*types.Binding{
{
Key: opts.GetKey(opts.Config.Universal.FocusMainView),
Handler: self.handleFocusMainView,
Description: self.c.Tr.FocusMainView,
},
}
return bindings
}
func (self *SwitchToFocusedMainViewController) Context() types.Context {
return self.context
}
func (self *SwitchToFocusedMainViewController) handleFocusMainView() error {
mainViewContext := self.c.Helpers().Window.GetContextForWindow("main")
mainViewContext.SetParentContext(self.context)
self.c.Context().Push(mainViewContext, types.OnFocusOpts{})
return nil
}