aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-04-25 20:20:20 +0200
committerJoe <rbo@gmx.us>2024-04-25 20:20:20 +0200
commitd5096d447b67cb30cbf242fe708a4b911d57344f (patch)
treea3cedc0f780e53f942004ee112b7194a2a62f1f1
parentok (diff)
downloadhardflip-d5096d447b67cb30cbf242fe708a4b911d57344f.tar.gz
hardflip-d5096d447b67cb30cbf242fe708a4b911d57344f.tar.bz2
hardflip-d5096d447b67cb30cbf242fe708a4b911d57344f.tar.xz
hardflip-d5096d447b67cb30cbf242fe708a4b911d57344f.tar.zst
hardflip-d5096d447b67cb30cbf242fe708a4b911d57344f.zip
qwe
-rw-r--r--src/c_defs.go9
-rw-r--r--src/e_keys.go3
-rw-r--r--src/i_insert.go8
-rw-r--r--src/i_ui.go1
4 files changed, 16 insertions, 5 deletions
diff --git a/src/c_defs.go b/src/c_defs.go
index 438ad26..3e61fff 100644
--- a/src/c_defs.go
+++ b/src/c_defs.go
@@ -63,6 +63,8 @@ const (
NORMAL_KEYS_HINTS = `!a/i: insert host -
m: mkdir -
!s: search -
+e: edit -
+d: cut -
y: yank -
p: paste -
[C-r]: reload
@@ -165,6 +167,13 @@ const (
INS_OS_OK
)
+const (
+ INSERT_ADD = iota
+ INSERT_COPY
+ INSERT_MOVE
+ INSERT_EDIT
+)
+
var (
HOST_ICONS = [4]string{" ", " ", " ", " "}
DIRS_ICONS = [2]string{" ", " "}
diff --git a/src/e_keys.go b/src/e_keys.go
index c4c16ff..b418bbc 100644
--- a/src/e_keys.go
+++ b/src/e_keys.go
@@ -172,6 +172,7 @@ func e_normal_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
} else if event.Rune() == 'a' ||
event.Rune() == 'i' {
ui.mode = INSERT_MODE
+ ui.insert_method = INSERT_ADD
ui.insert_sel = 0
ui.insert_sel_ok = false
} else if event.Rune() == 'e' &&
@@ -182,6 +183,7 @@ func e_normal_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
e_set_protocol_max(data, data.insert)
e_set_drive_keys(data)
ui.mode = INSERT_MODE
+ ui.insert_method = INSERT_EDIT
ui.insert_sel = 0
ui.insert_sel_ok = false
} else if event.Key() == tcell.KeyCtrlR {
@@ -192,6 +194,7 @@ func e_normal_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
} else if event.Rune() == 'y' &&
(data.litems.curr == nil ||
data.litems.curr.is_dir() == true) == false {
+ ui.insert_method = INSERT_COPY
data.yank = data.litems.curr
ui.msg_buff = "yanked " + data.yank.Host.Name +
" (" + data.yank.Host.parent.path() + data.yank.Host.filename + ")"
diff --git a/src/i_insert.go b/src/i_insert.go
index 0bb55a8..58fba1e 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -139,13 +139,11 @@ func i_insert_host(data *HardData, insert *HostNode) {
insert.Drive = nil
}
filename := insert.filename
- replace := false
- if len(filename) == 0 || data.yank != nil {
+ if data.ui.insert_method == INSERT_ADD ||
+ data.ui.insert_method == INSERT_COPY {
filename = i_insert_format_filename(insert.Name,
data.data_dir + insert.parent.path())
insert.filename = filename
- } else {
- replace = true
}
fmt, err := yaml.Marshal(insert)
if err != nil {
@@ -160,7 +158,7 @@ func i_insert_host(data *HardData, insert *HostNode) {
data.insert = nil
return
}
- if replace == true && data.litems.curr != nil {
+ if data.ui.insert_method == INSERT_EDIT && data.litems.curr != nil {
tmp := e_deep_copy_host(data.insert)
data.litems.curr.Host = &tmp
data.litems.reset_id()
diff --git a/src/i_ui.go b/src/i_ui.go
index 1407e98..3df9f49 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -72,6 +72,7 @@ type HardUI struct {
insert_sel int
insert_sel_max int
insert_sel_ok bool
+ insert_method int
}
type Quad struct {