in pkg/display/graph/tree/tree.go [38:111]
func Display(roots []*Node, serviceNames []string) error {
if err := ui.Init(); err != nil {
logger.Log.Fatalf("failed to initialize termui: %v", err)
}
defer ui.Close()
nodes := make([]*widgets.TreeNode, len(roots))
for i := range nodes {
nodes[i] = &widgets.TreeNode{}
}
for i, root := range roots {
adapt(root, nodes[i])
}
tree := widgets.NewTree()
tree.TextStyle = ui.Style{
Fg: ui.ColorWhite,
Bg: ui.ColorClear,
Modifier: 0,
}
tree.SelectedRowStyle = ui.Style{
Fg: ui.ColorBlack,
Bg: ui.ColorWhite,
Modifier: ui.ModifierBold,
}
tree.WrapText = false
tree.SetNodes(nodes)
tree.Title = fmt.Sprintf("[ %s ] [%s]", strings.Join(serviceNames, "->"), " Press ? to show help ")
tree.TitleStyle.Modifier = ui.ModifierBold
tree.TitleStyle.Fg = ui.ColorRed
x, y := ui.TerminalDimensions()
tree.SetRect(0, 0, x, y)
detail := widgets.NewParagraph()
detail.Title = Detail
detail.WrapText = false
detail.SetRect(x, 0, x, y)
help := widgets.NewParagraph()
help.WrapText = false
help.SetRect(x, 0, x, y)
help.Title = KeyMap
help.Text = `
[? ](fg:red,mod:bold) Toggle this help
[k ](fg:red,mod:bold) Scroll Up
[<Up> ](fg:red,mod:bold) Scroll Up
[j ](fg:red,mod:bold) Scroll Down
[<Down> ](fg:red,mod:bold) Scroll Down
[<Ctr-b> ](fg:red,mod:bold) Scroll Page Up
[<Ctr-u> ](fg:red,mod:bold) Scroll Half Page Up
[<Ctr-f> ](fg:red,mod:bold) Scroll Page Down
[<Ctr-d> ](fg:red,mod:bold) Scroll Half Page Down
[<Home> ](fg:red,mod:bold) Scroll to Top
[gg ](fg:red,mod:bold) Scroll to Top
[<Enter> ](fg:red,mod:bold) Show Trace Detail
[<Space> ](fg:red,mod:bold) Show Trace Detail
[o ](fg:red,mod:bold) Toggle Expand
[G ](fg:red,mod:bold) Scroll to Bottom
[<End> ](fg:red,mod:bold) Scroll to Bottom
[E ](fg:red,mod:bold) Expand All
[C ](fg:red,mod:bold) Collapse All
[q ](fg:red,mod:bold) Quit
[<Ctr-c> ](fg:red,mod:bold) Quit
`
ui.Render(tree, detail, help)
listenKeyboard(tree, detail, help)
return nil
}