Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public final class LiveRegion
- Object
- LiveRegion
ImplementsAutoCloseable
The last few lines of the terminal, redrawn in place: what progress bars, spinners and prompts are drawn on.
update replaces the lines; println prints a line above them, so log
output and a live display can be mixed without tearing. Each frame goes out
in one write. Lines are cut to the terminal’s width, because a line that
wrapped would throw off the count of lines to move back over.
When standard output is not a terminal nothing is redrawn: println
prints its line and close prints the final lines once, so a log gets the
outcome without a frame per update.
Constructors
public LiveRegion() | A region on standard output, live when it is a terminal. |
Methods
public boolean isLive() | Whether this region redraws in place. |
public void update(String... newLines) | Replaces the lines and redraws them, with the cursor hidden. |
public void println(String text) | Prints text above the region and redraws the region under it. |
public void clear() | Erases the region from the screen, leaving the cursor where it began. |
public void close() | Leaves the last lines on screen, moves below them and shows the cursor. |
Inherited methods
Constructor details
LiveRegion
public LiveRegion()A region on standard output, live when it is a terminal.
Method details
isLive
public boolean isLive()Whether this region redraws in place.
update
public void update(String... newLines)Replaces the lines and redraws them, with the cursor hidden.
println
public void println(String text)Prints
text above the region and redraws the region under it.clear
public void clear()Erases the region from the screen, leaving the cursor where it began.
close
public void close()Leaves the last lines on screen, moves below them and shows the
cursor. Off a terminal, prints the last lines.