aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/c_defs.go3
-rw-r--r--src/i_events.go35
-rw-r--r--src/i_insert.go23
-rw-r--r--src/i_ui.go3
4 files changed, 61 insertions, 3 deletions
diff --git a/src/c_defs.go b/src/c_defs.go
index 241ff0c..12ccc90 100644
--- a/src/c_defs.go
+++ b/src/c_defs.go
@@ -128,8 +128,9 @@ const (
INS_RDP_PASS
INS_RDP_FILE
INS_RDP_SCREENSIZE
- // TODO: here (dynamic)
+ INS_RDP_DYNAMIC
INS_RDP_QUALITY
+ // TODO: here
INS_RDP_OK
)
diff --git a/src/i_events.go b/src/i_events.go
index 63463bf..6468588 100644
--- a/src/i_events.go
+++ b/src/i_events.go
@@ -54,6 +54,7 @@ package main
import (
"os"
"strconv"
+ "strings"
"github.com/gdamore/tcell/v2"
"golang.org/x/term"
@@ -593,6 +594,16 @@ func i_events(data *HardData) {
} else if event.Rune() == 'i' ||
event.Rune() == 'a' ||
event.Key() == tcell.KeyEnter {
+ if data.ui.insert_sel == INS_RDP_DYNAMIC {
+ if data.insert.Dynamic == true {
+ data.insert.Dynamic = false
+ } else {
+ data.insert.Dynamic = true
+ }
+ ui.buff = ""
+ ui.s.HideCursor()
+ break
+ }
data.ui.insert_sel_ok = true
switch data.ui.insert_sel {
case INS_SSH_HOST,
@@ -621,6 +632,8 @@ 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_SCREENSIZE: break
+ case INS_RDP_DYNAMIC: break
case INS_RDP_QUALITY: break
case INS_SSH_OK,
INS_RDP_OK:
@@ -658,6 +671,26 @@ func i_events(data *HardData) {
ui.s.HideCursor()
i_set_protocol_defaults(data, data.insert)
}
+ case INS_RDP_SCREENSIZE:
+ if event.Rune() < '1' || event.Rune() > '7' {
+ data.ui.insert_sel_ok = false
+ ui.buff = ""
+ ui.s.HideCursor()
+ break
+ } else {
+ s := strings.Split(
+ RDP_SCREENSIZE[uint8(event.Rune() - 48 - 1)],
+ "x")
+ if len(s) != 2 {
+ return
+ }
+ tmp, _ := strconv.Atoi(s[W])
+ data.insert.Width = uint16(tmp)
+ tmp, _ = strconv.Atoi(s[H])
+ data.insert.Height = uint16(tmp)
+ data.ui.insert_sel_ok = false
+ ui.s.HideCursor()
+ }
case INS_RDP_QUALITY:
if event.Rune() < '1' || event.Rune() > '3' {
data.ui.insert_sel_ok = false
@@ -669,8 +702,6 @@ func i_events(data *HardData) {
data.ui.insert_sel_ok = false
ui.s.HideCursor()
}
- // tmp, _ := strconv.Atoi(ui.buff)
- // data.insert.Quality = uint8(tmp)
case INS_SSH_HOST,
INS_SSH_PORT,
INS_SSH_USER,
diff --git a/src/i_insert.go b/src/i_insert.go
index 907f041..f51cffd 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -218,6 +218,26 @@ func i_insert_check_ok(data *HardData, in *HostNode) {
}
}
+func i_draw_tick_box(ui HardUI, line int, dim Quad, label string, content bool,
+ id, selected int, red bool) {
+ tbox_style := ui.style[DEF_STYLE].Background(tcell.ColorBlack).Dim(true)
+
+ if id == selected {
+ tbox_style = tbox_style.Reverse(true).Dim(false)
+ }
+ l := ui.dim[W] / 2 - len(label) - 2
+ 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)
+ x := " "
+ if content == true {
+ x = "x"
+ }
+ i_draw_text(ui.s, ui.dim[W] / 2, line, dim.R, line,
+ tbox_style,
+ "[" + x + "]")
+}
+
func i_draw_text_box(ui HardUI, line int, dim Quad, label, content string,
id, selected int, red bool) {
const tbox_size int = 14
@@ -367,6 +387,9 @@ func i_draw_insert_rdp(ui HardUI, line int, win Quad, in *HostNode) int {
i_draw_text_box(ui, win.T + line, win, "Window size", screensize,
INS_RDP_SCREENSIZE, ui.insert_sel, 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, red)
+ 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)
if line += 2; win.T + line >= win.B { return line }
diff --git a/src/i_ui.go b/src/i_ui.go
index 251e3ff..c8b9a3d 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -706,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_SCREENSIZE:
+ i_prompt_list(data.ui, "Window size", "Size:",
+ RDP_SCREENSIZE[:])
case INS_RDP_QUALITY:
i_prompt_list(data.ui, "Quality", "Quality:",
RDP_QUALITY[:])