Struct View

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

Implementations§

Source§

impl View

Source

pub fn new(view_id: ViewId, buffer_id: BufferId) -> View

Source

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

Source

pub fn set_scroll(&mut self, first: i64, last: i64)

Source

pub fn scroll_height(&self) -> usize

Source

pub fn deselect_at_offset(&mut self, text: &Rope, offset: usize) -> bool

Removes any selection present at the given offset. Returns true if a selection was removed, false otherwise.

Source

pub fn do_move(&mut self, text: &Rope, movement: Movement, modify: bool)

Move the selection by the given movement. Return value is the offset of a point that should be scrolled into view.

If modify is true, the selections are modified, otherwise the results of individual region movements become carets.

Source

pub fn set_selection<S: Into<Selection>>(&mut self, text: &Rope, sel: S)

Set the selection to a new value.

Source

pub fn invalidate_styles(&mut self, text: &Rope, start: usize, end: usize)

Invalidates the styles of the given range (start and end are offsets within the text).

Source

pub fn update_annotations( &mut self, plugin: PluginId, interval: Interval, annotations: Annotations, )

Source

pub fn select_all(&mut self, text: &Rope)

Select entire buffer.

Note: unlike movement based selection, this does not scroll.

Source

pub fn extend_selection( &mut self, text: &Rope, offset: usize, granularity: SelectionGranularity, )

Extends an existing selection (eg. when the user performs SHIFT + click).

Source

pub fn range_region( &self, text: &Rope, start: (usize, usize), offset: usize, granularity: SelectionGranularity, ) -> SelRegion

Creates a SelRegion for range select or drag operations.

Source

pub fn sel_regions(&self) -> &[SelRegion]

Returns the regions of the current selection.

Source

pub fn collapse_selections(&mut self, text: &Rope)

Collapse all selections in this view into a single caret

Source

pub fn is_point_in_selection(&self, offset: usize) -> bool

Determines whether the offset is in any selection (counting carets and selection edges).

Source

pub fn render_styles( &self, client: &Client, styles: &RefCell<ThemeStyleMap>, start: usize, end: usize, sel: &[(usize, usize)], hls: &Vec<Vec<(usize, usize)>>, style_spans: &Spans<Style>, ) -> Vec<isize>

Source

pub fn find_status(&self, text: &Rope, matches_only: bool) -> Vec<FindStatus>

Determines the current number of find results and search parameters to send them to the frontend.

Source

pub fn render_if_dirty( &mut self, text: &Rope, client: &Client, styles: &RefCell<ThemeStyleMap>, style_spans: &Spans<Style>, pristine: bool, )

Update front-end with any changes to view since the last time sent. The pristine argument indicates whether or not the buffer has unsaved changes.

Source

pub fn request_lines( &mut self, text: &Rope, client: &Client, styles: &RefCell<ThemeStyleMap>, style_spans: &Spans<Style>, first_line: usize, last_line: usize, pristine: bool, )

Source

pub fn set_dirty(&mut self, text: &Rope)

Invalidates front-end’s entire line cache, forcing a full render at the next update cycle. This should be a last resort, updates should generally cause finer grain invalidation.

Source

pub fn line_of_offset(&self, text: &Rope, offset: usize) -> usize

Returns the visible line number containing the given offset.

Source

pub fn offset_of_line(&self, text: &Rope, line: usize) -> usize

Returns the byte offset corresponding to the given visual line.

Source

pub fn after_edit( &mut self, text: &Rope, last_text: &Rope, delta: &RopeDelta, client: &Client, width_cache: &mut WidthCache, drift: InsertDrift, )

Updates the view after the text has been modified by the given delta. This method is responsible for updating the cursors, and also for recomputing line wraps.

Source

pub fn do_find(&mut self, text: &Rope)

Source

pub fn do_find_next( &mut self, text: &Rope, reverse: bool, wrap: bool, allow_same: bool, modify_selection: &SelectionModifier, )

Selects the next find match.

Source

pub fn do_find_all(&mut self, text: &Rope)

Selects all find matches.

Source

pub fn select_next_occurrence( &mut self, text: &Rope, reverse: bool, wrapped: bool, _allow_same: bool, modify_selection: &SelectionModifier, )

Select the next occurrence relative to the last cursor. reverse determines whether the next occurrence before (true) or after (false) the last cursor is selected. wrapped indicates a search for the next occurrence past the end of the file.

Source

pub fn get_line_range(&self, text: &Rope, region: &SelRegion) -> Range<usize>

Get the line range of a selected region.

Source

pub fn get_caret_offset(&self) -> Option<usize>

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.