aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/c_defs.go2
-rw-r--r--src/i_events.go10
-rw-r--r--src/i_insert.go61
-rw-r--r--src/i_ui.go5
4 files changed, 53 insertions, 25 deletions
diff --git a/src/c_defs.go b/src/c_defs.go
index 4d185b5..2781c53 100644
--- a/src/c_defs.go
+++ b/src/c_defs.go
@@ -120,6 +120,7 @@ const (
INS_SSH_JUMP_USER
INS_SSH_JUMP_PASS
INS_SSH_JUMP_PRIV
+ INS_SSH_NOTE
INS_SSH_OK
INS_RDP_HOST
INS_RDP_PORT
@@ -131,6 +132,7 @@ const (
INS_RDP_DYNAMIC
INS_RDP_QUALITY
INS_RDP_DRIVE
+ INS_RDP_NOTE
// TODO: here
INS_RDP_OK
)
diff --git a/src/i_events.go b/src/i_events.go
index de59296..b0d0fda 100644
--- a/src/i_events.go
+++ b/src/i_events.go
@@ -642,6 +642,9 @@ func i_events(data *HardData) {
break
case INS_RDP_QUALITY: break
case INS_RDP_DRIVE + len(data.insert.Drive): break
+ case INS_SSH_NOTE,
+ INS_RDP_NOTE + len(data.insert.Drive):
+ ui.buff = data.insert.Note
case INS_SSH_OK,
INS_RDP_OK + len(data.insert.Drive):
data.ui.insert_sel_ok = false
@@ -775,12 +778,14 @@ func i_events(data *HardData) {
INS_SSH_JUMP_USER,
INS_SSH_JUMP_PASS,
INS_SSH_JUMP_PRIV,
+ INS_SSH_NOTE,
INS_RDP_HOST,
INS_RDP_PORT,
INS_RDP_DOMAIN,
INS_RDP_USER,
INS_RDP_PASS,
- INS_RDP_FILE:
+ INS_RDP_FILE,
+ INS_RDP_NOTE + len(data.insert.Drive):
if event.Key() == tcell.KeyEnter {
switch data.ui.insert_sel {
case INS_SSH_HOST,
@@ -819,6 +824,9 @@ func i_events(data *HardData) {
data.insert.Domain = ui.buff
case INS_RDP_FILE:
data.insert.RDPFile = ui.buff
+ case INS_SSH_NOTE,
+ INS_RDP_NOTE + len(data.insert.Drive):
+ data.insert.Note = ui.buff
}
data.ui.insert_sel_ok = false
ui.buff = ""
diff --git a/src/i_insert.go b/src/i_insert.go
index e64a623..80f4236 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/i_insert.go
- * Thu Apr 11 17:52:13 2024
+ * Tue Apr 16 15:42:45 2024
* Joe
*
* insert a new host
@@ -272,7 +272,8 @@ func i_draw_tick_box(ui HardUI, line int, dim Quad, label string, content bool,
}
func i_draw_text_box(ui HardUI, line int, dim Quad, label, content string,
- id, selected int, red bool) {
+ id int, red bool) {
+ selected := ui.insert_sel
const tbox_size int = 14
tbox_style := ui.style[DEF_STYLE].Background(tcell.ColorBlack).Dim(true)
@@ -341,7 +342,7 @@ func i_draw_insert_panel(ui HardUI, in *HostNode) {
line := 2
if win.T + line >= win.B { return }
i_draw_text_box(ui, win.T + line, win, "Connection type",
- PROTOCOL_STR[in.Protocol], 0, ui.insert_sel, false)
+ PROTOCOL_STR[in.Protocol], 0, false)
line += 2
var end_line int
fp := [PROTOCOL_MAX + 1]draw_insert_func{
@@ -365,16 +366,16 @@ func i_draw_insert_ssh(ui HardUI, line int, win Quad, in *HostNode) int {
win.T + line, ui.style[DEF_STYLE], text)
if line += 2; win.T + line >= win.B { return line }
i_draw_text_box(ui, win.T + line, win, "Host/IP", in.Host,
- INS_SSH_HOST, ui.insert_sel, false)
+ INS_SSH_HOST, false)
if line += 1; win.T + line >= win.B { return line }
i_draw_text_box(ui, win.T + line, win, "Port", strconv.Itoa(int(in.Port)),
- INS_SSH_PORT, ui.insert_sel, false);
+ INS_SSH_PORT, false);
if line += 2; win.T + line >= win.B { return line }
i_draw_text_box(ui, win.T + line, win, "User", in.User,
- INS_SSH_USER, ui.insert_sel, false)
+ INS_SSH_USER, false)
if line += 1; win.T + line >= win.B { return line }
i_draw_text_box(ui, win.T + line, win, "Pass", in.Pass,
- INS_SSH_PASS, ui.insert_sel, false)
+ INS_SSH_PASS, false)
if line += 1; win.T + line >= win.B { return line }
if file := in.Priv; len(file) > 0 {
if file[0] == '~' {
@@ -387,7 +388,7 @@ func i_draw_insert_ssh(ui HardUI, line int, win Quad, in *HostNode) int {
}
}
i_draw_text_box(ui, win.T + line, win, "SSH private key", in.Priv,
- INS_SSH_PRIV, ui.insert_sel, red)
+ INS_SSH_PRIV, red)
if red == true {
if line += 1; win.T + line >= win.B { return line }
text := "file does not exist"
@@ -401,17 +402,17 @@ func i_draw_insert_ssh(ui HardUI, line int, win Quad, in *HostNode) int {
win.T + line, ui.style[DEF_STYLE], text)
if line += 2; win.T + line >= win.B { return line }
i_draw_text_box(ui, win.T + line, win, "Host/IP", in.Jump.Host,
- INS_SSH_JUMP_HOST, ui.insert_sel, false)
+ INS_SSH_JUMP_HOST, false)
if line += 1; win.T + line >= win.B { return line }
i_draw_text_box(ui, win.T + line, win, "Port",
strconv.Itoa(int(in.Jump.Port)),
- INS_SSH_JUMP_PORT, ui.insert_sel, false)
+ INS_SSH_JUMP_PORT, false)
if line += 2; win.T + line >= win.B { return line }
i_draw_text_box(ui, win.T + line, win, "User", in.Jump.User,
- INS_SSH_JUMP_USER, ui.insert_sel, false)
+ INS_SSH_JUMP_USER, false)
if line += 1; win.T + line >= win.B { return line }
i_draw_text_box(ui, win.T + line, win, "Pass", in.Jump.Pass,
- INS_SSH_JUMP_PASS, ui.insert_sel, false)
+ INS_SSH_JUMP_PASS, false)
if line += 1; win.T + line >= win.B { return line}
if len(in.Jump.Priv) > 0 {
file := in.Jump.Priv
@@ -425,7 +426,7 @@ func i_draw_insert_ssh(ui HardUI, line int, win Quad, in *HostNode) int {
}
}
i_draw_text_box(ui, win.T + line, win, "SSH private key", in.Jump.Priv,
- INS_SSH_JUMP_PRIV, ui.insert_sel, red)
+ INS_SSH_JUMP_PRIV, red)
if red == true {
if line += 1; win.T + line >= win.B { return line }
text := "file does not exist"
@@ -433,6 +434,13 @@ func i_draw_insert_ssh(ui HardUI, line int, win Quad, in *HostNode) int {
win.R - 1, win.T + line, ui.style[ERR_STYLE], text)
}
if line += 2; win.T + line >= win.B { return line }
+ text = "---- Note ----"
+ 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 line }
+ i_draw_text_box(ui, win.T + line, win, "Note", in.Note,
+ INS_SSH_NOTE, false)
+ if line += 2; win.T + line >= win.B { return line }
i_draw_ok_butt(ui, win.T + line, INS_SSH_OK, ui.insert_sel)
return line
}
@@ -445,19 +453,19 @@ func i_draw_insert_rdp(ui HardUI, line int, win Quad, in *HostNode) int {
win.T + line, ui.style[DEF_STYLE], text)
if line += 2; win.T + line >= win.B { return line }
i_draw_text_box(ui, win.T + line, win, "Host/IP", in.Host,
- INS_RDP_HOST, ui.insert_sel, false)
+ INS_RDP_HOST, false)
if line += 1; win.T + line >= win.B { return line }
i_draw_text_box(ui, win.T + line, win, "Port", strconv.Itoa(int(in.Port)),
- INS_RDP_PORT, ui.insert_sel, false);
+ INS_RDP_PORT, false);
if line += 1; win.T + line >= win.B { return line }
i_draw_text_box(ui, win.T + line, win, "Domain", in.Domain,
- INS_RDP_DOMAIN, ui.insert_sel, false);
+ INS_RDP_DOMAIN, false);
if line += 2; win.T + line >= win.B { return line }
i_draw_text_box(ui, win.T + line, win, "User", in.User,
- INS_RDP_USER, ui.insert_sel, false)
+ INS_RDP_USER, false)
if line += 1; win.T + line >= win.B { return line }
i_draw_text_box(ui, win.T + line, win, "Pass", in.Pass,
- INS_RDP_PASS, ui.insert_sel, false)
+ INS_RDP_PASS, false)
if line += 2; win.T + line >= win.B { return line }
text = "---- RDP File ----"
i_draw_text(ui.s, ui.dim[W] / 2 - len(text) / 2, win.T + line, win.R - 1,
@@ -474,7 +482,7 @@ func i_draw_insert_rdp(ui HardUI, line int, win Quad, in *HostNode) int {
}
}
i_draw_text_box(ui, win.T + line, win, "RDP file", in.RDPFile,
- INS_RDP_FILE, ui.insert_sel, red)
+ INS_RDP_FILE, red)
if red == true {
if line += 1; win.T + line >= win.B { return line }
text := "file does not exist"
@@ -490,13 +498,13 @@ func i_draw_insert_rdp(ui HardUI, line int, win Quad, in *HostNode) int {
screensize := strconv.Itoa(int(in.Width)) + "x" +
strconv.Itoa(int(in.Height))
i_draw_text_box(ui, win.T + line, win, "Window size", screensize,
- INS_RDP_SCREENSIZE, ui.insert_sel, red)
+ INS_RDP_SCREENSIZE, red)
if line += 1; win.T + line >= win.B { return line }
i_draw_tick_box(ui, win.T + line, win, "Dynamic window", in.Dynamic,
INS_RDP_DYNAMIC, ui.insert_sel)
if line += 1; win.T + line >= win.B { return line }
i_draw_text_box(ui, win.T + line, win, "Quality", RDP_QUALITY[in.Quality],
- INS_RDP_QUALITY, ui.insert_sel, red)
+ INS_RDP_QUALITY, red)
if line += 2; win.T + line >= win.B { return line }
text = "---- Share mounts ----"
i_draw_text(ui.s, ui.dim[W] / 2 - len(text) / 2, win.T + line, win.R - 1,
@@ -516,7 +524,7 @@ func i_draw_insert_rdp(ui HardUI, line int, win Quad, in *HostNode) int {
}
i_draw_text_box(ui, win.T + line, win, "Share " + strconv.Itoa(k + 1),
"(" + v + "): " + in.Drive[v],
- INS_RDP_DRIVE + k, ui.insert_sel, red)
+ INS_RDP_DRIVE + k, red)
if red == true {
if line += 1; win.T + line >= win.B { return line }
text := "path is not a directory"
@@ -526,7 +534,14 @@ func i_draw_insert_rdp(ui HardUI, line int, win Quad, in *HostNode) int {
if line += 1; win.T + line >= win.B { return line }
}
i_draw_text_box(ui, win.T + line, win, "Add share", "",
- INS_RDP_DRIVE + len(in.Drive), ui.insert_sel, false)
+ INS_RDP_DRIVE + len(in.Drive), false)
+ if line += 2; win.T + line >= win.B { return line }
+ text = "---- Note ----"
+ 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 line }
+ i_draw_text_box(ui, win.T + line, win, "Note", in.Note,
+ INS_RDP_NOTE + len(in.Drive), false)
if line += 2; win.T + line >= win.B { return line }
i_draw_ok_butt(ui, win.T + line, INS_RDP_OK + len(in.Drive), ui.insert_sel)
return line
diff --git a/src/i_ui.go b/src/i_ui.go
index d6b8f46..7544316 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/i_ui.go
- * Fri Apr 12 13:53:42 2024
+ * Tue Apr 16 15:42:37 2024
* Joe
*
* interfacing with the user
@@ -738,6 +738,9 @@ func i_ui(data_dir string) {
INS_SSH_JUMP_PRIV:
i_prompt_generic(data.ui, "Private key: ",
false, home_dir)
+ case INS_SSH_NOTE,
+ INS_RDP_NOTE + len(data.insert.Drive):
+ i_prompt_generic(data.ui, "Note: ", false, "")
case INS_RDP_DOMAIN:
i_prompt_generic(data.ui, "Domain: ", false, "")
case INS_RDP_FILE: