ascii_canvas

Trait AsciiView

source
pub trait AsciiView {
    // Required methods
    fn columns(&self) -> usize;
    fn read_char(&mut self, row: usize, column: usize) -> char;
    fn write_char(&mut self, row: usize, column: usize, ch: char, style: Style);
}
Expand description

AsciiView is a view onto an AsciiCanvas which potentially applies transformations along the way (e.g., shifting, adding styling information). Most of the main drawing methods for AsciiCanvas are defined as inherent methods on an AsciiView trait object.

Required Methods§

source

fn columns(&self) -> usize

source

fn read_char(&mut self, row: usize, column: usize) -> char

source

fn write_char(&mut self, row: usize, column: usize, ch: char, style: Style)

Implementations§

source§

impl<'a> dyn AsciiView + 'a

source

pub fn draw_vertical_line(&mut self, rows: Range<usize>, column: usize)

Draws a line for the given range of rows at the given column.

source

pub fn draw_horizontal_line(&mut self, row: usize, columns: Range<usize>)

Draws a horizontal line along a given row for the given range of columns.

source

pub fn write_chars<I>( &mut self, row: usize, column: usize, chars: I, style: Style, )
where I: Iterator<Item = char>,

Writes characters in the given style at the given position.

source

pub fn shift(&mut self, row: usize, column: usize) -> ShiftedView<'_>

Creates a new view onto the same canvas, but writing at an offset.

source

pub fn styled(&mut self, style: Style) -> StyleView<'_>

Creates a new view onto the same canvas, but applying a style to all the characters written.

Implementors§

source§

impl AsciiView for AsciiCanvas

source§

impl<'canvas> AsciiView for ShiftedView<'canvas>

source§

impl<'canvas> AsciiView for StyleView<'canvas>