aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2023-12-27 20:20:20 +0100
committerJoe <rbo@gmx.us>2023-12-27 20:20:20 +0100
commit1578a5dc80edba9106a0c18282e3b69231a91b2a (patch)
treef37b71ada56577a189811662ac7cd777c3c475d2
parentdef (diff)
downloadhardflip-1578a5dc80edba9106a0c18282e3b69231a91b2a.tar.gz
hardflip-1578a5dc80edba9106a0c18282e3b69231a91b2a.tar.bz2
hardflip-1578a5dc80edba9106a0c18282e3b69231a91b2a.tar.xz
hardflip-1578a5dc80edba9106a0c18282e3b69231a91b2a.tar.zst
hardflip-1578a5dc80edba9106a0c18282e3b69231a91b2a.zip
cool
-rw-r--r--c_defs.go16
-rw-r--r--i_ui.go87
2 files changed, 62 insertions, 41 deletions
diff --git a/c_defs.go b/c_defs.go
index 4f57145..55a9438 100644
--- a/c_defs.go
+++ b/c_defs.go
@@ -39,7 +39,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/c_defs.go
- * Wed Dec 27 12:37:08 2023
+ * Wed Dec 27 15:55:11 2023
* Joe
*
* constants
@@ -50,7 +50,11 @@ package main
const (
W = 0
H = 1
- KEYS_HINTS = `
+ DATA_DIR_NAME = "hardflip"
+)
+
+const (
+ NORMAL_KEYS_HINTS = `
(q)uit -
[x](a)dd/(i)nsert host -
[x](e)dit -
@@ -59,7 +63,13 @@ const (
[x](m)kdir -
(c-r) reload -
[x](?) help`
- DATA_DIR_NAME = "hardflip"
+ DELETE_KEYS_HINTS = `
+(q)uit -
+(y)yes -
+(n)o`
+)
+
+const (
NORMAL_MODE = 0
DELETE_MODE = 1
)
diff --git a/i_ui.go b/i_ui.go
index 512109a..bd32b3d 100644
--- a/i_ui.go
+++ b/i_ui.go
@@ -125,13 +125,20 @@ func i_draw_box(s tcell.Screen, x1, y1, x2, y2 int, title string, fill bool) {
func i_bottom_text(ui HardUI) {
spaces := ""
+ text := ""
- for i := 0; i < (ui.dim[W]) - len(KEYS_HINTS); i++ {
+ switch ui.mode {
+ case NORMAL_MODE:
+ text = NORMAL_KEYS_HINTS
+ case DELETE_MODE:
+ text = DELETE_KEYS_HINTS
+ }
+ for i := 0; i < (ui.dim[W]) - len(text); i++ {
spaces += " "
}
i_draw_text(ui.s,
0, ui.dim[H] - 1, ui.dim[W], ui.dim[H] - 1,
- ui.def_style.Dim(true), spaces + KEYS_HINTS)
+ ui.def_style.Dim(true), spaces + text)
}
func i_draw_zhosts_box(ui HardUI) {
@@ -209,17 +216,9 @@ func i_draw_delete_box(ui HardUI, host *HostNode) {
// ui.def_style, "o")
}
-func i_host_panel_dirs() {
-}
-
-func i_host_panel_host() {
-}
-
-func i_host_panel(ui HardUI, opts HardOpts, ldirs *DirsList) {
- i_draw_box(ui.s, 0, 0,
- ui.dim[W] / 3, ui.dim[H] - 2,
- " Hosts ", false)
+func i_host_panel_dirs(ui HardUI, opts HardOpts, ldirs *DirsList) {
dirs := ldirs.head
+
for i := 0; i < ui.list_start && dirs.next != nil; i++ {
dirs = dirs.next
}
@@ -251,33 +250,45 @@ func i_host_panel(ui HardUI, opts HardOpts, ldirs *DirsList) {
1, line, ui.dim[W] / 3, line,
style, text)
line++
- host := dirs.lhost.head
- for dirs.Folded == false && host != nil {
- style := ui.def_style
- if ui.sel == dirs.ID {
- style = style.Reverse(true)
- }
- text := ""
- for i := 0; i < int(dirs.Depth) - 2; i++ {
- text += " "
- }
- if opts.Icon == true {
- text += HOST_ICONS[int(host.Protocol)]
- }
- text += host.Name
- spaces := ""
- for i := 0; i < (ui.dim[W] / 3) - len(text) + 1; i++ {
- spaces += " "
- }
- text += spaces
- i_draw_text(ui.s,
- 1, line, ui.dim[W] / 3, line,
- style, text)
- line++
- host = host.next
- }
+ i_host_panel_host(ui, opts, dirs, &line)
dirs = dirs.next
}
+}
+
+func i_host_panel_host(ui HardUI, opts HardOpts, dirs *DirsNode, line *int) {
+ host := dirs.lhost.head
+
+ for dirs.Folded == false && host != nil {
+ style := ui.def_style
+ if ui.sel == dirs.ID {
+ style = style.Reverse(true)
+ }
+ text := ""
+ for i := 0; i < int(dirs.Depth) - 2; i++ {
+ text += " "
+ }
+ if opts.Icon == true {
+ text += HOST_ICONS[int(host.Protocol)]
+ }
+ text += host.Name
+ spaces := ""
+ for i := 0; i < (ui.dim[W] / 3) - len(text) + 1; i++ {
+ spaces += " "
+ }
+ text += spaces
+ i_draw_text(ui.s,
+ 1, *line, ui.dim[W] / 3, *line,
+ style, text)
+ *line++
+ host = host.next
+ }
+}
+
+func i_host_panel(ui HardUI, opts HardOpts, ldirs *DirsList) {
+ i_draw_box(ui.s, 0, 0,
+ ui.dim[W] / 3, ui.dim[H] - 2,
+ " Hosts ", false)
+ i_host_panel_dirs(ui, opts, ldirs)
if ui.sel_max == 0 {
i_draw_text(ui.s,
1, ui.dim[H] - 2, (ui.dim[W] / 3) - 1, ui.dim[H] - 2,
@@ -505,7 +516,7 @@ func i_ui(data *HardData) {
// TODO - info panel
// i_info_panel(data.ui, data.lhost)
- if ui.sel_max == 0 {
+ if data.ldirs.head.lhost.head == nil && data.ldirs.head.next == nil {
i_draw_zhosts_box(*ui)
}
if ui.mode == DELETE_MODE {