robbielyman / seamstress

seamstress is an art engine
GNU General Public License v3.0
123 stars 12 forks source link

feat!: timers, rework update / draw cycle #132

Closed robbielyman closed 3 months ago

robbielyman commented 3 months ago

event listeners may now optionally return a second value; all non-nil values will be presented to the caller of seamstress.event.publish as an array. (this is cribbed very heavily from mediator_lua.) in the case of { 'tui', ... } events raised by seamstress itself, if any of the returned values are truthy, a draw event is triggered. by default, the last responder (priority 0) to draw calls seamstress.tui.renderCommit to actually push the updated cells to the terminal.

this commit adds Timer to the Lua layer, similar to metro from norns / seamstress 1. some differences: no new threads are spawned, so there is no limit on the number of timers. the timer has not gone back to sleep during the callback, so pattern_time-style dynamic timers should be much simpler to program. the type is entirely implemented in Zig, (yet memory is fully Lua-owned) so there is no actual timer.lua file. seamstress.update is available as a timer which will spawn an update-into-possible-draw event when enabled.

this represents partial progress towards #131.