aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-10-26 11:05:23 -0500
committerRobin Jarry <robin@jarry.cc>2022-11-06 23:18:06 +0100
commit1f682fc610de1beb57c68b92fe98bf057483773c (patch)
treec5371883c50ffe2e9b8b7c505a288e54f4e03bdf
parent59510c41c839004f037a20464f368c445a7a91d1 (diff)
downloadaerc-1f682fc610de1beb57c68b92fe98bf057483773c.tar.gz
msglist: style search results
Add option to style search results in the message list. Set default style for results. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--CHANGELOG.md1
-rw-r--r--config/default_styleset1
-rw-r--r--config/style.go2
-rw-r--r--doc/aerc-stylesets.7.scd2
-rw-r--r--lib/msgstore.go10
-rw-r--r--widgets/msglist.go5
6 files changed, 21 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8dc2b31b..43aa30c4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
`aerc.conf`.
- Display threads from bottom to top with `reverse-thread-order=true` in
`aerc.conf`.
+- Style search results in the message list with `msglist_result.*`
### Fixed
diff --git a/config/default_styleset b/config/default_styleset
index da57e936..078920bf 100644
--- a/config/default_styleset
+++ b/config/default_styleset
@@ -26,6 +26,7 @@ statusline_warning.reverse=true
msglist_unread.bold=true
msglist_deleted.fg=gray
+msglist_result.fg=green
completion_pill.reverse=true
diff --git a/config/style.go b/config/style.go
index 3a0f7a4f..d8da4c7f 100644
--- a/config/style.go
+++ b/config/style.go
@@ -36,6 +36,7 @@ const (
STYLE_MSGLIST_FLAGGED
STYLE_MSGLIST_DELETED
STYLE_MSGLIST_MARKED
+ STYLE_MSGLIST_RESULT
STYLE_DIRLIST_DEFAULT
STYLE_DIRLIST_UNREAD
@@ -75,6 +76,7 @@ var StyleNames = map[string]StyleObject{
"msglist_flagged": STYLE_MSGLIST_FLAGGED,
"msglist_deleted": STYLE_MSGLIST_DELETED,
"msglist_marked": STYLE_MSGLIST_MARKED,
+ "msglist_result": STYLE_MSGLIST_RESULT,
"dirlist_default": STYLE_DIRLIST_DEFAULT,
"dirlist_unread": STYLE_DIRLIST_UNREAD,
diff --git a/doc/aerc-stylesets.7.scd b/doc/aerc-stylesets.7.scd
index 0cb5a322..8aac6c49 100644
--- a/doc/aerc-stylesets.7.scd
+++ b/doc/aerc-stylesets.7.scd
@@ -112,6 +112,8 @@ styling.
: The messages marked as deleted.
| msglist_marked
: The messages with the marked flag.
+| msglist_result
+: The messages which match the current search.
| dirlist_default
: The default style for directories in the directory list.
| dirlist_unread
diff --git a/lib/msgstore.go b/lib/msgstore.go
index 085ca7f2..dfa25191 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -675,6 +675,16 @@ func (store *MessageStore) ApplySearch(results []uint32) {
store.NextResult()
}
+// IsResult returns true if uid is a search result
+func (store *MessageStore) IsResult(uid uint32) bool {
+ for _, hit := range store.results {
+ if hit == uid {
+ return true
+ }
+ }
+ return false
+}
+
func (store *MessageStore) SetFilter(args []string) {
store.filter = append(store.filter, args...)
}
diff --git a/widgets/msglist.go b/widgets/msglist.go
index 23d319da..ef29724a 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -250,6 +250,11 @@ func (ml *MessageList) drawRow(textWidth int, ctx *ui.Context, uid uint32, row i
msg_styles = append(msg_styles, config.STYLE_MSGLIST_MARKED)
}
+ // search result
+ if store.IsResult(msg.Uid) {
+ msg_styles = append(msg_styles, config.STYLE_MSGLIST_RESULT)
+ }
+
var style tcell.Style
// current row
if msg.Uid == ml.store.SelectedUid() {