aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-03-27 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-03-27 20:20:20 +0100
commit8d1bb55ef66e450106c22ae18c7105029e75f338 (patch)
tree0d7da559504293ebe923d474fa159a4d9ea55999
parentk (diff)
downloadhardflip-8d1bb55ef66e450106c22ae18c7105029e75f338.tar.gz
hardflip-8d1bb55ef66e450106c22ae18c7105029e75f338.tar.bz2
hardflip-8d1bb55ef66e450106c22ae18c7105029e75f338.tar.xz
hardflip-8d1bb55ef66e450106c22ae18c7105029e75f338.tar.zst
hardflip-8d1bb55ef66e450106c22ae18c7105029e75f338.zip
great
-rw-r--r--src/c_hardflip.go3
-rw-r--r--src/i_events.go15
-rw-r--r--src/i_insert.go35
-rw-r--r--src/i_ui.go30
4 files changed, 75 insertions, 8 deletions
diff --git a/src/c_hardflip.go b/src/c_hardflip.go
index 5b4761f..7b88913 100644
--- a/src/c_hardflip.go
+++ b/src/c_hardflip.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/c_hardflip.go
- * Wed Feb 21 19:38:57 2024
+ * Wed Mar 27 13:48:53 2024
* Joe
*
* the main
@@ -60,6 +60,7 @@ type HardData struct {
folds map[*DirsNode]*ItemsList
data_dir string
load_err []error
+ insert_err []error
keys [][2]string
insert *HostNode
}
diff --git a/src/i_events.go b/src/i_events.go
index 0c9c968..1ba9e7a 100644
--- a/src/i_events.go
+++ b/src/i_events.go
@@ -322,7 +322,7 @@ func i_set_protocol_defaults(data *HardData, in *HostNode) {
case 0:
in.Port = 22
in.Jump.Port = 22
- data.ui.insert_sel_max = 10
+ data.ui.insert_sel_max = 11
case 1:
in.Port = 3389
in.Quality = 2
@@ -549,7 +549,13 @@ func i_events(data *HardData) {
i_readline(event, data)
}
} else if data.insert != nil {
- if data.ui.insert_sel_ok == false {
+ if data.insert_err != nil {
+ if event.Rune() != 0 ||
+ event.Key() == tcell.KeyEscape ||
+ event.Key() == tcell.KeyEnter {
+ data.insert_err = nil
+ }
+ } else if data.ui.insert_sel_ok == false {
if event.Key() == tcell.KeyEscape ||
event.Key() == tcell.KeyCtrlC ||
event.Rune() == 'q' {
@@ -583,6 +589,9 @@ func i_events(data *HardData) {
case 8: ui.buff = data.insert.Jump.User
case 9: break
case 10: ui.buff = data.insert.Jump.Priv
+ case 11:
+ data.ui.insert_sel_ok = false
+ i_insert_check_ok(data, data.insert)
}
}
} else {
@@ -649,8 +658,8 @@ func i_events(data *HardData) {
if event.Key() == tcell.KeyEscape ||
event.Key() == tcell.KeyCtrlC {
ui.s.HideCursor()
- ui.buff = ""
ui.mode = NORMAL_MODE
+ ui.buff = ""
data.insert = nil
} else if event.Key() == tcell.KeyEnter {
i_mkdir(data, ui)
diff --git a/src/i_insert.go b/src/i_insert.go
index 23c2bc6..ddcefff 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -52,12 +52,24 @@
package main
import (
+ "errors"
"os"
"strconv"
"github.com/gdamore/tcell/v2"
)
+func i_insert_check_ok(data *HardData, insert *HostNode) {
+ if len(insert.Name) == 0 {
+ data.insert_err = append(data.insert_err,
+ errors.New("no name"))
+ }
+ if len(insert.Host) == 0 {
+ data.insert_err = append(data.insert_err,
+ errors.New("no host"))
+ }
+}
+
func i_draw_text_box(ui HardUI, line int, dim Quad, label, content string,
id, selected int, red bool) {
const tbox_size int = 14
@@ -88,6 +100,27 @@ func i_draw_text_box(ui HardUI, line int, dim Quad, label, content string,
line, tbox_style, content)
}
+func i_draw_ok_butt(ui HardUI, line int, id, selected int) {
+ const butt_size int = 10
+ const txt string = "ok"
+ style := ui.style[DEF_STYLE].Background(tcell.ColorBlack).Dim(true)
+
+ if id == selected {
+ style = style.Reverse(true).Dim(false)
+ }
+ buff := "["
+ for i := 0; i < butt_size / 2 - len(txt); i++ {
+ buff += " "
+ }
+ buff += txt
+ for i := 0; i < butt_size / 2 - len(txt); i++ {
+ buff += " "
+ }
+ buff += "]"
+ i_draw_text(ui.s, (ui.dim[W] / 2) - (butt_size / 2), line,
+ (ui.dim[W] / 2) + (butt_size / 2), line, style, buff)
+}
+
func i_draw_insert_panel(ui HardUI, in *HostNode) {
if len(in.Name) == 0 {
return
@@ -187,5 +220,7 @@ func i_draw_insert_ssh(ui HardUI, line int, win Quad, in *HostNode) {
i_draw_text(ui.s, ui.dim[W] / 2, win.T + line,
win.R - 1, win.T + line, ui.style[ERR_STYLE], text)
}
+ if line += 2; win.T + line >= win.B { return }
+ i_draw_ok_butt(ui, win.T + line, 11, ui.insert_sel)
// TODO: here
}
diff --git a/src/i_ui.go b/src/i_ui.go
index 89c89ac..7500b9f 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/i_ui.go
- * Thu Mar 14 10:39:01 2024
+ * Wed Mar 27 15:48:56 2024
* Joe
*
* interfacing with the user
@@ -173,7 +173,8 @@ func i_draw_msg(s tcell.Screen, lines int, box_style tcell.Style,
box_style, title)
}
-func i_draw_bottom_text(ui HardUI, opts HardOpts, insert *HostNode) {
+func i_draw_bottom_text(ui HardUI, opts HardOpts,
+ insert *HostNode, insert_err []error) {
text := ""
switch ui.mode {
@@ -194,6 +195,8 @@ func i_draw_bottom_text(ui HardUI, opts HardOpts, insert *HostNode) {
case INSERT_MODE:
if insert == nil {
text = ""
+ } else if insert_err != nil {
+ text = ERROR_KEYS_HINTS
} else {
text = INSERT_KEYS_HINTS
}
@@ -451,6 +454,22 @@ func i_draw_delete_msg(ui HardUI, item *ItemsNode) {
ui.style[DEF_STYLE].Bold(true), file)
}
+func i_draw_insert_err_msg(ui HardUI, insert_err []error) {
+ lines := len(insert_err)
+ i_draw_msg(ui.s, lines, ui.style[BOX_STYLE], ui.dim, " Errors ")
+ left, right := 1, ui.dim[W] - 1
+ line := ui.dim[H] - 2 - 1 - len(insert_err)
+ if line < 0 {
+ line = 0
+ }
+ for _, err := range insert_err {
+ line += 1
+ err_str := fmt.Sprintf("%v", err)
+ i_draw_text(ui.s, left, line, right, line,
+ ui.style[ERR_STYLE], err_str)
+ }
+}
+
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 ")
@@ -529,7 +548,7 @@ func i_draw_load_ui(ui *HardUI, opts HardOpts) {
}
i_draw_text(ui.s, 1, ui.dim[H] - 1, ui.dim[W], ui.dim[H] - 1,
ui.style[BOT_STYLE], text)
- i_draw_bottom_text(*ui, opts, nil)
+ i_draw_bottom_text(*ui, opts, nil, nil)
i_draw_msg(ui.s, 1, ui.style[BOX_STYLE], ui.dim, " Loading ")
text = "Loading " + strconv.Itoa(g_load_count) + " hosts"
left, right := i_left_right(len(text), ui)
@@ -620,6 +639,7 @@ func i_ui(data_dir string) {
make(map[*DirsNode]*ItemsList),
data_dir,
load_err,
+ nil,
[][2]string{},
nil,
}
@@ -629,7 +649,7 @@ func i_ui(data_dir string) {
}
for {
data.ui.s.Clear()
- i_draw_bottom_text(data.ui, data.opts, data.insert)
+ i_draw_bottom_text(data.ui, data.opts, data.insert, data.insert_err)
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)
@@ -673,6 +693,8 @@ func i_ui(data_dir string) {
i_prompt_generic(data.ui, "Private key: ",
false, home_dir)
}
+ } else if data.insert_err != nil {
+ i_draw_insert_err_msg(data.ui, data.insert_err)
}
}
}