aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-05-10 20:20:20 +0200
committerJoe <rbo@gmx.us>2024-05-10 20:20:20 +0200
commit17da73bbba8dee461fed7827c80fafc0f352b1fa (patch)
tree83f904d7f06869475e662ebb2f4ac1caeeec2742
parentdirt but eh fuck it works (diff)
downloadhardflip-17da73bbba8dee461fed7827c80fafc0f352b1fa.tar.gz
hardflip-17da73bbba8dee461fed7827c80fafc0f352b1fa.tar.bz2
hardflip-17da73bbba8dee461fed7827c80fafc0f352b1fa.tar.xz
hardflip-17da73bbba8dee461fed7827c80fafc0f352b1fa.tar.zst
hardflip-17da73bbba8dee461fed7827c80fafc0f352b1fa.zip
simpler is always better
-rw-r--r--ROADMAP.md2
-rw-r--r--src/e_keys.go12
-rw-r--r--src/i_insert.go42
-rw-r--r--src/i_ui.go1
4 files changed, 29 insertions, 28 deletions
diff --git a/ROADMAP.md b/ROADMAP.md
index 9e4d98f..29a2693 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -39,7 +39,7 @@
## v0.7
-- [ ] scroll insert
+- [x] scroll insert
- [ ] help
- [ ] better readline
diff --git a/src/e_keys.go b/src/e_keys.go
index d513a4e..966fabb 100644
--- a/src/e_keys.go
+++ b/src/e_keys.go
@@ -396,9 +396,7 @@ func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
} else if ui.insert_sel < ui.insert_sel_max {
ui.insert_sel += 1
}
- if ui.insert_sel < ui.insert_sel_max &&
- ui.insert_sel % 2 == 0 &&
- ui.insert_butt == false {
+ if ui.insert_butt == false {
ui.insert_scroll += 2
// TODO: gogo
}
@@ -425,7 +423,7 @@ func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
} else if ui.insert_sel > INS_PROTOCOL {
ui.insert_sel -= 1
}
- if ui.insert_scroll > 0 && ui.insert_sel % 2 == 0 {
+ if ui.insert_scroll > 0 {
ui.insert_scroll -= 2
if ui.insert_scroll < 0 {
ui.insert_scroll = 0
@@ -434,11 +432,13 @@ func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
} else if event.Rune() == 'g' ||
event.Rune() == 'h' ||
event.Key() == tcell.KeyLeft {
- ui.insert_sel = INS_PROTOCOL
+ ui.insert_sel = INS_PROTOCOL
+ ui.insert_scroll = 0
} else if event.Rune() == 'G' ||
event.Rune() == 'l' ||
event.Key() == tcell.KeyRight {
- ui.insert_sel = ui.insert_sel_max
+ ui.insert_sel = ui.insert_sel_max
+ // FIX: should scroll at some point
} else if event.Rune() == 'i' ||
event.Rune() == 'a' ||
event.Rune() == ' ' ||
diff --git a/src/i_insert.go b/src/i_insert.go
index fe24bce..17d11d1 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -454,29 +454,29 @@ func i_insert_follow_cursor(insert_scroll, line int) int {
}
func i_draw_insert_panel(ui *HardUI, in *HostNode, home_dir string) {
- type draw_insert_func func(ui *HardUI, line int,
+ type draw_insert_func func(ui *HardUI, line int, win Quad,
in *HostNode, home string) int
if len(in.Name) == 0 {
return
}
- ui.insert_win = Quad{
+ win := Quad{
ui.dim[W] / 8,
ui.dim[H] / 8,
ui.dim[W] - ui.dim[W] / 8 - 1,
ui.dim[H] - ui.dim[H] / 8 - 1,
}
i_draw_box(ui.s,
- ui.insert_win.L, ui.insert_win.T, ui.insert_win.R, ui.insert_win.B,
+ win.L, win.T, win.R, win.B,
ui.style[BOX_STYLE], ui.style[HEAD_STYLE],
" Insert - " + in.Name + " ", true)
line := i_insert_follow_cursor(ui.insert_scroll, 2)
- if line + 2 < ui.insert_win.T {
- ui.s.SetContent(ui.dim[W] / 2, ui.insert_win.T, '▲',
+ if line + 2 < win.T {
+ ui.s.SetContent(ui.dim[W] / 2, win.T, '▲',
nil, ui.style[BOX_STYLE])
}
- if ui.insert_win.T + line >= ui.insert_win.B { return }
- i_draw_text_box(ui, ui.insert_win.T + line, ui.insert_win,
+ if win.T + line >= win.B { return }
+ i_draw_text_box(ui, win.T + line, win,
"Connection type", PROTOCOL_STR[in.Protocol], 0, false, false)
line += 2
var end_line int
@@ -487,17 +487,17 @@ func i_draw_insert_panel(ui *HardUI, in *HostNode, home_dir string) {
i_draw_insert_os,
}
ui.insert_butt = false
- end_line = fp[in.Protocol](ui, line, in, home_dir)
- if ui.insert_win.T + end_line >= ui.insert_win.B {
- ui.s.SetContent(ui.dim[W] / 2, ui.insert_win.B, '▼',
+ end_line = fp[in.Protocol](ui, line, win, in, home_dir)
+ if win.T + end_line >= win.B {
+ ui.s.SetContent(ui.dim[W] / 2, win.B, '▼',
nil, ui.style[BOX_STYLE])
// TODO: scroll or something
}
i_draw_insert_inputs(*ui, in, home_dir)
}
-func i_draw_insert_ssh(ui *HardUI, line int, in *HostNode, home string) int {
- win := ui.insert_win
+func i_draw_insert_ssh(ui *HardUI, line int, win Quad,
+ in *HostNode, home string) int {
red := false
if win.T + line >= win.B { return line }
text := "---- Host settings ----"
@@ -532,8 +532,10 @@ func i_draw_insert_ssh(ui *HardUI, line int, in *HostNode, home string) int {
if red == true {
if line += 1; win.T + line >= win.B { return line }
text := "file does not exist"
- i_draw_text(ui.s, ui.dim[W] / 2, win.T + line,
- win.R - 1, win.T + line, ui.style[ERR_STYLE], text)
+ if line > win.T - 3 {
+ i_draw_text(ui.s, ui.dim[W] / 2, win.T + line,
+ win.R - 1, win.T + line, ui.style[ERR_STYLE], text)
+ }
}
red = false
if line += 2; win.T + line >= win.B { return line }
@@ -592,8 +594,8 @@ func i_draw_insert_ssh(ui *HardUI, line int, in *HostNode, home string) int {
return line
}
-func i_draw_insert_rdp(ui *HardUI, line int, in *HostNode, home string) int {
- win := ui.insert_win
+func i_draw_insert_rdp(ui *HardUI, line int, win Quad,
+ in *HostNode, home string) int {
red := false
if win.T + line >= win.B { return line }
text := "---- Host settings ----"
@@ -740,8 +742,8 @@ func i_draw_insert_rdp(ui *HardUI, line int, in *HostNode, home string) int {
return line
}
-func i_draw_insert_cmd(ui *HardUI, line int, in *HostNode, home string) int {
- win := ui.insert_win
+func i_draw_insert_cmd(ui *HardUI, line int, win Quad,
+ in *HostNode, home string) int {
red := false
if win.T + line >= win.B { return line }
text := "---- Settings ----"
@@ -785,8 +787,8 @@ func i_draw_insert_cmd(ui *HardUI, line int, in *HostNode, home string) int {
return line
}
-func i_draw_insert_os(ui *HardUI, line int, in *HostNode, home string) int {
- win := ui.insert_win
+func i_draw_insert_os(ui *HardUI, line int, win Quad,
+ in *HostNode, home string) int {
if win.T + line >= win.B { return line }
text := "---- Host settings ----"
i_draw_text(ui.s, ui.dim[W] / 2 - len(text) / 2, win.T + line, win.R - 1,
diff --git a/src/i_ui.go b/src/i_ui.go
index 0015625..09a1d65 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -75,7 +75,6 @@ type HardUI struct {
insert_method int
insert_scroll int
insert_butt bool
- insert_win Quad
}
type Quad struct {