From 2bcf613e91cfaa214cd6e1847df43e94358c3497 Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 10 Jan 2024 20:20:20 +0100 Subject: cool box bro --- c_ldirs.go | 1 - i_events.go | 29 +++++++++++------------------ i_ui.go | 13 +++++++++---- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/c_ldirs.go b/c_ldirs.go index 906e368..141a0b8 100644 --- a/c_ldirs.go +++ b/c_ldirs.go @@ -57,7 +57,6 @@ type DirsNode struct { Parent *DirsNode Depth uint16 lhost *HostList - // HACK: remove Folded bool if maps work Folded bool next *DirsNode } diff --git a/i_events.go b/i_events.go index 2448962..ff2c9c4 100644 --- a/i_events.go +++ b/i_events.go @@ -43,7 +43,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/i_events.go - * Wed Jan 10 17:38:06 2024 + * Wed Jan 10 18:56:02 2024 * Joe * * events in the code @@ -156,10 +156,11 @@ func i_delete_dir(data *HardData) { return } dir_path := data.data_dir + dir.path() - if err := os.Remove(dir_path); err != nil { + if err := os.RemoveAll(dir_path); err != nil { data.ui.s.Fini() c_die("can't remove " + dir_path, err) } + // TODO: finish this } func i_delete_host(data *HardData) { @@ -208,22 +209,19 @@ func i_events(data *HardData) { switch ui.mode { case NORMAL_MODE: if event.Key() == tcell.KeyCtrlC || - event.Rune() == 'q' || - event.Rune() == 'Q' { + event.Rune() == 'q' { ui.s.Fini() os.Exit(0) } else if event.Rune() == 'j' || - event.Rune() == 'J' || event.Key() == tcell.KeyDown { data.litems.inc(+1) } else if event.Rune() == 'k' || - event.Rune() == 'K' || event.Key() == tcell.KeyUp { data.litems.inc(-1) } else if event.Key() == tcell.KeyCtrlD { - data.litems.inc(+1000 + (ui.dim[H] / 3)) + data.litems.inc(+(ui.dim[H] / 3)) } else if event.Key() == tcell.KeyCtrlU { - data.litems.inc(-1000 - (ui.dim[H] / 3)) + data.litems.inc(-(ui.dim[H] / 3)) } else if event.Rune() == 'g' { data.litems.curr = data.litems.head data.litems.draw_start = data.litems.head @@ -250,12 +248,10 @@ func i_events(data *HardData) { } ui.s.SetStyle(ui.def_style) } + } else if data.litems.curr.Dirs.Folded == false { + i_fold_dir(data, data.litems.curr) } else { - if data.litems.curr.Dirs.Folded == false { - i_fold_dir(data, data.litems.curr) - } else { - i_unfold_dir(data, data.litems.curr) - } + i_unfold_dir(data, data.litems.curr) } } else if event.Rune() == ' ' { if data.litems.curr == nil || @@ -275,12 +271,9 @@ func i_events(data *HardData) { if event.Key() == tcell.KeyEscape || event.Key() == tcell.KeyCtrlC || event.Rune() == 'q' || - event.Rune() == 'n' || - event.Rune() == 'Q' || - event.Rune() == 'N' { + event.Rune() == 'n' { ui.mode = NORMAL_MODE - } else if event.Rune() == 'y' || - event.Rune() == 'Y' { + } else if event.Rune() == 'y' { i_delete_host(data) ui.mode = NORMAL_MODE } diff --git a/i_ui.go b/i_ui.go index 4e0b7c0..3db1e01 100644 --- a/i_ui.go +++ b/i_ui.go @@ -60,6 +60,7 @@ import ( type HardUI struct { s tcell.Screen mode uint8 + // HACK: fuck sel_max sel_max int def_style tcell.Style dir_style tcell.Style @@ -160,12 +161,16 @@ func i_draw_zhosts_box(ui HardUI) { } func i_draw_delete_box(ui HardUI, item *ItemsNode) { + var text string + var file string if item.is_dir() == true { - return + text = "Really delete this directory and all subsequent files?" + file = item.Dirs.path() + } else { + host := item.Host + text = "Really delete this host?" + file = host.Parent.path() + host.Filename } - host := item.Host - text := "Really delete this host?" - file := host.Parent.path() + host.Filename max_len := len(text) if max_len < len(file) { -- cgit v1.2.3