diff options
author | Koni Marti <koni.marti@gmail.com> | 2022-04-18 16:06:27 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-04-25 11:21:07 +0200 |
commit | ce18e928813526e59462e391c09e868c62facb42 (patch) | |
tree | 9898097ca19e9aea7792f08ec8694a25432b83b1 /lib/statusline/texter.go | |
parent | eb7e45d43be883c4be0e635875846f0d7ddca485 (diff) | |
download | aerc-ce18e928813526e59462e391c09e868c62facb42.tar.gz |
statusline: refactor to make it more customizable
Refactor statusline by clearly separating the rendering part from the
text display. Use printf-like format string for statusline
customization.
Document printf-like format string to customize the statusline.
Allow to completely mute the statusline (except for push notifications)
with a format specifier.
Provide a display mode with unicode icons for the status elements.
Implements: https://todo.sr.ht/~rjarry/aerc/34
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/statusline/texter.go')
-rw-r--r-- | lib/statusline/texter.go | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/lib/statusline/texter.go b/lib/statusline/texter.go new file mode 100644 index 00000000..d06b1982 --- /dev/null +++ b/lib/statusline/texter.go @@ -0,0 +1,73 @@ +package statusline + +import "strings" + +type Texter interface { + Connected() string + Disconnected() string + Passthrough() string + Sorting() string + Threading() string + FormatFilter(string) string + FormatSearch(string) string +} + +type text struct{} + +func (t text) Connected() string { + return "Connected" +} + +func (t text) Disconnected() string { + return "Disconnected" +} + +func (t text) Passthrough() string { + return "passthrough" +} + +func (t text) Sorting() string { + return "sorting" +} + +func (t text) Threading() string { + return "threading" +} + +func (t text) FormatFilter(s string) string { + return s +} + +func (t text) FormatSearch(s string) string { + return s +} + +type icon struct{} + +func (i icon) Connected() string { + return "โ" +} + +func (i icon) Disconnected() string { + return "โ" +} + +func (i icon) Passthrough() string { + return "โ" +} + +func (i icon) Sorting() string { + return "โ" +} + +func (i icon) Threading() string { + return "๐งต" +} + +func (i icon) FormatFilter(s string) string { + return strings.ReplaceAll(s, "filter", "๐ฆ") +} + +func (i icon) FormatSearch(s string) string { + return strings.ReplaceAll(s, "search", "๐") +} |