~sircmpwn/aerc

Add tab separator v1 PROPOSED

Jeffas: 1
 Add tab separator

 5 files changed, 22 insertions(+), 3 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/aerc/patches/8495/mbox | git am -3
Learn more about email & git

[PATCH] Add tab separator Export this patch

This is just a decorative separator for tabs so that they can be more
easily distinguished in some cases.
---
 config/aerc.conf.in   |  5 +++++
 config/config.go      |  1 +
 doc/aerc-config.5.scd |  5 +++++
 lib/ui/tab.go         | 12 ++++++++++--
 widgets/aerc.go       |  2 +-
 5 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/config/aerc.conf.in b/config/aerc.conf.in
index ec89ff7..e516044 100644
--- a/config/aerc.conf.in
+++ b/config/aerc.conf.in
@@ -62,6 +62,11 @@ sort=
# Default: false
next-message-on-delete=true

# String to separate tabs with.
#
# Default: ""
tab-separator=

[viewer]
#
# Specifies the pager to use when displaying emails. Note that some filters
diff --git a/config/config.go b/config/config.go
index 133a7f4..d9ec410 100644
--- a/config/config.go
+++ b/config/config.go
@@ -38,6 +38,7 @@ type UIConfig struct {
	DirListFormat       string   `ini:"dirlist-format"`
	Sort                []string `delim:" "`
	NextMessageOnDelete bool     `ini:"next-message-on-delete"`
	TabSeparator        string
}

const (
diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd
index f4f02f2..eaf4e1e 100644
--- a/doc/aerc-config.5.scd
+++ b/doc/aerc-config.5.scd
@@ -155,6 +155,11 @@ These options are configured in the *[ui]* section of aerc.conf.

	Default: true

*tab-separator*
	String to separate tabs with.

	Default: ""

## VIEWER

These options are configured in the *[viewer]* section of aerc.conf.
diff --git a/lib/ui/tab.go b/lib/ui/tab.go
index 9c19cd7..934d70a 100644
--- a/lib/ui/tab.go
+++ b/lib/ui/tab.go
@@ -3,6 +3,8 @@ package ui
import (
	"github.com/gdamore/tcell"
	"github.com/mattn/go-runewidth"

	"git.sr.ht/~sircmpwn/aerc/config"
)

type Tabs struct {
@@ -11,6 +13,7 @@ type Tabs struct {
	TabContent *TabContent
	Selected   int
	history    []int
	conf       *config.AercConfig

	onInvalidateStrip   func(d Drawable)
	onInvalidateContent func(d Drawable)
@@ -28,8 +31,8 @@ type Tab struct {
type TabStrip Tabs
type TabContent Tabs

func NewTabs() *Tabs {
	tabs := &Tabs{}
func NewTabs(conf *config.AercConfig) *Tabs {
	tabs := &Tabs{conf: conf}
	tabs.TabStrip = (*TabStrip)(tabs)
	tabs.TabStrip.parent = tabs
	tabs.TabContent = (*TabContent)(tabs)
@@ -185,6 +188,11 @@ func (strip *TabStrip) Draw(ctx *Context) {
		}
		trunc := runewidth.Truncate(tab.Name, tabWidth, "…")
		x += ctx.Printf(x, 0, style, " %s ", trunc)
		if i < len(strip.Tabs)-1 && ctx.Width()-x > 0 {
			x += ctx.Printf(x, 0,
				tcell.StyleDefault.Background(tcell.ColorGrey),
				strip.parent.conf.Ui.TabSeparator)
		}
		if x >= ctx.Width() {
			break
		}
diff --git a/widgets/aerc.go b/widgets/aerc.go
index 16fe8b7..f087d06 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -38,7 +38,7 @@ func NewAerc(conf *config.AercConfig, logger *log.Logger,
	cmd func(cmd []string) error, complete func(cmd string) []string,
	cmdHistory lib.History) *Aerc {

	tabs := ui.NewTabs()
	tabs := ui.NewTabs(conf)

	statusbar := ui.NewStack()
	statusline := NewStatusLine()
--
2.23.0
Gonna pass on any one-off appearance-related patches until we do a
larger design for how to implement them.
View this thread in the archives