Import std.term.screen
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.
Examples
Local canvas = Canvas(10, 3)
Local inner = canvas.DrawBox(canvas.Area, BorderStyle.SINGLE, Style())
Expect(inner == Region(1, 1, 8, 1))
canvas.Print(inner.Column, inner.Row, "hi")
Expect(canvas[1, 1].Text == "h" && canvas[2, 1].Text == "i")-
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.
Report an issue with this page or with FutureBlitz on GitHub.