aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2023-12-20 20:20:20 +0100
committerJoe <rbo@gmx.us>2023-12-20 20:20:20 +0100
commitb85ff5ba517f29928eeb35a0ffe10bcd7ba4309b (patch)
tree3cb593a6cdc905860fc4241d2d93b49389f1ed70
parentrefactor (diff)
downloadhardflip-b85ff5ba517f29928eeb35a0ffe10bcd7ba4309b.tar.gz
hardflip-b85ff5ba517f29928eeb35a0ffe10bcd7ba4309b.tar.bz2
hardflip-b85ff5ba517f29928eeb35a0ffe10bcd7ba4309b.tar.xz
hardflip-b85ff5ba517f29928eeb35a0ffe10bcd7ba4309b.tar.zst
hardflip-b85ff5ba517f29928eeb35a0ffe10bcd7ba4309b.zip
in progress
-rw-r--r--c_defs.go2
-rw-r--r--i_events.go2
-rw-r--r--i_ui.go40
3 files changed, 23 insertions, 21 deletions
diff --git a/c_defs.go b/c_defs.go
index 9b6d1f5..78daf3c 100644
--- a/c_defs.go
+++ b/c_defs.go
@@ -59,4 +59,6 @@ const (
(c-r) reload -
[x](?) help`
DATA_DIR_NAME = "hardflip"
+ NORMAL_MODE = 0
+ DELETE_MODE = 1
)
diff --git a/i_events.go b/i_events.go
index df96cab..c1a3951 100644
--- a/i_events.go
+++ b/i_events.go
@@ -96,7 +96,7 @@ func i_events(data *HardData) {
ui.sel = ui.sel_max - 1
}
if event.Rune() == 'D' {
- ui.delete_mode = true
+ ui.mode = DELETE_MODE
ui.delete_id = ui.sel
}
if event.Key() == tcell.KeyEnter {
diff --git a/i_ui.go b/i_ui.go
index d6c3c63..0ac7e60 100644
--- a/i_ui.go
+++ b/i_ui.go
@@ -57,12 +57,11 @@ import (
type HardUI struct {
s tcell.Screen
list_start int
- delete_mode bool
+ mode uint8
delete_id uint64
sel uint64
sel_max uint64
def_style tcell.Style
- bot_style tcell.Style
dim [2]int
}
@@ -144,6 +143,23 @@ func i_draw_zhosts_box(ui HardUI) {
ui.def_style, text)
}
+func i_draw_delete_box(ui HardUI, host *HostNode) {
+ // file_path := data.data_dir + "/" + host.Folder + host.Filename
+ text := "Do you really want to delete host " +
+ host.Folder + host.Filename + "?"
+ left, right :=
+ (ui.dim[W] / 2) - (len(text) / 2) - 5,
+ (ui.dim[W] / 2) + (len(text) / 2) + 5
+ top, bot :=
+ (ui.dim[H] / 2) - 3,
+ (ui.dim[H] / 2) + 3
+ i_draw_box(ui.s, left, top, right, bot, "")
+ // if err := os.Remove(file_path); err != nil {
+ // c_die("can't remove " + file_path, err)
+ // }
+ // i_reload_data(data, sel, sel_max)
+}
+
func i_host_panel(ui HardUI, lhost *HostList) {
i_draw_box(ui.s, 0, 0,
ui.dim[W] / 3, ui.dim[H] - 2,
@@ -377,9 +393,6 @@ func i_ui(data *HardData) {
ui.def_style = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.ColorReset)
- ui.bot_style = tcell.StyleDefault.
- Background(tcell.ColorReset).
- Foreground(tcell.ColorGrey)
ui.s.SetStyle(ui.def_style)
for {
ui.dim[W], ui.dim[H], _ = term.GetSize(0)
@@ -390,22 +403,9 @@ func i_ui(data *HardData) {
if data.lhost.head == nil {
i_draw_zhosts_box(*ui)
}
- if ui.delete_mode == true {
+ if ui.mode == DELETE_MODE {
host := data.lhost.sel(ui.sel)
- // file_path := data.data_dir + "/" + host.Folder + host.Filename
- text := "Do you really want to delete host " +
- host.Folder + host.Filename + "?"
- left, right :=
- (ui.dim[W] / 2) - (len(text) / 2) - 5,
- (ui.dim[W] / 2) + (len(text) / 2) + 5
- top, bot :=
- (ui.dim[H] / 2) - 3,
- (ui.dim[H] / 2) + 3
- i_draw_box(ui.s, left, top, right, bot, text)
- // if err := os.Remove(file_path); err != nil {
- // c_die("can't remove " + file_path, err)
- // }
- // i_reload_data(data, sel, sel_max)
+ i_draw_delete_box(*ui, host)
}
ui.s.Show()
i_events(data)