func listenKeyboard()

in pkg/display/graph/tree/tree.go [156:198]


func listenKeyboard(tree *widgets.Tree, detail, help *widgets.Paragraph) {
	var previousKey string
	var previousSelected *Node

	visibilities := make(map[interface{}]bool)

	uiEvents := ui.PollEvents()

	for {
		e := <-uiEvents

		switch e.ID {
		case "q", Quit:
			return
		case "g":
			if previousKey == "g" {
				tree.ScrollTop()
			}
		case "<Enter>", "<Space>":
			selected := extra[tree.SelectedNode()]
			detail.Text = selected.Detail

			selectionChanged := previousSelected != selected
			visibilities[detail] = selectionChanged || !visibilities[detail]

			previousSelected = selected
		case "?":
			visibilities[help] = !visibilities[help]
		default:
			if action := actions(e.ID, tree); action != nil {
				action()
			}
		}

		if previousKey == "g" {
			previousKey = ""
		} else {
			previousKey = e.ID
		}

		redraw(visibilities, tree, detail, help)
	}
}