aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ROADMAP.md1
-rw-r--r--src/i_events.go26
-rw-r--r--src/i_insert.go7
-rw-r--r--src/i_ui.go19
4 files changed, 46 insertions, 7 deletions
diff --git a/ROADMAP.md b/ROADMAP.md
index f65ef05..43181b4 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -39,6 +39,7 @@
- [ ] help
- [ ] ssh jump rdp
+- [ ] better readline
## v0.8
diff --git a/src/i_events.go b/src/i_events.go
index 4cf7201..2899d7c 100644
--- a/src/i_events.go
+++ b/src/i_events.go
@@ -53,6 +53,7 @@ package main
import (
"os"
+ "strconv"
"github.com/gdamore/tcell/v2"
"golang.org/x/term"
@@ -98,7 +99,7 @@ func i_unfold_dir(data *HardData, item *ItemsNode) {
return
}
// single empty dir
- if start == item && end == end {
+ if start == item && end == end { // HACK: i forgot why end == end
i_set_unfold(data, item)
return
}
@@ -565,11 +566,18 @@ func i_events(data *HardData) {
}
} else if event.Key() == tcell.KeyEnter {
data.ui.insert_sel_ok = true
+ switch data.ui.insert_sel {
+ case 1:
+ ui.buff = data.insert.Host
+ case 2:
+ ui.buff = strconv.Itoa(int(data.insert.Port))
+ }
}
} else {
if event.Key() == tcell.KeyEscape ||
event.Key() == tcell.KeyCtrlC {
data.ui.insert_sel_ok = false
+ ui.buff = ""
ui.s.HideCursor()
}
switch data.ui.insert_sel {
@@ -582,8 +590,20 @@ func i_events(data *HardData) {
ui.s.HideCursor()
i_set_protocol_defaults(data.insert)
}
- case 1:
- i_readline(event, data)
+ case 1, 2:
+ 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)
+ }
+ data.ui.insert_sel_ok = false
+ ui.buff = ""
+ ui.s.HideCursor()
+ } else {
+ i_readline(event, data)
+ }
}
}
}
diff --git a/src/i_insert.go b/src/i_insert.go
index 12f4cf3..ff967ce 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/i_insert.go
- * Tue Feb 27 14:31:54 2024
+ * Wed Feb 28 17:27:20 2024
* Joe
*
* insert a new host
@@ -97,7 +97,10 @@ func i_draw_insert_panel(ui HardUI, in *HostNode) {
i_draw_text_box(ui, win.T + line, win, "Connection type", in.protocol_str(),
0, ui.insert_sel)
line += 2
- i_draw_insert_ssh(ui, line, win, in)
+ switch in.Protocol {
+ case 0:
+ i_draw_insert_ssh(ui, line, win, in)
+ }
}
func i_draw_insert_ssh(ui HardUI, line int, win Quad, in *HostNode) {
diff --git a/src/i_ui.go b/src/i_ui.go
index 043bdca..8e1f3b5 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -376,6 +376,16 @@ func i_prompt_type(ui HardUI) {
ui.s.ShowCursor(len(text), ui.dim[H] - 1)
}
+func i_prompt_generic(ui HardUI, prompt string) {
+ i_draw_text(ui.s,
+ 1, ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
+ ui.style[STYLE_DEF], 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].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 {
@@ -386,7 +396,7 @@ func i_prompt_insert(ui HardUI, curr *ItemsNode) {
}
}
path = path[1:]
- prompt := "name: "
+ 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)
@@ -637,8 +647,13 @@ func i_ui(data_dir string) {
} else {
i_draw_insert_panel(data.ui, data.insert)
if data.ui.insert_sel_ok == true {
- if data.ui.insert_sel == 0 {
+ switch data.ui.insert_sel {
+ case 0:
i_prompt_type(data.ui)
+ case 1:
+ i_prompt_generic(data.ui, "Host/IP: ")
+ case 2:
+ i_prompt_generic(data.ui, "Port: ")
}
}
}