Skip to main content

render

Function render 

Source
pub fn render(
    source: &impl CellReader,
    glyphs: &GlyphCatalog,
    window: Window,
) -> String
Expand description

Renders the rectangle of window from source to a string of exactly window.size.height lines, each exactly window.size.width glyphs wide and ending in \n, the last line included. A glyph may be more than one character, so the line is the same rectangle without being the same character count.

Each position asks its own cell for the text it renders to — see Cell::glyph_str — and falls back to a space when there is no cell, or the cell has none to give. A position inside the rendered rectangle that the reader holds no cell for renders as a space too, since it never held one — and so does a position that the rectangle’s origin and an offset within its size cannot even address as a Pos, since nothing could ever have been stamped there.

A reader rather than a buffer: rendering asks for a cell and has no way to ask who owns one, or to reach anything else a Buffer keeps.

The window is passed rather than taken from the reader, and a reader need not have one: a rendering asks for the rectangle the cells were drawn in, a part of it, or one that reaches past it — the last of which is what the paragraph above is about.