diff --git a/go.mod b/go.mod index f8bf21e..6e0dee5 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/andybalholm/brotli v1.2.6 github.com/ayn2op/arikawa/v3 v3.0.0-20260929021956-7d0802bf4d7c github.com/ayn2op/ningen/v3 v3.0.1-0.20260929010920-29794d5fa70e - github.com/ayn2op/tview v0.0.0-20260930215038-4bb4ac90d11c + github.com/ayn2op/tview v0.0.0-20260930235645-239215f3c690 github.com/bogdanfinn/fhttp v0.6.9 github.com/bogdanfinn/tls-client v1.16.0 github.com/gdamore/tcell/v3 v3.5.0 diff --git a/go.sum b/go.sum index 8f93bce..121765a 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,8 @@ github.com/ayn2op/arikawa/v3 v3.0.0-20260929021956-7d0802bf4d7c h1:Qkl3W5RXzUQUR github.com/ayn2op/arikawa/v3 v3.0.0-20260929021956-7d0802bf4d7c/go.mod h1:SHqcr+EmZKeNtVKZybHJn4HNz+ufA1XbeKNSTigBCEE= github.com/ayn2op/ningen/v3 v3.0.1-0.20260929010920-29794d5fa70e h1:QAei/IVEyZV7GcpkpcFUh37+QRqwrt57z7OT3ciHrhI= github.com/ayn2op/ningen/v3 v3.0.1-0.20260929010920-29794d5fa70e/go.mod h1:RsvYiMzi4Si1F7vmml5NCL2DaKIZXkNUQC7QlGTMtCw= -github.com/ayn2op/tview v0.0.0-20260930215038-4bb4ac90d11c h1:ABMNEaSusSM3FiOjIrrR8zz9JUgA+oXQCs6bpUgqsmI= -github.com/ayn2op/tview v0.0.0-20260930215038-4bb4ac90d11c/go.mod h1:oRPTSZgaEJPhv3dmmNvo6grBq/BemrLG3wFQLMTZJkY= +github.com/ayn2op/tview v0.0.0-20260930235645-239215f3c690 h1:D9rzPnRksnsHtCszkHFwSalAO8fXnK4h2bbOCT+SyUo= +github.com/ayn2op/tview v0.0.0-20260930235645-239215f3c690/go.mod h1:oRPTSZgaEJPhv3dmmNvo6grBq/BemrLG3wFQLMTZJkY= github.com/bdandy/go-errors v1.2.2 h1:WdFv/oukjTJCLa79UfkGmwX7ZxONAihKu4V0mLIs11Q= github.com/bdandy/go-errors v1.2.2/go.mod h1:NkYHl4Fey9oRRdbB1CoC6e84tuqQHiqrOcZpqFEkBxM= github.com/bdandy/go-socks4 v1.2.3 h1:Q6Y2heY1GRjCtHbmlKfnwrKVU/k81LS8mRGLRlmDlic= diff --git a/internal/config/config.go b/internal/config/config.go index eafb934..96a5105 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -178,7 +178,8 @@ type ( MembersTree PaneConfig `toml:"members_tree"` Composer ComposerConfig `toml:"composer"` - Icons Icons `toml:"icons"` + UI UIConfig `toml:"ui"` + Icons Icons `toml:"icons"` Keybinds Keybinds `toml:"keybinds"` Theme Theme `toml:"theme"` diff --git a/internal/config/config.toml b/internal/config/config.toml index 52593a1..ea6c646 100644 --- a/internal/config/config.toml +++ b/internal/config/config.toml @@ -55,6 +55,20 @@ separator = " • " width = 80 height = 25 +[ui.tabs] +# Where tabs that fit are placed: "left", "center" or "right". +alignment = "center" +# Whether moving past the last tab selects the first, and past the first selects the last. +wrap = false +# Text between tabs. +separator = "│" +# Text on either side of each tab: [left, right] +padding = [" ", " "] +# Arrows shown while tabs are hidden past an end: [start, end]. An empty string turns that arrow off. +arrows = ["◀", "▶"] +# Whether clicking an arrow selects the tab next to the active one. +clickable_arrows = true + [timestamps] enabled = true # https://pkg.go.dev/time#Layout diff --git a/internal/config/ui.go b/internal/config/ui.go new file mode 100644 index 0000000..81c2582 --- /dev/null +++ b/internal/config/ui.go @@ -0,0 +1,16 @@ +package config + +type ( + UIConfig struct { + Tabs TabsConfig `toml:"tabs"` + } + + TabsConfig struct { + Alignment AlignmentWrapper `toml:"alignment"` + Wrap bool `toml:"wrap"` + Separator string `toml:"separator"` + Padding [2]string `toml:"padding"` + Arrows [2]string `toml:"arrows"` + ClickableArrows bool `toml:"clickable_arrows"` + } +) diff --git a/internal/ui/login/model.go b/internal/ui/login/model.go index 335a418..3827668 100644 --- a/internal/ui/login/model.go +++ b/internal/ui/login/model.go @@ -60,7 +60,7 @@ func (m Model) View() tview.Element { case tabToken: content = m.token.View() } - t := tabs.New(m.password.Label(), m.qr.Label(), m.token.Label()). + t := m.tabs(). Active(int(m.active)). Content(content). Keybind(tabAction). @@ -68,6 +68,18 @@ func (m Model) View() tview.Element { return ui.Box(t, &m.cfg.Theme, false) } +// tabs returns the login methods as tabs set up by the tabs config. +func (m Model) tabs() tabs.Widget { + cfg := m.cfg.UI.Tabs + return tabs.New(m.password.Label(), m.qr.Label(), m.token.Label()). + Alignment(cfg.Alignment.Alignment). + Wrap(cfg.Wrap). + Separator(cfg.Separator). + Padding(cfg.Padding[0], cfg.Padding[1]). + Arrows(cfg.Arrows[0], cfg.Arrows[1]). + ClickableArrows(cfg.ClickableArrows) +} + func (m Model) Update(msg tview.Msg) (Model, tview.Cmd) { var errCmd tview.Cmd switch msg := msg.(type) {