aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ROADMAP.md2
-rw-r--r--c_exec.go1
-rw-r--r--c_init.go23
-rw-r--r--i_events.go6
-rw-r--r--i_ui.go43
5 files changed, 48 insertions, 27 deletions
diff --git a/ROADMAP.md b/ROADMAP.md
index 533c84c..f928c46 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -8,7 +8,7 @@
## v0.2
-- [ ] load scr
+- [x] load scr
- [ ] err msg
## v0.3
diff --git a/c_exec.go b/c_exec.go
index 407c0f7..15b3a28 100644
--- a/c_exec.go
+++ b/c_exec.go
@@ -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")
}
diff --git a/c_init.go b/c_init.go
index d39ab71..d2250af 100644
--- a/c_init.go
+++ b/c_init.go
@@ -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)
}
diff --git a/i_ui.go b/i_ui.go
index 6757f9b..0c3e1fc 100644
--- a/i_ui.go
+++ b/i_ui.go
@@ -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,