diff options
author | Joe <rbo@gmx.us> | 2024-02-09 20:20:20 +0100 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2024-02-09 20:20:20 +0100 |
commit | c57bd4c629eca16d665b116a8b296fc595413c43 (patch) | |
tree | 63cabb012487b158cb861d6c49448db0e8f660c3 | |
parent | 2000 sloc (diff) | |
download | hardflip-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-- | go.mod | 6 | ||||
-rw-r--r-- | go.sum | 6 | ||||
-rw-r--r-- | src/c_defs.go | 9 | ||||
-rw-r--r-- | src/i_events.go | 24 | ||||
-rw-r--r-- | src/i_ui.go | 23 |
5 files changed, 58 insertions, 10 deletions
@@ -1,10 +1,10 @@ module hf -go 1.21.5 +go 1.22rc2 require ( github.com/gdamore/tcell/v2 v2.7.0 - golang.org/x/term v0.15.0 + golang.org/x/term v0.17.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -13,6 +13,6 @@ require ( github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect github.com/rivo/uniseg v0.4.3 // indirect - golang.org/x/sys v0.15.0 // indirect + golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect ) @@ -27,13 +27,15 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= +golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= +golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= 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) } |