Import std.term.screen
std.term.screen
std.term's full-screen apps: a Screen takes the whole terminal, on its alternate screen, in raw mode, with the cursor hidden, and shows a Canvas of cells there, writing only the cells that changed since it last did. A Canvas holds a grapheme cluster and a Style in each cell, two cells for a wide one, and draws text, fills, and boxes, each kept to the canvas, or to a Region of it.
std/term/screen.fb
Types
Cell
struct
Public Struct Cell Implements Hashable, Printable
One of a canvas's cells: the grapheme cluster that shows there, a space where it's blank, and how it looks. The right half of a wide one, which the cell before it shows, holds "".
-
The grapheme cluster that shows there, a space where it's blank, or "" for a wide one's right half.
-
How it looks.
-
Its text.
Canvas
class
Public Class Canvas Implements Printable
A grid of Cells, Columns by Rows, each blank at first, which a Screen shows. What's drawn on it stops at its edges, and a wide grapheme cluster that doesn't fit before an edge isn't drawn.
-
A canvas of
columnsbyrows, each cell blank. Panics for a negative size. -
How many columns it has.
-
How many rows it has.
-
All of it, from (0, 0).
-
The cell at column and row. Panics outside it.
-
Makes every cell blank, as the terminal shows plain text.
-
Makes every cell a space in
look, as behind a screen's text. -
Makes it
columnsbyrows, keeping the cells it still has, and blank ones past them. Panics for a negative size. -
Writes
textonrowfromcolumn, a grapheme cluster a cell, or two for a wide one, in plaintext, as far as the canvas goes. Control characters, like tabs and line breaks, take no cell. Gives thecolumnafter what it wrote. -
Writes
textonrowfromcolumninlook, as far as the canvas goes. -
Writes
textinareainlook, its lines wrapped to its width, as many as fit, and gives how many rows it took. -
Fills
area's cells withtext, a grapheme cluster, inlook: each cell, or each two for a wide one, with a space in a last column that has no room for it. Panics fortextthat isn't one grapheme cluster, one or two columns wide. -
Makes each of
area's cells look aslooksays, keeping their text, as a selection does. -
Public Method DrawBox(area: Region, border: BorderStyle, look: Style, title: String = ""): Regionmethod #Draws a box around
area's edge withborder's lines inlook, withtitlein its top line or not, and gives what's inside it. An area narrower or shorter than 2 has nothing inside. -
Its cells' text, row by row, with a line break after each but the last, and without the spaces at each row's end.
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.
-
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. -
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.