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

Method subscribers

termdash.go:212–244  ·  view source on GitHub ↗

subscribers subscribes event receivers that live in this package to EDS.

()

Source from the content-addressed store, hash-verified

210
211// subscribers subscribes event receivers that live in this package to EDS.
212func (td *termdash) subscribers() {
213 // Handler for all errors that occur during input event processing.
214 td.eds.Subscribe([]terminalapi.Event{terminalapi.NewError("")}, func(ev terminalapi.Event) {
215 td.handleError(ev.(*terminalapi.Error).Error())
216 })
217
218 // Handles terminal resize events.
219 td.eds.Subscribe([]terminalapi.Event{&terminalapi.Resize{}}, func(terminalapi.Event) {
220 td.setClearNeeded()
221 })
222
223 // Redraws the screen on Keyboard and Mouse events.
224 // These events very likely change the content of the widgets (e.g. zooming
225 // a LineChart) so a redraw is needed to make that visible.
226 td.eds.Subscribe([]terminalapi.Event{
227 &terminalapi.Keyboard{},
228 &terminalapi.Mouse{},
229 }, func(terminalapi.Event) {
230 td.evRedraw()
231 }, event.MaxRepetitive(0)) // No repetitive events that cause terminal redraw.
232
233 // Keyboard and Mouse subscribers specified via options.
234 if td.keyboardSubscriber != nil {
235 td.eds.Subscribe([]terminalapi.Event{&terminalapi.Keyboard{}}, func(ev terminalapi.Event) {
236 td.keyboardSubscriber(ev.(*terminalapi.Keyboard))
237 })
238 }
239 if td.mouseSubscriber != nil {
240 td.eds.Subscribe([]terminalapi.Event{&terminalapi.Mouse{}}, func(ev terminalapi.Event) {
241 td.mouseSubscriber(ev.(*terminalapi.Mouse))
242 })
243 }
244}
245
246// handleError forwards the error to the error handler if one was
247// provided or panics.

Callers 1

newTermdashFunction · 0.95

Calls 7

handleErrorMethod · 0.95
setClearNeededMethod · 0.95
evRedrawMethod · 0.95
NewErrorFunction · 0.92
MaxRepetitiveFunction · 0.92
ErrorMethod · 0.80
SubscribeMethod · 0.45

Tested by

no test coverage detected