aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-01-15 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-01-15 20:20:20 +0100
commitbc7effa71d5d7329af950aca3143bc01b84201c3 (patch)
tree767c71d05a750394aa6ae50bb9d413f6c3e9b7ec
parentok (diff)
downloadhardflip-bc7effa71d5d7329af950aca3143bc01b84201c3.tar.gz
hardflip-bc7effa71d5d7329af950aca3143bc01b84201c3.tar.bz2
hardflip-bc7effa71d5d7329af950aca3143bc01b84201c3.tar.xz
hardflip-bc7effa71d5d7329af950aca3143bc01b84201c3.tar.zst
hardflip-bc7effa71d5d7329af950aca3143bc01b84201c3.zip
i think its good? pls
-rw-r--r--c_ldirs.go3
-rw-r--r--i_events.go38
-rw-r--r--i_ui.go2
3 files changed, 25 insertions, 18 deletions
diff --git a/c_ldirs.go b/c_ldirs.go
index d7a98a1..77f017d 100644
--- a/c_ldirs.go
+++ b/c_ldirs.go
@@ -155,6 +155,9 @@ func (dir *DirsNode) count_hosts() int {
}
func (ldirs *DirsList) prev(dir *DirsNode) *DirsNode {
+ if ldirs.head == dir {
+ return dir
+ }
for ptr := ldirs.head; ptr != nil; ptr = ptr.next {
if ptr.next == dir {
return ptr
diff --git a/i_events.go b/i_events.go
index d54e9f7..a0dc267 100644
--- a/i_events.go
+++ b/i_events.go
@@ -171,6 +171,7 @@ func i_reload_data(data *HardData) {
data.data_dir = c_get_data_dir()
data.ldirs = c_load_data_dir(data.data_dir, data.opts)
data.litems = c_load_litems(data.ldirs)
+ data.folds = make(map[*DirsNode]*ItemsList)
data.ui.sel_max = data.litems.last.ID
}
@@ -178,29 +179,32 @@ func i_delete_dir(data *HardData) {
if data.litems.curr == nil || data.litems.curr.Dirs == nil {
return
}
- if data.folds[data.litems.curr.Dirs] == nil {
- i_fold_dir(data, data.litems.curr)
+ curr := data.litems.curr
+ if data.folds[curr.Dirs] == nil {
+ i_fold_dir(data, curr)
}
- delete(data.folds,data.litems.curr.Dirs)
- if data.litems.last == data.litems.curr {
- data.litems.last = data.litems.curr.prev
- }
- data.litems.curr.prev.next = data.litems.curr.next
- data.litems.curr.next.prev = data.litems.curr.prev
- prev_dir := data.ldirs.prev(data.litems.curr.Dirs)
- if data.ldirs.last == data.litems.curr.Dirs {
+ delete(data.folds, curr.Dirs)
+ prev_dir := data.ldirs.prev(curr.Dirs)
+ curr.prev.next = curr.next
+ if curr.next != nil {
+ curr.next.prev = curr.prev
+ prev_dir.next = curr.Dirs.next
+ data.litems.curr = curr.next
+ } else {
+ data.litems.last = curr.prev
+ prev_dir.next = nil
data.ldirs.last = prev_dir
+ data.ldirs.last.next = nil
+ data.litems.curr = curr.prev
}
- prev_dir.next = data.litems.curr.Dirs.next
- data.litems.curr = data.litems.curr.next
for ptr := data.litems.head; ptr.next != nil; ptr = ptr.next {
ptr.next.ID = ptr.ID + 1
}
- // dir_path := data.data_dir + dir.path()
- // if err := os.RemoveAll(dir_path); err != nil {
- // data.ui.s.Fini()
- // c_die("can't remove " + dir_path, err)
- // }
+ dir_path := data.data_dir + dir.path()
+ if err := os.RemoveAll(dir_path); err != nil {
+ data.ui.s.Fini()
+ c_die("can't remove " + dir_path, err)
+ }
// TODO: delete folds map reference if folded - OK
// TEST: single empty dir
// TEST: single non-empty dir
diff --git a/i_ui.go b/i_ui.go
index 3971478..31183fe 100644
--- a/i_ui.go
+++ b/i_ui.go
@@ -165,7 +165,7 @@ func i_draw_delete_box(ui HardUI, item *ItemsNode) {
var text string
var file string
if item.is_dir() == true {
- text = "Really delete this directory and all subsequent files?"
+ text = "Really delete this directory and all of its content?"
file = item.Dirs.path()
} else {
host := item.Host