Trait sourceview4::prelude::SearchContextExt
source · pub trait SearchContextExt: IsA<SearchContext> + Sealed + 'static {
Show 20 methods
// Provided methods
fn backward(&self, iter: &TextIter) -> Option<(TextIter, TextIter, bool)> { ... }
fn backward_async<P: FnOnce(Result<(TextIter, TextIter, bool), Error>) + 'static>(
&self,
iter: &TextIter,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
) { ... }
fn backward_future(
&self,
iter: &TextIter
) -> Pin<Box_<dyn Future<Output = Result<(TextIter, TextIter, bool), Error>> + 'static>> { ... }
fn forward(&self, iter: &TextIter) -> Option<(TextIter, TextIter, bool)> { ... }
fn forward_async<P: FnOnce(Result<(TextIter, TextIter, bool), Error>) + 'static>(
&self,
iter: &TextIter,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
) { ... }
fn forward_future(
&self,
iter: &TextIter
) -> Pin<Box_<dyn Future<Output = Result<(TextIter, TextIter, bool), Error>> + 'static>> { ... }
fn buffer(&self) -> Option<Buffer> { ... }
fn is_highlight(&self) -> bool { ... }
fn match_style(&self) -> Option<Style> { ... }
fn occurrence_position(
&self,
match_start: &TextIter,
match_end: &TextIter
) -> i32 { ... }
fn occurrences_count(&self) -> i32 { ... }
fn regex_error(&self) -> Option<Error> { ... }
fn settings(&self) -> Option<SearchSettings> { ... }
fn replace(
&self,
match_start: &mut TextIter,
match_end: &mut TextIter,
replace: &str
) -> Result<(), Error> { ... }
fn set_highlight(&self, highlight: bool) { ... }
fn set_match_style(&self, match_style: Option<&Style>) { ... }
fn connect_highlight_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_match_style_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_occurrences_count_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_regex_error_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
}
Expand description
Provided Methods§
sourcefn backward(&self, iter: &TextIter) -> Option<(TextIter, TextIter, bool)>
fn backward(&self, iter: &TextIter) -> Option<(TextIter, TextIter, bool)>
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 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 wrap-around
property.
iter
start of search.
Returns
whether a match was found.
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
.
sourcefn backward_async<P: FnOnce(Result<(TextIter, TextIter, bool), Error>) + 'static>(
&self,
iter: &TextIter,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
fn backward_async<P: FnOnce(Result<(TextIter, TextIter, bool), Error>) + 'static>( &self, iter: &TextIter, cancellable: Option<&impl IsA<Cancellable>>, callback: P )
The asynchronous version of backward()
.
See the documentation of backward()
for more
details.
See the GAsyncResult
documentation to know how to use this function.
If the operation is cancelled, the callback
will only be called if
cancellable
was not None
. 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.
fn backward_future( &self, iter: &TextIter ) -> Pin<Box_<dyn Future<Output = Result<(TextIter, TextIter, bool), Error>> + 'static>>
sourcefn forward(&self, iter: &TextIter) -> Option<(TextIter, TextIter, bool)>
fn forward(&self, iter: &TextIter) -> Option<(TextIter, TextIter, bool)>
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 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 wrap-around
property.
iter
start of search.
Returns
whether a match was found.
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
.
sourcefn forward_async<P: FnOnce(Result<(TextIter, TextIter, bool), Error>) + 'static>(
&self,
iter: &TextIter,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
fn forward_async<P: FnOnce(Result<(TextIter, TextIter, bool), Error>) + 'static>( &self, iter: &TextIter, cancellable: Option<&impl IsA<Cancellable>>, callback: P )
The asynchronous version of forward()
.
See the documentation of forward()
for more
details.
See the GAsyncResult
documentation to know how to use this function.
If the operation is cancelled, the callback
will only be called if
cancellable
was not None
. 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.
fn forward_future( &self, iter: &TextIter ) -> Pin<Box_<dyn Future<Output = Result<(TextIter, TextIter, bool), Error>> + 'static>>
sourcefn is_highlight(&self) -> bool
fn is_highlight(&self) -> bool
Returns
whether to highlight the search occurrences.
sourcefn occurrence_position(
&self,
match_start: &TextIter,
match_end: &TextIter
) -> i32
fn occurrence_position( &self, match_start: &TextIter, match_end: &TextIter ) -> i32
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.
sourcefn occurrences_count(&self) -> i32
fn occurrences_count(&self) -> i32
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.
sourcefn regex_error(&self) -> Option<Error>
fn regex_error(&self) -> Option<Error>
Regular expression patterns must follow certain rules. If
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 g_error_free()
.
Returns
the glib::Error
, or None
if the pattern is valid.
sourcefn settings(&self) -> Option<SearchSettings>
fn settings(&self) -> Option<SearchSettings>
Returns
the search settings.
sourcefn replace(
&self,
match_start: &mut TextIter,
match_end: &mut TextIter,
replace: &str
) -> Result<(), Error>
fn replace( &self, match_start: &mut TextIter, match_end: &mut TextIter, replace: &str ) -> Result<(), Error>
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 g_regex_check_replacement()
. The replace
text can contain
backreferences; read the g_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.
sourcefn set_highlight(&self, highlight: bool)
fn set_highlight(&self, highlight: bool)
sourcefn set_match_style(&self, match_style: Option<&Style>)
fn set_match_style(&self, match_style: Option<&Style>)
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
set_highlight()
.