diff options
Diffstat (limited to 'gui/internal/model/prefs.go')
| -rw-r--r-- | gui/internal/model/prefs.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gui/internal/model/prefs.go b/gui/internal/model/prefs.go index f5ffee5..9ae79a0 100644 --- a/gui/internal/model/prefs.go +++ b/gui/internal/model/prefs.go @@ -112,3 +112,41 @@ func (p Prefs) Save() error { } return os.WriteFile(file, append(data, '\n'), 0o644) } + +// Display is everything the Settings window can change about the window +// itself. It deliberately leaves out the divider positions: those are set +// by dragging, and a settings change must not disturb them. Composing a +// whole Prefs in the Settings window instead is what used to write +// PreviewWidth, ListWidth and ListHeight back as zeros, so dragging the +// panes to taste and then ticking any checkbox threw the panes away. +type Display struct { + Sort string + Layout string + ShowSize bool + ShowAge bool + ShowRule bool + Colours bool + Preview bool + SelectAll bool + PreviewHeight int +} + +// DisplayOf is the part of p the Settings window shows. +func (p Prefs) DisplayOf() Display { + return Display{ + Sort: p.Sort, Layout: p.Layout, + ShowSize: p.ShowSize, ShowAge: p.ShowAge, ShowRule: p.ShowRule, + Colours: p.Colours, Preview: p.Preview, SelectAll: p.SelectAll, + PreviewHeight: p.PreviewHeight, + } +} + +// WithDisplay is p with d applied and everything else - where each divider +// was left - kept as it was. +func (p Prefs) WithDisplay(d Display) Prefs { + p.Sort, p.Layout = d.Sort, d.Layout + p.ShowSize, p.ShowAge, p.ShowRule = d.ShowSize, d.ShowAge, d.ShowRule + p.Colours, p.Preview, p.SelectAll = d.Colours, d.Preview, d.SelectAll + p.PreviewHeight = d.PreviewHeight + return p +} |
