aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-03-01 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-03-01 20:20:20 +0100
commitb56388dde593f09c03addbe65093289c1b70d1e6 (patch)
tree14931b9eb6cfd0a3e5317c04527a86915519e4ae /src
parentcommit (diff)
downloadhardflip-b56388dde593f09c03addbe65093289c1b70d1e6.tar.gz
hardflip-b56388dde593f09c03addbe65093289c1b70d1e6.tar.bz2
hardflip-b56388dde593f09c03addbe65093289c1b70d1e6.tar.xz
hardflip-b56388dde593f09c03addbe65093289c1b70d1e6.tar.zst
hardflip-b56388dde593f09c03addbe65093289c1b70d1e6.zip
qwe
Diffstat (limited to 'src')
-rw-r--r--src/i_events.go6
-rw-r--r--src/i_insert.go48
-rw-r--r--src/i_ui.go16
3 files changed, 51 insertions, 19 deletions
diff --git a/src/i_events.go b/src/i_events.go
index 6143f8c..6582ac6 100644
--- a/src/i_events.go
+++ b/src/i_events.go
@@ -321,7 +321,7 @@ func i_set_protocol_defaults(data *HardData, in *HostNode) {
switch in.Protocol {
case 0:
in.Port = 22
- data.ui.insert_sel_max = 5
+ data.ui.insert_sel_max = 6
case 1:
in.Port = 3389
in.Quality = 2
@@ -602,7 +602,7 @@ func i_events(data *HardData) {
ui.s.HideCursor()
i_set_protocol_defaults(data, data.insert)
}
- case 1, 2, 3, 4:
+ case 1, 2, 3, 4, 5, 6:
if event.Key() == tcell.KeyEnter {
if data.ui.insert_sel == 1 {
data.insert.Host = ui.buff
@@ -617,6 +617,8 @@ func i_events(data *HardData) {
data.insert.Pass = pass
} else if data.ui.insert_sel == 5 {
data.insert.Priv = ui.buff
+ } else if data.ui.insert_sel == 6 {
+ data.insert.Jump.Host = ui.buff
}
data.ui.insert_sel_ok = false
ui.buff = ""
diff --git a/src/i_insert.go b/src/i_insert.go
index 536d3fa..e2f677d 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/i_insert.go
- * Wed Feb 28 17:27:20 2024
+ * Fri Mar 01 15:35:55 2024
* Joe
*
* insert a new host
@@ -52,7 +52,9 @@
package main
import (
+ "os"
"strconv"
+
"github.com/gdamore/tcell/v2"
)
@@ -69,6 +71,19 @@ 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 {
+ content = "***"
+ } else if id == 5 && len(content) > 0 {
+ file := content
+ if file[0] == '~' {
+ home, _ := os.UserHomeDir()
+ file = home + file[1:]
+ }
+ if _, err := os.Stat(file);
+ err != nil {
+ tbox_style = tbox_style.Foreground(tcell.ColorRed)
+ }
+ }
spaces := ""
for i := 0; i < tbox_size; i++ {
spaces += " "
@@ -76,9 +91,6 @@ func i_draw_text_box(ui HardUI, line int, dim Quad, label, content string,
i_draw_text(ui.s, ui.dim[W] / 2, line, dim.R, line,
tbox_style,
"[" + spaces + "]")
- if id == 4 && len(content) > 0 {
- content = "***"
- }
i_draw_text(ui.s, ui.dim[W] / 2 + 1, line, ui.dim[W] / 2 + 1 + tbox_size,
line, tbox_style, content)
}
@@ -90,16 +102,17 @@ func i_draw_insert_panel(ui HardUI, in *HostNode) {
win := Quad{
ui.dim[W] / 8,
ui.dim[H] / 8,
- ui.dim[W] - ui.dim[W] / 8,
- ui.dim[H] - ui.dim[H] / 8,
+ ui.dim[W] - ui.dim[W] / 8 - 1,
+ ui.dim[H] - ui.dim[H] / 8 - 1,
}
i_draw_box(ui.s, win.L, win.T, win.R, win.B,
ui.style[BOX_STYLE], ui.style[HEAD_STYLE],
" Insert - " + in.Name + " ", true)
line := 2
+ if win.T + line >= win.B { return }
i_draw_text_box(ui, win.T + line, win, "Connection type", in.protocol_str(),
0, ui.insert_sel)
- line += 3
+ line += 2
switch in.Protocol {
case 0:
i_draw_insert_ssh(ui, line, win, in)
@@ -122,10 +135,27 @@ func i_draw_insert_ssh(ui HardUI, line int, win Quad, in *HostNode) {
i_draw_text_box(ui, win.T + line, win, "Pass", in.Pass, 4, ui.insert_sel)
if line += 1; win.T + line >= win.B { return }
i_draw_text_box(ui, win.T + line, win, "SSH private key",
- in.Pass, 5, ui.insert_sel)
- if line += 3; win.T + line >= win.B { return }
+ in.Priv, 5, ui.insert_sel)
+ if len(in.Priv) > 0 {
+ file := in.Priv
+ if file[0] == '~' {
+ home, _ := os.UserHomeDir()
+ file = home + file[1:]
+ }
+ if _, err := os.Stat(file);
+ err != nil {
+ if line += 1; win.T + line >= win.B { return }
+ text := "file does not exist"
+ i_draw_text(ui.s, ui.dim[W] / 2 - len(text) / 2, win.T + line,
+ win.R - 1, win.T + line, ui.style[ERR_STYLE], text)
+ }
+ }
+ 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,
win.T + line, ui.style[DEF_STYLE], text)
+ if line += 2; win.T + line >= win.B { return }
+ i_draw_text_box(ui, win.T + line, win, "Host/IP",
+ in.Jump.Host, 6, ui.insert_sel)
// TODO: here
}
diff --git a/src/i_ui.go b/src/i_ui.go
index f52a3bc..31cc6bb 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/i_ui.go
- * Tue Feb 27 14:31:52 2024
+ * Fri Mar 01 15:27:17 2024
* Joe
*
* interfacing with the user
@@ -372,7 +372,7 @@ func i_prompt_type(ui HardUI) {
ui.s.ShowCursor(len(text), ui.dim[H] - 1)
}
-func i_prompt_generic(ui HardUI, prompt string, secret bool) {
+func i_prompt_generic(ui HardUI, prompt string, secret, file bool) {
i_draw_text(ui.s,
1, ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
ui.style[DEF_STYLE], prompt)
@@ -643,16 +643,16 @@ func i_ui(data_dir string) {
switch data.ui.insert_sel {
case 0:
i_prompt_type(data.ui)
- case 1:
- i_prompt_generic(data.ui, "Host/IP: ", false)
+ case 1, 6:
+ i_prompt_generic(data.ui, "Host/IP: ", false, false)
case 2:
- i_prompt_generic(data.ui, "Port: ", false)
+ i_prompt_generic(data.ui, "Port: ", false, false)
case 3:
- i_prompt_generic(data.ui, "User: ", false)
+ i_prompt_generic(data.ui, "User: ", false, false)
case 4:
- i_prompt_generic(data.ui, "Pass: ", true)
+ i_prompt_generic(data.ui, "Pass: ", true, false)
case 5:
- i_prompt_generic(data.ui, "Private key: ", false)
+ i_prompt_generic(data.ui, "Private key: ", false, true)
}
}
}