mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-05 13:24:54 +02:00
move toggle whitespace action to controllers package
This commit is contained in:
parent
2e32e55957
commit
0faa41e6f8
@ -107,6 +107,11 @@ func (self *GlobalController) GetKeybindings(opts types.KeybindingsOpts) []*type
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: self.escape,
|
||||
},
|
||||
{
|
||||
Key: opts.GetKey(opts.Config.Universal.ToggleWhitespaceInDiffView),
|
||||
Handler: self.toggleWhitespace,
|
||||
Description: self.c.Tr.ToggleWhitespaceInDiffView,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,3 +162,7 @@ func (self *GlobalController) quitWithoutChangingDirectory() error {
|
||||
func (self *GlobalController) escape() error {
|
||||
return (&QuitActions{c: self.c}).Escape()
|
||||
}
|
||||
|
||||
func (self *GlobalController) toggleWhitespace() error {
|
||||
return (&ToggleWhitespaceAction{c: self.c}).Call()
|
||||
}
|
||||
|
21
pkg/gui/controllers/toggle_whitespace_action.go
Normal file
21
pkg/gui/controllers/toggle_whitespace_action.go
Normal file
@ -0,0 +1,21 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
)
|
||||
|
||||
type ToggleWhitespaceAction struct {
|
||||
c *ControllerCommon
|
||||
}
|
||||
|
||||
func (self *ToggleWhitespaceAction) Call() error {
|
||||
self.c.State().SetIgnoreWhitespaceInDiffView(!self.c.State().GetIgnoreWhitespaceInDiffView())
|
||||
|
||||
toastMessage := self.c.Tr.ShowingWhitespaceInDiffView
|
||||
if self.c.State().GetIgnoreWhitespaceInDiffView() {
|
||||
toastMessage = self.c.Tr.IgnoringWhitespaceInDiffView
|
||||
}
|
||||
self.c.Toast(toastMessage)
|
||||
|
||||
return self.c.CurrentSideContext().HandleFocus(types.OnFocusOpts{})
|
||||
}
|
@ -258,12 +258,6 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi
|
||||
Handler: self.handleCopySelectedSideContextItemToClipboard,
|
||||
Description: self.c.Tr.LcCopySubmoduleNameToClipboard,
|
||||
},
|
||||
{
|
||||
ViewName: "",
|
||||
Key: opts.GetKey(opts.Config.Universal.ToggleWhitespaceInDiffView),
|
||||
Handler: self.toggleWhitespaceInDiffView,
|
||||
Description: self.c.Tr.ToggleWhitespaceInDiffView,
|
||||
},
|
||||
{
|
||||
ViewName: "extras",
|
||||
Key: gocui.MouseWheelUp,
|
||||
|
@ -1,17 +0,0 @@
|
||||
package gui
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
)
|
||||
|
||||
func (gui *Gui) toggleWhitespaceInDiffView() error {
|
||||
gui.IgnoreWhitespaceInDiffView = !gui.IgnoreWhitespaceInDiffView
|
||||
|
||||
toastMessage := gui.c.Tr.ShowingWhitespaceInDiffView
|
||||
if gui.IgnoreWhitespaceInDiffView {
|
||||
toastMessage = gui.c.Tr.IgnoringWhitespaceInDiffView
|
||||
}
|
||||
gui.c.Toast(toastMessage)
|
||||
|
||||
return gui.c.CurrentSideContext().HandleFocus(types.OnFocusOpts{})
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user