Trait sourceview4::prelude::BufferExt
source · pub trait BufferExt: IsA<Buffer> + Sealed + 'static {
Show 44 methods
// Provided methods
fn begin_not_undoable_action(&self) { ... }
fn can_redo(&self) -> bool { ... }
fn can_undo(&self) -> bool { ... }
fn change_case(
&self,
case_type: ChangeCaseType,
start: &mut TextIter,
end: &mut TextIter
) { ... }
fn create_source_mark(
&self,
name: Option<&str>,
category: &str,
where_: &TextIter
) -> Option<Mark> { ... }
fn end_not_undoable_action(&self) { ... }
fn ensure_highlight(&self, start: &TextIter, end: &TextIter) { ... }
fn context_classes_at_iter(&self, iter: &TextIter) -> Vec<GString> { ... }
fn is_highlight_matching_brackets(&self) -> bool { ... }
fn is_highlight_syntax(&self) -> bool { ... }
fn is_implicit_trailing_newline(&self) -> bool { ... }
fn language(&self) -> Option<Language> { ... }
fn max_undo_levels(&self) -> i32 { ... }
fn source_marks_at_iter(
&self,
iter: &mut TextIter,
category: Option<&str>
) -> Vec<Mark> { ... }
fn source_marks_at_line(
&self,
line: i32,
category: Option<&str>
) -> Vec<Mark> { ... }
fn style_scheme(&self) -> Option<StyleScheme> { ... }
fn undo_manager(&self) -> Option<UndoManager> { ... }
fn iter_has_context_class(
&self,
iter: &TextIter,
context_class: &str
) -> bool { ... }
fn join_lines(&self, start: &mut TextIter, end: &mut TextIter) { ... }
fn redo(&self) { ... }
fn remove_source_marks(
&self,
start: &TextIter,
end: &TextIter,
category: Option<&str>
) { ... }
fn set_highlight_matching_brackets(&self, highlight: bool) { ... }
fn set_highlight_syntax(&self, highlight: bool) { ... }
fn set_implicit_trailing_newline(&self, implicit_trailing_newline: bool) { ... }
fn set_language(&self, language: Option<&impl IsA<Language>>) { ... }
fn set_max_undo_levels(&self, max_undo_levels: i32) { ... }
fn set_style_scheme(&self, scheme: Option<&impl IsA<StyleScheme>>) { ... }
fn set_undo_manager(&self, manager: Option<&impl IsA<UndoManager>>) { ... }
fn sort_lines(
&self,
start: &mut TextIter,
end: &mut TextIter,
flags: SortFlags,
column: i32
) { ... }
fn undo(&self) { ... }
fn connect_bracket_matched<F: Fn(&Self, Option<&TextIter>, BracketMatchType) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_highlight_updated<F: Fn(&Self, &TextIter, &TextIter) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_redo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { ... }
fn connect_source_mark_updated<F: Fn(&Self, &TextMark) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_undo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { ... }
fn connect_can_redo_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_can_undo_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_highlight_matching_brackets_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_highlight_syntax_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_implicit_trailing_newline_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_language_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_max_undo_levels_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_style_scheme_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_undo_manager_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
}
Expand description
Provided Methods§
sourcefn begin_not_undoable_action(&self)
fn begin_not_undoable_action(&self)
Marks the beginning of a not undoable action on the buffer, disabling the undo manager. Typically you would call this function before initially setting the contents of the buffer (e.g. when loading a file in a text editor).
You may nest begin_not_undoable_action()
/
end_not_undoable_action()
blocks.
sourcefn change_case(
&self,
case_type: ChangeCaseType,
start: &mut TextIter,
end: &mut TextIter
)
fn change_case( &self, case_type: ChangeCaseType, start: &mut TextIter, end: &mut TextIter )
sourcefn create_source_mark(
&self,
name: Option<&str>,
category: &str,
where_: &TextIter
) -> Option<Mark>
fn create_source_mark( &self, name: Option<&str>, category: &str, where_: &TextIter ) -> Option<Mark>
Creates a source mark in the self
of category category
. A source mark is
a gtk::TextMark
but organised into categories. Depending on the category
a pixbuf can be specified that will be displayed along the line of the mark.
Like a gtk::TextMark
, a Mark
can be anonymous if the
passed name
is None
. Also, the buffer owns the marks so you
shouldn’t unreference it.
Marks always have left gravity and are moved to the beginning of the line when the user deletes the line they were in.
Typical uses for a source mark are bookmarks, breakpoints, current executing instruction indication in a source file, etc..
name
the name of the mark, or None
.
category
a string defining the mark category.
where_
location to place the mark.
Returns
a new Mark
, owned by the buffer.
sourcefn end_not_undoable_action(&self)
fn end_not_undoable_action(&self)
Marks the end of a not undoable action on the buffer. When the last not undoable block is closed through the call to this function, the list of undo actions is cleared and the undo manager is re-enabled.
sourcefn ensure_highlight(&self, start: &TextIter, end: &TextIter)
fn ensure_highlight(&self, start: &TextIter, end: &TextIter)
Forces buffer to analyze and highlight the given area synchronously.
<note>
<para>
This is a potentially slow operation and should be used only
when you need to make sure that some text not currently
visible is highlighted, for instance before printing.
</para>
</note>
start
start of the area to highlight.
end
end of the area to highlight.
sourcefn context_classes_at_iter(&self, iter: &TextIter) -> Vec<GString>
fn context_classes_at_iter(&self, iter: &TextIter) -> Vec<GString>
sourcefn is_highlight_matching_brackets(&self) -> bool
fn is_highlight_matching_brackets(&self) -> bool
sourcefn is_highlight_syntax(&self) -> bool
fn is_highlight_syntax(&self) -> bool
sourcefn is_implicit_trailing_newline(&self) -> bool
fn is_implicit_trailing_newline(&self) -> bool
Returns
whether the self
has an implicit trailing newline.
sourcefn language(&self) -> Option<Language>
fn language(&self) -> Option<Language>
Returns the Language
associated with the buffer,
see set_language()
. The returned object should not be
unreferenced by the user.
Returns
sourcefn max_undo_levels(&self) -> i32
fn max_undo_levels(&self) -> i32
Determines the number of undo levels the buffer will track for buffer edits.
Returns
the maximum number of possible undo levels or -1 if no limit is set.
sourcefn style_scheme(&self) -> Option<StyleScheme>
fn style_scheme(&self) -> Option<StyleScheme>
Returns the StyleScheme
associated with the buffer,
see set_style_scheme()
.
The returned object should not be unreferenced by the user.
Returns
the StyleScheme
associated with the buffer, or None
.
sourcefn undo_manager(&self) -> Option<UndoManager>
fn undo_manager(&self) -> Option<UndoManager>
Returns the UndoManager
associated with the buffer,
see set_undo_manager()
. The returned object should not be
unreferenced by the user.
Returns
the UndoManager
associated
with the buffer, or None
.
sourcefn iter_has_context_class(&self, iter: &TextIter, context_class: &str) -> bool
fn iter_has_context_class(&self, iter: &TextIter, context_class: &str) -> bool
Check if the class context_class
is set on iter
.
See the Buffer
description for the list of default context classes.
iter
context_class
class to search for.
Returns
whether iter
has the context class.
sourcefn join_lines(&self, start: &mut TextIter, end: &mut TextIter)
fn join_lines(&self, start: &mut TextIter, end: &mut TextIter)
sourcefn redo(&self)
fn redo(&self)
Redoes the last undo operation. Use can_redo()
to check whether a call to this function will have any effect.
This function emits the redo
signal.
sourcefn remove_source_marks(
&self,
start: &TextIter,
end: &TextIter,
category: Option<&str>
)
fn remove_source_marks( &self, start: &TextIter, end: &TextIter, category: Option<&str> )
sourcefn set_highlight_matching_brackets(&self, highlight: bool)
fn set_highlight_matching_brackets(&self, highlight: bool)
Controls the bracket match highlighting function in the buffer. If activated, when you position your cursor over a bracket character (a parenthesis, a square bracket, etc.) the matching opening or closing bracket character will be highlighted.
highlight
true
if you want matching brackets highlighted.
sourcefn set_highlight_syntax(&self, highlight: bool)
fn set_highlight_syntax(&self, highlight: bool)
Controls whether syntax is highlighted in the buffer.
If highlight
is true
, the text will be highlighted according to the syntax
patterns specified in the Language
set with
set_language()
.
If highlight
is false
, syntax highlighting is disabled and all the
gtk::TextTag
objects that have been added by the syntax highlighting engine
are removed from the buffer.
highlight
sourcefn set_implicit_trailing_newline(&self, implicit_trailing_newline: bool)
fn set_implicit_trailing_newline(&self, implicit_trailing_newline: bool)
Sets whether the self
has an implicit trailing newline.
If an explicit trailing newline is present in a gtk::TextBuffer
, gtk::TextView
shows it as an empty line. This is generally not what the user expects.
If implicit_trailing_newline
is true
(the default value):
- when a
FileLoader
loads the content of a file into theself
, the trailing newline (if present in the file) is not inserted into theself
. - when a
FileSaver
saves the content of theself
into a file, a trailing newline is added to the file.
On the other hand, if implicit_trailing_newline
is false
, the file’s
content is not modified when loaded into the self
, and the self
’s
content is not modified when saved into a file.
implicit_trailing_newline
the new value.
sourcefn set_language(&self, language: Option<&impl IsA<Language>>)
fn set_language(&self, language: Option<&impl IsA<Language>>)
Associates a Language
with the buffer.
Note that a Language
affects not only the syntax highlighting, but
also the [context classes][context-classes]. If you want to disable just the
syntax highlighting, see set_highlight_syntax()
.
The buffer holds a reference to language
.
language
sourcefn set_max_undo_levels(&self, max_undo_levels: i32)
fn set_max_undo_levels(&self, max_undo_levels: i32)
Sets the number of undo levels for user actions the buffer will track. If the number of user actions exceeds the limit set by this function, older actions will be discarded.
If max_undo_levels
is -1, the undo/redo is unlimited.
If max_undo_levels
is 0, the undo/redo is disabled.
max_undo_levels
the desired maximum number of undo levels.
sourcefn set_style_scheme(&self, scheme: Option<&impl IsA<StyleScheme>>)
fn set_style_scheme(&self, scheme: Option<&impl IsA<StyleScheme>>)
Sets a StyleScheme
to be used by the buffer and the view.
Note that a StyleScheme
affects not only the syntax highlighting,
but also other View
features such as highlighting the current line,
matching brackets, the line numbers, etc.
Instead of setting a None
scheme
, it is better to disable syntax
highlighting with set_highlight_syntax()
, and setting the
StyleScheme
with the “classic” or “tango” ID, because those two
style schemes follow more closely the GTK+ theme (for example for the
background color).
The buffer holds a reference to scheme
.
scheme
a StyleScheme
or None
.
sourcefn set_undo_manager(&self, manager: Option<&impl IsA<UndoManager>>)
fn set_undo_manager(&self, manager: Option<&impl IsA<UndoManager>>)
Set the buffer undo manager. If manager
is None
the default undo manager
will be set.
manager
A UndoManager
or None
.
sourcefn sort_lines(
&self,
start: &mut TextIter,
end: &mut TextIter,
flags: SortFlags,
column: i32
)
fn sort_lines( &self, start: &mut TextIter, end: &mut TextIter, flags: SortFlags, column: i32 )
sourcefn undo(&self)
fn undo(&self)
Undoes the last user action which modified the buffer. Use
can_undo()
to check whether a call to this
function will have any effect.
This function emits the undo
signal.
sourcefn connect_bracket_matched<F: Fn(&Self, Option<&TextIter>, BracketMatchType) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_bracket_matched<F: Fn(&Self, Option<&TextIter>, BracketMatchType) + 'static>( &self, f: F ) -> SignalHandlerId
iter
is set to a valid iterator pointing to the matching bracket
if state
is BracketMatchType::Found
. Otherwise iter
is
meaningless.
The signal is emitted only when the state
changes, typically when
the cursor moves.
A use-case for this signal is to show messages in a GtkStatusbar
.
iter
if found, the location of the matching bracket.
state
state of bracket matching.
sourcefn connect_highlight_updated<F: Fn(&Self, &TextIter, &TextIter) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_highlight_updated<F: Fn(&Self, &TextIter, &TextIter) + 'static>( &self, f: F ) -> SignalHandlerId
sourcefn connect_redo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_redo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
The ::redo signal is emitted to redo the last undo operation.
sourcefn connect_source_mark_updated<F: Fn(&Self, &TextMark) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_source_mark_updated<F: Fn(&Self, &TextMark) + 'static>( &self, f: F ) -> SignalHandlerId
sourcefn connect_undo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_undo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
The ::undo signal is emitted to undo the last user action which modified the buffer.