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

Trait containing all Buffer methods.

Implementors

Buffer

Provided Methods§

source

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.

source

fn can_redo(&self) -> bool

Determines whether a source buffer can redo the last action (i.e. if the last operation was an undo).

Returns

true if a redo is possible.

source

fn can_undo(&self) -> bool

Determines whether a source buffer can undo the last action.

Returns

true if it’s possible to undo the last action.

source

fn change_case( &self, case_type: ChangeCaseType, start: &mut TextIter, end: &mut TextIter )

Changes the case of the text between the specified iterators.

case_type

how to change the case.

start

a gtk::TextIter.

end

a gtk::TextIter.

source

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.

source

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.

source

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.

source

fn context_classes_at_iter(&self, iter: &TextIter) -> Vec<GString>

Get all defined context classes at iter.

See the Buffer description for the list of default context classes.

iter

a gtk::TextIter.

Returns

a new None terminated array of context class names. Use g_strfreev() to free the array if it is no longer needed.

source

fn is_highlight_matching_brackets(&self) -> bool

Determines whether bracket match highlighting is activated for the source buffer.

Returns

true if the source buffer will highlight matching brackets.

source

fn is_highlight_syntax(&self) -> bool

Determines whether syntax highlighting is activated in the source buffer.

Returns

true if syntax highlighting is enabled, false otherwise.

source

fn is_implicit_trailing_newline(&self) -> bool

Returns

whether the self has an implicit trailing newline.

source

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

the Language associated with the buffer, or None.

source

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.

source

fn source_marks_at_iter( &self, iter: &mut TextIter, category: Option<&str> ) -> Vec<Mark>

Returns the list of marks of the given category at iter. If category is None it returns all marks at iter.

iter

an iterator.

category

category to search for, or None

Returns

a newly allocated GSList.

source

fn source_marks_at_line(&self, line: i32, category: Option<&str>) -> Vec<Mark>

Returns the list of marks of the given category at line. If category is None, all marks at line are returned.

line

a line number.

category

category to search for, or None

Returns

a newly allocated GSList.

source

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.

source

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.

source

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

a gtk::TextIter.

context_class

class to search for.

Returns

whether iter has the context class.

source

fn join_lines(&self, start: &mut TextIter, end: &mut TextIter)

Joins the lines of text between the specified iterators.

start

a gtk::TextIter.

end

a gtk::TextIter.

source

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.

source

fn remove_source_marks( &self, start: &TextIter, end: &TextIter, category: Option<&str> )

Remove all marks of category between start and end from the buffer. If category is NULL, all marks in the range will be removed.

start

a gtk::TextIter.

end

a gtk::TextIter.

category

category to search for, or None.

source

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.

source

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

true to enable syntax highlighting, false to disable it.

source

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 the self, the trailing newline (if present in the file) is not inserted into the self.
  • when a FileSaver saves the content of the self 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.

source

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

a Language to set, or None.

source

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.

source

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.

source

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.

source

fn sort_lines( &self, start: &mut TextIter, end: &mut TextIter, flags: SortFlags, column: i32 )

Sort the lines of text between the specified iterators.

start

a gtk::TextIter.

end

a gtk::TextIter.

flags

SortFlags specifying how the sort should behave

column

sort considering the text starting at the given column

source

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.

source

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.

source

fn connect_highlight_updated<F: Fn(&Self, &TextIter, &TextIter) + 'static>( &self, f: F ) -> SignalHandlerId

The ::highlight-updated signal is emitted when the syntax highlighting and [context classes][context-classes] are updated in a certain region of the buffer.

start

the start of the updated region

end

the end of the updated region

source

fn connect_redo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

The ::redo signal is emitted to redo the last undo operation.

source

fn connect_source_mark_updated<F: Fn(&Self, &TextMark) + 'static>( &self, f: F ) -> SignalHandlerId

The ::source-mark-updated signal is emitted each time a mark is added to, moved or removed from the buffer.

mark

the Mark

source

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.

source

fn connect_can_redo_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_can_undo_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_highlight_matching_brackets_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_highlight_syntax_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_implicit_trailing_newline_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_language_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_max_undo_levels_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_style_scheme_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_undo_manager_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<O: IsA<Buffer>> BufferExt for O