diff options
author | Joe <rbo@gmx.us> | 2024-01-11 20:20:20 +0100 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2024-01-11 20:20:20 +0100 |
commit | 126c13a9234317769088337bea9e263fd588c71c (patch) | |
tree | 927b57904f12271b10f9761508dd615bc50001c0 | |
parent | revert here if needed (diff) | |
download | hardflip-126c13a9234317769088337bea9e263fd588c71c.tar.gz hardflip-126c13a9234317769088337bea9e263fd588c71c.tar.bz2 hardflip-126c13a9234317769088337bea9e263fd588c71c.tar.xz hardflip-126c13a9234317769088337bea9e263fd588c71c.tar.zst hardflip-126c13a9234317769088337bea9e263fd588c71c.zip |
folded was useless indeed
-rw-r--r-- | c_init.go | 4 | ||||
-rw-r--r-- | c_ldirs.go | 6 | ||||
-rw-r--r-- | i_events.go | 14 | ||||
-rw-r--r-- | i_ui.go | 26 |
4 files changed, 25 insertions, 25 deletions
@@ -76,7 +76,6 @@ func c_recurse_data_dir(dir, root string, opts HardOpts, parent, depth, &HostList{}, - false, nil, } ldirs.add_back(&dir_node) @@ -111,9 +110,6 @@ func c_load_data_dir(dir string, opts HardOpts) *DirsList { func c_load_litems(ldirs *DirsList) *ItemsList { litems := ItemsList{} - if ldirs.head != nil { - ldirs.head.Folded = false - } for ptr := ldirs.head; ptr != nil; ptr = ptr.next { item := ItemsNode{ Dirs: ptr, Host: nil } litems.add_back(&item) @@ -57,7 +57,6 @@ type DirsNode struct { Parent *DirsNode Depth uint16 lhost *HostList - Folded bool next *DirsNode } @@ -156,12 +155,13 @@ func (dir *DirsNode) count_hosts() int { } // return the number of hosts and subfolders of the dir -func (dir *DirsNode) count_elements(skip_folds bool) int { +func (dir *DirsNode) count_elements(skip_folds bool, + folds map[*DirsNode]*ItemsList) int { items := 0 items += dir.count_hosts() for ptr := dir.next; ptr != nil && ptr.Depth > dir.Depth; ptr = ptr.next { - if skip_folds == true && ptr.Folded == true { + if skip_folds == true && folds[dir] != nil { items += 1 // HACK: key to the map is the key // TODO: fix you shit diff --git a/i_events.go b/i_events.go index 75beb40..20cf306 100644 --- a/i_events.go +++ b/i_events.go @@ -98,7 +98,6 @@ func i_unfold_dir(data *HardData, item *ItemsNode) { for ptr := data.litems.head; ptr.next != nil; ptr = ptr.next { ptr.next.ID = ptr.ID + 1 } - item.Dirs.Folded = false } func i_fold_dir(data *HardData, item *ItemsNode) { @@ -114,7 +113,9 @@ func i_fold_dir(data *HardData, item *ItemsNode) { } else { folded_end = nil } - for i := 0; folded_end != nil && i < item.Dirs.count_elements(false); i++ { + for i := 0; + folded_end != nil && i < item.Dirs.count_elements(false, data.folds); + i++ { folded_end = folded_end.next } if folded_end != nil { @@ -140,7 +141,6 @@ func i_fold_dir(data *HardData, item *ItemsNode) { for ptr := data.litems.head; ptr.next != nil; ptr = ptr.next { ptr.next.ID = ptr.ID + 1 } - item.Dirs.Folded = true } func i_reload_data(data *HardData) { @@ -162,7 +162,7 @@ func i_delete_dir(data *HardData) { // c_die("can't remove " + dir_path, err) // } tmp := data.litems.curr.prev - count := data.litems.curr.Dirs.count_elements(false) + 1 + count := data.litems.curr.Dirs.count_elements(false, data.folds) + 1 data.ldirs.del(data.litems.curr.Dirs) for i := 0; data.litems.curr != nil && i < count; i++ { data.litems.del(data.litems.curr) @@ -271,7 +271,8 @@ func i_events(data *HardData) { } ui.s.SetStyle(ui.def_style) } - } else if data.litems.curr.Dirs.Folded == false { + } else if data.litems.curr.Dirs != nil && + data.folds[data.litems.curr.Dirs] == nil { i_fold_dir(data, data.litems.curr) } else { i_unfold_dir(data, data.litems.curr) @@ -281,7 +282,8 @@ func i_events(data *HardData) { data.litems.curr.is_dir() == false { break } - if data.litems.curr.Dirs.Folded == false { + if data.litems.curr.Dirs != nil && + data.folds[data.litems.curr.Dirs] == nil { i_fold_dir(data, data.litems.curr) } else { i_unfold_dir(data, data.litems.curr) @@ -227,7 +227,7 @@ func i_draw_delete_box(ui HardUI, item *ItemsNode) { ui.def_style, "o]") } -func i_host_panel_dirs(ui HardUI, icons bool, +func i_host_panel_dirs(ui HardUI, icons bool, dir_icon uint8, dir *DirsNode, curr *DirsNode, line int) { style := ui.dir_style if dir == curr { @@ -238,11 +238,7 @@ func i_host_panel_dirs(ui HardUI, icons bool, text += " " } if icons == true { - var fold_var uint8 - if dir.Folded == true { - fold_var = 1 - } - text += DIRS_ICONS[fold_var] + text += DIRS_ICONS[dir_icon] } text += dir.Name spaces := "" @@ -253,9 +249,6 @@ func i_host_panel_dirs(ui HardUI, icons bool, i_draw_text(ui.s, 1, line, ui.dim[W] / 3, line, style, text) - i_draw_text(ui.s, - ui.dim[W] / 3 - 2, line, ui.dim[W] / 3, line, - ui.def_style, strconv.Itoa(dir.count_elements(true))) } func i_host_panel_host(ui HardUI, icons bool, @@ -282,7 +275,7 @@ func i_host_panel_host(ui HardUI, icons bool, style, text) } -func i_host_panel(ui HardUI, icons bool, litems *ItemsList) { +func i_host_panel(ui HardUI, icons bool, litems *ItemsList, data *HardData) { i_draw_box(ui.s, 0, 0, ui.dim[W] / 3, ui.dim[H] - 2, " Hosts ", false) @@ -298,10 +291,19 @@ func i_host_panel(ui HardUI, icons bool, litems *ItemsList) { line) line++ } else if ptr.Dirs != nil { - i_host_panel_dirs(ui, icons, + var dir_icon uint8 + if data.folds[ptr.Dirs] != nil { + dir_icon = 1 + } + i_host_panel_dirs(ui, icons, dir_icon, ptr.Dirs, litems.curr.Dirs, line) + // FIX: === delete this + i_draw_text(ui.s, + ui.dim[W] / 3 - 2, line, ui.dim[W] / 3, line, + ui.def_style, strconv.Itoa(ptr.Dirs.count_elements(true, data.folds))) + // FIX: === line++ } } @@ -549,7 +551,7 @@ func i_ui(data *HardData) { for { ui.s.Clear() i_bottom_text(*ui) - i_host_panel(data.ui, data.opts.Icon, data.litems) + i_host_panel(data.ui, data.opts.Icon, data.litems, data) i_info_panel(data.ui, data.litems) if data.litems.head == nil { i_draw_zhosts_box(*ui) |