From 9450fb124b141bcfbf4e993685836020fbd574fc Mon Sep 17 00:00:00 2001 From: ayn2op Date: Tue, 30 Dec 2025 18:27:34 -0500 Subject: [PATCH] feat: add footer configuration support to message input and theme --- cmd/message_input.go | 12 ++---------- cmd/messages_list.go | 2 +- go.mod | 4 ++-- go.sum | 10 ++++++---- internal/config/config.toml | 4 ++++ internal/config/theme.go | 6 ++++++ internal/ui/util.go | 14 +++++++++++--- 7 files changed, 32 insertions(+), 20 deletions(-) diff --git a/cmd/message_input.go b/cmd/message_input.go index 35ed6c1..0326e7f 100644 --- a/cmd/message_input.go +++ b/cmd/message_input.go @@ -83,6 +83,7 @@ func (mi *messageInput) reset() { mi.edit = false mi.sendMessageData = &api.SendMessageData{} mi.SetTitle("") + mi.SetFooter("") mi.SetText("", true) } @@ -584,15 +585,6 @@ func (mi *messageInput) editor() { mi.SetText(strings.TrimSpace(string(msg)), true) } -func (mi *messageInput) addTitle(s string) { - title := mi.GetTitle() - if title != "" { - title += " | " - } - - mi.SetTitle(title + s) -} - func (mi *messageInput) openFilePicker() { if app.chatView.selectedChannel == nil { return @@ -618,5 +610,5 @@ func (mi *messageInput) openFilePicker() { func (mi *messageInput) attach(name string, reader io.Reader) { mi.sendMessageData.Files = append(mi.sendMessageData.Files, sendpart.File{Name: name, Reader: reader}) - mi.addTitle("Attached " + name) + mi.SetFooter("Attached " + name) } diff --git a/cmd/messages_list.go b/cmd/messages_list.go index da81391..86aa967 100644 --- a/cmd/messages_list.go +++ b/cmd/messages_list.go @@ -566,7 +566,7 @@ func (ml *messagesList) reply(mention bool) { } app.chatView.messageInput.sendMessageData = data - app.chatView.messageInput.addTitle(title + name) + app.chatView.messageInput.SetTitle(title + name) app.SetFocus(app.chatView.messageInput) } diff --git a/go.mod b/go.mod index e07b870..2e5a829 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ go 1.25.3 require ( github.com/BurntSushi/toml v1.6.0 github.com/andybalholm/brotli v1.2.0 - github.com/ayn2op/tview v0.0.0-20251226064735-943253237ba5 + github.com/ayn2op/tview v0.0.0-20251230225448-356dde2ef7cd github.com/deckarep/gosx-notifier v0.0.0-20180201035817-e127226297fb github.com/diamondburned/arikawa/v3 v3.6.1-0.20250928004212-a891a653eb26 github.com/diamondburned/ningen/v3 v3.0.1-0.20250920191746-98fbd92e134d @@ -35,7 +35,7 @@ require ( github.com/esiqveland/notify v0.13.3 // indirect github.com/gdamore/encoding v1.0.1 // indirect github.com/go-ole/go-ole v1.3.0 // indirect - github.com/godbus/dbus/v5 v5.2.1 // indirect + github.com/godbus/dbus/v5 v5.2.2 // indirect github.com/gorilla/schema v1.4.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jackmordaunt/icns/v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index b64fd6a..7f14e98 100644 --- a/go.sum +++ b/go.sum @@ -27,8 +27,10 @@ github.com/akavel/rsrc v0.10.2 h1:Zxm8V5eI1hW4gGaYsJQUhxpjkENuG91ki8B4zCrvEsw= github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ= github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY= -github.com/ayn2op/tview v0.0.0-20251226064735-943253237ba5 h1:l0Rn1qjz8e3PYnKSB3qb++IB3eYRe5WwJeAcI4Wk8a4= -github.com/ayn2op/tview v0.0.0-20251226064735-943253237ba5/go.mod h1:SQ8WZwN/KA5/KFvA1ZJ8gIyTLirCzSCE2iCWOn38GAA= +github.com/ayn2op/tview v0.0.0-20251230034634-8f3b735a2b2a h1:ytqqCvcO+J1+JwfRhL8TLNnNUbRoQGm5ie9bPqDALZI= +github.com/ayn2op/tview v0.0.0-20251230034634-8f3b735a2b2a/go.mod h1:SQ8WZwN/KA5/KFvA1ZJ8gIyTLirCzSCE2iCWOn38GAA= +github.com/ayn2op/tview v0.0.0-20251230225448-356dde2ef7cd h1:Rb+lUnHD3Xki2fP9eN2R8f95J1lILdYThxCoz4SfGJU= +github.com/ayn2op/tview v0.0.0-20251230225448-356dde2ef7cd/go.mod h1:SQ8WZwN/KA5/KFvA1ZJ8gIyTLirCzSCE2iCWOn38GAA= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= @@ -63,8 +65,8 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2 github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/godbus/dbus/v5 v5.2.1 h1:I4wwMdWSkmI57ewd+elNGwLRf2/dtSaFz1DujfWYvOk= -github.com/godbus/dbus/v5 v5.2.1/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c= +github.com/godbus/dbus/v5 v5.2.2 h1:TUR3TgtSVDmjiXOgAAyaZbYmIeP3DPkld3jgKGV8mXQ= +github.com/godbus/dbus/v5 v5.2.2/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= diff --git a/internal/config/config.toml b/internal/config/config.toml index 7963bf3..ce53198 100644 --- a/internal/config/config.toml +++ b/internal/config/config.toml @@ -108,7 +108,11 @@ down = "Ctrl+N" # style = { foreground = "", background = "", attributes = "" or [""] } [theme.title] alignment = "left" # `"left"`, `"center"`, or `"right"`. +normal_style = { attributes = "dim" } +active_style = { foreground = "green", attributes = "bold" } +[theme.footer] +alignment = "left" normal_style = { attributes = "dim" } active_style = { foreground = "green", attributes = "bold" } diff --git a/internal/config/theme.go b/internal/config/theme.go index db479bd..7a71d8e 100644 --- a/internal/config/theme.go +++ b/internal/config/theme.go @@ -118,6 +118,11 @@ type ( Alignment AlignmentWrapper `toml:"alignment"` } + FooterTheme struct { + ThemeStyle + Alignment AlignmentWrapper `toml:"alignment"` + } + BorderTheme struct { ThemeStyle Enabled bool `toml:"enabled"` @@ -150,6 +155,7 @@ type ( Theme struct { Title TitleTheme `toml:"title"` + Footer FooterTheme `toml:"footer"` Border BorderTheme `toml:"border"` GuildsTree GuildsTreeTheme `toml:"guilds_tree"` MessagesList MessagesListTheme `toml:"messages_list"` diff --git a/internal/ui/util.go b/internal/ui/util.go index d5952f6..aeca96c 100644 --- a/internal/ui/util.go +++ b/internal/ui/util.go @@ -11,28 +11,36 @@ import ( // ConfigureBox configures the provided box according to the provided theme. func ConfigureBox(box *tview.Box, cfg *config.Theme) *tview.Box { border := cfg.Border - title := cfg.Title normalBorderStyle, activeBorderStyle := border.NormalStyle.Style, border.ActiveStyle.Style normalBorderSet, activeBorderSet := border.NormalSet.BorderSet, border.ActiveSet.BorderSet + + title := cfg.Title normalTitleStyle, activeTitleStyle := title.NormalStyle.Style, title.ActiveStyle.Style + + footer := cfg.Footer + normalFooterStyle, activeFooterStyle := footer.NormalStyle.Style, footer.ActiveStyle.Style + padding := border.Padding + box. SetBorderStyle(normalBorderStyle). SetBorderSet(normalBorderSet). SetBorderPadding(padding[0], padding[1], padding[2], padding[3]). SetTitleStyle(normalTitleStyle). SetTitleAlignment(title.Alignment.Alignment). + SetFooterStyle(normalFooterStyle). + SetFooterAlignment(footer.Alignment.Alignment). SetBlurFunc(func() { box. SetBorderStyle(normalBorderStyle). SetBorderSet(normalBorderSet) - box.SetTitleStyle(normalTitleStyle) + box.SetTitleStyle(normalTitleStyle).SetFooterStyle(normalFooterStyle) }). SetFocusFunc(func() { box. SetBorderStyle(activeBorderStyle). SetBorderSet(activeBorderSet) - box.SetTitleStyle(activeTitleStyle) + box.SetTitleStyle(activeTitleStyle).SetFooterStyle(activeFooterStyle) }) if border.Enabled {