Package com.tonic.vellum
Class App
- java.lang.Object
-
- com.tonic.vellum.App
-
public final class App extends java.lang.ObjectThe application engine: owns the terminal, the single UI thread and event loop, layout, repaint, focus, and resize. Background threads interact with the UI only throughpost(Runnable).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classApp.BuilderFluent builder for an App.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static App.Builderbuilder()static Appcurrent()OverlayHandleopenOverlay(Section content, Placement placement, Section... focusTargets)Opens a modal overlay rendered on top of the UI and routes keys to it.voidpost(java.lang.Runnable task)Marshals a runnable onto the UI thread.voidquit()Stops the event loop;run()then restores the terminal.voidrun()Installs the terminal, runs the event loop until quit, and restores the terminal on exit, even if an exception propagates.Cancellableschedule(java.time.Duration delay, java.lang.Runnable task)Schedules a one-shot task on the UI thread.CancellablescheduleAtFixedRate(java.time.Duration initialDelay, java.time.Duration period, java.lang.Runnable task)Schedules a repeating task on the UI thread.
-
-
-
Method Detail
-
builder
public static App.Builder builder()
- Returns:
- a new app builder
-
current
public static App current()
- Returns:
- the running app, or null when no app is running
-
run
public void run()
Installs the terminal, runs the event loop until quit, and restores the terminal on exit, even if an exception propagates.
-
quit
public void quit()
Stops the event loop;run()then restores the terminal.
-
post
public void post(java.lang.Runnable task)
Marshals a runnable onto the UI thread. Safe to call from any thread.- Parameters:
task- the runnable to run on the UI thread
-
openOverlay
public OverlayHandle openOverlay(Section content, Placement placement, Section... focusTargets)
Opens a modal overlay rendered on top of the UI and routes keys to it. UI-thread-only. Close overlays in reverse order of opening.- Parameters:
content- the overlay content sectionplacement- resolves the overlay's bounds against the screenfocusTargets- the sections Tab cycles between, or none to focus the content itself- Returns:
- a handle that closes the overlay
-
schedule
public Cancellable schedule(java.time.Duration delay, java.lang.Runnable task)
Schedules a one-shot task on the UI thread.- Parameters:
delay- the delay before the task runstask- the task to run on the UI thread- Returns:
- a handle to cancel the scheduled task
-
scheduleAtFixedRate
public Cancellable scheduleAtFixedRate(java.time.Duration initialDelay, java.time.Duration period, java.lang.Runnable task)
Schedules a repeating task on the UI thread.- Parameters:
initialDelay- the delay before the first runperiod- the period between successive runstask- the task to run on the UI thread- Returns:
- a handle to cancel the scheduled task
-
-