[][src]Struct sunrise_vi::terminal::Terminal

pub struct Terminal {
    framebuffer: Arc<Buffer>,
    cursor_pos: Pos,
    font: Font<'static>,
    cached_glyphs: HashMap<char, GlyphBitmap>,
    advance_width: usize,
    linespace: usize,
    ascent: usize,
    descent: usize,
}

A struct for logging text to the window. Renders characters from a .ttf font using the font-rs crate

Fields

framebuffer: Arc<Buffer>

Rendering target for this terminal.

cursor_pos: Pos

Cursor pos, in pixels. Does not account for bpp. Reprensents the pen position on the baseline.

font: Font<'static>

The font in use for this terminal.

cached_glyphs: HashMap<char, GlyphBitmap>

We cache ascii glyphs to avoid rendering them every time.

advance_width: usize

Expected to be the same for every glyph since it should be a monospaced font.

linespace: usize

The distance between two baselines.

ascent: usize

The maximum ascent in the font.

descent: usize

The maximum descent in the font.

Implementations

impl Terminal[src]

pub fn new(
    sharedmem: SharedMemory,
    top: i32,
    left: i32,
    width: u32,
    height: u32
) -> Result<Self, Error>
[src]

Creates a new Window of the requested size for terminal usage.

pub fn draw(&mut self)[src]

Ask the compositor to redraw the window.

fn carriage_return(&mut self)[src]

Move the cursor to the beginning of the current line.

fn line_feed(&mut self)[src]

Move the cursor to the beginning of the next line, scrolling the screen if necessary.

fn advance_pos(&mut self)[src]

Move the cursor to the next position for drawing a character, possibly the next line if we need to wrap.

fn move_pos_back(&mut self)[src]

Move the cursor back to the previous position. If we are already on the first character position on this line, do not move.

fn scroll_screen(&mut self)[src]

scrolls the whole screen by one line. self.pos must be on last baseline.

pub fn clear(&mut self)[src]

Clears the whole screen and reset cursor

pub fn print_attr(&mut self, string: &str, fg: Color, bg: Color)[src]

Prints a string to the screen with attributes

fn display_glyph_in_box(
    glyph: &GlyphBitmap,
    framebuffer: &Buffer,
    box_width: usize,
    box_ascent: usize,
    box_descent: usize,
    fg: Color,
    bg: Color,
    pos: Pos
)
[src]

Copies a rendered character to the screen, displaying it in a bg colored box

Panics

Panics if pos makes writing the glyph overflow the screen

Trait Implementations

impl Write for Terminal[src]

Auto Trait Implementations

impl RefUnwindSafe for Terminal

impl Send for Terminal

impl Sync for Terminal

impl Unpin for Terminal

impl UnwindSafe for Terminal

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SizedIPCBuffer for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.