aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-09-09 18:33:04 +0200
committerJoe <rbo@gmx.us>2024-09-09 18:33:04 +0200
commit0527dc94765eace6fb2096fb9105858d51b83deb (patch)
tree1b844e1ffa571f12ec3261f98936e7b0e9dec749
parentfuck (diff)
downloadhardflip-0527dc94765eace6fb2096fb9105858d51b83deb.tar.gz
hardflip-0527dc94765eace6fb2096fb9105858d51b83deb.tar.bz2
hardflip-0527dc94765eace6fb2096fb9105858d51b83deb.tar.xz
hardflip-0527dc94765eace6fb2096fb9105858d51b83deb.tar.zst
hardflip-0527dc94765eace6fb2096fb9105858d51b83deb.zip
gg
-rw-r--r--src/c_litems.go21
-rw-r--r--src/e_keys.go1
-rw-r--r--src/i_insert.go4
3 files changed, 24 insertions, 2 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 {
diff --git a/src/e_keys.go b/src/e_keys.go
index d46df05..56164e0 100644
--- a/src/e_keys.go
+++ b/src/e_keys.go
@@ -656,6 +656,7 @@ func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
data.insert.parent = parent
data.insert.filename = filename
data.insert.Protocol = int8(event.Rune() - 48 - 1)
+ data.litems.curr.Host.Protocol = data.insert.Protocol
ui.insert_sel_ok = false
ui.s.HideCursor()
e_set_protocol_defaults(data, data.insert)
diff --git a/src/i_insert.go b/src/i_insert.go
index 1a2575c..abe5c30 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -183,12 +183,12 @@ func i_insert_host(data *HardData, insert *HostNode) error {
0,
nil,
insert,
- data.litems.curr,
+ data.litems.curr.prev,
next,
}
curr := data.litems.curr
if curr != nil {
- data.litems.add_after(item)
+ data.litems.overwrite(item)
// curr.next = item
// if curr.next.next != nil {
// data.litems.curr.next.next.prev = item