override config file only if components positions changed
This commit is contained in:
parent
2596f6b0cd
commit
2343f8e970
|
@ -21,6 +21,7 @@ type Layout struct {
|
||||||
ChangeModeEvents chan Mode
|
ChangeModeEvents chan Mode
|
||||||
mode Mode
|
mode Mode
|
||||||
selection int
|
selection int
|
||||||
|
positionsChanged bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Mode rune
|
type Mode rune
|
||||||
|
@ -70,6 +71,9 @@ func (l *Layout) RunIntro() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Layout) changeMode(m Mode) {
|
func (l *Layout) changeMode(m Mode) {
|
||||||
|
if m == ModeComponentResize || m == ModeComponentMove {
|
||||||
|
l.positionsChanged = true
|
||||||
|
}
|
||||||
l.mode = m
|
l.mode = m
|
||||||
l.ChangeModeEvents <- m
|
l.ChangeModeEvents <- m
|
||||||
}
|
}
|
||||||
|
@ -367,3 +371,7 @@ func (l *Layout) resetAlerts() {
|
||||||
c.AlertChannel <- nil
|
c.AlertChannel <- nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *Layout) WerePositionsChanged() bool {
|
||||||
|
return l.positionsChanged
|
||||||
|
}
|
||||||
|
|
|
@ -48,7 +48,9 @@ func (h *Handler) HandleEvents() {
|
||||||
payload := e.Payload.(ui.Mouse)
|
payload := e.Payload.(ui.Mouse)
|
||||||
h.layout.HandleMouseClick(payload.X, payload.Y)
|
h.layout.HandleMouseClick(payload.X, payload.Y)
|
||||||
case console.KeyQuit, console.KeyExit:
|
case console.KeyQuit, console.KeyExit:
|
||||||
h.handleExit()
|
if h.layout.WerePositionsChanged() {
|
||||||
|
h.updateConfigFile()
|
||||||
|
}
|
||||||
return
|
return
|
||||||
case console.SignalResize:
|
case console.SignalResize:
|
||||||
payload := e.Payload.(ui.Resize)
|
payload := e.Payload.(ui.Resize)
|
||||||
|
@ -76,7 +78,7 @@ func (h *Handler) handleModeChange(m layout.Mode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) handleExit() {
|
func (h *Handler) updateConfigFile() {
|
||||||
var settings []config.ComponentSettings
|
var settings []config.ComponentSettings
|
||||||
for _, c := range h.layout.Components {
|
for _, c := range h.layout.Components {
|
||||||
settings = append(settings,
|
settings = append(settings,
|
||||||
|
|
Loading…
Reference in New Issue