Widget is a single widget on the dashboard. Implementations must be thread safe.
| 163 | // Widget is a single widget on the dashboard. |
| 164 | // Implementations must be thread safe. |
| 165 | type 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 | } |
no outgoing calls
no test coverage detected