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
commit80e1dc0b0b8a358a1a9a04802d37ef55821e0ed9 (patch)
tree8be2d2ab57e42fae8335717e2cebea933e8dfa43
parentmove was fast too (diff)
downloadhardflip-80e1dc0b0b8a358a1a9a04802d37ef55821e0ed9.tar.gz
hardflip-80e1dc0b0b8a358a1a9a04802d37ef55821e0ed9.tar.bz2
hardflip-80e1dc0b0b8a358a1a9a04802d37ef55821e0ed9.tar.xz
hardflip-80e1dc0b0b8a358a1a9a04802d37ef55821e0ed9.tar.zst
hardflip-80e1dc0b0b8a358a1a9a04802d37ef55821e0ed9.zip
red
-rw-r--r--src/c_defs.go3
-rw-r--r--src/e_keys.go4
-rw-r--r--src/i_host.go3
-rw-r--r--src/i_insert.go9
-rw-r--r--src/i_ui.go3
5 files changed, 16 insertions, 6 deletions
diff --git a/src/c_defs.go b/src/c_defs.go
index 3e61fff..f16abaa 100644
--- a/src/c_defs.go
+++ b/src/c_defs.go
@@ -104,7 +104,8 @@ const (
TITLE_STYLE
BOT_STYLE
YANK_STYLE
- MAX_STYLE = YANK_STYLE
+ MOVE_STYLE
+ MAX_STYLE = MOVE_STYLE
)
const (
diff --git a/src/e_keys.go b/src/e_keys.go
index d21b299..20552d7 100644
--- a/src/e_keys.go
+++ b/src/e_keys.go
@@ -224,7 +224,9 @@ func e_normal_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
} else {
new_host.parent = data.litems.curr.Host.parent
}
- i_insert_host(data, &new_host)
+ if err := i_insert_host(data, &new_host); err != nil {
+ return true
+ }
if ui.insert_method == INSERT_MOVE {
data.litems.del(data.yank)
file_path := data.data_dir + data.yank.Host.parent.path() +
diff --git a/src/i_host.go b/src/i_host.go
index 2ad71d2..ed4ac77 100644
--- a/src/i_host.go
+++ b/src/i_host.go
@@ -82,6 +82,9 @@ func i_host_panel_host(ui HardUI, icons bool,
style := ui.style[DEF_STYLE]
if yank != nil && host == yank.Host {
style = ui.style[YANK_STYLE]
+ if ui.insert_method == INSERT_MOVE {
+ style = ui.style[MOVE_STYLE]
+ }
}
if host == curr {
// style = style.Background(tcell.ColorBlack)
diff --git a/src/i_insert.go b/src/i_insert.go
index 58fba1e..97dda36 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -132,7 +132,7 @@ func i_insert_default_users(insert *HostNode) {
}
}
-func i_insert_host(data *HardData, insert *HostNode) {
+func i_insert_host(data *HardData, insert *HostNode) error {
i_insert_abs_files(insert, data.home_dir)
i_insert_default_users(insert)
if len(insert.Drive) == 0 {
@@ -149,14 +149,14 @@ func i_insert_host(data *HardData, insert *HostNode) {
if err != nil {
c_error_mode("yaml", err, &data.ui)
data.insert = nil
- return
+ return err
}
err = os.WriteFile(data.data_dir + insert.parent.path() + filename,
fmt, 0644)
if err != nil {
c_error_mode("can't write file", err, &data.ui)
data.insert = nil
- return
+ return err
}
if data.ui.insert_method == INSERT_EDIT && data.litems.curr != nil {
tmp := e_deep_copy_host(data.insert)
@@ -164,7 +164,7 @@ func i_insert_host(data *HardData, insert *HostNode) {
data.litems.reset_id()
data.ui.mode = NORMAL_MODE
data.insert = nil
- return
+ return nil
}
// HACK: not sure if this is necessary
// if data.litems.curr.is_dir() == true {
@@ -199,6 +199,7 @@ func i_insert_host(data *HardData, insert *HostNode) {
data.litems.reset_id()
data.ui.mode = NORMAL_MODE
data.insert = nil
+ return nil
}
func i_insert_check_ok(data *HardData, in *HostNode) {
diff --git a/src/i_ui.go b/src/i_ui.go
index 3df9f49..e6155aa 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -653,6 +653,9 @@ func i_init_styles(ui *HardUI) {
ui.style[YANK_STYLE] = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.ColorYellow).Dim(true).Bold(true)
+ ui.style[MOVE_STYLE] = tcell.StyleDefault.
+ Background(tcell.ColorReset).
+ Foreground(tcell.ColorRed).Dim(true).Bold(true)
}
type key_event_mode_func func(*HardData, *HardUI, tcell.EventKey) bool