Skip to main content

View

Struct View 

Source
pub struct View {
    pub offset_row: usize,
    pub offset_col: usize,
    pub show_line_numbers: bool,
    pub wrap_mode: bool,
    pub screen_rows: usize,
    pub screen_cols: usize,
    /* private fields */
}

Fields§

§offset_row: usize§offset_col: usize§show_line_numbers: bool§wrap_mode: bool§screen_rows: usize§screen_cols: usize

Implementations§

Source§

impl View

Source

pub fn new(terminal: &Terminal) -> Self

從 Terminal 建立 View(自動取得終端尺寸)

Source

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

使用指定尺寸建立 View(不需要 Terminal)

§Arguments
  • rows - 螢幕行數(不含狀態欄)
  • cols - 螢幕列數
§Example
use wedi_core::View;
let view = View::new_simple(24, 80);
Source

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

調整視圖尺寸

§Arguments
  • rows - 新的螢幕行數
  • cols - 新的螢幕列數
Source

pub fn invalidate_cache(&mut self)

完全清空緩存(用於大範圍變更或視窗調整)

Source

pub fn invalidate_line(&mut self, logical_row: usize)

部分失效:僅清除指定邏輯行的緩存(用於單行編輯)

Source

pub fn invalidate_lines(&mut self, start_row: usize, end_row: usize)

部分失效:清除指定範圍的緩存(用於多行編輯)

Source

pub fn update_size(&mut self)

Source

pub fn render( &mut self, buffer: &RopeBuffer, cursor: &Cursor, selection: Option<&Selection>, message: Option<&str>, ) -> Result<()>

Source

pub fn scroll_if_needed( &mut self, cursor: &Cursor, buffer: &RopeBuffer, has_debug_ruler: bool, )

Source

pub fn scroll_horizontal_if_needed( &mut self, cursor: &Cursor, buffer: &RopeBuffer, )

水平滾動(單行模式專用)

Source

pub fn toggle_line_numbers(&mut self)

Source

pub fn toggle_display_mode(&mut self)

切換顯示模式(單行/多行),不影響行號顯示

Source

pub fn get_display_mode_name(&self) -> &'static str

獲取當前顯示模式名稱

Source

pub fn get_available_width(&self, buffer: &RopeBuffer) -> usize

獲取可用於顯示內容的寬度(扣除行號寬度)

Source

pub fn calculate_visual_lines_for_row( &self, buffer: &RopeBuffer, row: usize, ) -> Vec<String>

計算指定邏輯行的視覺行分割(給其他模組用,不依賴 cache 也可以)

Source

pub fn logical_col_to_visual_col(&self, line: &str, logical_col: usize) -> usize

將邏輯列轉換為視覺列(考慮 Tab 展開和字符寬度)

Source

pub fn visual_to_logical_col( &self, buffer: &RopeBuffer, row: usize, visual_line_index: usize, visual_col: usize, ) -> usize

從視覺行索引和視覺列轉換為邏輯列

Source

pub fn get_effective_screen_rows(&self, has_debug_ruler: bool) -> usize

實際可用於顯示文本的螢幕行數(扣除 debug 標尺)

Source

pub fn get_cursor_visual_position( &self, cursor: &Cursor, buffer: &RopeBuffer, ) -> (usize, usize)

獲取cursor的視覺位置(螢幕座標)

Auto Trait Implementations§

§

impl Freeze for View

§

impl RefUnwindSafe for View

§

impl Send for View

§

impl Sync for View

§

impl Unpin for View

§

impl UnwindSafe for View

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.