aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-02-14 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-02-14 20:20:20 +0100
commit1c340dc589f5107d9956378e35637a0dfdf55bcb (patch)
tree530b03ac19fad0c68f3ff600f38f1d2cfe34f2d0 /src
parentfuck it (diff)
downloadhardflip-1c340dc589f5107d9956378e35637a0dfdf55bcb.tar.gz
hardflip-1c340dc589f5107d9956378e35637a0dfdf55bcb.tar.bz2
hardflip-1c340dc589f5107d9956378e35637a0dfdf55bcb.tar.xz
hardflip-1c340dc589f5107d9956378e35637a0dfdf55bcb.tar.zst
hardflip-1c340dc589f5107d9956378e35637a0dfdf55bcb.zip
cool looking
Diffstat (limited to 'src')
-rw-r--r--src/c_defs.go1
-rw-r--r--src/i_events.go44
-rw-r--r--src/i_ui.go30
3 files changed, 57 insertions, 18 deletions
diff --git a/src/c_defs.go b/src/c_defs.go
index c54232e..6d49da9 100644
--- a/src/c_defs.go
+++ b/src/c_defs.go
@@ -75,6 +75,7 @@ const (
LOAD_MODE = 2
ERROR_MODE = 3
WELCOME_MODE = 4
+ MKDIR_MODE = 5
)
const (
diff --git a/src/i_events.go b/src/i_events.go
index 613709b..b543fc6 100644
--- a/src/i_events.go
+++ b/src/i_events.go
@@ -245,6 +245,18 @@ func i_delete_host(data *HardData) error {
return nil
}
+func i_readline(event *tcell.EventKey, data *HardData) {
+ 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.Rune() >= 32 && event.Rune() <= 126 {
+ data.ui.buff += string(event.Rune())
+ }
+}
+
// screen events such as keypresses
func i_events(data *HardData) {
ui := &data.ui
@@ -324,6 +336,9 @@ func i_events(data *HardData) {
} else if event.Key() == tcell.KeyCtrlR {
event = nil
i_reload_data(data)
+ } else if event.Rune() == 'm' ||
+ event.Key() == tcell.KeyF7 {
+ data.ui.mode = MKDIR_MODE
}
i_list_follow_cursor(data.litems, ui)
case DELETE_MODE:
@@ -365,22 +380,19 @@ func i_events(data *HardData) {
data.opts.GPG = ""
}
}
+ case MKDIR_MODE:
+ if event.Key() == tcell.KeyEscape ||
+ event.Key() == tcell.KeyCtrlC {
+ ui.s.HideCursor()
+ ui.buff = ""
+ ui.mode = NORMAL_MODE
+ } else if event.Key() == tcell.KeyEnter {
+ ui.s.HideCursor()
+ ui.buff = ""
+ ui.mode = NORMAL_MODE
+ } else {
+ i_readline(event, data)
+ }
}
-
}
}
-
-// readline type beat
-// 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())
-// }
diff --git a/src/i_ui.go b/src/i_ui.go
index 97921e0..1eccdcc 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -300,8 +300,8 @@ func i_prompt_gpg(ui HardUI, keys [][2]string) {
}
i_draw_text(ui.s,
1, ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
- ui.style[STYLE_BOT], "gpg: ")
- ui.s.ShowCursor(6 + len(ui.buff), ui.dim[H] - 1)
+ ui.style[STYLE_DEF], "gpg: ")
+ ui.s.ShowCursor(6, ui.dim[H] - 1)
}
func i_prompt_confirm_gpg(ui HardUI, opts HardOpts) {
@@ -323,6 +323,29 @@ func i_prompt_confirm_gpg(ui HardUI, opts HardOpts) {
ui.style[STYLE_DEF], opts.GPG)
}
+func i_draw_mkdir(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 := "mkdir: "
+ 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)"
@@ -554,6 +577,9 @@ func i_ui(data_dir string) {
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)
+ }
data.ui.s.Show()
i_events(&data)
}