aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-01-04 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-01-04 20:20:20 +0100
commit303764a80bf0e4a79a463d2dd41b7baad6c38038 (patch)
tree21a2e67b3e7c274a7ccdce329187140f80c5eb35
parentworks for now (diff)
downloadhardflip-303764a80bf0e4a79a463d2dd41b7baad6c38038.tar.gz
hardflip-303764a80bf0e4a79a463d2dd41b7baad6c38038.tar.bz2
hardflip-303764a80bf0e4a79a463d2dd41b7baad6c38038.tar.xz
hardflip-303764a80bf0e4a79a463d2dd41b7baad6c38038.tar.zst
hardflip-303764a80bf0e4a79a463d2dd41b7baad6c38038.zip
awy
-rw-r--r--c_hardflip.go16
-rw-r--r--c_ldirs.go4
-rw-r--r--c_lhosts.go4
-rw-r--r--i_events.go4
-rw-r--r--i_ui.go13
5 files changed, 32 insertions, 9 deletions
diff --git a/c_hardflip.go b/c_hardflip.go
index 2e6dd5c..f54320b 100644
--- a/c_hardflip.go
+++ b/c_hardflip.go
@@ -55,6 +55,7 @@ package main
type HardPtr interface {
is_dir() bool
+ get_id() int
get_self_dirs() *DirsNode
get_self_host() *HostNode
}
@@ -77,6 +78,21 @@ func c_reset_ptr(data *HardData) {
}
}
+func (data *HardData) sel_unique_id(id int) {
+ for ptr := data.ldirs.head; ptr != nil; ptr = ptr.next {
+ if ptr.ID == id {
+ data.ptr = ptr
+ return
+ }
+ for ptr := ptr.lhost.head; ptr != nil; ptr = ptr.next {
+ if ptr.ID == id {
+ data.ptr = ptr
+ return
+ }
+ }
+ }
+}
+
func main() {
data_dir := c_get_data_dir()
opts := HardOpts{true, true, false}
diff --git a/c_ldirs.go b/c_ldirs.go
index 82b3607..880c1b7 100644
--- a/c_ldirs.go
+++ b/c_ldirs.go
@@ -131,6 +131,10 @@ func (dir *DirsNode) is_dir() bool {
return true
}
+func (dir *DirsNode) get_id() int {
+ return dir.ID
+}
+
func (dir *DirsNode) get_self_dirs() *DirsNode {
return dir
}
diff --git a/c_lhosts.go b/c_lhosts.go
index 986fd71..c3d2c77 100644
--- a/c_lhosts.go
+++ b/c_lhosts.go
@@ -157,6 +157,10 @@ func (host *HostNode) is_dir() bool {
return false
}
+func (host *HostNode) get_id() int {
+ return host.ID
+}
+
func (host *HostNode) get_self_dirs() *DirsNode {
return nil
}
diff --git a/i_events.go b/i_events.go
index 7f585de..614ef94 100644
--- a/i_events.go
+++ b/i_events.go
@@ -98,12 +98,12 @@ func i_events(data *HardData) {
} else if event.Rune() == 'j' ||
event.Key() == tcell.KeyDown {
if ui.line < ui.sel_max - 1 {
- ui.inc_sel(1)
+ ui.inc_sel(1, data)
}
} else if event.Rune() == 'k' ||
event.Key() == tcell.KeyUp {
if ui.line > 0 {
- ui.inc_sel(-1)
+ ui.inc_sel(-1, data)
}
} else if event.Rune() == 'g' {
ui.line = 0
diff --git a/i_ui.go b/i_ui.go
index f3f042a..c2b116a 100644
--- a/i_ui.go
+++ b/i_ui.go
@@ -72,14 +72,13 @@ type HardUI struct {
dim [2]int
}
-func (ui *HardUI) inc_sel(n int) {
- ui.line += n
- if ui.line < 1 {
- ui.line = 1
- }
- if ui.line >= ui.sel_max {
- ui.line = ui.sel_max - 1
+func (ui *HardUI) inc_sel(n int, data *HardData) {
+ if ui.line + n < 1 ||
+ ui.line + n >= ui.sel_max {
+ n = 0
}
+ ui.line += n
+ data.sel_unique_id(ui.line)
if ui.line > ui.list_start + ui.dim[H] - 4 {
ui.list_start = (ui.line + 1) - (ui.dim[H] + 3)
} else if ui.line < ui.list_start {