Skip to content
FutureBlitz

    Install

    Import std.term.screen

    Canvas

    std.term.screen

    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")

    std/term/screen.fb, line 57

    • @PanicsAtCaller Public New(columns: Int, rows: Int) constructor #

      A canvas of columns by rows, each cell blank. Panics for a negative size.

    • Public Property Columns: Int property #

      How many columns it has.

    • Public Property Rows: Int property #

      How many rows it has.

    • Public Property Area: Region property #

      All of it, from (0, 0).

    • @PanicsAtCaller Operator [](column: Int, row: Int): Cell operator #

      The cell at column and row. Panics outside it.

    • Public Method Clear() method #

      Makes every cell blank, as the terminal shows plain text.

    • Public Method Clear(look: Style) method #

      Makes every cell a space in look, as behind a screen's text.

    • @PanicsAtCaller Public Method Resize(columns: Int, rows: Int) method #

      Makes it columns by rows, keeping the cells it still has, and blank ones past them. Panics for a negative size.

    • Public Method Print(column: Int, row: Int, text: String): Int method #

      Writes text on row from column, a grapheme cluster a cell, or two for a wide one, in plain text, as far as the canvas goes. Control characters, like tabs and line breaks, take no cell. Gives the column after what it wrote.

    • Public Method Print(column: Int, row: Int, text: String, look: Style): Int method #

      Writes text on row from column in look, as far as the canvas goes.

    • Public Method Print(area: Region, text: String, look: Style): Int method #

      Writes text in area in look, its lines wrapped to its width, as many as fit, and gives how many rows it took.

    • @PanicsAtCaller Public Method Fill(area: Region, text: String, look: Style) method #

      Fills area's cells with text, a grapheme cluster, in look: each cell, or each two for a wide one, with a space in a last column that has no room for it. Panics for text that isn't one grapheme cluster, one or two columns wide.

    • Public Method SetLook(area: Region, look: Style) method #

      Makes each of area's cells look as look says, keeping their text, as a selection does.

    • Public Method DrawBox(area: Region, border: BorderStyle, look: Style, title: String = ""): Region method #

      Draws a box around area's edge with border's lines in look, with title in its top line or not, and gives what's inside it. An area narrower or shorter than 2 has nothing inside.

    • Public Method ToString(): String method #

      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.