aboutsummaryrefslogtreecommitdiffstats
path: root/src/c_litems.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/c_litems.go')
-rw-r--r--src/c_litems.go21
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 {