The WidgetWatchers struct is designed to be embedded into custom widgets
in order to satisfy the WidgetWatcher interface. The implementation uses
an internal map for storing EventHandlers, but does not lock access to
the access of the map within each method. A race condition can occur if
Watch, Unwatch, or any event is Posted from separate goroutines.
Lock access to the internal map. When posting an event, create a deep
copy of the map for iterating. This prevents potential deadlocks from a
widget calling Unwatch while handling an event.
Fixes#553
This function is supposed to return a minimum 2x2 square. However, as the comparison operators are the wrong way around a maximum 2x2 square is returned instead. Inverting the comparison operators fixes the issue.
The 'equal to' comparisons in the `ViewPort.ValidateViewX()` and `ViewPort.ValidateViewY()` methods are not required as the `ViewPort`s corresponding `view` attributes will be set equal to the right operand if the conditional resolves as true. The current behaviour results in the `view` attributes being set unnecessarily if it already equals the limit.
Removing SetCursor makes it possible to add lines to the model on the fly,
while keeping the cursor in position.
Go also initializes them with 0, no need to set it manually.
This way GetCell() will get full runes, not just bytes. Now accent characters will show properly
Adjust SetLines() and Init() to work on [][]rune instead of []string
Do not store cursor info (cursorX, CursorY) in CellView, as it belongs to the model (CellModel)
Use GetCursor() to identify current cursor position from CellModel
The defer of the screen.Fini() needed to include the defer of the
app.wg.Done(), and the original wg.Done needed to be eliminated.
The problem was originally spotted by @thechriswalker, with a proposed
fix that was close but not quite correct.
- Widget might be using not just View but other mechanisms for rendering
aware of the view size (e.g. ViewPort).
- By updating the view reference out of Widget, Widget doesn't have a
chance to react on this layout algorithm
- That's an existing bug that happens when we try to use CellView inside
of an BoxLayout