Skip to main content

VgaWriter

Struct VgaWriter 

Source
pub struct VgaWriter {
Show 24 fields pub(crate) enabled: bool, pub(crate) canvas: Option<CanvasBuffer>, pub(crate) fmt: PixelFormat, pub(crate) cols: usize, pub(crate) rows: usize, pub(crate) col: usize, pub(crate) row: usize, pub(crate) fg: u32, pub(crate) bg: u32, pub(crate) font: &'static [u8], pub(crate) font_info: FontInfo, pub(crate) glyph_mask_cache: Vec<u8>, pub(crate) unicode_map: Vec<(u32, usize)>, pub(crate) status_bar_height: usize, pub(crate) clip: ClipRect, pub(crate) sb: ScrollbackBuffer, pub(crate) scroll_offset: usize, pub(crate) cursor: CursorManager, pub(crate) sel_active: bool, pub(crate) sel_start_row: usize, pub(crate) sel_start_col: usize, pub(crate) sel_end_row: usize, pub(crate) sel_end_col: usize, pub(crate) prepared_row_cells: Vec<(usize, u32, u32)>,
}

Fields§

§enabled: bool§canvas: Option<CanvasBuffer>

Shared double-buffered framebuffer canvas (None before init).

§fmt: PixelFormat

Pixel format (pack_rgb/unpack_color helpers).

§cols: usize§rows: usize§col: usize§row: usize§fg: u32§bg: u32§font: &'static [u8]§font_info: FontInfo§glyph_mask_cache: Vec<u8>§unicode_map: Vec<(u32, usize)>§status_bar_height: usize§clip: ClipRect§sb: ScrollbackBuffer

Scrollback ring-buffer.

§scroll_offset: usize§cursor: CursorManager

Mouse + text cursor manager.

§sel_active: bool§sel_start_row: usize§sel_start_col: usize§sel_end_row: usize§sel_end_col: usize§prepared_row_cells: Vec<(usize, u32, u32)>

Implementations§

Source§

impl VgaWriter

Short helpers to access the optional canvas without repeating unwrap.

Source

fn can(&self) -> &CanvasBuffer

Source

fn canm(&mut self) -> &mut CanvasBuffer

Source§

impl VgaWriter

Source

pub(crate) fn sb_capacity(&self) -> usize

Maximum capacity of the scrollback ring buffer.

Source

pub(crate) fn sb_row_at(&self, logical_idx: usize) -> Option<&Vec<SbCell>>

Source

pub(crate) fn sb_push_row(&mut self, row: Vec<SbCell>)

Source

pub(crate) fn build_glyph_mask_cache( font: &'static [u8], info: &FontInfo, ) -> Vec<u8>

Source

pub(crate) fn glyph_mask_slice(&self, glyph_index: usize) -> Option<&[u8]>

Source

pub const fn new() -> Self

Creates a new instance.

Source

pub(crate) fn configure( &mut self, fb_addr: *mut u8, fb_width: usize, fb_height: usize, pitch: usize, fmt: PixelFormat, ) -> bool

Performs the configure operation.

Source

pub(crate) fn pack_color(&self, color: RgbColor) -> u32

Performs the pack color operation.

Source

pub(crate) fn unpack_color(&self, value: u32) -> RgbColor

Performs the unpack color operation.

Source

pub fn set_color(&mut self, fg: Color, bg: Color)

Sets color.

Source

pub fn set_rgb_color(&mut self, fg: RgbColor, bg: RgbColor)

Sets rgb color.

Source

pub fn text_colors(&self) -> (RgbColor, RgbColor)

Performs the text colors operation.

Source

pub fn width(&self) -> usize

Performs the width operation.

Source

pub fn height(&self) -> usize

Performs the height operation.

Source

pub fn cols(&self) -> usize

Performs the cols operation.

Source

pub fn rows(&self) -> usize

Performs the rows operation.

Source

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

Performs the glyph size operation.

Source

pub fn set_cursor_cell(&mut self, col: usize, row: usize)

Sets cursor cell.

Source

pub(crate) fn text_area_height(&self) -> usize

Performs the text area height operation.

Source

pub fn enabled(&self) -> bool

Performs the enabled operation.

Source

pub fn framebuffer_info(&self) -> FramebufferInfo

Performs the framebuffer info operation.

Source

pub(crate) fn in_clip(&self, x: usize, y: usize) -> bool

Performs the in clip operation.

Source

pub(crate) fn clipped_rect( &self, x: usize, y: usize, width: usize, height: usize, ) -> Option<(usize, usize, usize, usize)>

Performs the clipped rect operation.

Source

pub(crate) fn clear_dirty(&mut self)

Performs the clear dirty operation.

Source

pub(crate) fn mark_dirty_rect( &mut self, x: usize, y: usize, width: usize, height: usize, )

Performs the mark dirty rect operation.

Source

pub fn set_clip_rect(&mut self, x: usize, y: usize, width: usize, height: usize)

Sets clip rect.

Source

pub fn reset_clip_rect(&mut self)

Performs the reset clip rect operation.

Source

pub(crate) fn draw_to_back_buffer(&self) -> bool

Performs the draw to back buffer operation.

Source

pub fn enable_double_buffer(&mut self) -> bool

Enables double buffer.

Source

pub fn disable_double_buffer(&mut self, present: bool)

Disables double buffer.

Source

pub fn present(&mut self)

Performs the present operation.

Source

pub(crate) fn request_present(&mut self)

Source

pub(crate) fn present_if_due(&mut self, force: bool)

Source

pub(crate) fn mc_save_hw(&mut self)

Performs the mc save hw operation. Uses read_pixel_packed (back-buffer aware) instead of read_hw_pixel_packed.

Source

pub(crate) fn mc_draw_hw(&mut self)

Performs the mc draw hw operation. Uses put_pixel_raw (back-buffer aware) instead of write_hw_pixel_packed.

Source

pub(crate) fn mc_erase_hw(&mut self)

Performs the mc erase hw operation. Uses put_pixel_raw (back-buffer aware) instead of write_hw_pixel_packed.

Source

pub fn update_mouse_cursor(&mut self, x: i32, y: i32)

Updates mouse cursor.

Source

pub fn hide_mouse_cursor(&mut self)

Performs the hide mouse cursor operation.

Source

pub(crate) fn text_cursor_rect(&self) -> Option<(usize, usize, usize, usize)>

Source

pub(crate) fn text_cursor_save_hw(&mut self)

Save text cursor pixels. Uses read_pixel_packed (back-buffer aware).

Source

pub(crate) fn text_cursor_draw_hw(&mut self)

Draw text cursor. Uses put_pixel_raw (back-buffer aware).

Source

pub(crate) fn text_cursor_erase_hw(&mut self)

Erase text cursor (restore saved pixels). Uses put_pixel_raw (back-buffer aware).

Source

pub(crate) fn draw_text_cursor_overlay(&mut self, color: RgbColor)

Source

pub fn hide_text_cursor(&mut self)

Performs the hide text cursor operation on the writer.

Source

pub(crate) fn sel_normalized(&self) -> (usize, usize, usize, usize)

Performs the sel normalized operation.

Source

pub fn pixel_to_sb_pos(&self, px: usize, py: usize) -> Option<(usize, usize)>

Performs the pixel to sb pos operation.

Source

pub fn start_selection(&mut self, px: usize, py: usize)

Starts selection.

Source

pub fn update_selection(&mut self, px: usize, py: usize)

Updates selection.

Source

pub fn end_selection(&mut self)

Performs the end selection operation.

Source

pub fn clear_selection(&mut self)

Performs the clear selection operation.

Source

pub fn clear_with(&mut self, color: RgbColor)

Performs the clear with operation.

Source

pub fn clear(&mut self)

Performs the clear operation.

Source

pub(crate) fn pixel_offset(&self, x: usize, y: usize) -> Option<usize>

Performs the pixel offset operation.

Source

pub(crate) fn write_hw_pixel_packed(&mut self, x: usize, y: usize, color: u32)

Writes hw pixel packed.

Source

pub(crate) fn read_hw_pixel_packed(&self, x: usize, y: usize) -> u32

Reads hw pixel packed.

Source

pub(crate) fn read_pixel_packed(&self, x: usize, y: usize) -> u32

Reads pixel packed.

Source

pub(crate) fn put_pixel_raw(&mut self, x: usize, y: usize, color: u32)

Performs the put pixel raw operation.

Source

pub fn draw_pixel(&mut self, x: usize, y: usize, color: RgbColor)

Performs the draw pixel operation.

Source

pub fn draw_pixel_alpha( &mut self, x: usize, y: usize, color: RgbColor, alpha: u8, )

Performs the draw pixel alpha operation.

Source

pub fn draw_line( &mut self, x0: isize, y0: isize, x1: isize, y1: isize, color: RgbColor, )

Performs the draw line operation.

Source

pub fn draw_rect( &mut self, x: usize, y: usize, width: usize, height: usize, color: RgbColor, )

Performs the draw rect operation.

Source

pub fn fill_rect( &mut self, x: usize, y: usize, width: usize, height: usize, color: RgbColor, )

Performs the fill rect operation.

Source

pub fn fill_rect_alpha( &mut self, x: usize, y: usize, width: usize, height: usize, color: RgbColor, alpha: u8, )

Performs the fill rect alpha operation.

Source

pub fn blit_rgb( &mut self, dst_x: usize, dst_y: usize, src_width: usize, src_height: usize, pixels: &[RgbColor], ) -> bool

Performs the blit rgb operation.

Source

pub fn blit_rgb24( &mut self, dst_x: usize, dst_y: usize, src_width: usize, src_height: usize, bytes: &[u8], ) -> bool

Performs the blit rgb24 operation.

Source

pub fn blit_rgba( &mut self, dst_x: usize, dst_y: usize, src_width: usize, src_height: usize, bytes: &[u8], global_alpha: u8, ) -> bool

Performs the blit rgba operation.

Source

pub fn blit_sprite_rgba( &mut self, dst_x: usize, dst_y: usize, sprite: SpriteRgba<'_>, global_alpha: u8, ) -> bool

Performs the blit sprite rgba operation.

Source

pub fn draw_text_at( &mut self, pixel_x: usize, pixel_y: usize, text: &str, fg: RgbColor, bg: RgbColor, )

Performs the draw text at operation.

Source

pub(crate) fn glyph_index_for_char(&self, ch: char) -> usize

Performs the glyph index for char operation.

Source

pub(crate) fn draw_glyph_index_at_pixel( &mut self, pixel_x: usize, pixel_y: usize, glyph_index: usize, fg: u32, bg: u32, )

Performs the draw glyph index at pixel operation.

Source

pub(crate) fn draw_glyph_at_pixel( &mut self, pixel_x: usize, pixel_y: usize, ch: char, fg: u32, bg: u32, )

Performs the draw glyph at pixel operation.

Source

pub(crate) fn fill_text_span_bg( &mut self, pixel_x: usize, pixel_y: usize, width: usize, height: usize, bg: u32, )

Source

pub(crate) fn clear_text_line_pixels(&mut self, vis_row: usize)

Source

pub(crate) fn visible_virtual_bounds( &self, ) -> (usize, usize, usize, usize, bool)

Source

pub(crate) fn sync_live_cursor_from_view( &mut self, total_complete: usize, view_start: usize, view_end: usize, )

Source

pub(crate) fn selection_colors_for_cell( &self, virt_row: usize, col: usize, fg: u32, bg: u32, ) -> (u32, u32)

Source

pub(crate) fn render_virtual_row( &mut self, virt_row: usize, vis_row: usize, total_complete: usize, has_partial: bool, )

Source

pub(crate) fn redraw_visible_rows(&mut self, start_vis_row: usize, count: usize)

Source

pub(crate) fn ensure_back_buffer_for_viewport(&mut self)

Source

pub(crate) fn begin_viewport_render(&mut self) -> (bool, bool)

Source

pub(crate) fn end_viewport_render( &mut self, prev_draw_to_back: bool, prev_track_dirty: bool, )

Source

pub(crate) fn finalize_live_view_state(&mut self)

Source

pub(crate) fn render_viewport_full(&mut self)

Source

pub(crate) fn refresh_viewport_decorations(&mut self)

Source

pub(crate) fn set_scroll_offset_and_render(&mut self, new_offset: usize)

Source

pub(crate) fn move_text_view_pixels_up(&mut self, pixels: usize)

Source

pub(crate) fn move_text_view_pixels_down(&mut self, pixels: usize)

Source

pub(crate) fn layout_text_lines( &self, text: &str, wrap: bool, max_cols: Option<usize>, ) -> Vec<Vec<char>>

Performs the layout text lines operation.

Source

pub fn measure_text( &self, text: &str, max_width: Option<usize>, wrap: bool, ) -> TextMetrics

Performs the measure text operation.

Source

pub fn draw_text( &mut self, pixel_x: usize, pixel_y: usize, text: &str, opts: TextOptions, ) -> TextMetrics

Performs the draw text operation.

Source

pub fn draw_strata_stack( &mut self, origin_x: usize, origin_y: usize, layer_w: usize, layer_h: usize, )

Performs the draw strata stack operation.

Source

pub(crate) fn draw_glyph(&mut self, cx: usize, cy: usize, ch: char)

Performs the draw glyph operation.

Source

pub(crate) fn clear_row(&mut self, row: usize)

Performs the clear row operation.

Source

pub(crate) fn scroll(&mut self)

Performs the scroll operation.

Source

pub(crate) fn write_char(&mut self, c: char)

Writes char.

Source

pub(crate) fn write_bytes(&mut self, s: &str)

Writes bytes.

Source

pub(crate) fn sb_mirror_char(&mut self, c: char)

Mirror a normalized character into the scrollback model. Called by write_char before any live rendering. Mirror a typed character into the scrollback buffer.

Source

pub(crate) fn sb_trim(&mut self)

Keep the scrollback buffer within MAX_SCROLLBACK + rows.

Source

pub(crate) fn draw_scrollbar_inner(&mut self)

Draw (or refresh) the scrollbar strip on the right edge of the text area.

Source

pub(crate) fn redraw_from_scrollback(&mut self)

Redraw the entire text area from the scrollback buffer. Called when scroll_offset changes.

Source

pub(crate) fn redraw_from_scrollback_incremental( &mut self, old_offset: usize, ) -> bool

Source

pub fn scroll_view_up(&mut self, lines: usize)

Scroll the view up (backward in history) by lines lines.

Source

pub fn scroll_view_down(&mut self, lines: usize)

Scroll the view down (forward, toward live) by lines lines.

Source

pub fn scroll_to_live(&mut self)

Immediately return to the live (bottom) view.

Source

pub fn scrollbar_click(&mut self, px_x: usize, px_y: usize)

Handle a click at pixel (px_x, px_y) : if it falls in the scrollbar, jump the view to the corresponding scroll position.

Source

pub fn scrollbar_drag_to(&mut self, px_y: usize)

Drag the scrollbar thumb to vertical pixel px_y.

Unlike scrollbar_click, this only depends on Y and is intended for click-and-drag interactions where the pointer may slightly leave the scrollbar strip horizontally.

Source

pub fn scrollbar_hit_test(&self, px_x: usize, px_y: usize) -> bool

Returns true if the pixel coordinates fall within the scrollbar strip.

Trait Implementations§

Source§

impl Send for VgaWriter

Source§

impl Write for VgaWriter

Source§

fn write_str(&mut self, s: &str) -> Result

Writes str.

1.1.0 · Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more

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
§

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

§

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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

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

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.