aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ROADMAP.md1
-rw-r--r--src/c_defs.go3
-rw-r--r--src/e_events.go10
-rw-r--r--src/e_keys.go24
-rw-r--r--src/i_insert.go3
-rw-r--r--src/i_ui.go14
6 files changed, 48 insertions, 7 deletions
diff --git a/ROADMAP.md b/ROADMAP.md
index 40046cc..3ef8558 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -56,6 +56,7 @@
## v1.1 - 360 hard
- [ ] fuzz
+- [ ] rename dirs
## v1.2 - ghetto bird
diff --git a/src/c_defs.go b/src/c_defs.go
index f16abaa..53c8317 100644
--- a/src/c_defs.go
+++ b/src/c_defs.go
@@ -82,7 +82,8 @@ const (
WELCOME_MODE
MKDIR_MODE
INSERT_MODE
- MODE_MAX = INSERT_MODE
+ RENAME_MODE
+ MODE_MAX = RENAME_MODE
)
const (
diff --git a/src/e_events.go b/src/e_events.go
index 673fc1a..60f7db9 100644
--- a/src/e_events.go
+++ b/src/e_events.go
@@ -316,6 +316,16 @@ func e_mkdir(data *HardData, ui *HardUI) {
}
}
+func e_rename(data *HardData, ui *HardUI) {
+ if len(ui.buff) == 0 ||
+ data.litems.curr == nil || data.litems.curr.is_dir() == true {
+ return
+ }
+ data.litems.curr.Host.Name = ui.buff
+ // ui.insert_method = INSERT_MOVE
+ // i_insert_host(data, new_host)
+}
+
func e_set_drive_keys(data *HardData) {
data.insert.drive_keys = nil
for key := range data.insert.Drive {
diff --git a/src/e_keys.go b/src/e_keys.go
index 20552d7..d160f47 100644
--- a/src/e_keys.go
+++ b/src/e_keys.go
@@ -238,6 +238,14 @@ func e_normal_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
}
data.yank = nil
ui.msg_buff = "pasted " + new_host.Name
+ } else if (event.Rune() == 'c' ||
+ event.Rune() == 'C' ||
+ event.Rune() == 'r' ||
+ event.Rune() == 'R') &&
+ data.litems.curr != nil &&
+ data.litems.curr.is_dir() == false {
+ ui.mode = RENAME_MODE
+ ui.buff = data.litems.curr.Host.Name
}
return false
}
@@ -766,3 +774,19 @@ func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
}
return false
}
+
+func e_rename_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
+ if event.Key() == tcell.KeyEscape ||
+ event.Key() == tcell.KeyCtrlC {
+ data.insert = nil
+ } else if event.Key() == tcell.KeyEnter {
+ e_rename(data, ui)
+ } else {
+ e_readline(event, &ui.buff)
+ return true
+ }
+ ui.s.HideCursor()
+ ui.mode = NORMAL_MODE
+ ui.buff = ""
+ return false
+}
diff --git a/src/i_insert.go b/src/i_insert.go
index 97dda36..8ea6754 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -140,7 +140,8 @@ func i_insert_host(data *HardData, insert *HostNode) error {
}
filename := insert.filename
if data.ui.insert_method == INSERT_ADD ||
- data.ui.insert_method == INSERT_COPY {
+ data.ui.insert_method == INSERT_COPY ||
+ data.ui.insert_method == INSERT_MOVE {
filename = i_insert_format_filename(insert.Name,
data.data_dir + insert.parent.path())
insert.filename = filename
diff --git a/src/i_ui.go b/src/i_ui.go
index e6155aa..dc7165e 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/i_ui.go
- * Thu Apr 18 16:59:53 2024
+ * Thu Apr 25 16:20:41 2024
* Joe
*
* interfacing with the user
@@ -710,6 +710,7 @@ func i_ui(data_dir string) {
WELCOME_MODE: e_welcome_events,
MKDIR_MODE: e_mkdir_events,
INSERT_MODE: e_insert_events,
+ RENAME_MODE: e_rename_events,
}
for {
data.ui.s.Clear()
@@ -730,13 +731,14 @@ func i_ui(data_dir string) {
} else if data.litems.head == nil {
i_draw_zhosts_box(data.ui)
}
- if data.ui.mode == DELETE_MODE {
+ switch data.ui.mode {
+ case DELETE_MODE:
i_draw_delete_msg(data.ui, data.litems.curr)
- } else if data.ui.mode == ERROR_MODE {
+ case ERROR_MODE:
i_draw_error_msg(data.ui, data.load_err)
- } else if data.ui.mode == MKDIR_MODE {
+ case MKDIR_MODE:
i_prompt_mkdir(data.ui, data.litems.curr)
- } else if data.ui.mode == INSERT_MODE {
+ case INSERT_MODE:
if data.insert == nil {
i_prompt_insert(data.ui, data.litems.curr)
} else {
@@ -745,6 +747,8 @@ func i_ui(data_dir string) {
i_draw_insert_err_msg(data.ui, data.insert_err)
}
}
+ case RENAME_MODE:
+ i_prompt_insert(data.ui, data.litems.curr)
}
data.ui.s.Show()
e_events(&data, fp)