diff options
author | Joe <rbo@gmx.us> | 2024-01-09 20:20:20 +0100 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2024-01-09 20:20:20 +0100 |
commit | d614eb676448a8b03de7a54b738446caf64343ee (patch) | |
tree | f918a9817a243f9c5d52979b3c90b3d18b0f7067 | |
parent | this fucking bug (diff) | |
download | hardflip-d614eb676448a8b03de7a54b738446caf64343ee.tar.gz hardflip-d614eb676448a8b03de7a54b738446caf64343ee.tar.bz2 hardflip-d614eb676448a8b03de7a54b738446caf64343ee.tar.xz hardflip-d614eb676448a8b03de7a54b738446caf64343ee.tar.zst hardflip-d614eb676448a8b03de7a54b738446caf64343ee.zip |
i can't fix that shit
-rw-r--r-- | c_ldirs.go | 14 | ||||
-rw-r--r-- | i_events.go | 17 |
2 files changed, 24 insertions, 7 deletions
@@ -110,9 +110,21 @@ func (dir *DirsNode) path() string { return path } +// returns the number of hosts of the dir func (dir *DirsNode) count_hosts() int { - if dir.lhost.head == nil { + if dir.lhost.head == nil || dir.lhost.last == nil { return 0 } return dir.lhost.last.ID + 1 } + +// return the number of hosts and subfolders of the dir +func (dir *DirsNode) count_elements() int { + items := 0 + + items += dir.count_hosts() + for ptr := dir.next; ptr != nil && ptr.Depth > dir.Depth; ptr = ptr.next { + items += ptr.count_hosts() + 1 + } + return items +} diff --git a/i_events.go b/i_events.go index 900bc19..62c93d7 100644 --- a/i_events.go +++ b/i_events.go @@ -52,7 +52,7 @@ package main import ( - "fmt" + // "fmt" "os" "github.com/gdamore/tcell/v2" @@ -61,15 +61,11 @@ import ( func i_update_folded_count(dir *DirsNode, ui *HardUI) { delta := 0 - delta += dir.count_hosts() - for ptr := dir.next; ptr.Depth > dir.Depth && ptr != nil; ptr = ptr.next { - delta += ptr.count_hosts() + 1 - } + delta += dir.count_elements() if dir.Folded == false { delta *= -1 } ui.folded_count += delta - fmt.Println(">>>>> COUNT:", ui.folded_count) } func i_list_follow_cursor(litems *ItemsList, ui *HardUI) { @@ -86,6 +82,15 @@ func i_list_follow_cursor(litems *ItemsList, ui *HardUI) { litems.draw_start.prev != nil { litems.draw_start = litems.draw_start.prev } + // fmt.Println(">>>>> DRAW_START:", litems.draw_start.ID, "<<<<<<< >>>>>>>> VIRT_ID:", virt_id) + if litems.draw_start.prev != nil && + litems.draw_start.prev.is_dir() == true && + litems.draw_start.prev.Dirs.Folded == true { + tmp := litems.draw_start.prev.Dirs.count_elements() + for i := 0; i < tmp && litems.draw_start != nil; i++ { + litems.draw_start = litems.draw_start.next + } + } } func i_reload_data(data *HardData) { |