summary refs log tree commit diff stats
path: root/widgets/directories.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-01-13 15:32:52 -0500
committerDrew DeVault <sir@cmpwn.com>2019-01-13 15:32:52 -0500
commitcf664620005cf65d060e689fbb27b939dd3192a7 (patch)
treea74ea7f69e6004cd407e272ab80768b5ee314735 /widgets/directories.go
parent257affcd4841b8f595a4a13cdb0fd2a1a2dd0faa (diff)
downloadaerc-cf664620005cf65d060e689fbb27b939dd3192a7.tar.gz
Simplify approach to directory list
This doesn't really need to be abstract tbh
Diffstat (limited to 'widgets/directories.go')
-rw-r--r--widgets/directories.go21
1 files changed, 18 insertions, 3 deletions
diff --git a/widgets/directories.go b/widgets/directories.go
index 16b0e5a..1602b3c 100644
--- a/widgets/directories.go
+++ b/widgets/directories.go
@@ -16,6 +16,7 @@ type DirectoryList struct {
 	dirs         []string
 	logger       *log.Logger
 	onInvalidate func(d ui.Drawable)
+	selected     string
 	worker       *types.Worker
 }
 
@@ -25,7 +26,7 @@ func NewDirectoryList(conf *config.AccountConfig,
 	return &DirectoryList{conf: conf, logger: logger, worker: worker}
 }
 
-func (dirlist *DirectoryList) UpdateList() {
+func (dirlist *DirectoryList) UpdateList(done func(dirs []string)) {
 	var dirs []string
 	dirlist.worker.PostAction(
 		&types.ListDirectories{}, func(msg types.WorkerMessage) {
@@ -37,10 +38,18 @@ func (dirlist *DirectoryList) UpdateList() {
 				sort.Strings(dirs)
 				dirlist.dirs = dirs
 				dirlist.Invalidate()
+				if done != nil {
+					done(dirs)
+				}
 			}
 		})
 }
 
+func (dirlist *DirectoryList) Select(name string) {
+	dirlist.selected = name
+	dirlist.Invalidate()
+}
+
 func (dirlist *DirectoryList) OnInvalidate(onInvalidate func(d ui.Drawable)) {
 	dirlist.onInvalidate = onInvalidate
 }
@@ -58,14 +67,20 @@ func (dirlist *DirectoryList) Draw(ctx *ui.Context) {
 		if row >= ctx.Height() {
 			break
 		}
-		if len(dirlist.conf.Folders) > 1 {
+		if len(dirlist.conf.Folders) > 1 && name != dirlist.selected {
 			idx := sort.SearchStrings(dirlist.conf.Folders, name)
 			if idx == len(dirlist.conf.Folders) ||
 				dirlist.conf.Folders[idx] != name {
 				continue
 			}
 		}
-		ctx.Printf(0, row, tcell.StyleDefault, "%s", name)
+		style := tcell.StyleDefault
+		if name == dirlist.selected {
+			style = style.Background(tcell.ColorWhite).
+				Foreground(tcell.ColorBlack)
+		}
+		ctx.Fill(0, row, ctx.Width(), 1, ' ', style)
+		ctx.Printf(0, row, style, "%s", name)
 		row++
 	}
 }
ain__' href='/akspecs/ranger/commit/ranger/__main__.py?id=d00083250fefaabb8df5e97256e03411beac06b4'>d0008325 ^
e57c337d ^
2948ed45 ^
0128bee7 ^
20d28b94 ^
d0008325 ^



f349f201 ^



75013dc7 ^
0128bee7 ^
75013dc7 ^
0128bee7 ^

ea87d005 ^
d4e2dfe9 ^

d0008325 ^
0128bee7 ^
a049ec03 ^
d0008325 ^




0128bee7 ^
d0008325 ^





d0008325 ^




0128bee7 ^
d0008325 ^








0128bee7 ^
766a5b6a ^
d0008325 ^


524d95e1 ^

d0008325 ^
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149