aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-04-12 20:20:20 +0200
committerJoe <rbo@gmx.us>2024-04-12 20:20:20 +0200
commitbca4186e5550006f99ba38017840e660aa4016b1 (patch)
tree96c982168cabae474aef68e7b5d1aa62491abf7b /src
parentcool (diff)
downloadhardflip-bca4186e5550006f99ba38017840e660aa4016b1.tar.gz
hardflip-bca4186e5550006f99ba38017840e660aa4016b1.tar.bz2
hardflip-bca4186e5550006f99ba38017840e660aa4016b1.tar.xz
hardflip-bca4186e5550006f99ba38017840e660aa4016b1.tar.zst
hardflip-bca4186e5550006f99ba38017840e660aa4016b1.zip
commit
Diffstat (limited to 'src')
-rw-r--r--src/c_defs.go7
-rw-r--r--src/c_lhosts.go9
-rw-r--r--src/c_utils.go2
-rw-r--r--src/i_events.go7
-rw-r--r--src/i_info.go3
-rw-r--r--src/i_insert.go7
-rw-r--r--src/i_ui.go38
7 files changed, 45 insertions, 28 deletions
diff --git a/src/c_defs.go b/src/c_defs.go
index d899720..f0126da 100644
--- a/src/c_defs.go
+++ b/src/c_defs.go
@@ -135,6 +135,13 @@ const (
var (
HOST_ICONS = [4]string{" ", " ", " ", "󰅟 "}
DIRS_ICONS = [2]string{" ", " "}
+ RDP_QUALITY = [3]string{"Low", "Medium", "High"}
+ PROTOCOL_STR = [PROTOCOL_MAX + 1]string{
+ "SSH",
+ "RDP",
+ "Single command",
+ "OpenStack CLI",
+ }
)
var DEFAULT_OPTS = HardOpts{
diff --git a/src/c_lhosts.go b/src/c_lhosts.go
index 6e69a79..877135c 100644
--- a/src/c_lhosts.go
+++ b/src/c_lhosts.go
@@ -160,11 +160,8 @@ func (lhost *HostList) count() int {
}
func (host *HostNode) protocol_str() string {
- switch host.Protocol {
- case PROTOCOL_SSH: return "SSH"
- case PROTOCOL_RDP: return "RDP"
- case PROTOCOL_CMD: return "Single command"
- case PROTOCOL_OS: return "OpenStack CLI"
- default: return ""
+ if host.Protocol > PROTOCOL_MAX {
+ return ""
}
+ return PROTOCOL_STR[host.Protocol]
}
diff --git a/src/c_utils.go b/src/c_utils.go
index 8ee2fe1..2aa3fec 100644
--- a/src/c_utils.go
+++ b/src/c_utils.go
@@ -175,7 +175,7 @@ func c_decrypt_str(str string) (string, error) {
return string(out), err
}
-func c_get_secret_gpg_keyring(ui *HardUI) [][2]string {
+func c_get_secret_gpg_keyring() [][2]string {
var keys [][2]string
var sed_out bytes.Buffer
gpg_fmt := []string{
diff --git a/src/i_events.go b/src/i_events.go
index de92428..35f7a4c 100644
--- a/src/i_events.go
+++ b/src/i_events.go
@@ -621,6 +621,7 @@ func i_events(data *HardData) {
case INS_SSH_JUMP_PRIV: ui.buff = data.insert.Jump.Priv
case INS_RDP_DOMAIN: ui.buff = data.insert.Domain
case INS_RDP_FILE: ui.buff = data.insert.RDPFile
+ case INS_RDP_QUALITY: break
case INS_SSH_OK,
INS_RDP_OK:
data.ui.insert_sel_ok = false
@@ -672,7 +673,8 @@ func i_events(data *HardData) {
INS_RDP_DOMAIN,
INS_RDP_USER,
INS_RDP_PASS,
- INS_RDP_FILE:
+ INS_RDP_FILE,
+ INS_RDP_QUALITY:
if event.Key() == tcell.KeyEnter {
switch data.ui.insert_sel {
case INS_SSH_HOST,
@@ -711,6 +713,9 @@ func i_events(data *HardData) {
data.insert.Domain = ui.buff
case INS_RDP_FILE:
data.insert.RDPFile = ui.buff
+ case INS_RDP_QUALITY:
+ tmp, _ := strconv.Atoi(ui.buff)
+ data.insert.Quality = uint8(tmp)
}
data.ui.insert_sel_ok = false
ui.buff = ""
diff --git a/src/i_info.go b/src/i_info.go
index f36a998..7efd683 100644
--- a/src/i_info.go
+++ b/src/i_info.go
@@ -255,7 +255,6 @@ func i_info_rdp(ui HardUI, host *HostNode, line int) int {
}
if line += 1; line > ui.dim[H] - 3 { return line }
// rdp shit
- qual := [3]string{"Low", "Medium", "High"}
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
ui.style[TITLE_STYLE], "Screen size: ")
@@ -277,7 +276,7 @@ func i_info_rdp(ui HardUI, host *HostNode, line int) int {
ui.style[TITLE_STYLE], "Quality: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 12, line, ui.dim[W] - 2, line,
- ui.style[DEF_STYLE], qual[host.Quality])
+ ui.style[DEF_STYLE], RDP_QUALITY[host.Quality])
if line += 2; line > ui.dim[H] - 3 { return line }
if host.Drive != nil {
i_draw_text(ui.s,
diff --git a/src/i_insert.go b/src/i_insert.go
index dac18a6..0e08f6c 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -358,6 +358,13 @@ func i_draw_insert_rdp(ui HardUI, line int, win Quad, in *HostNode) int {
}
red = false
if line += 2; win.T + line >= win.B { return line }
+ text = "---- Window 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 line }
+ i_draw_text_box(ui, win.T + line, win, "Quality", RDP_QUALITY[in.Quality],
+ INS_RDP_QUALITY, ui.insert_sel, red)
+ if line += 2; win.T + line >= win.B { return line }
i_draw_ok_butt(ui, win.T + line, INS_RDP_OK, ui.insert_sel)
return line
}
diff --git a/src/i_ui.go b/src/i_ui.go
index 9c9c229..f8cb2aa 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/i_ui.go
- * Wed Mar 27 15:48:56 2024
+ * Fri Apr 12 13:53:42 2024
* Joe
*
* interfacing with the user
@@ -358,21 +358,19 @@ func i_prompt_mkdir(ui HardUI, curr *ItemsNode) {
ui.s.ShowCursor(len(prompt) + 1 + len(path) + len(ui.buff), ui.dim[H] - 1)
}
-func i_prompt_type(ui HardUI) {
- i_draw_msg(ui.s, 4, ui.style[BOX_STYLE], ui.dim, " Connection type ")
- i_draw_text(ui.s, 2, ui.dim[H] - 6, ui.dim[W] - 2, ui.dim[H] - 6,
- ui.style[DEF_STYLE], "[1] SSH")
- i_draw_text(ui.s, 2, ui.dim[H] - 5, ui.dim[W] - 2, ui.dim[H] - 5,
- ui.style[DEF_STYLE], "[2] RDP")
- i_draw_text(ui.s, 2, ui.dim[H] - 4, ui.dim[W] - 2, ui.dim[H] - 4,
- ui.style[DEF_STYLE], "[3] Single command")
- i_draw_text(ui.s, 2, ui.dim[H] - 3, ui.dim[W] - 2, ui.dim[H] - 3,
- ui.style[DEF_STYLE], "[4] OpenStack CLI")
- text := "Type: "
- i_draw_text(ui.s, 0,
- ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
- ui.style[DEF_STYLE], text)
- ui.s.ShowCursor(len(text), ui.dim[H] - 1)
+func i_prompt_list(ui HardUI, name, prompt string, list []string) {
+ i := len(list)
+ i_draw_msg(ui.s, i, ui.style[BOX_STYLE], ui.dim, " " + name + " ")
+ for k, v := range list {
+ i_draw_text(ui.s, 2, ui.dim[H] - 2 - i,
+ ui.dim[W] - 2, ui.dim[H] - 2 - i,
+ ui.style[DEF_STYLE], "[" + strconv.Itoa(k + 1) + "] " + v)
+ i -= 1
+ }
+ i_draw_text(ui.s, 1,
+ ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
+ ui.style[DEF_STYLE], prompt)
+ ui.s.ShowCursor(len(prompt) + 2, ui.dim[H] - 1)
}
func i_prompt_generic(ui HardUI, prompt string, secret bool, home_dir string) {
@@ -647,7 +645,7 @@ func i_ui(data_dir string) {
}
if data.opts.GPG == DEFAULT_OPTS.GPG && data.litems.head == nil {
data.ui.mode = WELCOME_MODE
- data.keys = c_get_secret_gpg_keyring(&data.ui)
+ data.keys = c_get_secret_gpg_keyring()
}
for {
data.ui.s.Clear()
@@ -682,7 +680,8 @@ func i_ui(data_dir string) {
if data.ui.insert_sel_ok == true {
switch data.ui.insert_sel {
case INS_PROTOCOL:
- i_prompt_type(data.ui)
+ i_prompt_list(data.ui, "Connection type", "Type:",
+ PROTOCOL_STR[:])
case INS_SSH_HOST,
INS_SSH_JUMP_HOST,
INS_RDP_HOST:
@@ -707,6 +706,9 @@ func i_ui(data_dir string) {
i_prompt_generic(data.ui, "Domain: ", false, "")
case INS_RDP_FILE:
i_prompt_generic(data.ui, "RDP file: ", false, home_dir)
+ case INS_RDP_QUALITY:
+ i_prompt_list(data.ui, "hey", "Quality:",
+ RDP_QUALITY[:])
}
} else if data.insert_err != nil {
i_draw_insert_err_msg(data.ui, data.insert_err)