Skip to main content

Screen

Struct Screen 

Source
pub struct Screen {
    pub pen: Cell,
    pub autowrap: bool,
    pub cursor_visible: bool,
    pub ice_colors: bool,
    pub look: Look,
    pub base_font: u8,
    pub base_ice: bool,
    pub tiles: Tiles,
    /* private fields */
}

Fields§

§pen: Cell

Attributes applied to newly written glyphs (ch is unused).

§autowrap: bool§cursor_visible: bool§ice_colors: bool§look: Look

The palette and fonts the BBS has chosen.

§base_font: u8

The font (CTerm ID) a reset returns to: the entry’s choice.

§base_ice: bool

Whether a reset leaves iCE colors on: the entry’s choice.

§tiles: Tiles

The pixel graphics cells show (see Cell::tile).

Implementations§

Source§

impl Screen

Source

pub fn new(cols: usize, rows: usize, scrollback_limit: usize) -> Self

Source

pub fn cols(&self) -> usize

Source

pub fn rows(&self) -> usize

Source

pub fn cursor(&self) -> (usize, usize)

Source

pub fn row(&self, y: usize) -> &[Cell]

Source

pub fn cell_mut(&mut self, x: usize, y: usize) -> Option<&mut Cell>

Source

pub fn scrollback_len(&self) -> usize

Source

pub fn scrollback_line(&self, i: usize) -> &[Cell]

Line i of the scrollback, 0 being the oldest.

Source

pub fn clear_scrollback(&mut self)

Source

pub fn reset(&mut self)

Full reset (RIS): clears the screen and modes but keeps scrollback.

Source

pub fn resize(&mut self, cols: usize, rows: usize)

Source

pub fn put(&mut self, ch: u8)

Write a glyph at the cursor and advance.

Source

pub fn carriage_return(&mut self)

Source

pub fn line_feed(&mut self)

Move down one line, scrolling the region if at its bottom.

Source

pub fn reverse_index(&mut self)

Move up one line, scrolling the region down if at its top (ESC M).

Source

pub fn backspace(&mut self)

Source

pub fn tab(&mut self)

Source

pub fn back_tab(&mut self, n: usize)

Source

pub fn move_to(&mut self, x: usize, y: usize)

Absolute move, 0-based, clamped to the screen.

Source

pub fn move_by(&mut self, dx: isize, dy: isize)

Source

pub fn set_scroll_region(&mut self, top: usize, bottom: usize)

Source

pub fn save_cursor(&mut self)

Source

pub fn restore_cursor(&mut self)

Source

pub fn scroll_up(&mut self, n: usize)

Scroll the region up n lines. Lines leaving the top of a full-screen region go to scrollback.

Source

pub fn scroll_down(&mut self, n: usize)

Source

pub fn erase_display(&mut self, mode: u32)

ED: 0 = cursor to end, 1 = start to cursor, 2/3 = whole screen.

Clearing the whole screen saves its content to scrollback first, so BBS screens that are wiped between menus can still be reviewed, and, like ANSI.SYS, homes the cursor.

Source

pub fn erase_line(&mut self, mode: u32)

EL: 0 = cursor to end of line, 1 = start to cursor, 2 = whole line.

Source

pub fn erase_chars(&mut self, n: usize)

ECH: blank n cells from the cursor without moving it.

Source

pub fn insert_chars(&mut self, n: usize)

ICH: insert n blanks at the cursor, shifting the rest of the line right.

Source

pub fn delete_chars(&mut self, n: usize)

DCH: delete n cells at the cursor, shifting the rest of the line left.

Source

pub fn insert_lines(&mut self, n: usize)

IL: insert n lines at the cursor row (within the scroll region).

Source

pub fn delete_lines(&mut self, n: usize)

DL: delete n lines at the cursor row (within the scroll region).

Source

pub fn draw_text( &mut self, x: usize, y: usize, text: &[u8], fg: Color, bg: Color, )

Write a string of CP437 glyphs directly at a position without moving the cursor; used by the built-in text-mode UI.

Source

pub fn fill_rect(&mut self, x: usize, y: usize, w: usize, h: usize, cell: Cell)

Source

pub fn cell_px(&self) -> (usize, usize)

The size of a cell in pixels, for pixel graphics: an 8x16 VGA font, or 8x8 on screens of 43 rows or more (as BadTerm draws them).

Source

pub fn size_px(&self) -> (usize, usize)

The screen’s size in pixels, for pixel graphics.

Source

pub fn place_image(&mut self, img: &Image, scrolling: bool)

Put a picture on the screen with its top left at the cursor’s cell, as sixel does: with scrolling, the screen scrolls to make room and the cursor ends on the row below the picture’s last full band, at the column it started in; without, it goes at the top left of the screen, what doesn’t fit is cut off and the cursor stays put.

Source

pub fn draw_pixels( &mut self, rect: (isize, isize, usize, usize), pixel: impl Fn(isize, isize) -> u32, )

Draw pixels over the screen in rect (x, y, w, h, in screen pixels; it may go off the screen, and that part is clipped): pixel(x, y) is each one’s color, 0xFFRRGGBB, or 0 to leave it as it is.

Source

pub fn pixel_at(&self, x: usize, y: usize) -> Rgb

The color of a screen pixel, as pixel operations see it: the cell’s pixel graphics, or else its background (text isn’t drawn here, so it reads as background).

Source

pub fn row_text(row: &[Cell]) -> String

Plain-text contents of a row, trailing blanks trimmed.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more