MCPcopy
hub / github.com/mum4k/termdash / Example_triggered

Function Example_triggered

termdash_test.go:87–122  ·  view source on GitHub ↗

Example shows how to setup and run termdash with manually triggered redraw.

()

Source from the content-addressed store, hash-verified

85
86// Example shows how to setup and run termdash with manually triggered redraw.
87func Example_triggered() {
88 // Create the terminal.
89 t, err := tcell.New()
90 if err != nil {
91 panic(err)
92 }
93 defer t.Close()
94
95 // Create a widget.
96 bc, err := barchart.New()
97 if err != nil {
98 panic(err)
99 }
100
101 // Create the container with a widget.
102 c, err := container.New(
103 t,
104 container.PlaceWidget(bc),
105 )
106 if err != nil {
107 panic(err)
108 }
109
110 // Create the controller and disable periodic redraw.
111 ctrl, err := NewController(t, c)
112 if err != nil {
113 panic(err)
114 }
115 // Close the controller and termdash once it isn't required anymore.
116 defer ctrl.Close()
117
118 // Redraw the terminal manually.
119 if err := ctrl.Redraw(); err != nil {
120 panic(err)
121 }
122}
123
124// errorHandler just stores the last error received.
125type errorHandler struct {

Callers

nothing calls this directly

Calls 8

CloseMethod · 0.95
RedrawMethod · 0.95
NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
PlaceWidgetFunction · 0.92
NewControllerFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected