pub struct View { /* private fields */ }
Implementations§
Source§impl View
impl View
pub fn new(view_id: ViewId, buffer_id: BufferId) -> View
pub fn set_size(&mut self, size: Size)
pub fn set_scroll(&mut self, first: i64, last: i64)
pub fn scroll_height(&self) -> usize
Sourcepub fn deselect_at_offset(&mut self, text: &Rope, offset: usize) -> bool
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.
Sourcepub fn do_move(&mut self, text: &Rope, movement: Movement, modify: bool)
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.
Sourcepub fn set_selection<S: Into<Selection>>(&mut self, text: &Rope, sel: S)
pub fn set_selection<S: Into<Selection>>(&mut self, text: &Rope, sel: S)
Set the selection to a new value.
Sourcepub fn invalidate_styles(&mut self, text: &Rope, start: usize, end: usize)
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).
pub fn update_annotations( &mut self, plugin: PluginId, interval: Interval, annotations: Annotations, )
Sourcepub fn select_all(&mut self, text: &Rope)
pub fn select_all(&mut self, text: &Rope)
Select entire buffer.
Note: unlike movement based selection, this does not scroll.
Sourcepub fn extend_selection(
&mut self,
text: &Rope,
offset: usize,
granularity: SelectionGranularity,
)
pub fn extend_selection( &mut self, text: &Rope, offset: usize, granularity: SelectionGranularity, )
Extends an existing selection (eg. when the user performs SHIFT + click).
Sourcepub fn range_region(
&self,
text: &Rope,
start: (usize, usize),
offset: usize,
granularity: SelectionGranularity,
) -> SelRegion
pub fn range_region( &self, text: &Rope, start: (usize, usize), offset: usize, granularity: SelectionGranularity, ) -> SelRegion
Creates a SelRegion
for range select or drag operations.
Sourcepub fn sel_regions(&self) -> &[SelRegion]
pub fn sel_regions(&self) -> &[SelRegion]
Returns the regions of the current selection.
Sourcepub fn collapse_selections(&mut self, text: &Rope)
pub fn collapse_selections(&mut self, text: &Rope)
Collapse all selections in this view into a single caret
Sourcepub fn is_point_in_selection(&self, offset: usize) -> bool
pub fn is_point_in_selection(&self, offset: usize) -> bool
Determines whether the offset is in any selection (counting carets and selection edges).
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>
Sourcepub fn find_status(&self, text: &Rope, matches_only: bool) -> Vec<FindStatus>
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.
Sourcepub fn render_if_dirty(
&mut self,
text: &Rope,
client: &Client,
styles: &RefCell<ThemeStyleMap>,
style_spans: &Spans<Style>,
pristine: bool,
)
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.
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, )
Sourcepub fn set_dirty(&mut self, text: &Rope)
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.
Sourcepub fn line_of_offset(&self, text: &Rope, offset: usize) -> usize
pub fn line_of_offset(&self, text: &Rope, offset: usize) -> usize
Returns the visible line number containing the given offset.
Sourcepub fn offset_of_line(&self, text: &Rope, line: usize) -> usize
pub fn offset_of_line(&self, text: &Rope, line: usize) -> usize
Returns the byte offset corresponding to the given visual line.
Sourcepub fn after_edit(
&mut self,
text: &Rope,
last_text: &Rope,
delta: &RopeDelta,
client: &Client,
width_cache: &mut WidthCache,
drift: InsertDrift,
)
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.
pub fn do_find(&mut self, text: &Rope)
Sourcepub fn do_find_next(
&mut self,
text: &Rope,
reverse: bool,
wrap: bool,
allow_same: bool,
modify_selection: &SelectionModifier,
)
pub fn do_find_next( &mut self, text: &Rope, reverse: bool, wrap: bool, allow_same: bool, modify_selection: &SelectionModifier, )
Selects the next find match.
Sourcepub fn do_find_all(&mut self, text: &Rope)
pub fn do_find_all(&mut self, text: &Rope)
Selects all find matches.
Sourcepub fn select_next_occurrence(
&mut self,
text: &Rope,
reverse: bool,
wrapped: bool,
_allow_same: bool,
modify_selection: &SelectionModifier,
)
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.
Sourcepub fn get_line_range(&self, text: &Rope, region: &SelRegion) -> Range<usize>
pub fn get_line_range(&self, text: &Rope, region: &SelRegion) -> Range<usize>
Get the line range of a selected region.