aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-02-09 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-02-09 20:20:20 +0100
commitc57bd4c629eca16d665b116a8b296fc595413c43 (patch)
tree63cabb012487b158cb861d6c49448db0e8f660c3 /src
parent2000 sloc (diff)
downloadhardflip-c57bd4c629eca16d665b116a8b296fc595413c43.tar.gz
hardflip-c57bd4c629eca16d665b116a8b296fc595413c43.tar.bz2
hardflip-c57bd4c629eca16d665b116a8b296fc595413c43.tar.xz
hardflip-c57bd4c629eca16d665b116a8b296fc595413c43.tar.zst
hardflip-c57bd4c629eca16d665b116a8b296fc595413c43.zip
fine actually
Diffstat (limited to '')
-rw-r--r--src/c_defs.go9
-rw-r--r--src/i_events.go24
-rw-r--r--src/i_ui.go23
3 files changed, 51 insertions, 5 deletions
diff --git a/src/c_defs.go b/src/c_defs.go
index cb6f9f8..6cb8e05 100644
--- a/src/c_defs.go
+++ b/src/c_defs.go
@@ -72,10 +72,11 @@ n: no`
)
const (
- NORMAL_MODE = 0
- DELETE_MODE = 1
- LOAD_MODE = 2
- ERROR_MODE = 3
+ NORMAL_MODE = 0
+ DELETE_MODE = 1
+ LOAD_MODE = 2
+ ERROR_MODE = 3
+ WELCOME_MODE = 4
)
const (
diff --git a/src/i_events.go b/src/i_events.go
index 47a439f..48db64c 100644
--- a/src/i_events.go
+++ b/src/i_events.go
@@ -345,6 +345,30 @@ func i_events(data *HardData) {
ui.mode = NORMAL_MODE
data.load_err = nil
}
+ case WELCOME_MODE:
+ if event.Key() == tcell.KeyEscape ||
+ event.Key() == tcell.KeyCtrlC {
+ ui.s.Fini()
+ os.Exit(0)
+ }
+ if len(data.opts.GPG) == 0 {
+ if len(data.ui.buff) > 0 &&
+ (event.Key() == tcell.KeyBackspace ||
+ event.Key() == tcell.KeyBackspace2) {
+ data.ui.buff = data.ui.buff[:len(data.ui.buff) - 1]
+ } else if event.Key() == tcell.KeyCtrlU {
+ data.ui.buff = ""
+ } else if event.Key() == tcell.KeyEnter {
+ data.opts.GPG = data.ui.buff
+ data.ui.buff = ""
+ data.ui.s.HideCursor()
+ } else if event.Rune() >= 32 && event.Rune() <= 126 {
+ data.ui.buff += string(event.Rune())
+ }
+ } else {
+ // TODO: confirm
+ }
}
+
}
}
diff --git a/src/i_ui.go b/src/i_ui.go
index eefb79f..312f8b5 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -66,6 +66,7 @@ type HardUI struct {
style [7]tcell.Style
dim [2]int
err [2]string
+ buff string
}
func i_left_right(text_len int, ui *HardUI) (int, int) {
@@ -177,6 +178,9 @@ func i_draw_bottom_text(ui HardUI) {
text = "Loading..."
case ERROR_MODE:
text = ERROR_KEYS_HINTS
+ case WELCOME_MODE:
+ default:
+ text = ""
}
i_draw_text(ui.s,
1, ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
@@ -268,6 +272,16 @@ func i_draw_welcome_box(ui HardUI) {
i_draw_text(ui.s, l, line, r, line, ui.style[STYLE_DEF], text)
}
+func i_prompt_gpg(ui HardUI) {
+ text := "gpg: "
+ i_draw_text(ui.s,
+ 1, ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
+ ui.style[STYLE_DEF], text)
+ ui.s.ShowCursor(6 + len(ui.buff), ui.dim[H] - 1)
+ i_draw_text(ui.s, 6, ui.dim[H] - 1, ui.dim[W], ui.dim[H] - 1,
+ ui.style[STYLE_DEF], ui.buff)
+}
+
func i_draw_zhosts_box(ui HardUI) {
i_draw_msg(ui.s, 1, ui.style[STYLE_BOX], ui.dim, " No hosts ")
text := "Hosts list empty. Add hosts/folders by pressing (a/m)"
@@ -469,6 +483,9 @@ func i_ui(data_dir string) {
data_dir,
load_err,
}
+ if data.opts.GPG == DEFAULT_OPTS.GPG && data.litems.head == nil {
+ data.ui.mode = WELCOME_MODE
+ }
for {
data.ui.s.Clear()
i_draw_bottom_text(data.ui)
@@ -478,8 +495,12 @@ func i_ui(data_dir string) {
if data.load_err != nil && len(data.load_err) > 0 {
data.ui.mode = ERROR_MODE
}
- if data.opts.GPG == DEFAULT_OPTS.GPG && data.litems.head == nil {
+ if data.ui.mode == WELCOME_MODE {
i_draw_welcome_box(data.ui)
+ if len(data.opts.GPG) == 0 {
+ i_prompt_gpg(data.ui)
+ } else {
+ }
} else if data.litems.head == nil {
i_draw_zhosts_box(data.ui)
}