diff options
author | Joe <rbo@gmx.us> | 2024-02-21 20:20:20 +0100 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2024-02-21 20:20:20 +0100 |
commit | e71ae89a1b3a1c8e0f2372575b5997d8e38f9242 (patch) | |
tree | 96975a8dc5d5ee79fd9cb25ec216ae345fec6ee1 /src/i_ui.go | |
parent | tmp (diff) | |
download | hardflip-e71ae89a1b3a1c8e0f2372575b5997d8e38f9242.tar.gz hardflip-e71ae89a1b3a1c8e0f2372575b5997d8e38f9242.tar.bz2 hardflip-e71ae89a1b3a1c8e0f2372575b5997d8e38f9242.tar.xz hardflip-e71ae89a1b3a1c8e0f2372575b5997d8e38f9242.tar.zst hardflip-e71ae89a1b3a1c8e0f2372575b5997d8e38f9242.zip |
quad
Diffstat (limited to '')
-rw-r--r-- | src/i_ui.go | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/src/i_ui.go b/src/i_ui.go index 0edcc62..0c9f14c 100644 --- a/src/i_ui.go +++ b/src/i_ui.go @@ -43,7 +43,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/i_ui.go - * Tue Jan 23 18:11:28 2024 + * Wed Feb 21 19:42:11 2024 * Joe * * interfacing with the user @@ -69,6 +69,10 @@ type HardUI struct { buff string } +type Quad struct { + L, R, T, B int +} + func i_left_right(text_len int, ui *HardUI) (int, int) { left := (ui.dim[W] / 2) - text_len / 2 right := ui.dim[W] - 1 @@ -323,7 +327,7 @@ func i_prompt_confirm_gpg(ui HardUI, opts HardOpts) { ui.style[STYLE_DEF], opts.GPG) } -func i_draw_mkdir(ui HardUI, curr *ItemsNode) { +func i_prompt_mkdir(ui HardUI, curr *ItemsNode) { path := "/" if curr != nil { if curr.is_dir() == true { @@ -346,6 +350,29 @@ func i_draw_mkdir(ui HardUI, curr *ItemsNode) { ui.s.ShowCursor(len(prompt) + 1 + len(path) + 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 = 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) + 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) + 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.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 ") text := "Hosts list empty. Add hosts/folders by pressing (a/m)" @@ -547,6 +574,7 @@ func i_ui(data_dir string) { data_dir, load_err, [][2]string{}, + nil, } if data.opts.GPG == DEFAULT_OPTS.GPG && data.litems.head == nil { data.ui.mode = WELCOME_MODE @@ -573,12 +601,16 @@ func i_ui(data_dir string) { } if data.ui.mode == DELETE_MODE { i_draw_delete_msg(data.ui, data.litems.curr) - } - if data.ui.mode == ERROR_MODE { + } else if data.ui.mode == ERROR_MODE { i_draw_error_msg(data.ui, data.load_err) - } - if data.ui.mode == MKDIR_MODE { - i_draw_mkdir(data.ui, data.litems.curr) + } else if data.ui.mode == MKDIR_MODE { + i_prompt_mkdir(data.ui, data.litems.curr) + } else if data.ui.mode == INSERT_MODE { + if data.insert == nil { + i_prompt_insert(data.ui, data.litems.curr) + } else { + i_draw_insert_panel(data.ui, data.insert) + } } data.ui.s.Show() i_events(&data) |