feat(chat): add sidebar.width_percent field for guilds tree width (#805)
Co-authored-by: ayn2op <ayn2op@gmail.com>
This commit is contained in:
parent
6a2a5fa7fb
commit
ab731f06fd
3 changed files with 20 additions and 4 deletions
|
|
@ -96,8 +96,11 @@ type (
|
|||
}
|
||||
|
||||
SidebarConfig struct {
|
||||
Markers SidebarMarkersConfig `toml:"markers"`
|
||||
Indents SidebarIndentsConfig `toml:"indents"`
|
||||
// WidthPercent is the percentage (%) of the total
|
||||
// window width that the guilds tree sidebar occupies
|
||||
WidthPercent int `toml:"width_percent"`
|
||||
Markers SidebarMarkersConfig `toml:"markers"`
|
||||
Indents SidebarIndentsConfig `toml:"indents"`
|
||||
}
|
||||
|
||||
Config struct {
|
||||
|
|
@ -182,6 +185,14 @@ func applyDefaults(cfg *Config) {
|
|||
cfg.Composer.MaxHeight = 10
|
||||
}
|
||||
|
||||
if cfg.Sidebar.WidthPercent <= 0 || cfg.Sidebar.WidthPercent >= 100 {
|
||||
// these guidelines are simply to guarantee functionality;
|
||||
// there's no guarantee that there's functional utility in
|
||||
// setting an extremely low width, but that's for the
|
||||
// user to decide.
|
||||
cfg.Sidebar.WidthPercent = 20
|
||||
}
|
||||
|
||||
if cfg.DateSeparator.Format == "" {
|
||||
cfg.DateSeparator.Format = "January 2, 2006"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,11 @@ send = true
|
|||
# Whether to receive typing status or not.
|
||||
receive = true
|
||||
|
||||
[sidebar]
|
||||
# Percentage (%) of the available width used by the guilds tree sidebar.
|
||||
# Valid values are 1-99. Invalid values fall back to 20.
|
||||
width_percent = 20
|
||||
|
||||
[sidebar.markers]
|
||||
expanded = "▾ "
|
||||
collapsed = "▸ "
|
||||
|
|
|
|||
|
|
@ -138,8 +138,8 @@ func (m *Model) buildLayout() {
|
|||
AddItem(m.composer, 3, 1, false)
|
||||
// The guilds tree is always focused first at start-up.
|
||||
m.mainFlex.
|
||||
AddItem(m.guildsTree, 0, 1, true).
|
||||
AddItem(m.rightFlex, 0, 4, false)
|
||||
AddItem(m.guildsTree, 0, m.cfg.Sidebar.WidthPercent, true).
|
||||
AddItem(m.rightFlex, 0, 100-m.cfg.Sidebar.WidthPercent, false)
|
||||
|
||||
m.AddLayer(m.mainFlex, layers.WithName(flexLayerName), layers.WithResize(true), layers.WithVisible(true))
|
||||
m.AddLayer(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue