Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

robbielyman
Copy link
Owner

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.

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.
@robbielyman robbielyman merged commit 33c0b93 into seamstress-2 Jun 20, 2024
@robbielyman robbielyman deleted the seamstress-2-timers branch June 20, 2024 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant