aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--c_hardflip.go22
-rw-r--r--c_litems.go23
-rw-r--r--i_events.go4
-rw-r--r--i_ui.go4
4 files changed, 36 insertions, 17 deletions
diff --git a/c_hardflip.go b/c_hardflip.go
index 2181207..7e75444 100644
--- a/c_hardflip.go
+++ b/c_hardflip.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/c_hardflip.go
- * Fri Jan 05 14:41:26 2024
+ * Fri Jan 05 16:10:29 2024
* Joe
*
* the main
@@ -51,12 +51,11 @@
package main
-import "fmt"
+// import "fmt"
// the main data structure, holds up everything important
type HardData struct {
litems *ItemsList
- ptr *ItemsNode
ldirs *DirsList
ui HardUI
opts HardOpts
@@ -64,7 +63,7 @@ type HardData struct {
}
func main() {
- // TODO: delete data.ptr | replace everything ui with litems
+ // TODO: replace everything ui with litems
data_dir := c_get_data_dir()
opts := HardOpts{true, true, false}
ldirs := c_load_data_dir(data_dir, opts)
@@ -103,15 +102,14 @@ func main() {
// fmt.Println(host.ID, host.Name, "HOST")
// }
// }
- for item := litems.head; item != nil ; item = item.next {
- if item.is_dir() == true {
- fmt.Println(item.ID, item.Dirs.Name)
- } else {
- fmt.Println(item.ID, item.Host.Name)
- }
- }
+ // for item := litems.head; item != nil; item = item.next {
+ // if item.is_dir() == true {
+ // fmt.Println(item.ID, item.Dirs.Name)
+ // } else {
+ // fmt.Println(item.ID, item.Host.Name)
+ // }
+ // }
- return
// PERF: test performance over a large amount of hosts with litems
i_ui(&data)
}
diff --git a/c_litems.go b/c_litems.go
index 44831ff..68d7137 100644
--- a/c_litems.go
+++ b/c_litems.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/c_litems.go
- * Fri Jan 05 12:29:08 2024
+ * Fri Jan 05 15:04:07 2024
* Joe
*
* the dir and hosts linked list
@@ -62,8 +62,10 @@ type ItemsNode struct {
type ItemsList struct {
head *ItemsNode
last *ItemsNode
+ curr *ItemsNode
}
+// adds an item node to the list
func (litems *ItemsList) add_back(node *ItemsNode) {
if litems.head == nil {
litems.head = node
@@ -77,6 +79,22 @@ func (litems *ItemsList) add_back(node *ItemsNode) {
litems.last = last.next
}
+// sets litems.curr to be used
+func (litems *ItemsList) sel(id int) {
+ curr := litems.head
+
+ if curr == nil {
+ litems.curr = nil
+ }
+ for curr.next != nil && curr.ID != id {
+ curr = curr.next
+ }
+ if curr.ID != id {
+ litems.curr = nil
+ }
+ litems.curr = curr
+}
+
func (item *ItemsNode) is_dir() bool {
if item.Dirs == nil {
return false
@@ -85,6 +103,9 @@ func (item *ItemsNode) is_dir() bool {
}
func (item *ItemsNode) inc(jump int) *ItemsNode {
+ if item == nil {
+ return nil
+ }
if jump == 0 {
return item
} else if jump == 1 {
diff --git a/i_events.go b/i_events.go
index a95666a..3afbac0 100644
--- a/i_events.go
+++ b/i_events.go
@@ -115,9 +115,9 @@ func i_events(data *HardData) {
ui.sel_max != 0 {
ui.mode = DELETE_MODE
} else if event.Key() == tcell.KeyEnter {
- if data.ptr != nil && data.ptr.is_dir() == false {
+ if data.litems.curr != nil && data.litems.curr.is_dir() == false {
ui.s.Fini()
- c_exec(data.ptr.get_self_host())
+ c_exec(data.litems.curr.Host)
if data.opts.Loop == false {
os.Exit(0)
} else {
diff --git a/i_ui.go b/i_ui.go
index ca3cbe4..51ba600 100644
--- a/i_ui.go
+++ b/i_ui.go
@@ -78,7 +78,7 @@ func (ui *HardUI) inc_sel(n int, data *HardData) {
n = 0
}
ui.line += n
- data.sel_unique_id(ui.line)
+ data.litems.curr = data.litems.curr.inc(n)
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 {
@@ -326,8 +326,8 @@ func i_host_panel(ui HardUI, icons bool, ldirs *DirsList) {
func i_info_panel(ui HardUI, lhost *HostList) {
var host *HostNode
- curr_line := 2
var host_type string
+ curr_line := 2
i_draw_box(ui.s, (ui.dim[W] / 3), 0,
ui.dim[W] - 1, ui.dim[H] - 2,