aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/directories.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-03-10 21:15:24 -0400
committerDrew DeVault <sir@cmpwn.com>2019-03-10 21:15:24 -0400
commitb60999c39e11bf4d1e236f2b10a2f895b44d23fb (patch)
tree8ce8023277815a7d1f25dc7c48fa910c698d5b1b /widgets/directories.go
parent62862d8a9e7f684bc3ff4e9ea115678ff44d8644 (diff)
downloadaerc-b60999c39e11bf4d1e236f2b10a2f895b44d23fb.tar.gz
Start building out command subsystem
Diffstat (limited to 'widgets/directories.go')
-rw-r--r--widgets/directories.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/widgets/directories.go b/widgets/directories.go
index 11fe2d64..ae31d297 100644
--- a/widgets/directories.go
+++ b/widgets/directories.go
@@ -103,3 +103,40 @@ func (dirlist *DirectoryList) Draw(ctx *ui.Context) {
row++
}
}
+
+func (dirlist *DirectoryList) nextPrev(delta int) {
+ for i, dir := range dirlist.dirs {
+ if dir == dirlist.selected {
+ var j int
+ ndirs := len(dirlist.dirs)
+ for j = i + delta; j != i; j += delta {
+ if j < 0 {
+ j = ndirs - 1
+ }
+ if j >= ndirs {
+ j = 0
+ }
+ name := dirlist.dirs[j]
+ 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
+ }
+ }
+ break
+ }
+ dirlist.Select(dirlist.dirs[j])
+ break
+ }
+ }
+}
+
+func (dirlist *DirectoryList) Next() {
+ dirlist.nextPrev(1)
+}
+
+func (dirlist *DirectoryList) Prev() {
+ dirlist.nextPrev(-1)
+}