Skip to main content

FindReplaceState

Struct FindReplaceState 

Source
pub struct FindReplaceState {
    pub query: String,
    pub replacement: String,
    pub case_sensitive: bool,
    pub whole_word: bool,
    pub use_regex: bool,
    pub is_open: bool,
    pub show_replace: bool,
    pub active_match_index: usize,
    pub matches: Vec<SearchMatch>,
    pub regex_error: Option<String>,
}
Expand description

Interactive Find & Replace controller state.

Fields§

§query: String§replacement: String§case_sensitive: bool§whole_word: bool§use_regex: bool§is_open: bool§show_replace: bool§active_match_index: usize§matches: Vec<SearchMatch>§regex_error: Option<String>

Implementations§

Source§

impl FindReplaceState

Source

pub fn new() -> Self

Source

pub fn open_find(&mut self)

Source

pub fn open_replace(&mut self)

Source

pub fn close(&mut self)

Source

pub fn set_query(&mut self, query: impl Into<String>, buffer: &LineBuffer)

Source

pub fn set_replacement(&mut self, replacement: impl Into<String>)

Source

pub fn toggle_case_sensitive(&mut self, buffer: &LineBuffer)

Source

pub fn toggle_whole_word(&mut self, buffer: &LineBuffer)

Source

pub fn toggle_regex(&mut self, buffer: &LineBuffer)

Source

pub fn recompute_matches(&mut self, buffer: &LineBuffer)

Recomputes all matches across buffer cleanly with Unicode char-column accuracy.

Source

pub fn active_match(&self) -> Option<&SearchMatch>

Returns the currently focused match, if any.

Source

pub fn find_next(&mut self) -> Option<SearchMatch>

Advances to the next match (wrapping around to match 0).

Source

pub fn find_prev(&mut self) -> Option<SearchMatch>

Moves to the previous match (wrapping around to the last match).

Source

pub fn select_nearest_after(&mut self, pos: Position) -> Option<SearchMatch>

Moves active_match_index to the first match starting at or after pos.

Source

pub fn matches_on_line(&self, line: usize) -> Vec<(usize, &SearchMatch)>

Binary-searches all matches on logical line, returning (match_index, &SearchMatch).

Source

pub fn replace_current(&mut self, editor: &mut CodeEditor) -> bool

Replaces the active match in editor, recomputes matches, and selects the next match.

Source

pub fn replace_all(&mut self, editor: &mut CodeEditor) -> usize

Replaces every match in editor as ONE atomic undo transaction and single incremental reparse.

Source

pub fn status_label(&self) -> String

Formats a Monaco-style status label like "2 of 14" or "No results".

Trait Implementations§

Source§

impl Clone for FindReplaceState

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FindReplaceState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FindReplaceState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for FindReplaceState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for FindReplaceState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> IntoInitialState<T> for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,