Skip to main content

EditorPanel

Struct EditorPanel 

Source
pub struct EditorPanel { /* private fields */ }

Implementations§

Source§

impl EditorPanel

Source

pub fn perform(&mut self, action: Action) -> Option<Vec<PanelEvent>>

The entry point every consumer uses. None means this panel does not handle the action, so the app should try it.

Source§

impl EditorPanel

Source

pub fn from_str(s: &str) -> Self

Source

pub fn from_path(path: &Path) -> Result<Self>

Source

pub fn selections(&self) -> &Selections

Source

pub fn cursor(&self) -> Position

The primary head — where the terminal cursor is drawn.

Source

pub fn top_line(&self) -> usize

Source

pub fn left_col(&self) -> usize

Source

pub fn save(&mut self) -> Result<()>

Source

pub fn line_text(&self, line: usize) -> String

Line contents without the trailing newline.

Source

pub fn buffer_find_all(&self, query: &SearchQuery) -> Vec<Selection>

Every match in the buffer.

The app asks through here rather than reaching into self.buffer: a panel’s internals are not application state, which is the same rule RenderContext enforces pointing the other way.

ponytail: this scans the whole buffer, which is ~10 ms on a 50k-line file — fine for answering Enter, too slow to run on every keystroke. An incremental search box scans the viewport first and completes off the render thread; see typ-buffer/tests/perf.rs.

Source

pub fn select_range(&mut self, selection: Selection)

Select a range and scroll it into view.

Source

pub fn replace_all(&mut self, query: &SearchQuery, replacement: &str) -> usize

Replace every match, as one undo step. Returns how many.

Trait Implementations§

Source§

impl Panel for EditorPanel

Source§

fn handle_key(&mut self, _chord: KeyChord) -> Vec<PanelEvent>

The editor has no raw-key behavior left.

Every key that does anything here is a keymap row resolving to an Action, which is the invariant the whole milestone exists to establish: a primitive reachable only from a key handler is invisible to the command palette and to the vim layer. The M1-era arms that used to live here were the last thing violating it.

Source§

fn name(&self) -> &'static str

Stable type name, used for registry lookup and session records.
Source§

fn title(&self) -> String

Dynamic title shown in the panel header.
Source§

fn render(&mut self, area: Rect, buf: &mut Buffer, ctx: &RenderContext<'_>)

Source§

fn apply_action(&mut self, action: Action) -> Option<Vec<PanelEvent>>

Perform a named action. Read more
Source§

fn cursor_position(&self, panel_area: Rect) -> Option<(u16, u16)>

Where the terminal cursor belongs, in screen coordinates, when this panel holds focus. None hides it. Read more
Source§

fn handle_mouse( &mut self, event: MouseEvent, panel_area: Rect, ) -> Vec<PanelEvent>

panel_area is supplied so the panel can translate to local coordinates.
Source§

fn handle_scroll(&mut self, delta: i32, _panel_area: Rect) -> Vec<PanelEvent>

Coalesced scroll. Positive is down.
Source§

fn needs_close_confirmation(&self) -> Option<String>

Some(message) blocks closing until confirmed.
Source§

fn as_any(&self) -> &dyn Any

Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Source§

fn tick(&mut self) -> Vec<PanelEvent>

Periodic hook for background work.
Source§

fn captures_escape(&self) -> bool

True when the panel consumes Escape itself (e.g. an open search box).

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