Import std.term.screen
Screen
class
Public Class Screen
The whole terminal, for a full-screen app: made, it changes to the terminal's alternate screen, hides the cursor, takes pasted text as a paste and the mouse's reports, if it's asked to, and starts raw mode, all of which Close puts back, as does the program's end, however it ends. Draw on its Frame, then Present shows what changed since the last Present; ReadEvent and PollEvent give keys, the mouse, pastes, and resizes, after which the next Present draws it all.
Examples
Local screen = Screen()
Local draw = Function(canvas: Canvas)
canvas.Print(0, 0, "Press q to quit")
End Function
Local handle = Function(event: InputEvent): Bool => !event.IsChar('q')
screen.Run(draw, handle)-
The console's whole screen, with the mouse's reports, and Ctrl+C ending the program.
-
terminal's whole screen, with themouse's reports or not, and Ctrl+C a key withctrlCIsKey, or ending the program without it. -
How many columns it has, the terminal's.
-
How many rows it has, the terminal's.
-
All of it, from (0, 0).
-
What the next Present shows, to draw on, as the last Present left it.
-
Whether it's still the terminal's, until Close.
-
Makes its Frame blank, to draw it all again.
-
Shows the cursor at
columnandrowonce the next Present is done, as for a text input. -
Hides the cursor once the next Present is done.
-
Has the next Present write every cell, as when something else has written on the screen.
-
Shows its Frame: writes the cells that changed since the last Present, or every cell after a resize or a Redraw, moving the cursor only to where they are, and sends them on at once. Gives how many cells it wrote. Panics once it's closed.
-
The next event, which waits for it, or Null at the end of the input. A RESIZE resizes its Frame, keeping what's on it, and has the next Present draw it all.
-
The next event, which waits for
timeoutat most, or Null when none came by then. -
Runs an app until
handlegives False or the input ends:drawdraws each frame on a blank Frame, which is presented, thenhandletakes the next event. It steps the main scheduler after each, so the program's coroutines run while it waits for keys: while one waits, it waits for an event for 10 milliseconds at most, and draws again after each Step, whether an event came or not. -
Gives the terminal back: the mouse's reports and pastes off, the cursor shown, its first screen back, and raw mode over. Once is enough, and its Destroy does it too.
Report an issue with this page or with FutureBlitz on GitHub.