diff --git a/internal/config/config.go b/internal/config/config.go index d4ded89..d25830e 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -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" } diff --git a/internal/config/config.toml b/internal/config/config.toml index 159e28d..0b837c6 100644 --- a/internal/config/config.toml +++ b/internal/config/config.toml @@ -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 = "▸ " diff --git a/internal/ui/chat/model.go b/internal/ui/chat/model.go index d193da3..41fe91b 100644 --- a/internal/ui/chat/model.go +++ b/internal/ui/chat/model.go @@ -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(