Struct sourceview5::SearchContext[][src]

pub struct SearchContext(_);

Implementations

impl SearchContext[src]

pub fn new<P: IsA<Buffer>, Q: IsA<SearchSettings>>(
    buffer: &P,
    settings: Option<&Q>
) -> SearchContext
[src]

Creates a new search context, associated with buffer, and customized with settings. If settings is None, a new SearchSettings object will be created, that you can retrieve with SearchContext::get_settings.

buffer

a Buffer.

settings

a SearchSettings, or None.

Returns

a new search context.

pub fn backward(&self, iter: &TextIter) -> Option<(TextIter, TextIter, bool)>[src]

Synchronous backward search. It is recommended to use the asynchronous functions instead, to not block the user interface. However, if you are sure that the buffer is small, this function is more convenient to use.

If the SearchSettings:wrap-around property is false, this function doesn’t try to wrap around.

The has_wrapped_around out parameter is set independently of whether a match is found. So if this function returns false, has_wrapped_around will have the same value as the SearchSettings:wrap-around property.

iter

start of search.

match_start

return location for start of match, or None.

match_end

return location for end of match, or None.

has_wrapped_around

return location to know whether the search has wrapped around, or None.

Returns

whether a match was found.

pub fn backward_async<P: IsA<Cancellable>, Q: FnOnce(Result<(TextIter, TextIter, bool), Error>) + Send + 'static>(
    &self,
    iter: &TextIter,
    cancellable: Option<&P>,
    callback: Q
)
[src]

The asynchronous version of SearchContext::backward.

See the documentation of SearchContext::backward for more details.

See the gio::AsyncResult documentation to know how to use this function.

If the operation is cancelled, the callback will only be called if cancellable was not None. SearchContext::backward_async takes ownership of cancellable, so you can unref it after calling this function.

iter

start of search.

cancellable

a gio::Cancellable, or None.

callback

a GAsyncReadyCallback to call when the operation is finished.

user_data

the data to pass to the callback function.

pub fn backward_async_future(
    &self,
    iter: &TextIter
) -> Pin<Box_<dyn Future<Output = Result<(TextIter, TextIter, bool), Error>> + 'static>>
[src]

pub fn forward(&self, iter: &TextIter) -> Option<(TextIter, TextIter, bool)>[src]

Synchronous forward search. It is recommended to use the asynchronous functions instead, to not block the user interface. However, if you are sure that the buffer is small, this function is more convenient to use.

If the SearchSettings:wrap-around property is false, this function doesn’t try to wrap around.

The has_wrapped_around out parameter is set independently of whether a match is found. So if this function returns false, has_wrapped_around will have the same value as the SearchSettings:wrap-around property.

iter

start of search.

match_start

return location for start of match, or None.

match_end

return location for end of match, or None.

has_wrapped_around

return location to know whether the search has wrapped around, or None.

Returns

whether a match was found.

pub fn forward_async<P: IsA<Cancellable>, Q: FnOnce(Result<(TextIter, TextIter, bool), Error>) + Send + 'static>(
    &self,
    iter: &TextIter,
    cancellable: Option<&P>,
    callback: Q
)
[src]

The asynchronous version of SearchContext::forward.

See the documentation of SearchContext::forward for more details.

See the gio::AsyncResult documentation to know how to use this function.

If the operation is cancelled, the callback will only be called if cancellable was not None. SearchContext::forward_async takes ownership of cancellable, so you can unref it after calling this function.

iter

start of search.

cancellable

a gio::Cancellable, or None.

callback

a GAsyncReadyCallback to call when the operation is finished.

user_data

the data to pass to the callback function.

pub fn forward_async_future(
    &self,
    iter: &TextIter
) -> Pin<Box_<dyn Future<Output = Result<(TextIter, TextIter, bool), Error>> + 'static>>
[src]

pub fn get_buffer(&self) -> Option<Buffer>[src]

Returns

the associated buffer.

pub fn get_highlight(&self) -> bool[src]

Returns

whether to highlight the search occurrences.

pub fn get_match_style(&self) -> Option<Style>[src]

Returns

the Style to apply on search matches.

pub fn get_occurrence_position(
    &self,
    match_start: &TextIter,
    match_end: &TextIter
) -> i32
[src]

Gets the position of a search occurrence. If the buffer is not already fully scanned, the position may be unknown, and -1 is returned. If 0 is returned, it means that this part of the buffer has already been scanned, and that match_start and match_end don’t delimit an occurrence.

match_start

the start of the occurrence.

match_end

the end of the occurrence.

Returns

the position of the search occurrence. The first occurrence has the position 1 (not 0). Returns 0 if match_start and match_end don’t delimit an occurrence. Returns -1 if the position is not yet known.

pub fn get_occurrences_count(&self) -> i32[src]

Gets the total number of search occurrences. If the buffer is not already fully scanned, the total number of occurrences is unknown, and -1 is returned.

Returns

the total number of search occurrences, or -1 if unknown.

pub fn get_regex_error(&self) -> Option<Error>[src]

Regular expression patterns must follow certain rules. If SearchSettings:search-text breaks a rule, the error can be retrieved with this function. The error domain is G_REGEX_ERROR.

Free the return value with glib::Error::free.

Returns

the glib::Error, or None if the pattern is valid.

pub fn get_settings(&self) -> Option<SearchSettings>[src]

Returns

the search settings.

pub fn replace(
    &self,
    match_start: &mut TextIter,
    match_end: &mut TextIter,
    replace: &str
) -> Result<(), Error>
[src]

Replaces a search match by another text. If match_start and match_end doesn’t correspond to a search match, false is returned.

match_start and match_end iters are revalidated to point to the replacement text boundaries.

For a regular expression replacement, you can check if replace is valid by calling glib::Regex::check_replacement. The replace text can contain backreferences; read the glib::Regex::replace documentation for more details.

match_start

the start of the match to replace.

match_end

the end of the match to replace.

replace

the replacement text.

replace_length

the length of replace in bytes, or -1.

Returns

whether the match has been replaced.

pub fn replace_all(&self, replace: &str) -> Result<(), Error>[src]

Replaces all search matches by another text. It is a synchronous function, so it can block the user interface.

For a regular expression replacement, you can check if replace is valid by calling glib::Regex::check_replacement. The replace text can contain backreferences; read the glib::Regex::replace documentation for more details.

replace

the replacement text.

replace_length

the length of replace in bytes, or -1.

Returns

the number of replaced matches.

pub fn set_highlight(&self, highlight: bool)[src]

Enables or disables the search occurrences highlighting.

highlight

the setting.

pub fn set_match_style(&self, match_style: Option<&Style>)[src]

Set the style to apply on search matches. If match_style is None, default theme’s scheme ‘match-style’ will be used. To enable or disable the search highlighting, use SearchContext::set_highlight.

match_style

a Style, or None.

pub fn connect_property_highlight_notify<F: Fn(&SearchContext) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

pub fn connect_property_match_style_notify<F: Fn(&SearchContext) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

pub fn connect_property_occurrences_count_notify<F: Fn(&SearchContext) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

pub fn connect_property_regex_error_notify<F: Fn(&SearchContext) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

Trait Implementations

impl Clone for SearchContext[src]

impl Debug for SearchContext[src]

impl Display for SearchContext[src]

impl Eq for SearchContext[src]

impl Hash for SearchContext[src]

impl Ord for SearchContext[src]

impl ParentClassIs for SearchContext[src]

type Parent = Object

impl<T: ObjectType> PartialEq<T> for SearchContext[src]

impl<T: ObjectType> PartialOrd<T> for SearchContext[src]

impl StaticType for SearchContext[src]

impl StructuralEq for SearchContext[src]

Auto Trait Implementations

impl RefUnwindSafe for SearchContext

impl !Send for SearchContext

impl !Sync for SearchContext

impl Unpin for SearchContext

impl UnwindSafe for SearchContext

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Super, Sub> CanDowncast<Sub> for Super where
    Sub: IsA<Super>,
    Super: IsA<Super>, 

impl<T> Cast for T where
    T: ObjectType, 

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ObjectExt for T where
    T: ObjectType, 

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToSendValue for T where
    T: SetValue + Send + ToValue + ?Sized

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToValue for T where
    T: SetValue + ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.