aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-03-19 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-03-19 20:20:20 +0100
commitc596bf0560c2eceb25e00ed57586d31a629bd695 (patch)
tree7b5366887a2a56b5a1cf6f7fdc2e97e74a663654
parentport (diff)
downloadhardflip-c596bf0560c2eceb25e00ed57586d31a629bd695.tar.gz
hardflip-c596bf0560c2eceb25e00ed57586d31a629bd695.tar.bz2
hardflip-c596bf0560c2eceb25e00ed57586d31a629bd695.tar.xz
hardflip-c596bf0560c2eceb25e00ed57586d31a629bd695.tar.zst
hardflip-c596bf0560c2eceb25e00ed57586d31a629bd695.zip
go
-rw-r--r--src/i_events.go25
-rw-r--r--src/i_insert.go29
-rw-r--r--src/i_ui.go6
3 files changed, 49 insertions, 11 deletions
diff --git a/src/i_events.go b/src/i_events.go
index 48c3471..3e1b810 100644
--- a/src/i_events.go
+++ b/src/i_events.go
@@ -159,7 +159,7 @@ func i_fold_dir(data *HardData, item *ItemsNode) {
return
}
// this is not the end
- end = next_dir.prev
+ end = next_dir.prev
end.next = nil
item.next = next_dir
next_dir.prev = item
@@ -285,7 +285,7 @@ func i_readline(event *tcell.EventKey, data *HardData) {
event.Key() == tcell.KeyBackspace2) {
data.ui.buff = data.ui.buff[:len(data.ui.buff) - 1]
} else if event.Key() == tcell.KeyCtrlU {
- data.ui.buff = ""
+ data.ui.buff = ""
} else if event.Rune() >= 32 && event.Rune() <= 126 {
data.ui.buff += string(event.Rune())
}
@@ -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 = 7
+ data.ui.insert_sel_max = 10
case 1:
in.Port = 3389
in.Quality = 2
@@ -577,6 +577,11 @@ func i_events(data *HardData) {
case 4: break
case 5: ui.buff = data.insert.Priv
case 6: ui.buff = data.insert.Jump.Host
+ case 7: ui.buff = strconv.Itoa(int(
+ data.insert.Jump.Port))
+ case 8: ui.buff = data.insert.Jump.User
+ case 9: break
+ case 10: ui.buff = data.insert.Jump.Priv
}
}
} else {
@@ -605,11 +610,11 @@ func i_events(data *HardData) {
ui.s.HideCursor()
i_set_protocol_defaults(data, data.insert)
}
- case 1, 2, 3, 4, 5, 6, 7:
+ case 1, 2, 3, 4, 5, 6, 7, 8, 9, 10:
if event.Key() == tcell.KeyEnter {
switch data.ui.insert_sel {
case 1: data.insert.Host = ui.buff
- case 2:
+ case 2:
tmp, _ := strconv.Atoi(ui.buff)
data.insert.Port = uint16(tmp)
case 3: data.insert.User = ui.buff
@@ -622,6 +627,12 @@ func i_events(data *HardData) {
case 7:
tmp, _ := strconv.Atoi(ui.buff)
data.insert.Jump.Port = uint16(tmp)
+ case 8: data.insert.Jump.User = ui.buff
+ case 9:
+ pass, _ := c_encrypt_str(ui.buff,
+ data.opts.GPG)
+ data.insert.Jump.Pass = pass
+ case 10: data.insert.Jump.Priv = ui.buff
}
data.ui.insert_sel_ok = false
ui.buff = ""
@@ -639,7 +650,7 @@ func i_events(data *HardData) {
ui.s.HideCursor()
ui.buff = ""
ui.mode = NORMAL_MODE
- data.insert = nil
+ data.insert = nil
} else if event.Key() == tcell.KeyEnter {
i_mkdir(data, ui)
ui.s.HideCursor()
@@ -648,6 +659,6 @@ func i_events(data *HardData) {
} else {
i_readline(event, data)
}
- }
+ }
}
}
diff --git a/src/i_insert.go b/src/i_insert.go
index a0f629f..23c2bc6 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -71,7 +71,7 @@ func i_draw_text_box(ui HardUI, line int, dim Quad, label, content string,
if l <= dim.L { l = dim.L + 1 }
i_draw_text(ui.s, l, line, ui.dim[W] / 2, line,
ui.style[DEF_STYLE], label)
- if id == 4 && len(content) > 0 {
+ if (id == 4 || id == 9) && len(content) > 0 {
content = "***"
}
if red == true {
@@ -150,6 +150,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)
}
+ red = false
if line += 2; win.T + line >= win.B { return }
text = "---- Jump settings ----"
i_draw_text(ui.s, ui.dim[W] / 2 - len(text) / 2, win.T + line, win.R - 1,
@@ -160,5 +161,31 @@ func i_draw_insert_ssh(ui HardUI, line int, win Quad, in *HostNode) {
if line += 1; win.T + line >= win.B { return }
i_draw_text_box(ui, win.T + line, win, "Port",
strconv.Itoa(int(in.Jump.Port)), 7, ui.insert_sel, false)
+ if line += 2; win.T + line >= win.B { return }
+ i_draw_text_box(ui, win.T + line, win, "User",
+ in.Jump.User, 8, ui.insert_sel, false)
+ if line += 1; win.T + line >= win.B { return }
+ i_draw_text_box(ui, win.T + line, win, "Pass",
+ in.Jump.Pass, 9, ui.insert_sel, false)
+ if line += 1; win.T + line >= win.B { return }
+ if len(in.Jump.Priv) > 0 {
+ file := in.Jump.Priv
+ if file[0] == '~' {
+ home, _ := os.UserHomeDir()
+ file = home + file[1:]
+ }
+ if stat, err := os.Stat(file);
+ err != nil || stat.IsDir() == true {
+ red = true
+ }
+ }
+ i_draw_text_box(ui, win.T + line, win, "SSH private key",
+ in.Jump.Priv, 10, ui.insert_sel, red)
+ if red == true {
+ if line += 1; win.T + line >= win.B { return }
+ text := "file does not exist"
+ i_draw_text(ui.s, ui.dim[W] / 2, win.T + line,
+ win.R - 1, win.T + line, ui.style[ERR_STYLE], text)
+ }
// TODO: here
}
diff --git a/src/i_ui.go b/src/i_ui.go
index 97ca3d5..89c89ac 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -665,11 +665,11 @@ func i_ui(data_dir string) {
i_prompt_generic(data.ui, "Host/IP: ", false, "")
case 2, 7:
i_prompt_generic(data.ui, "Port: ", false, "")
- case 3:
+ case 3, 8:
i_prompt_generic(data.ui, "User: ", false, "")
- case 4:
+ case 4, 9:
i_prompt_generic(data.ui, "Pass: ", true, "")
- case 5:
+ case 5, 10:
i_prompt_generic(data.ui, "Private key: ",
false, home_dir)
}