diff options
author | Joe <rbo@gmx.us> | 2024-09-09 18:33:04 +0200 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2024-09-09 18:33:04 +0200 |
commit | 0527dc94765eace6fb2096fb9105858d51b83deb (patch) | |
tree | 1b844e1ffa571f12ec3261f98936e7b0e9dec749 /src/c_litems.go | |
parent | fuck (diff) | |
download | hardflip-0527dc94765eace6fb2096fb9105858d51b83deb.tar.gz hardflip-0527dc94765eace6fb2096fb9105858d51b83deb.tar.bz2 hardflip-0527dc94765eace6fb2096fb9105858d51b83deb.tar.xz hardflip-0527dc94765eace6fb2096fb9105858d51b83deb.tar.zst hardflip-0527dc94765eace6fb2096fb9105858d51b83deb.zip |
gg
Diffstat (limited to '')
-rw-r--r-- | src/c_litems.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/c_litems.go b/src/c_litems.go index 9b07ab3..14afbf2 100644 --- a/src/c_litems.go +++ b/src/c_litems.go @@ -82,6 +82,27 @@ func (litems *ItemsList) add_back(node *ItemsNode) { litems.last = last.next } +// replaces an item +func (litems *ItemsList) overwrite(node *ItemsNode) { + if litems.head == nil || litems.curr == nil { + litems.add_back(node) + return + } + curr := litems.curr + node.prev = curr.prev + node.next = curr.next + if node.next != nil { + curr.next.prev = node + } + if litems.last == curr { + litems.last = node + } + if curr.prev != nil { + curr.prev.next = node + } + litems.curr = node +} + // 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 { |