diff options
author | Joe <rbo@gmx.us> | 2024-05-13 20:20:20 +0200 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2024-05-13 20:20:20 +0200 |
commit | 0ddfbf62fde8b8e0bde9a548b203d67b812ab61e (patch) | |
tree | 9843ed6d3420f1295e2b30355cfa743d4fa62202 /src/c_litems.go | |
parent | gg (diff) | |
download | hardflip-0ddfbf62fde8b8e0bde9a548b203d67b812ab61e.tar.gz hardflip-0ddfbf62fde8b8e0bde9a548b203d67b812ab61e.tar.bz2 hardflip-0ddfbf62fde8b8e0bde9a548b203d67b812ab61e.tar.xz hardflip-0ddfbf62fde8b8e0bde9a548b203d67b812ab61e.tar.zst hardflip-0ddfbf62fde8b8e0bde9a548b203d67b812ab61e.zip |
fix
Diffstat (limited to '')
-rw-r--r-- | src/c_litems.go | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/c_litems.go b/src/c_litems.go index 3f5a654..2b92816 100644 --- a/src/c_litems.go +++ b/src/c_litems.go @@ -82,6 +82,22 @@ func (litems *ItemsList) add_back(node *ItemsNode) { litems.last = last.next } +// adds an item node to the list after the current selected item +func (litems *ItemsList) add_after(node *ItemsNode) { + if litems.head == nil || litems.curr == nil { + litems.add_back(node) + return + } + curr := litems.curr + node.prev = curr + node.next = curr.next + curr.next = node + if litems.last == curr { + litems.last = node + } + litems.curr = node +} + // removes an item node from the list and resets the ids func (litems *ItemsList) del(item *ItemsNode) { if litems.head == nil { @@ -122,22 +138,6 @@ func (litems *ItemsList) del(item *ItemsNode) { } } -// 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 |