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
commit721d2697f777c5d8050f37f735a9b74eb69555b8 (patch)
tree041dafee9751de4ef98c33bc723347afcc697aaf /src
parentfuckye (diff)
downloadhardflip-721d2697f777c5d8050f37f735a9b74eb69555b8.tar.gz
hardflip-721d2697f777c5d8050f37f735a9b74eb69555b8.tar.bz2
hardflip-721d2697f777c5d8050f37f735a9b74eb69555b8.tar.xz
hardflip-721d2697f777c5d8050f37f735a9b74eb69555b8.tar.zst
hardflip-721d2697f777c5d8050f37f735a9b74eb69555b8.zip
commit
Diffstat (limited to 'src')
-rw-r--r--src/c_defs.go14
-rw-r--r--src/c_exec.go8
-rw-r--r--src/c_ldirs.go2
-rw-r--r--src/c_litems.go12
-rw-r--r--src/c_utils.go3
-rw-r--r--src/i_events.go42
-rw-r--r--src/i_host.go6
-rw-r--r--src/i_info.go154
-rw-r--r--src/i_insert.go32
-rw-r--r--src/i_ui.go155
10 files changed, 238 insertions, 190 deletions
diff --git a/src/c_defs.go b/src/c_defs.go
index 1385a4c..cc4c264 100644
--- a/src/c_defs.go
+++ b/src/c_defs.go
@@ -85,13 +85,13 @@ const (
H = 1
ERROR_MSG = 0
ERROR_ERR = 1
- STYLE_DEF = 0
- STYLE_DIR = 1
- STYLE_BOX = 2
- STYLE_HEAD = 3
- STYLE_ERR = 4
- STYLE_TITLE = 5
- STYLE_BOT = 6
+ DEF_STYLE = 0
+ DIR_STYLE = 1
+ BOX_STYLE = 2
+ HEAD_STYLE = 3
+ ERR_STYLE = 4
+ TITLE_STYLE = 5
+ BOT_STYLE = 6
)
const (
diff --git a/src/c_exec.go b/src/c_exec.go
index 69bff7c..9e96188 100644
--- a/src/c_exec.go
+++ b/src/c_exec.go
@@ -195,11 +195,11 @@ func c_format_cmd(host *HostNode, opts HardOpts,
return nil, nil
}
if len(gpg) > 0 && gpg != "plain" && len(host.Pass) > 0 {
- i_draw_msg(ui.s, 1, ui.style[STYLE_BOX], ui.dim, " GnuPG ")
+ i_draw_msg(ui.s, 1, ui.style[BOX_STYLE], ui.dim, " GnuPG ")
text := "decryption using gpg..."
left, right := i_left_right(len(text), ui)
i_draw_text(ui.s, left, ui.dim[H] - 3, right, ui.dim[H] - 3,
- ui.style[STYLE_DEF], text)
+ ui.style[DEF_STYLE], text)
ui.s.Show()
var err error
pass, err = c_decrypt_str(host.Pass)
@@ -245,11 +245,11 @@ func c_exec(host *HostNode, opts HardOpts, ui *HardUI) {
return
}
} else {
- i_draw_msg(ui.s, 1, ui.style[STYLE_BOX], ui.dim, " Exec ")
+ i_draw_msg(ui.s, 1, ui.style[BOX_STYLE], ui.dim, " Exec ")
text := "running command..."
left, right := i_left_right(len(text), ui)
i_draw_text(ui.s, left, ui.dim[H] - 3, right, ui.dim[H] - 3,
- ui.style[STYLE_DEF], text)
+ ui.style[DEF_STYLE], text)
ui.s.Show()
}
if err, err_str := c_exec_cmd(cmd_fmt, cmd_env, silent);
diff --git a/src/c_ldirs.go b/src/c_ldirs.go
index b2978f3..ce9c424 100644
--- a/src/c_ldirs.go
+++ b/src/c_ldirs.go
@@ -112,7 +112,7 @@ func (dir *DirsNode) path() string {
var path string
if dir == nil {
- return ""
+ return "/"
}
curr := dir
for curr != nil {
diff --git a/src/c_litems.go b/src/c_litems.go
index 229df41..67240c3 100644
--- a/src/c_litems.go
+++ b/src/c_litems.go
@@ -219,3 +219,15 @@ func (litems *ItemsList) reset_id() {
ptr.next.ID = ptr.ID + 1
}
}
+
+func (item *ItemsNode) path_node() *DirsNode {
+ if item.is_dir() == true {
+ return item.Dirs
+ } else {
+ return item.Host.Parent
+ }
+}
+
+func (item *ItemsNode) path() string {
+ return item.path_node().path()
+}
diff --git a/src/c_utils.go b/src/c_utils.go
index 667ecbc..8ee2fe1 100644
--- a/src/c_utils.go
+++ b/src/c_utils.go
@@ -158,6 +158,9 @@ func c_error_mode(msg string, err error, ui *HardUI) {
// c_encrypt_str encrypts a string with the given gpgkey
func c_encrypt_str(str string, gpg string) (string, error) {
+ if len(gpg) == 0 || gpg == "plain" {
+ return str, nil
+ }
cmd := exec.Command("gpg", "-r", gpg, "-a", "-e")
cmd.Stdin = strings.NewReader(str)
out, err := cmd.Output()
diff --git a/src/i_events.go b/src/i_events.go
index 2899d7c..6143f8c 100644
--- a/src/i_events.go
+++ b/src/i_events.go
@@ -297,11 +297,7 @@ func i_mkdir(data *HardData, ui *HardUI) {
}
path := "/"
if data.litems.curr != nil {
- if data.litems.curr.is_dir() == true {
- path = data.litems.curr.Dirs.path()
- } else {
- path = data.litems.curr.Host.Parent.path()
- }
+ path = data.litems.curr.path()
}
if err := os.MkdirAll(data.data_dir +
path +
@@ -321,18 +317,21 @@ func i_mkdir(data *HardData, ui *HardUI) {
}
}
-func i_set_protocol_defaults(in *HostNode) {
+func i_set_protocol_defaults(data *HardData, in *HostNode) {
switch in.Protocol {
case 0:
in.Port = 22
+ data.ui.insert_sel_max = 5
case 1:
in.Port = 3389
in.Quality = 2
in.Width = 1600
in.Height = 1200
in.Dynamic = true
+ data.ui.insert_sel_max = 4
case 2:
in.Shell = []string{"/bin/sh", "-c"}
+ data.ui.insert_sel_max = 2
case 3:
in.Stack.RegionName = "eu-west-0"
in.Stack.IdentityAPI = "3"
@@ -341,6 +340,7 @@ func i_set_protocol_defaults(in *HostNode) {
in.Stack.VolumeAPI = "3.42"
in.Stack.EndpointType = "publicURL"
in.Stack.Interface = "public"
+ data.ui.insert_sel_max = 2
}
}
@@ -469,7 +469,6 @@ func i_events(data *HardData) {
event.Rune() == 'i' {
data.ui.mode = INSERT_MODE
data.ui.insert_sel = 0
- data.ui.insert_sel_max = 4
data.ui.insert_sel_ok = false
} else if event.Key() == tcell.KeyCtrlR {
event = nil
@@ -539,16 +538,20 @@ func i_events(data *HardData) {
}
ui.s.HideCursor()
data.insert = &HostNode{}
- i_set_protocol_defaults(data.insert)
+ i_set_protocol_defaults(data, data.insert)
data.insert.Name = ui.buff
ui.buff = ""
+ if data.litems.curr != nil {
+ data.insert.Parent = data.litems.curr.path_node()
+ }
} else {
i_readline(event, data)
}
} else if data.insert != nil {
if data.ui.insert_sel_ok == false {
if event.Key() == tcell.KeyEscape ||
- event.Key() == tcell.KeyCtrlC {
+ event.Key() == tcell.KeyCtrlC ||
+ event.Rune() == 'q' {
ui.s.HideCursor()
data.ui.mode = NORMAL_MODE
data.ui.insert_sel = 0
@@ -583,20 +586,37 @@ func i_events(data *HardData) {
switch data.ui.insert_sel {
case 0:
if event.Rune() < '1' || event.Rune() > '4' {
+ data.ui.insert_sel_ok = false
+ ui.buff = ""
+ ui.s.HideCursor()
break
} else {
+ name := data.insert.Name
+ parent := data.insert.Parent
+ data.insert = nil
+ data.insert = &HostNode{}
+ data.insert.Name = name
+ data.insert.Parent = parent
data.insert.Protocol = int8(event.Rune() - 48 - 1)
data.ui.insert_sel_ok = false
ui.s.HideCursor()
- i_set_protocol_defaults(data.insert)
+ i_set_protocol_defaults(data, data.insert)
}
- case 1, 2:
+ case 1, 2, 3, 4:
if event.Key() == tcell.KeyEnter {
if data.ui.insert_sel == 1 {
data.insert.Host = ui.buff
} else if data.ui.insert_sel == 2 {
tmp, _ := strconv.Atoi(ui.buff)
data.insert.Port = uint16(tmp)
+ } else if data.ui.insert_sel == 3 {
+ data.insert.User = ui.buff
+ } else if data.ui.insert_sel == 4 {
+ pass, _ := c_encrypt_str(ui.buff,
+ data.opts.GPG)
+ data.insert.Pass = pass
+ } else if data.ui.insert_sel == 5 {
+ data.insert.Priv = ui.buff
}
data.ui.insert_sel_ok = false
ui.buff = ""
diff --git a/src/i_host.go b/src/i_host.go
index 9afb352..76334e1 100644
--- a/src/i_host.go
+++ b/src/i_host.go
@@ -53,7 +53,7 @@ package main
func i_host_panel_dirs(ui HardUI, icons bool, dir_icon uint8,
dir *DirsNode, curr *DirsNode, line int) {
- style := ui.style[STYLE_DIR]
+ style := ui.style[DIR_STYLE]
if dir == curr {
// style = style.Background(tcell.ColorBlack)
style = style.Reverse(true)
@@ -78,7 +78,7 @@ func i_host_panel_dirs(ui HardUI, icons bool, dir_icon uint8,
func i_host_panel_host(ui HardUI, icons bool,
depth uint16, host *HostNode, curr *HostNode, line int) {
- style := ui.style[STYLE_DEF]
+ style := ui.style[DEF_STYLE]
if host == curr {
// style = style.Background(tcell.ColorBlack)
style = style.Reverse(true)
@@ -105,7 +105,7 @@ func i_draw_host_panel(ui HardUI, icons bool,
litems *ItemsList, data *HardData) {
i_draw_box(ui.s, 0, 0,
ui.dim[W] / 3, ui.dim[H] - 2,
- ui.style[STYLE_BOX], ui.style[STYLE_HEAD], " Hosts ", false)
+ ui.style[BOX_STYLE], ui.style[HEAD_STYLE], " Hosts ", false)
line := 1
if litems == nil || litems.head == nil {
return
diff --git a/src/i_info.go b/src/i_info.go
index 14eb9b0..f36a998 100644
--- a/src/i_info.go
+++ b/src/i_info.go
@@ -63,24 +63,24 @@ func i_info_dirs(ui HardUI, dir *DirsNode) {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Name: ")
+ ui.style[TITLE_STYLE], "Name: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], dir.Name)
+ ui.style[DEF_STYLE], dir.Name)
if line += 1; line > ui.dim[H] - 3 { return }
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Type: ")
+ ui.style[TITLE_STYLE], "Type: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], "Directory")
+ ui.style[DEF_STYLE], "Directory")
if line += 2; line > ui.dim[H] - 3 { return }
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Path: ")
+ ui.style[TITLE_STYLE], "Path: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], dir.path()[1:])
+ ui.style[DEF_STYLE], dir.path()[1:])
}
func i_info_name_type(ui HardUI, host *HostNode) int {
@@ -90,17 +90,17 @@ func i_info_name_type(ui HardUI, host *HostNode) int {
// name, type
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Name: ")
+ ui.style[TITLE_STYLE], "Name: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.Name)
+ ui.style[DEF_STYLE], host.Name)
if line += 1; line > ui.dim[H] - 3 { return line }
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Type: ")
+ ui.style[TITLE_STYLE], "Type: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host_type)
+ ui.style[DEF_STYLE], host_type)
if line += 2; line > ui.dim[H] - 3 { return line }
return line
}
@@ -110,42 +110,42 @@ func i_info_ssh(ui HardUI, host *HostNode, line int) int {
// host, port
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Host: ")
+ ui.style[TITLE_STYLE], "Host: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.Host)
+ ui.style[DEF_STYLE], host.Host)
if line += 1; line > ui.dim[H] - 3 { return line }
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Port: ")
+ ui.style[TITLE_STYLE], "Port: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], strconv.Itoa(int(host.Port)))
+ ui.style[DEF_STYLE], strconv.Itoa(int(host.Port)))
if line += 2; line > ui.dim[H] - 3 { return line }
// user infos
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "User: ")
+ ui.style[TITLE_STYLE], "User: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.User)
+ ui.style[DEF_STYLE], host.User)
if line += 1; line > ui.dim[H] - 3 { return line }
if len(host.Pass) > 0 {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Pass: ")
+ ui.style[TITLE_STYLE], "Pass: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], "***")
+ ui.style[DEF_STYLE], "***")
if line += 1; line > ui.dim[H] - 3 { return line }
}
if len(host.Priv) > 0 {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Privkey: ")
+ ui.style[TITLE_STYLE], "Privkey: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 12, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.Priv)
+ ui.style[DEF_STYLE], host.Priv)
if line += 1; line > ui.dim[H] - 3 { return line }
}
if line += 1; line > ui.dim[H] - 3 { return line }
@@ -153,45 +153,45 @@ func i_info_ssh(ui HardUI, host *HostNode, line int) int {
if len(host.Jump.Host) > 0 {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Jump settings: ")
+ ui.style[TITLE_STYLE], "Jump settings: ")
if line += 1; line > ui.dim[H] - 3 { return line }
i_draw_text(ui.s,
(ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Host: ")
+ ui.style[TITLE_STYLE], "Host: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.Jump.Host)
+ ui.style[DEF_STYLE], host.Jump.Host)
if line += 1; line > ui.dim[H] - 3 { return line }
i_draw_text(ui.s,
(ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Port: ")
+ ui.style[TITLE_STYLE], "Port: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], strconv.Itoa(int(host.Jump.Port)))
+ ui.style[DEF_STYLE], strconv.Itoa(int(host.Jump.Port)))
if line += 1; line > ui.dim[H] - 3 { return line }
i_draw_text(ui.s,
(ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "User: ")
+ ui.style[TITLE_STYLE], "User: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.Jump.User)
+ ui.style[DEF_STYLE], host.Jump.User)
if line += 1; line > ui.dim[H] - 3 { return line }
if len(host.Jump.Pass) > 0 {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Pass: ")
+ ui.style[TITLE_STYLE], "Pass: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], "***")
+ ui.style[DEF_STYLE], "***")
if line += 1; line > ui.dim[H] - 3 { return line }
}
if len(host.Jump.Priv) > 0 {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Privkey: ")
+ ui.style[TITLE_STYLE], "Privkey: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 13, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.Jump.Priv)
+ ui.style[DEF_STYLE], host.Jump.Priv)
if line += 1; line > ui.dim[H] - 3 { return line }
}
if line += 1; line > ui.dim[H] - 3 { return line }
@@ -204,53 +204,53 @@ func i_info_rdp(ui HardUI, host *HostNode, line int) int {
// host, port
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Host: ")
+ ui.style[TITLE_STYLE], "Host: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.Host)
+ ui.style[DEF_STYLE], host.Host)
if line += 1; line > ui.dim[H] - 3 { return line }
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Port: ")
+ ui.style[TITLE_STYLE], "Port: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], strconv.Itoa(int(host.Port)))
+ ui.style[DEF_STYLE], strconv.Itoa(int(host.Port)))
if line += 1; line > ui.dim[H] - 3 { return line }
// rdp shit
if len(host.Domain) > 0 {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Domain: ")
+ ui.style[TITLE_STYLE], "Domain: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 11, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.Domain)
+ ui.style[DEF_STYLE], host.Domain)
if line += 1; line > ui.dim[H] - 3 { return line }
}
if line += 1; line > ui.dim[H] - 3 { return line }
if len(host.RDPFile) > 0 {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "RDP File: ")
+ ui.style[TITLE_STYLE], "RDP File: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 13, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.RDPFile)
+ ui.style[DEF_STYLE], host.RDPFile)
if line += 2; line > ui.dim[H] - 3 { return line }
}
// user infos
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "User: ")
+ ui.style[TITLE_STYLE], "User: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.User)
+ ui.style[DEF_STYLE], host.User)
if line += 1; line > ui.dim[H] - 3 { return line }
if len(host.Pass) > 0 {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Pass: ")
+ ui.style[TITLE_STYLE], "Pass: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], "***")
+ ui.style[DEF_STYLE], "***")
if line += 1; line > ui.dim[H] - 3 { return line }
}
if line += 1; line > ui.dim[H] - 3 { return line }
@@ -258,40 +258,40 @@ func i_info_rdp(ui HardUI, host *HostNode, line int) int {
qual := [3]string{"Low", "Medium", "High"}
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Screen size: ")
+ ui.style[TITLE_STYLE], "Screen size: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 16, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF],
+ ui.style[DEF_STYLE],
strconv.Itoa(int(host.Width)) + "x" +
strconv.Itoa(int(host.Height)))
if line += 1; line > ui.dim[H] - 3 { return line }
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Dynamic window: ")
+ ui.style[TITLE_STYLE], "Dynamic window: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 19, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], strconv.FormatBool(host.Dynamic))
+ ui.style[DEF_STYLE], strconv.FormatBool(host.Dynamic))
if line += 1; line > ui.dim[H] - 3 { return line }
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Quality: ")
+ ui.style[TITLE_STYLE], "Quality: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 12, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], qual[host.Quality])
+ ui.style[DEF_STYLE], qual[host.Quality])
if line += 2; line > ui.dim[H] - 3 { return line }
if host.Drive != nil {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Drives: ")
+ ui.style[TITLE_STYLE], "Drives: ")
if line += 1; line > ui.dim[H] - 3 { return line }
for share, path := range host.Drive {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 4, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], share + ":")
+ ui.style[TITLE_STYLE], share + ":")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 4 + len(share) + 2, line,
ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], path)
+ ui.style[DEF_STYLE], path)
if line += 1; line > ui.dim[H] - 3 { return line }
}
if line += 1; line > ui.dim[H] - 3 { return line }
@@ -303,28 +303,28 @@ func i_info_cmd(ui HardUI, host *HostNode, line int) int {
if line > ui.dim[H] - 3 { return line }
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Command: ")
+ ui.style[TITLE_STYLE], "Command: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 12, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.Host)
+ ui.style[DEF_STYLE], host.Host)
if line += 2; line > ui.dim[H] - 3 { return line }
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Silent: ")
+ ui.style[TITLE_STYLE], "Silent: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 11, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], strconv.FormatBool(host.Silent))
+ ui.style[DEF_STYLE], strconv.FormatBool(host.Silent))
if line += 1; line > ui.dim[H] - 3 { return line }
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Shell: ")
+ ui.style[TITLE_STYLE], "Shell: ")
str := ""
for _, s := range host.Shell {
str += s + " "
}
i_draw_text(ui.s,
(ui.dim[W] / 3) + 10, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], str)
+ ui.style[DEF_STYLE], str)
if line += 2; line > ui.dim[H] - 3 { return line }
return line
}
@@ -333,47 +333,47 @@ func i_info_openstack(ui HardUI, host *HostNode, line int) int {
if line > ui.dim[H] - 3 { return line }
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Endpoint: ")
+ ui.style[TITLE_STYLE], "Endpoint: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 13, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.Host)
+ ui.style[DEF_STYLE], host.Host)
if line += 2; line > ui.dim[H] - 3 { return line }
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "User domain ID: ")
+ ui.style[TITLE_STYLE], "User domain ID: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 19, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.Stack.UserDomainID)
+ ui.style[DEF_STYLE], host.Stack.UserDomainID)
if line += 1; line > ui.dim[H] - 3 { return line }
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Project ID: ")
+ ui.style[TITLE_STYLE], "Project ID: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 15, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.Stack.ProjectID)
+ ui.style[DEF_STYLE], host.Stack.ProjectID)
if line += 1; line > ui.dim[H] - 3 { return line }
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Region name: ")
+ ui.style[TITLE_STYLE], "Region name: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 16, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.Stack.RegionName)
+ ui.style[DEF_STYLE], host.Stack.RegionName)
if line += 2; line > ui.dim[H] - 3 { return line }
// user infos
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "User: ")
+ ui.style[TITLE_STYLE], "User: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.User)
+ ui.style[DEF_STYLE], host.User)
if line += 1; line > ui.dim[H] - 3 { return line }
if len(host.Pass) > 0 {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Pass: ")
+ ui.style[TITLE_STYLE], "Pass: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], "***")
+ ui.style[DEF_STYLE], "***")
if line += 1; line > ui.dim[H] - 3 { return line }
}
if line += 1; line > ui.dim[H] - 3 { return line }
@@ -388,10 +388,10 @@ func i_info_note(ui HardUI, host *HostNode, line int) {
if len(host.Note) > 0 {
i_draw_text(ui.s,
(ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Note: ")
+ ui.style[TITLE_STYLE], "Note: ")
i_draw_text(ui.s,
(ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.Note)
+ ui.style[DEF_STYLE], host.Note)
}
}
@@ -400,10 +400,10 @@ func i_draw_info_panel(ui HardUI, percent bool, litems *ItemsList) {
i_draw_box(ui.s, (ui.dim[W] / 3), 0,
ui.dim[W] - 1, ui.dim[H] - 2,
- ui.style[STYLE_BOX], ui.style[STYLE_HEAD], " Infos ", false)
- ui.s.SetContent(ui.dim[W] / 3, 0, tcell.RuneTTee, nil, ui.style[STYLE_BOX])
+ ui.style[BOX_STYLE], ui.style[HEAD_STYLE], " Infos ", false)
+ ui.s.SetContent(ui.dim[W] / 3, 0, tcell.RuneTTee, nil, ui.style[BOX_STYLE])
ui.s.SetContent(ui.dim[W] / 3, ui.dim[H] - 2,
- tcell.RuneBTee, nil, ui.style[STYLE_BOX])
+ tcell.RuneBTee, nil, ui.style[BOX_STYLE])
if litems == nil {
return
}
@@ -420,7 +420,7 @@ func i_draw_info_panel(ui HardUI, percent bool, litems *ItemsList) {
ui.dim[H] - 2,
(ui.dim[W] - 1) - 1,
ui.dim[H] - 2,
- ui.style[STYLE_DEF],
+ ui.style[DEF_STYLE],
text)
} else {
text := " 0 hosts "
@@ -429,7 +429,7 @@ func i_draw_info_panel(ui HardUI, percent bool, litems *ItemsList) {
ui.dim[H] - 2,
(ui.dim[W] - 1) - 1,
ui.dim[H] - 2,
- ui.style[STYLE_DEF],
+ ui.style[DEF_STYLE],
text)
}
// panel
diff --git a/src/i_insert.go b/src/i_insert.go
index ff967ce..536d3fa 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -59,7 +59,7 @@ import (
func i_draw_text_box(ui HardUI, line int, dim Quad, label, content string,
id, selected int) {
const tbox_size int = 14
- tbox_style := ui.style[STYLE_DEF].Background(tcell.ColorBlack).Dim(true)
+ tbox_style := ui.style[DEF_STYLE].Background(tcell.ColorBlack).Dim(true)
if id == selected {
tbox_style = tbox_style.Reverse(true).Dim(false)
@@ -68,7 +68,7 @@ func i_draw_text_box(ui HardUI, line int, dim Quad, label, content string,
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[STYLE_DEF], label)
+ ui.style[DEF_STYLE], label)
spaces := ""
for i := 0; i < tbox_size; i++ {
spaces += " "
@@ -76,6 +76,9 @@ 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)
}
@@ -91,12 +94,12 @@ func i_draw_insert_panel(ui HardUI, in *HostNode) {
ui.dim[H] - ui.dim[H] / 8,
}
i_draw_box(ui.s, win.L, win.T, win.R, win.B,
- ui.style[STYLE_BOX], ui.style[STYLE_HEAD],
+ ui.style[BOX_STYLE], ui.style[HEAD_STYLE],
" Insert - " + in.Name + " ", true)
line := 2
i_draw_text_box(ui, win.T + line, win, "Connection type", in.protocol_str(),
0, ui.insert_sel)
- line += 2
+ line += 3
switch in.Protocol {
case 0:
i_draw_insert_ssh(ui, line, win, in)
@@ -104,14 +107,25 @@ func i_draw_insert_panel(ui HardUI, in *HostNode) {
}
func i_draw_insert_ssh(ui HardUI, line int, win Quad, in *HostNode) {
+ if win.T + line >= win.B { return }
+ text := "---- Host 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.Host, 1, ui.insert_sel)
- line += 1
+ if line += 1; win.T + line >= win.B { return }
i_draw_text_box(ui, win.T + line, win, "Port", strconv.Itoa(int(in.Port)),
2, ui.insert_sel)
- line += 2
+ if line += 2; win.T + line >= win.B { return }
i_draw_text_box(ui, win.T + line, win, "User", in.User, 3, ui.insert_sel)
- line += 1
- i_draw_text_box(ui, win.T + line, win, "Pass", in.Pass, 4, ui.insert_sel) // TODO: gpg
- line += 1
+ if line += 1; win.T + line >= win.B { return }
+ 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 }
+ 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)
// TODO: here
}
diff --git a/src/i_ui.go b/src/i_ui.go
index 8e1f3b5..f52a3bc 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -202,10 +202,10 @@ func i_draw_bottom_text(ui HardUI, opts HardOpts, insert *HostNode) {
}
i_draw_text(ui.s,
1, ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
- ui.style[STYLE_BOT], text)
+ ui.style[BOT_STYLE], text)
i_draw_text(ui.s,
ui.dim[W] - len(VERSION) - 2, ui.dim[H] - 1,
- ui.dim[W] - 1, ui.dim[H] - 1, ui.style[STYLE_BOT], " " + VERSION)
+ ui.dim[W] - 1, ui.dim[H] - 1, ui.style[BOT_STYLE], " " + VERSION)
}
func i_draw_welcome_box(ui HardUI) {
@@ -213,7 +213,7 @@ func i_draw_welcome_box(ui HardUI) {
b_max := ui.dim[H] / 2 - 1
i_draw_box(ui.s,
l_max - 1, 0, r_max, b_max + 1,
- ui.style[STYLE_BOX], ui.style[STYLE_HEAD], "", true)
+ ui.style[BOX_STYLE], ui.style[HEAD_STYLE], "", true)
art := [4]string{
` _ __`,
`| |_ / _|`,
@@ -228,7 +228,7 @@ func i_draw_welcome_box(ui HardUI) {
if l < l_max { l = l_max }; if r > r_max { r = r_max }
i_draw_text(ui.s,
l, k + 1, r, k + 1,
- ui.style[STYLE_DEF], v)
+ ui.style[DEF_STYLE], v)
}
if line > b_max { return }
text := "hf " + VERSION
@@ -238,32 +238,32 @@ func i_draw_welcome_box(ui HardUI) {
l, r := ui.dim[W] / 2 - len(text) / 2 + 7,
ui.dim[W] / 2 + len(text) / 2 + 1 + 7
if l < l_max { l = l_max }; if r > r_max { r = r_max }
- i_draw_text(ui.s, l, line, r, line, ui.style[STYLE_DEF], text)
+ i_draw_text(ui.s, l, line, r, line, ui.style[DEF_STYLE], text)
if line += 2; line > b_max { return }
text = `Welcome to hardflip!`
l, r = ui.dim[W] / 2 - len(text) / 2, ui.dim[W] / 2 + len(text) / 2 + 1
if l < l_max { l = l_max }; if r > r_max { r = r_max }
- i_draw_text(ui.s, l, line, r, line, ui.style[STYLE_DEF], text)
+ i_draw_text(ui.s, l, line, r, line, ui.style[DEF_STYLE], text)
text = `Please select the gpg key ID to be used`
if line += 1; line > b_max { return }
l, r = ui.dim[W] / 2 - len(text) / 2, ui.dim[W] / 2 + len(text) / 2 + 1
if l < l_max { l = l_max }; if r > r_max { r = r_max }
- i_draw_text(ui.s, l, line, r, line, ui.style[STYLE_DEF], text)
+ i_draw_text(ui.s, l, line, r, line, ui.style[DEF_STYLE], text)
text = `for password encryption`
if line += 1; line > b_max { return }
l, r = ui.dim[W] / 2 - len(text) / 2, ui.dim[W] / 2 + len(text) / 2 + 1
if l < l_max { l = l_max }; if r > r_max { r = r_max }
- i_draw_text(ui.s, l, line, r, line, ui.style[STYLE_DEF], text)
+ i_draw_text(ui.s, l, line, r, line, ui.style[DEF_STYLE], text)
text = `Set gpg key can be modified in the config file`
if line += 1; line > b_max { return }
l, r = ui.dim[W] / 2 - len(text) / 2, ui.dim[W] / 2 + len(text) / 2 + 1
if l < l_max { l = l_max }; if r > r_max { r = r_max }
- i_draw_text(ui.s, l, line, r, line, ui.style[STYLE_DEF], text)
+ i_draw_text(ui.s, l, line, r, line, ui.style[DEF_STYLE], text)
text = `If you don't want to use GnuPG for password`
if line += 2; line > b_max { return }
l, r = ui.dim[W] / 2 - len(text) / 2, ui.dim[W] / 2 + len(text) / 2 + 1
if l < l_max { l = l_max }; if r > r_max { r = r_max }
- i_draw_text(ui.s, l, line, r, line, ui.style[STYLE_DEF], text)
+ i_draw_text(ui.s, l, line, r, line, ui.style[DEF_STYLE], text)
text = `storage, please select `
text_2 := `plain`
text_3 := ` (plaintext passwords`
@@ -271,21 +271,21 @@ func i_draw_welcome_box(ui HardUI) {
l = ui.dim[W] / 2 - len(text + text_2 + text_3) / 2
r = r_max
if l < l_max { l = l_max }; if r > r_max { r = r_max }
- i_draw_text(ui.s, l, line, r, line, ui.style[STYLE_DEF], text)
+ i_draw_text(ui.s, l, line, r, line, ui.style[DEF_STYLE], text)
l = l + len(text)
r = l + len(text_2)
if l < l_max { l = l_max }; if r > r_max { r = r_max }
if l >= r_max { return }
- i_draw_text(ui.s, l, line, r, line, ui.style[STYLE_DEF].Bold(true), text_2)
+ i_draw_text(ui.s, l, line, r, line, ui.style[DEF_STYLE].Bold(true), text_2)
l = l + len(text_2)
r = l + len(text_3)
if l < l_max { l = l_max }; if r > r_max { r = r_max }
- i_draw_text(ui.s, l, line, r, line, ui.style[STYLE_DEF], text_3)
+ i_draw_text(ui.s, l, line, r, line, ui.style[DEF_STYLE], text_3)
text = `are not recommended)`
if line += 1; line > b_max { return }
l, r = ui.dim[W] / 2 - len(text) / 2, ui.dim[W] / 2 + len(text) / 2 + 1
if l < l_max { l = l_max }; if r > r_max { r = r_max }
- i_draw_text(ui.s, l, line, r, line, ui.style[STYLE_DEF], text)
+ i_draw_text(ui.s, l, line, r, line, ui.style[DEF_STYLE], text)
}
func i_prompt_gpg(ui HardUI, keys [][2]string) {
@@ -293,7 +293,7 @@ func i_prompt_gpg(ui HardUI, keys [][2]string) {
if lines == 1 {
lines = 2
}
- i_draw_msg(ui.s, lines, ui.style[STYLE_BOX], ui.dim, " GnuPG keys ")
+ i_draw_msg(ui.s, lines, ui.style[BOX_STYLE], ui.dim, " GnuPG keys ")
for k, v := range keys {
text := ""
if v[0] != "plain" {
@@ -304,146 +304,139 @@ func i_prompt_gpg(ui HardUI, keys [][2]string) {
}
line := ui.dim[H] - 2 - len(keys) + k
i_draw_text(ui.s, 2, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], text)
+ ui.style[DEF_STYLE], text)
}
if len(keys) == 1 {
i_draw_text(ui.s, 2, ui.dim[H] - 4, ui.dim[W] - 1, ui.dim[H] - 4,
- ui.style[STYLE_DEF],
+ ui.style[DEF_STYLE],
"No gpg key! Creating your gpg key first is recommended")
}
i_draw_text(ui.s,
1, ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
- ui.style[STYLE_DEF], "gpg: ")
+ ui.style[DEF_STYLE], "gpg: ")
ui.s.ShowCursor(6, ui.dim[H] - 1)
}
func i_prompt_confirm_gpg(ui HardUI, opts HardOpts) {
if opts.GPG == "plain" {
- i_draw_msg(ui.s, 1, ui.style[STYLE_BOX], ui.dim, " Confirm plaintext ")
+ i_draw_msg(ui.s, 1, ui.style[BOX_STYLE], ui.dim, " Confirm plaintext ")
text := "Really use plaintext to store passwords?"
l, r := i_left_right(len(text), &ui)
i_draw_text(ui.s, l, ui.dim[H] - 3, r, ui.dim[H] - 3,
- ui.style[STYLE_DEF], text)
+ ui.style[DEF_STYLE], text)
return
}
- i_draw_msg(ui.s, 2, ui.style[STYLE_BOX], ui.dim, " Confirm GnuPG key ")
+ i_draw_msg(ui.s, 2, ui.style[BOX_STYLE], ui.dim, " Confirm GnuPG key ")
text := "Really use this gpg key?"
l, r := i_left_right(len(text), &ui)
i_draw_text(ui.s, l, ui.dim[H] - 4, r, ui.dim[H] - 4,
- ui.style[STYLE_DEF], text)
+ ui.style[DEF_STYLE], text)
l, r = i_left_right(len(opts.GPG), &ui)
i_draw_text(ui.s, l, ui.dim[H] - 3, r, ui.dim[H] - 3,
- ui.style[STYLE_DEF], opts.GPG)
+ ui.style[DEF_STYLE], opts.GPG)
}
func i_prompt_mkdir(ui HardUI, curr *ItemsNode) {
path := "/"
if curr != nil {
- if curr.is_dir() == true {
- path = curr.Dirs.path()
- } else {
- path = curr.Host.Parent.path()
- }
+ path = curr.path()
}
path = path[1:]
prompt := "mkdir: "
i_draw_text(ui.s,
1, ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
- ui.style[STYLE_DEF], prompt)
+ ui.style[DEF_STYLE], prompt)
i_draw_text(ui.s, len(prompt) + 1,
ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
- ui.style[STYLE_DEF], path)
+ ui.style[DEF_STYLE], path)
i_draw_text(ui.s, len(prompt) + 1 + len(path),
ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
- ui.style[STYLE_DEF].Bold(true), ui.buff)
+ ui.style[DEF_STYLE].Bold(true), ui.buff)
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[STYLE_BOX], ui.dim, " Connection type ")
+ 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[STYLE_DEF], "[1] SSH")
+ 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[STYLE_DEF], "[2] RDP")
+ 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[STYLE_DEF], "[3] Single command")
+ 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[STYLE_DEF], "[4] OpenStack CLI")
+ 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[STYLE_DEF], text)
+ ui.style[DEF_STYLE], text)
ui.s.ShowCursor(len(text), ui.dim[H] - 1)
}
-func i_prompt_generic(ui HardUI, prompt string) {
+func i_prompt_generic(ui HardUI, prompt string, secret bool) {
i_draw_text(ui.s,
1, ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
- ui.style[STYLE_DEF], prompt)
+ ui.style[DEF_STYLE], prompt)
+ if secret == true {
+ ui.s.ShowCursor(len(prompt) + 1, ui.dim[H] - 1)
+ return
+ }
i_draw_text(ui.s, len(prompt) + 1,
ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
- ui.style[STYLE_DEF].Bold(true), ui.buff)
+ ui.style[DEF_STYLE].Bold(true), ui.buff)
ui.s.ShowCursor(len(prompt) + 1 + len(ui.buff), ui.dim[H] - 1)
}
func i_prompt_insert(ui HardUI, curr *ItemsNode) {
path := "/"
- if curr != nil {
- if curr.is_dir() == true {
- path = curr.Dirs.path()
- } else {
- path = curr.Host.Parent.path()
- }
- }
+ path = curr.path()
path = path[1:]
prompt := "Name: "
i_draw_text(ui.s,
1, ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
- ui.style[STYLE_DEF], prompt)
+ ui.style[DEF_STYLE], prompt)
i_draw_text(ui.s, len(prompt) + 1,
ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
- ui.style[STYLE_DEF], path)
+ ui.style[DEF_STYLE], path)
i_draw_text(ui.s, len(prompt) + 1 + len(path),
ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
- ui.style[STYLE_DEF].Bold(true), ui.buff)
+ ui.style[DEF_STYLE].Bold(true), ui.buff)
ui.s.ShowCursor(len(prompt) + 1 + len(path) + len(ui.buff), ui.dim[H] - 1)
}
func i_draw_zhosts_box(ui HardUI) {
- i_draw_msg(ui.s, 1, ui.style[STYLE_BOX], ui.dim, " No hosts ")
+ i_draw_msg(ui.s, 1, ui.style[BOX_STYLE], ui.dim, " No hosts ")
text := "Hosts list empty. Add hosts/folders by pressing (a/m)"
left, right := i_left_right(len(text), &ui)
i_draw_text(ui.s, left, ui.dim[H] - 2 - 1, right, ui.dim[H] - 2 - 1,
- ui.style[STYLE_DEF], text)
+ ui.style[DEF_STYLE], text)
}
func i_draw_delete_msg(ui HardUI, item *ItemsNode) {
var text string
var file string
+ file = item.path()
if item.is_dir() == true {
text = "Really delete this directory and all of its content?"
- file = item.Dirs.path()
} else {
- host := item.Host
text = "Really delete this host?"
- file = host.Parent.path() + host.Filename
+ file += item.Host.Filename
}
file = file[1:]
- i_draw_msg(ui.s, 2, ui.style[STYLE_BOX], ui.dim, " Delete ")
+ i_draw_msg(ui.s, 2, ui.style[BOX_STYLE], ui.dim, " Delete ")
left, right := i_left_right(len(text), &ui)
line := ui.dim[H] - 2 - 2
- i_draw_text(ui.s, left, line, right, line, ui.style[STYLE_DEF], text)
+ i_draw_text(ui.s, left, line, right, line, ui.style[DEF_STYLE], text)
left, right = i_left_right(len(file), &ui)
line += 1
i_draw_text(ui.s,
left, line, right, line,
- ui.style[STYLE_DEF].Bold(true), file)
+ ui.style[DEF_STYLE].Bold(true), file)
}
func i_draw_load_error_msg(ui HardUI, load_err []error) {
lines := len(load_err)
- i_draw_msg(ui.s, lines, ui.style[STYLE_BOX], ui.dim, " Load time errors ")
+ i_draw_msg(ui.s, lines, ui.style[BOX_STYLE], ui.dim, " Load time errors ")
left, right := 1, ui.dim[W] - 1
line := ui.dim[H] - 2 - 1 - len(load_err)
if line < 0 {
@@ -453,7 +446,7 @@ func i_draw_load_error_msg(ui HardUI, load_err []error) {
line += 1
err_str := fmt.Sprintf("%v", err)
i_draw_text(ui.s, left, line, right, line,
- ui.style[STYLE_ERR], err_str)
+ ui.style[ERR_STYLE], err_str)
}
}
@@ -466,18 +459,18 @@ func i_draw_error_msg(ui HardUI, load_err []error) {
if len(ui.err[ERROR_ERR]) == 0 {
lines = 1
}
- i_draw_msg(ui.s, lines, ui.style[STYLE_BOX], ui.dim, " Error ")
+ i_draw_msg(ui.s, lines, ui.style[BOX_STYLE], ui.dim, " Error ")
left, right := 1, ui.dim[W] - 2
line := ui.dim[H] - 2 - 2
if len(ui.err[ERROR_ERR]) == 0 {
line += 1
}
i_draw_text(ui.s, left, line, right, line,
- ui.style[STYLE_ERR], ui.err[ERROR_MSG])
+ ui.style[ERR_STYLE], ui.err[ERROR_MSG])
if len(ui.err[ERROR_ERR]) > 0 {
line += 1
i_draw_text(ui.s, left, line, right, line,
- ui.style[STYLE_ERR], ui.err[ERROR_ERR])
+ ui.style[ERR_STYLE], ui.err[ERROR_ERR])
}
}
@@ -494,12 +487,12 @@ func i_draw_scrollhint(ui HardUI, litems *ItemsList) {
if draw_id > 1 {
ui.s.SetContent(0, 1,
'▲',
- nil, ui.style[STYLE_BOX])
+ nil, ui.style[BOX_STYLE])
}
if last - draw_id > h {
ui.s.SetContent(0, ui.dim[H] - 3,
'▼',
- nil, ui.style[STYLE_BOX])
+ nil, ui.style[BOX_STYLE])
return
}
}
@@ -518,14 +511,14 @@ func i_draw_load_ui(ui *HardUI, opts HardOpts) {
text += " "
}
i_draw_text(ui.s, 1, ui.dim[H] - 1, ui.dim[W], ui.dim[H] - 1,
- ui.style[STYLE_BOT], text)
+ ui.style[BOT_STYLE], text)
i_draw_bottom_text(*ui, opts, nil)
- i_draw_msg(ui.s, 1, ui.style[STYLE_BOX], ui.dim, " Loading ")
+ i_draw_msg(ui.s, 1, ui.style[BOX_STYLE], ui.dim, " Loading ")
text = "Loading " + strconv.Itoa(g_load_count) + " hosts"
left, right := i_left_right(len(text), ui)
i_draw_text(ui.s,
left, ui.dim[H] - 2 - 1, right, ui.dim[H] - 2 - 1,
- ui.style[STYLE_DEF], text)
+ ui.style[DEF_STYLE], text)
ui.s.Show()
ui.s.PostEvent(nil)
event := ui.s.PollEvent()
@@ -570,28 +563,28 @@ func i_ui(data_dir string) {
if err := ui.s.Init(); err != nil {
c_die("view", err)
}
- ui.style[STYLE_DEF] = tcell.StyleDefault.
+ ui.style[DEF_STYLE] = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.ColorReset)
- ui.style[STYLE_DIR] = tcell.StyleDefault.
+ ui.style[DIR_STYLE] = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.ColorBlue).Dim(true).Bold(true)
- ui.style[STYLE_BOX] = tcell.StyleDefault.
+ ui.style[BOX_STYLE] = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.ColorReset)
- ui.style[STYLE_HEAD] = tcell.StyleDefault.
+ ui.style[HEAD_STYLE] = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.ColorReset)
- ui.style[STYLE_ERR] = tcell.StyleDefault.
+ ui.style[ERR_STYLE] = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.ColorRed).Dim(true)
- ui.style[STYLE_TITLE] = tcell.StyleDefault.
+ ui.style[TITLE_STYLE] = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.ColorBlue).Dim(true).Bold(true)
- ui.style[STYLE_BOT] = tcell.StyleDefault.
+ ui.style[BOT_STYLE] = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.ColorBlue).Dim(true)
- ui.s.SetStyle(ui.style[STYLE_DEF])
+ ui.s.SetStyle(ui.style[DEF_STYLE])
ui.dim[W], ui.dim[H], _ = term.GetSize(0)
var load_err []error
conf_dir := c_get_conf_dir(&load_err)
@@ -651,9 +644,15 @@ func i_ui(data_dir string) {
case 0:
i_prompt_type(data.ui)
case 1:
- i_prompt_generic(data.ui, "Host/IP: ")
+ i_prompt_generic(data.ui, "Host/IP: ", false)
case 2:
- i_prompt_generic(data.ui, "Port: ")
+ i_prompt_generic(data.ui, "Port: ", false)
+ case 3:
+ i_prompt_generic(data.ui, "User: ", false)
+ case 4:
+ i_prompt_generic(data.ui, "Pass: ", true)
+ case 5:
+ i_prompt_generic(data.ui, "Private key: ", false)
}
}
}