MCPcopy Create free account
hub / github.com/Macmod/godap / treePanelKeyHandler

Function treePanelKeyHandler

tui/explorer.go:377–480  ·  view source on GitHub ↗
(event *tcell.EventKey)

Source from the content-addressed store, hash-verified

375}
376
377func treePanelKeyHandler(event *tcell.EventKey) *tcell.EventKey {
378 currentNode := treePanel.GetCurrentNode()
379 if currentNode == nil {
380 return event
381 }
382
383 parentNode := getParentNode(currentNode, treePanel)
384 baseDN := currentNode.GetReference().(string)
385
386 switch event.Rune() {
387 case 'r', 'R':
388 go app.QueueUpdateDraw(func() {
389 updateLog("Reloading node "+baseDN, "yellow")
390
391 explorerCache.Delete(baseDN)
392 reloadAttributesPanel(currentNode, explorerAttrsPanel, false, &explorerCache)
393
394 unloadChildren(currentNode)
395 loadChildren(currentNode)
396
397 updateLog("Node "+baseDN+" reloaded", "green")
398 })
399
400 return event
401 }
402
403 switch event.Key() {
404 case tcell.KeyRight:
405 expandTreeNode(currentNode)
406 return nil
407 case tcell.KeyLeft:
408 if currentNode.IsExpanded() { // Collapse current node
409 collapseTreeNode(currentNode)
410 treePanel.SetCurrentNode(currentNode)
411 return nil
412 } else { // Collapse parent node
413 pathToCurrent := treePanel.GetPath(currentNode)
414 if len(pathToCurrent) > 1 {
415 parentNode := pathToCurrent[len(pathToCurrent)-2]
416 collapseTreeNode(parentNode)
417 treePanel.SetCurrentNode(parentNode)
418 }
419 return nil
420 }
421 case tcell.KeyDelete:
422 openDeleteObjectForm(currentNode, func() {
423 explorerCache.Delete(baseDN)
424
425 if parentNode != nil {
426 idx := findEntryInChildren(baseDN, parentNode)
427
428 parent := reloadParentNode(currentNode)
429 otherNodeToSelect := parent
430
431 if idx > 0 {
432 siblings := parent.GetChildren()
433 otherNodeToSelect = siblings[idx-1]
434 }

Callers

nothing calls this directly

Calls 15

getParentNodeFunction · 0.85
updateLogFunction · 0.85
reloadAttributesPanelFunction · 0.85
unloadChildrenFunction · 0.85
loadChildrenFunction · 0.85
expandTreeNodeFunction · 0.85
collapseTreeNodeFunction · 0.85
openDeleteObjectFormFunction · 0.85
findEntryInChildrenFunction · 0.85
reloadParentNodeFunction · 0.85
reloadExplorerPageFunction · 0.85
openCreateObjectFormFunction · 0.85

Tested by

no test coverage detected