aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-01-23 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-01-23 20:20:20 +0100
commitd2c0fdf3e0166f7ba2b82df74a2b5d858c00178e (patch)
tree3b18e17799f832ee0f072eae6f21df27b4e21e0d
parentbench time (diff)
downloadhardflip-d2c0fdf3e0166f7ba2b82df74a2b5d858c00178e.tar.gz
hardflip-d2c0fdf3e0166f7ba2b82df74a2b5d858c00178e.tar.bz2
hardflip-d2c0fdf3e0166f7ba2b82df74a2b5d858c00178e.tar.xz
hardflip-d2c0fdf3e0166f7ba2b82df74a2b5d858c00178e.tar.zst
hardflip-d2c0fdf3e0166f7ba2b82df74a2b5d858c00178e.zip
good loading errmsg
-rw-r--r--src/c_hardflip.go2
-rw-r--r--src/c_init.go15
-rw-r--r--src/i_events.go6
-rw-r--r--src/i_ui.go27
4 files changed, 28 insertions, 22 deletions
diff --git a/src/c_hardflip.go b/src/c_hardflip.go
index 538cb30..8ffdaba 100644
--- a/src/c_hardflip.go
+++ b/src/c_hardflip.go
@@ -59,7 +59,7 @@ type HardData struct {
opts HardOpts
folds map[*DirsNode]*ItemsList
data_dir string
- load_err *[]error
+ load_err []error
}
func main() {
diff --git a/src/c_init.go b/src/c_init.go
index 5d399e2..5c9f115 100644
--- a/src/c_init.go
+++ b/src/c_init.go
@@ -92,24 +92,23 @@ func c_recurse_data_dir(dir, root string, opts HardOpts,
host_node, err := c_read_yaml_file(root + dir + filename, ui)
if err != nil {
*load_err = append(*load_err, err)
- return
- } else if host_node == nil {
- return
+ } else if host_node != nil {
+ host_node.Filename = filename
+ host_node.Parent = &dir_node
+ dir_node.lhost.add_back(host_node)
}
- host_node.Filename = filename
- host_node.Parent = &dir_node
- dir_node.lhost.add_back(host_node)
i_draw_load_ui(ui)
}
}
}
-func c_load_data_dir(dir string, opts HardOpts, ui *HardUI) (*DirsList, *[]error) {
+func c_load_data_dir(dir string, opts HardOpts,
+ ui *HardUI) (*DirsList, []error) {
ldirs := DirsList{}
var load_err []error
c_recurse_data_dir("", dir + "/", opts, &ldirs, "", nil, 1, ui, &load_err)
- return &ldirs, &load_err
+ return &ldirs, load_err
}
// fills litems sorting with dirs last
diff --git a/src/i_events.go b/src/i_events.go
index 427f9c1..7ca1511 100644
--- a/src/i_events.go
+++ b/src/i_events.go
@@ -168,7 +168,8 @@ func i_fold_dir(data *HardData, item *ItemsNode) {
func i_reload_data(data *HardData) {
data.data_dir = c_get_data_dir()
g_load_count = -1
- data.ldirs, data.litems, data.load_err = i_load_ui(data.data_dir, data.opts, &data.ui)
+ data.ldirs, data.litems, data.load_err = i_load_ui(data.data_dir, data.opts,
+ &data.ui)
// FIX: must input to start reloading for some reason
data.folds = make(map[*DirsNode]*ItemsList)
}
@@ -325,6 +326,7 @@ func i_events(data *HardData) {
i_unfold_dir(data, data.litems.curr)
}
} else if event.Key() == tcell.KeyCtrlR {
+ event = nil
i_reload_data(data)
}
i_list_follow_cursor(data.litems, ui)
@@ -341,7 +343,7 @@ func i_events(data *HardData) {
}
}
case ERROR_MODE:
- if event.Rune() == 'q' ||
+ if event.Rune() != 0 ||
event.Key() == tcell.KeyEnter {
ui.mode = NORMAL_MODE
data.load_err = nil
diff --git a/src/i_ui.go b/src/i_ui.go
index 53bd056..6777f6c 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -221,19 +221,24 @@ func i_draw_delete_msg(ui HardUI, item *ItemsNode) {
ui.style[DEF_STYLE].Bold(true), file)
}
-func i_draw_load_error_msg(ui HardUI, load_err *[]error) {
- lines := len(*load_err)
+func i_draw_load_error_msg(ui HardUI, load_err []error) {
+ lines := len(load_err)
i_draw_msg(ui.s, lines, ui.style[BOX_STYLE], ui.dim, " Load time errors ")
- left, right := 1, ui.dim[W] - 2
- for i, err := range *load_err {
+ left, right := 1, ui.dim[W] - 1
+ line := ui.dim[H] - 2 - 1 - len(load_err)
+ if line < 0 {
+ line = 0
+ }
+ for i, err := range load_err {
+ line += 1
err_str := fmt.Sprintf("%v", err)
- i_draw_text(ui.s, left, i, right, i,
- ui.style[ERR_STYLE], strconv.Itoa(i) + err_str)
+ i_draw_text(ui.s, left, line, right, line,
+ ui.style[ERR_STYLE], strconv.Itoa(i + 1) + " " + err_str)
}
}
-func i_draw_error_msg(ui HardUI, load_err *[]error) {
- if len(*load_err) > 0 {
+func i_draw_error_msg(ui HardUI, load_err []error) {
+ if len(load_err) > 0 {
i_draw_load_error_msg(ui, load_err)
return
}
@@ -316,12 +321,12 @@ func i_draw_load_ui(ui *HardUI) {
func i_load_ui(data_dir string,
opts HardOpts,
- ui *HardUI) (*DirsList, *ItemsList, *[]error) {
+ ui *HardUI) (*DirsList, *ItemsList, []error) {
ui.mode = LOAD_MODE
ldirs, load_err := c_load_data_dir(data_dir, opts, ui)
litems := c_load_litems(ldirs)
ui.mode = NORMAL_MODE
- if len(*load_err) == 0 {
+ if len(load_err) == 0 {
load_err = nil
}
return ldirs, litems, load_err
@@ -378,7 +383,7 @@ func i_ui(data_dir string, opts HardOpts) {
i_draw_host_panel(data.ui, data.opts.Icon, data.litems, &data)
i_draw_info_panel(data.ui, data.opts.Perc, data.litems)
i_draw_scrollhint(data.ui, data.litems)
- if data.load_err != nil && len(*data.load_err) > 0 {
+ if data.load_err != nil && len(data.load_err) > 0 {
data.ui.mode = ERROR_MODE
}
if data.litems.head == nil {