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

Interface Widget

widgetapi/widgetapi.go:165–202  ·  view source on GitHub ↗

Widget is a single widget on the dashboard. Implementations must be thread safe.

Source from the content-addressed store, hash-verified

163// Widget is a single widget on the dashboard.
164// Implementations must be thread safe.
165type Widget interface {
166 // When the infrastructure calls Draw(), the widget must block on the call
167 // until it finishes drawing onto the provided canvas. When given the
168 // canvas, the widget must first determine its size by calling
169 // Canvas.Size(), then limit all its drawing to this area.
170 //
171 // The widget must not assume that the size of the canvas or its content
172 // remains the same between calls.
173 //
174 // The argument meta is guaranteed to be valid (i.e. non-nil).
175 Draw(cvs *canvas.Canvas, meta *Meta) error
176
177 // Keyboard is called with every keyboard event whose scope the widget
178 // registered for.
179 //
180 // The argument meta is guaranteed to be valid (i.e. non-nil).
181 Keyboard(k *terminalapi.Keyboard, meta *EventMeta) error
182
183 // Mouse is called with every mouse event whose scope the widget registered
184 // for.
185 //
186 // The argument meta is guaranteed to be valid (i.e. non-nil).
187 Mouse(m *terminalapi.Mouse, meta *EventMeta) error
188
189 // Options returns registration options for the widget.
190 // This is how the widget indicates to the infrastructure whether it is
191 // interested in keyboard or mouse shortcuts, what is its minimum canvas
192 // size, etc.
193 //
194 // Most widgets will return statically compiled options (minimum and
195 // maximum size, etc.). If the returned options depend on the runtime state
196 // of the widget (e.g. the user data provided to the widget), the widget
197 // must protect against a case where the infrastructure calls the Draw
198 // method with a canvas that doesn't meet the requested options. This is
199 // because the data in the widget might change between calls to Options and
200 // Draw.
201 Options() Options
202}

Callers 32

redrawMethod · 0.65
drawWidgetFunction · 0.65
TestNewFunction · 0.65
TestKeyboardFunction · 0.65
TestMouseFunction · 0.65
TestUpdateFunction · 0.65
TestPointContFunction · 0.65
TestFocusTrackerMouseFunction · 0.65
prepareEvTargetsMethod · 0.65
TestMirrorFunction · 0.65
DrawWithMirrorFunction · 0.65
TestKeyboardFunction · 0.65

Implementers 15

explorerTabPreviewtermdashdemo/termdashdemo.go
Mirrorprivate/fakewidget/fakewidget.go
HeatMapwidgets/heatmap/heatmap.go
SegmentDisplaywidgets/segmentdisplay/segmentdisplay.
TreeViewwidgets/treeview/treeview.go
Checkboxwidgets/checkbox/checkbox.go
Timelinewidgets/timeline/timeline.go
TimeRangePickerwidgets/timeline/timerangepicker.go
BarChartwidgets/barchart/barchart.go
FocusEffectWidgetwidgets/fx/focus.go
framedTestWidgetwidgets/fx/framed_test.go
EffectWidgetwidgets/fx/fx.go

Calls

no outgoing calls

Tested by

no test coverage detected