aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ROADMAP.md2
-rw-r--r--src/e_events.go6
-rw-r--r--src/e_keys.go27
3 files changed, 26 insertions, 9 deletions
diff --git a/ROADMAP.md b/ROADMAP.md
index ee46988..40046cc 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -34,7 +34,7 @@
- [x] clone
- [x] ssh jump for rdp
- [x] edit
-- [ ] move
+- [x] move
- [ ] rename
## v0.7
diff --git a/src/e_events.go b/src/e_events.go
index 9a2b867..673fc1a 100644
--- a/src/e_events.go
+++ b/src/e_events.go
@@ -379,12 +379,6 @@ func e_deep_copy_host(base *HostNode) HostNode {
return new_host
}
-func e_paste_prepare_item(yank *ItemsNode) HostNode {
- new_host := e_deep_copy_host(yank.Host)
- new_host.Name += " (copy)"
- return new_host
-}
-
// func e_paste_item(litems *ItemsList, item ItemsNode) {
// curr := litems.curr
// }
diff --git a/src/e_keys.go b/src/e_keys.go
index 17e8189..d21b299 100644
--- a/src/e_keys.go
+++ b/src/e_keys.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/e_keys.go
- * Thu Apr 25 15:31:49 2024
+ * Thu Apr 25 15:49:50 2024
* Joe
*
* events in the keys
@@ -200,8 +200,22 @@ func e_normal_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
data.yank = data.litems.curr
ui.msg_buff = "yanked " + data.yank.Host.Name +
" (" + data.yank.Host.parent.path() + data.yank.Host.filename + ")"
+ } else if event.Rune() == 'd' &&
+ (data.litems.curr == nil ||
+ data.litems.curr.is_dir() == true) == false {
+ ui.insert_method = INSERT_MOVE
+ data.yank = data.litems.curr
+ ui.msg_buff = "yanked " + data.yank.Host.Name +
+ " (" + data.yank.Host.parent.path() + data.yank.Host.filename + ")"
} else if event.Rune() == 'p' && data.yank != nil {
- new_host := e_paste_prepare_item(data.yank)
+ new_host := e_deep_copy_host(data.yank.Host)
+ if ui.insert_method == INSERT_COPY {
+ new_host.Name += " (copy)"
+ } else if ui.insert_method == INSERT_MOVE && data.litems.curr != nil &&
+ data.litems.curr.path_node() == data.yank.path_node() {
+ data.yank = nil
+ return true
+ }
if data.litems.curr.is_dir() == true {
new_host.parent = data.litems.curr.Dirs
if data.folds[data.litems.curr.Dirs] != nil {
@@ -211,6 +225,15 @@ func e_normal_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
new_host.parent = data.litems.curr.Host.parent
}
i_insert_host(data, &new_host)
+ if ui.insert_method == INSERT_MOVE {
+ data.litems.del(data.yank)
+ file_path := data.data_dir + data.yank.Host.parent.path() +
+ data.yank.Host.filename
+ if err := os.Remove(file_path); err != nil {
+ c_error_mode("can't remove " + file_path, err, &data.ui)
+ return true
+ }
+ }
data.yank = nil
ui.msg_buff = "pasted " + new_host.Name
}