Skip to main content

Buffer

Struct Buffer 

Source
pub struct Buffer {
    pub size: Size,
    pub cells: Vec<Cell>,
}
Expand description

字符格缓冲区

Fields§

§size: Size§cells: Vec<Cell>

Implementations§

Source§

impl Buffer

Source

pub fn new(size: Size) -> Self

Creates a new buffer of the given size, filled with default (blank) cells.

Source

pub fn resize(&mut self, size: Size)

Resizes the buffer, discarding all existing content.

Source

pub fn clear(&mut self)

Resets every cell in the buffer to its default (blank) state.

Source

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

Returns a mutable reference to the cell at (x, y), or None if out of bounds.

Source

pub fn write_text(&mut self, pos: Pos, clip: Rect, text: &str, style: &Style)

写入文本到缓冲区(支持宽字符)

CJK 等宽字符占 2 cell,第二格标记为 continuation。

Source

pub fn draw_border(&mut self, rect: Rect, border: Border, style: &Style)

在指定 rect 边框绘制边框字符

Source

pub fn all_ops(&self) -> Vec<DiffOp>

返回所有 cell 的 DiffOp(跳过 continuation)

Source

pub fn diff(&self, next: &Buffer) -> Vec<DiffOp>

比较两个 buffer,返回所有变更的 DiffOp(跳过 continuation)

支持不同尺寸的 buffer 比较,以 next 的尺寸为基准输出。

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<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, 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.