aboutsummaryrefslogtreecommitdiffstats
path: root/src/i_events.go
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
commit39013067acc3428d6751f4af828488b90a56c94c (patch)
tree2e4b117a49b0946b262a295e822b9aacc6bb914c /src/i_events.go
parentyes (diff)
downloadhardflip-39013067acc3428d6751f4af828488b90a56c94c.tar.gz
hardflip-39013067acc3428d6751f4af828488b90a56c94c.tar.bz2
hardflip-39013067acc3428d6751f4af828488b90a56c94c.tar.xz
hardflip-39013067acc3428d6751f4af828488b90a56c94c.tar.zst
hardflip-39013067acc3428d6751f4af828488b90a56c94c.zip
tmp
Diffstat (limited to 'src/i_events.go')
-rw-r--r--src/i_events.go45
1 files changed, 31 insertions, 14 deletions
diff --git a/src/i_events.go b/src/i_events.go
index 0a4d9e7..7b4f38c 100644
--- a/src/i_events.go
+++ b/src/i_events.go
@@ -257,6 +257,36 @@ func i_readline(event *tcell.EventKey, data *HardData) {
}
}
+func i_mkdir(data *HardData, ui *HardUI) {
+ if len(ui.buff) == 0 {
+ return
+ }
+ path := "/"
+ if data.litems.curr != nil {
+ if data.litems.curr.is_dir() == true {
+ path = data.litems.curr.Dirs.path()
+ } else {
+ path = data.litems.curr.Host.Parent.path()
+ }
+ }
+ if err := os.MkdirAll(data.data_dir +
+ path +
+ ui.buff, os.ModePerm); err != nil {
+ c_error_mode("mkdir " + path[1:] + ui.buff + " failed",
+ err, ui)
+ return
+ }
+ i_reload_data(data)
+ for curr := data.litems.head; curr != nil; curr = curr.next {
+ if curr.is_dir() == true &&
+ curr.Dirs.Name == ui.buff &&
+ curr.Dirs.Parent.path() == path {
+ data.litems.curr = curr
+ return
+ }
+ }
+}
+
// screen events such as keypresses
func i_events(data *HardData) {
ui := &data.ui
@@ -387,22 +417,9 @@ func i_events(data *HardData) {
ui.buff = ""
ui.mode = NORMAL_MODE
} else if event.Key() == tcell.KeyEnter {
+ i_mkdir(data, ui)
ui.s.HideCursor()
ui.mode = NORMAL_MODE
- if data.litems.curr != nil && len(ui.buff) > 0 {
- path := ""
- if data.litems.curr.is_dir() == true {
- path = data.litems.curr.Dirs.path()
- } else {
- path = data.litems.curr.Host.Parent.path()
- }
- if err := os.MkdirAll(data.data_dir +
- path +
- ui.buff, os.ModePerm); err != nil {
- c_error_mode("mkdir " + path + ui.buff, err, ui)
- }
- }
- i_reload_data(data)
ui.buff = ""
} else {
i_readline(event, data)