aboutsummaryrefslogtreecommitdiffstats
path: root/c_litems.go
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-01-09 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-01-09 20:20:20 +0100
commit1b348ade03ecf708c13a37f353ac1533f7c0d747 (patch)
tree6b824ba4eb790cba11e8c45813b696a0cfca8ccd /c_litems.go
parentfolding visually (diff)
downloadhardflip-1b348ade03ecf708c13a37f353ac1533f7c0d747.tar.gz
hardflip-1b348ade03ecf708c13a37f353ac1533f7c0d747.tar.bz2
hardflip-1b348ade03ecf708c13a37f353ac1533f7c0d747.tar.xz
hardflip-1b348ade03ecf708c13a37f353ac1533f7c0d747.tar.zst
hardflip-1b348ade03ecf708c13a37f353ac1533f7c0d747.zip
folding functionally
Diffstat (limited to 'c_litems.go')
-rw-r--r--c_litems.go55
1 files changed, 37 insertions, 18 deletions
diff --git a/c_litems.go b/c_litems.go
index c5e93ff..6b64e8c 100644
--- a/c_litems.go
+++ b/c_litems.go
@@ -147,32 +147,51 @@ func (item *ItemsNode) is_dir() bool {
}
func (litems *ItemsList) inc(jump int) {
- item := litems.curr
- if item == nil {
+ new_item := litems.curr
+
+ if new_item == nil || jump == 0 {
return
- }
- if jump == 0 {
- litems.curr = item
} else if jump == 1 {
- if item.next != nil {
- litems.curr = item.next
+ if new_item.next != nil {
+ new_item = new_item.next
}
- litems.curr = item
} else if jump == -1 {
- if item.prev != nil {
- litems.curr = item.prev
+ if new_item.prev != nil {
+ new_item = new_item.prev
}
- litems.curr = item
- }
- new_item := item
- if jump > 0 {
- for i := 0; new_item.next != nil && i < jump; i++ {
+ } else {
+ for i := 0; jump > +1 && new_item.next != nil && i < jump; i++ {
new_item = new_item.next
}
- litems.curr = new_item
+ for i := 0; jump < -1 && new_item.prev != nil && i > jump; i-- {
+ new_item = new_item.prev
+ }
}
- for i := 0; new_item.prev != nil && i > jump; i-- {
- new_item = new_item.prev
+ for new_item.folded_parents() == true &&
+ new_item.next != nil &&
+ new_item.prev != nil {
+ if jump > 0 {
+ new_item = new_item.next
+ } else {
+ new_item = new_item.prev
+ }
}
litems.curr = new_item
+ // FIX: still will select the last
+}
+
+func (item *ItemsNode) folded_parents() bool {
+ var ptr *DirsNode
+
+ if item.is_dir() == false {
+ ptr = item.Host.Parent
+ } else {
+ ptr = item.Dirs.Parent
+ }
+ for ; ptr.Parent != nil; ptr = ptr.Parent {
+ if ptr.Folded == true {
+ return true
+ }
+ }
+ return false
}