about summary refs log tree commit diff stats
path: root/widgets
diff options
context:
space:
mode:
authorDaniel Xu <dxu@dxuuu.xyz>2019-08-16 00:11:37 -0700
committerDrew DeVault <sir@cmpwn.com>2019-08-19 15:22:59 +0900
commit9fd6054ca1a99205d2abb6408ece747d2eddaae7 (patch)
tree00e9e394ddd7d486797aefef065b450692b7cbec /widgets
parentb47143ccc7fdb54e62d8536414a5cf38852eae40 (diff)
downloadaerc-9fd6054ca1a99205d2abb6408ece747d2eddaae7.tar.gz
Support regex filters for folders
It's nice to be able to filter the folders displayed in the side
bar. Basic string matching can get verbose with enough folders
whitelisted.

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Diffstat (limited to 'widgets')
-rw-r--r--widgets/dirlist.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/widgets/dirlist.go b/widgets/dirlist.go
index b0807ae..c84f839 100644
--- a/widgets/dirlist.go
+++ b/widgets/dirlist.go
@@ -2,6 +2,7 @@ package widgets
 
 import (
 	"log"
+	"regexp"
 	"sort"
 
 	"github.com/gdamore/tcell"
@@ -159,6 +160,15 @@ func (dirlist *DirectoryList) Prev() {
 	dirlist.NextPrev(-1)
 }
 
+func folderMatches(folder string, pattern string) bool {
+	r, err := regexp.Compile(pattern)
+	if err != nil {
+		return false
+	}
+
+	return r.Match([]byte(folder))
+}
+
 // filterDirsByFoldersConfig sets dirlist.dirs to the filtered subset of the
 // dirstore, based on the AccountConfig.Folders option
 func (dirlist *DirectoryList) filterDirsByFoldersConfig() {
@@ -170,7 +180,7 @@ func (dirlist *DirectoryList) filterDirsByFoldersConfig() {
 	var filtered []string
 	for _, folder := range dirlist.dirs {
 		for _, cfgfolder := range dirlist.acctConf.Folders {
-			if folder == cfgfolder {
+			if folderMatches(folder, cfgfolder) {
 				filtered = append(filtered, folder)
 				break
 			}
-0700 4262 - literal 'null'' href='/akkartik/mu/commit/continuation2.mu?h=hlt&id=01ce563dfe3e6cf58337708b9dbb60a8a99fa0f2'>01ce563d ^
a3195d44 ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37


                                                                       




                                              



                  


             
                           


                
                                                                           









                                                      
             
                                         

                          


              
p;id=66083e54a0a122e0b9f396ee32ee632065ecbb66'>^
51530916 ^
2ed1aa9c ^
51530916 ^


60c566ea ^
54e4548d ^
51530916 ^

2ed1aa9c ^
51530916 ^

ec99eb7a ^
de49fb42 ^

b39ceb27 ^
df0b469f ^
b39ceb27 ^






51530916 ^
6ff9413c ^
b39ceb27 ^
6c96a437 ^
9e608a77 ^
6c96a437 ^
46b6e2a3 ^
9e608a77 ^
6ff9413c ^

9e608a77 ^
b39ceb27 ^
5a9e3a11 ^
6ff9413c ^


b39ceb27 ^
683d53ca ^

b39ceb27 ^
df0b469f ^
ccd792da ^
6e1eeeeb ^

9e5e87ca ^
6e1eeeeb ^



51530916 ^
ac0e9db5 ^
7d13531e ^



6573fe1f ^
eb3a527a ^

b5ab709c ^
51530916 ^

53172ce1 ^
17d3003d ^




53172ce1 ^

53172ce1 ^







51530916 ^
f2043a73 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109