diff options
Diffstat (limited to '')
-rw-r--r-- | ROADMAP.md | 2 | ||||
-rw-r--r-- | c_exec.go | 1 | ||||
-rw-r--r-- | c_init.go | 23 | ||||
-rw-r--r-- | i_events.go | 6 | ||||
-rw-r--r-- | i_ui.go | 43 |
5 files changed, 48 insertions, 27 deletions
@@ -8,7 +8,7 @@ ## v0.2 -- [ ] load scr +- [x] load scr - [ ] err msg ## v0.3 @@ -147,6 +147,7 @@ func c_format_cmd(host *HostNode, term string) { c_die("type not found", nil) } if len(term) > 0 { + // TODO: setsid if term == "$TERMINAL" { term = os.Getenv("TERMINAL") } @@ -43,7 +43,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/c_init.go - * Wed Jan 10 16:36:49 2024 + * Thu Jan 18 16:23:10 2024 * Joe * * init functions @@ -52,7 +52,6 @@ package main import ( - "strconv" "os" "path/filepath" ) @@ -65,7 +64,7 @@ type HardOpts struct { } // HACK: fuck global vars -var count int = 0 +var g_load_count int = -1 // this function recurses into the specified root directory in order to load // every yaml file into memory @@ -85,6 +84,7 @@ func c_recurse_data_dir(dir, root string, opts HardOpts, nil, } ldirs.add_back(&dir_node) + i_display_load_ui(ui) for _, file := range files { filename := file.Name() if file.IsDir() == true { @@ -98,22 +98,7 @@ func c_recurse_data_dir(dir, root string, opts HardOpts, host_node.Filename = filename host_node.Parent = &dir_node dir_node.lhost.add_back(host_node) - ui.s.Clear() - count += 1 - text := "Loading " + strconv.Itoa(count) + " hosts" - text_len := len(text) / 2 - i_draw_box(ui.s, - (ui.dim[W] / 2) - (text_len + 2), - (ui.dim[H] / 2) - 2, - (ui.dim[W] / 2) + (text_len + 2), - (ui.dim[H] / 2) + 2, " Loading hosts ", false) - i_draw_text(ui.s, - (ui.dim[W] / 2) - text_len, - (ui.dim[H] / 2), - (ui.dim[W] / 2) + text_len, - (ui.dim[H] / 2), - ui.def_style, text) - ui.s.Show() + i_display_load_ui(ui) } } } diff --git a/i_events.go b/i_events.go index d799824..8217978 100644 --- a/i_events.go +++ b/i_events.go @@ -43,7 +43,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/i_events.go - * Thu Jan 18 12:33:22 2024 + * Thu Jan 18 18:01:23 2024 * Joe * * events in the code @@ -168,8 +168,8 @@ func i_fold_dir(data *HardData, item *ItemsNode) { 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.ui) - data.litems = c_load_litems(data.ldirs) + g_load_count = 0 + data.ldirs, data.litems = i_load_ui(data.data_dir, data.opts, &data.ui) data.folds = make(map[*DirsNode]*ItemsList) } @@ -43,7 +43,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/i_ui.go - * Mon Jan 15 17:59:26 2024 + * Thu Jan 18 17:51:03 2024 * Joe * * interfacing with the user @@ -52,6 +52,7 @@ package main import ( + "os" "strconv" "github.com/gdamore/tcell/v2" @@ -556,13 +557,48 @@ func i_scrollhint(ui HardUI, litems *ItemsList) { } } +func i_display_load_ui(ui *HardUI) { + g_load_count += 1 + if g_load_count % 1000 != 0 { + return + } + ui.s.Clear() + text := "Loading " + strconv.Itoa(g_load_count) + " hosts" + text_len := len(text) / 2 + // TODO: max len + i_draw_box(ui.s, + (ui.dim[W] / 2) - (text_len + 2) - 1, + (ui.dim[H] / 2) - 2, + (ui.dim[W] / 2) + (text_len + 2), + (ui.dim[H] / 2) + 2, " Loading hosts ", false) + i_draw_text(ui.s, + (ui.dim[W] / 2) - text_len, + (ui.dim[H] / 2), + (ui.dim[W] / 2) + text_len + 1, + (ui.dim[H] / 2), + ui.def_style, text) + ui.s.Show() + event := ui.s.PollEvent() + ui.s.PostEvent(event) + switch event := event.(type) { + case *tcell.EventResize: + ui.dim[W], ui.dim[H], _ = term.GetSize(0) + ui.s.Sync() + case *tcell.EventKey: + if event.Key() == tcell.KeyCtrlC || + event.Rune() == 'q' { + ui.s.Fini() + os.Exit(0) + } + } +} + func i_load_ui(data_dir string, opts HardOpts, ui *HardUI) (*DirsList, *ItemsList) { - ui.s.Clear() + ui.mode = LOAD_MODE ldirs := c_load_data_dir(data_dir, opts, ui) litems := c_load_litems(ldirs) - ui.s.Show() ui.mode = NORMAL_MODE return ldirs, litems } @@ -589,7 +625,6 @@ func i_ui(data_dir string, opts HardOpts) { Foreground(tcell.ColorBlue).Dim(true).Bold(true) ui.s.SetStyle(ui.def_style) ui.dim[W], ui.dim[H], _ = term.GetSize(0) - ui.mode = LOAD_MODE ldirs, litems := i_load_ui(data_dir, opts, &ui) data := HardData{ litems, |