organizing the code a bit better

This commit is contained in:
2026-06-09 14:51:11 +01:00
parent 99a4f794c5
commit d3c4464aa0
2 changed files with 25 additions and 21 deletions
+23
View File
@@ -0,0 +1,23 @@
package tviewhelpers
import "github.com/rivo/tview"
func FindNodeByID(node *tview.TreeNode, id int16) *tview.TreeNode {
if node == nil {
return nil
}
if ref, ok := node.GetReference().(int16); ok {
if ref == id {
return node
}
}
for _, child := range node.GetChildren() {
if found := FindNodeByID(child, id); found != nil {
return found
}
}
return nil
}