Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Rikitav/Terminality/llms.txt
Use this file to discover all available pages before exploring further.
DispatchTimer is the engine’s frame clock. Each iteration of the render loop calls Tick(), which measures the elapsed time since the previous call, stores it as DeltaTime, and fires TickEvent with that value. Subscribing to TickEvent is the standard way to animate properties, poll state, or run any logic that should repeat at the frame rate. A second event, ResizeFinishedEvent, fires after the terminal window stops being resized, giving you a clean moment to re-measure layouts.
Class: DispatchTimer
DispatchTimer is a non-copyable singleton; obtain the instance with DispatchTimer::Current().
Current
DispatchTimer instance.
TickEvent
+=:
Tick(), on the engine’s render thread.
ResizeFinishedEvent
RESIZE_DELAY = 0.1f); ResizeFinishedEvent fires on the first tick after that delay expires. Use it to invalidate custom layout measurements that depend on absolute terminal dimensions.
DeltaTime
Tick() call, in seconds. The same value that is passed to TickEvent handlers. Valid after the first Tick() and zero before Start() is called.
Seconds elapsed between the last two frames.
TotalTime
DeltaTime values since Start() was called — effectively the wall-clock time in seconds since the application loop began.
Total elapsed time in seconds since the timer was started.
IsRunning
true after Start() has been called and before Stop() is called. Tick() is a no-op when the timer is not running.
true if the timer is currently running.IsResizing
true during the debounce window after a terminal resize event arrives and before ResizeFinishedEvent fires.
true while a resize is being debounced.Start and Stop
Start records the current high-resolution time as the baseline for the first delta. Stop sets the running flag to false so subsequent Tick() calls are no-ops. The engine calls these automatically around RunUILoop; application code rarely needs to call them directly.
Tick
deltaTime_ as the duration since lastTime_, accumulates it into totalTime_, fires TickEvent, and advances the resize debounce timer if a resize is in progress. Calling Tick() when IsRunning() is false is a no-op.
GetRemainingFrameTime
Target frames per second used to calculate the per-frame budget.
Remaining time in the current frame, clamped to zero if the frame overran.
Understanding delta time
dt (delta time) is the number of seconds between the current frame and the previous one. At 60 fps it is approximately 0.0167. Using dt rather than a fixed increment makes animations frame-rate independent:
rate of 10.0f advances value by 10 units per second regardless of whether the frame rate is 30, 60, or 120 fps.
Animating a progress bar
This pattern from the Terminality test application drives a looping progress bar animation entirely fromTickEvent:
progress->Value marks the widget dirty, causing Terminality to redraw only that control on the next frame. No manual invalidation call is needed.
DispatchTimer vs. OnPropertyChanged
| Use case | Recommended mechanism |
|---|---|
| Continuous animation (position, fill, opacity) | DispatchTimer::Current().TickEvent |
| React to a specific property changing | OnPropertyChanged callback on a Property<T> |
| One-shot deferred action | TickEvent with an unsubscribe after first run |
| Terminal resize recovery | DispatchTimer::Current().ResizeFinishedEvent |
TickEvent whenever the logic needs to run every frame or accumulate over time. Prefer OnPropertyChanged for reactions that should fire exactly when a value changes and have no concept of elapsed time.
Related
RenderContext— draw the animated state insideRenderOverrideFocusManager— focus changes fire synchronously, not throughTickEventHostApplication—RunUILoopstarts the frame loop that callsTick()