aboutsummaryrefslogtreecommitdiffstats
path: root/i_events.go
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-01-08 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-01-08 20:20:20 +0100
commit4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e (patch)
tree42a8fccdc094212485ca682340d9229e407cd12d /i_events.go
parenttmp (diff)
downloadhardflip-4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e.tar.gz
hardflip-4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e.tar.bz2
hardflip-4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e.tar.xz
hardflip-4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e.tar.zst
hardflip-4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e.zip
fix
Diffstat (limited to 'i_events.go')
-rw-r--r--i_events.go33
1 files changed, 20 insertions, 13 deletions
diff --git a/i_events.go b/i_events.go
index 3406088..3c67a7f 100644
--- a/i_events.go
+++ b/i_events.go
@@ -79,19 +79,26 @@ func i_reload_data(data *HardData) {
}
func i_delete_host(data *HardData) {
-// ui := &data.ui
-// host := data.lhost.sel(data.ui.sel)
-// file_path := data.data_dir + "/" + host.Folder + host.Filename
-//
-// if err := os.Remove(file_path); err != nil {
-// c_die("can't remove " + file_path, err)
-// }
-// data.lhost.del(data.ui.sel)
-// data.lhost.reset_id()
-// ui.sel_max = data.lhost.count()
-// if ui.sel >= ui.sel_max {
-// ui.sel = ui.sel_max - 1
-// }
+ curr := data.litems.curr
+ if curr.is_dir() == true {
+ return
+ }
+ host := curr.Host
+ file_path := data.data_dir + host.Parent.path() + host.Filename
+
+ if err := os.Remove(file_path); err != nil {
+ c_die("can't remove " + file_path, err)
+ }
+ host.Parent.lhost.del(host)
+ prev := data.litems.curr.prev
+ data.litems.del(curr)
+ if prev == nil {
+ prev = data.litems.head
+ }
+ data.litems.curr = prev
+ if data.litems.last != nil {
+ data.ui.sel_max = data.litems.last.ID
+ }
}
// screen events such as keypresses