Xfce Foundation Classes
Main Page  | IndexNamespace List  |  Alphabetical List  |  Class List  |  File List


Public Member Functions
Xfc::Gtk::SourceBuffer Class Reference

A GtkSourceBuffer C++ wrapper class. More...

Inheritance diagram for Xfc::Gtk::SourceBuffer:
Xfc::Gtk::TextBuffer Xfc::G::Object Xfc::G::TypeInstance Xfc::Trackable

List of all members.

Public Member Functions

Constructors


Detailed Description

A GtkSourceBuffer C++ wrapper class.

The SourceBuffer object is the text model for SourceView widgets. It extends the Gtk::TextBuffer object by adding features necessary to display and edit source code: syntax highlighting, bracket matching and markers. It also implements support for undo/redo operations. By default syntax highlighting is enabled, but you can disable it with set_highlight(). This can be useful if you're not using SourceLanguage objects to set the highlighting patterns but instead you're manually adding SourceTag objects to the buffer's tag table.


Constructor & Destructor Documentation

Xfc::Gtk::SourceBuffer::SourceBuffer ( GtkSourceBuffer *  buffer,
bool  owns_reference = true 
) [explicit, protected]

Construct a new SourceBuffer from an existing GtkSourceBuffer.

Parameters:
bufferA pointer to a GtkSourceBuffer.
referenceSet false if the initial reference count is floating, set true if it's not.


The buffer can be a newly created GtkSourceBuffer or an existing GtkSourceBuffer (see G::Object::Object).

Xfc::Gtk::SourceBuffer::SourceBuffer ( SourceTagTable table = 0)

Constructs a new source buffer with a empty default buffer.

Parameters:
tableA source tag table, or null to have the text buffer create one for you.
Xfc::Gtk::SourceBuffer::SourceBuffer ( const SourceLanguage language)

Constructs a new source buffer which will highlight text according to the specified language.

Parameters:
languageThe source language.

Member Function Documentation

Marks the beginning of a not undoable action on the buffer, disabling the undo manager.

Typically you would call this method 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.

Determines whether a source buffer can redo the last undo action.

Returns:
true if buffer changes that were undone can be redone.

Determines whether a source buffer can undo the last action.

Returns:
true if it's possible to undo the last action.
SourceMarker* Xfc::Gtk::SourceBuffer::create_marker ( const String name,
const String type,
const TextIter where 
)

Creates a marker in the buffer of type type.

Parameters:
nameThe name of the marker, or null for an anonymous marker.
typeA String defining the marker type, or null.
whereThe location to place the new marker.
Returns:
The new SourceMarker object, owned by the buffer.


A marker is semantically very similar to a Gtk::TextMark, except it has a type which is used by the SourceView displaying the buffer to show a pixmap on the left margin, at the line the marker is in. Because of this, a marker is generally associated to a line and not a character position. Markers are also accessible through a position or range in the buffer.

Markers are implemented using Gtk::TextMark, so all characteristics and restrictions to marks apply to markers too. These includes life cycle issues and "mark-set" and "mark-deleted" signal emissions. Like a Gtk::TextMark, a SourceMarker can be anonymous if the passed name is null. Also, the buffer owns the markers so you shouldn't unreference it.

Markers always have left gravity and are moved to the beginning of the line when the user deletes the line they were in. Also, if the user deletes a region of text which contained lines with markers, those are deleted. Typical uses for a marker are bookmarks, breakpoints, current executing instruction indication in a source file, etc..

Deletes marker from the source buffer.

Parameters:
markerA SourceMarker in the buffer.


The same conditions as for Gtk::TextMark apply here. The marker is no longer accessible from the buffer, but if you held a reference to it, it will not be destroyed.

Marks the end of a not undoable action on the buffer.

When the last not undoable block is closed through the call to this method, the list of undo actions is cleared and the undo manager is re-enabled.

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

Returns:
true if the source buffer will highlight matching brackets.

Determines the escape character used by the source buffer highlighting engine.

Returns:
A G::Unichar that holds the UTF-8 escape character the buffer is using.

Gets the first marker (nearest to the top) in the buffer.

Returns:
A pointer to the first SourceMarker, or null if there are no markers in the buffer.

Determines whether text highlighting is activated in the source buffer.

Returns:
true if highlighting is enabled.

Obtains an initialized iterator to the location of marker.

Returns:
The initialized iterator.

Determines the SourceLanguage used by the buffer.

Returns:
The SourceLangauge (should not be unreferenced by the user).

Gets the last marker (nearest to the end) in the buffer.

Returns:
A pointer to the last SourceMarker, or null if there are no markers in the buffer.

Looks up the SourceMarker named name in the buffer, returning null if it doesn't exists.

Parameters:
nameThe name of the marker to retrieve.
Returns:
The SourceMarker identified by name, or null.
std::vector<SourceMarker*> Xfc::Gtk::SourceBuffer::get_markers ( const TextIter start,
const TextIter end 
) const

Gets a list of the source markers inside the range delimited by start and end.

Parameters:
startThe beginning of the range.
endThe end of the range.
Returns:
A vector of SourceMarker pointers inside the range.

Determines the number of undo levels the buffer will track for buffer edits.

Returns:
The maximum number of possible undo levels.

Gets the nearest marker to the right of iter.

Parameters:
iterThe location to start searching from.
Returns:
The SourceMarker nearest to the right of iter, or null if there are no more markers after iter.


If there are multiple markers at the same position, this function will always return the first one (from the internal linked list), even if starting the search exactly at its location. You can get the others using Gtk::SourceMarker::next().

Gets the nearest marker to the left of iter.

Parameters:
iterThe location to start searching from.
Returns:
The SourceMarker nearest to the left of iter, or null if there are no more markers before iter.


If there are multiple markers at the same position, this function will always return the last one (from the internal linked list), even if starting the search exactly at its location. You can get the others using Gtk::SourceMarker::prev().

Get the SourceTagTable associated with the buffer.

Returns:
The buffer's tag table.
void Xfc::Gtk::SourceBuffer::move_marker ( SourceMarker marker,
const TextIter where 
)

Moves marker to the new location where.

Parameters:
markerA SourceMarker.
whereThe new location for marker in the buffer.

Redoes the last undo operation.

Use can_redo() to check whether a call to this method will have any effect.

Sets the style used for highlighting matching brackets.

Parameters:
styleThe SourceTagStyle that specifies the color and text attributes to use.
void Xfc::Gtk::SourceBuffer::set_check_brackets ( bool  check_brackets)

Controls the bracket match highlighting function in the buffer.

Parameters:
check_bracketsSet true if you want matching brackets highlighted.


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. You can specify the style with the set_bracket_match_style() method.

Sets the escape character to be used by the highlighting engine.

Parameters:
escape_charA G::Unichar holding the escape character the buffer should use.


When performing the initial analysis, the engine will discard a matching syntax pattern if it's prefixed with an odd number of escape characters. This allows for example to correctly highlight strings with escaped quotes embedded. This setting affects only syntax patterns (i.e. those defined in SyntaxTags).

void Xfc::Gtk::SourceBuffer::set_highlight ( bool  highlight)

Controls whether text is highlighted in the buffer.

Parameters:
highlightSet true if you want to activate highlighting.


If highlight is true the text will be highlighted according to the patterns installed in the buffer (either set with set_language() or by adding individual SourceTags to the buffer's tag table). Otherwise, any current highlighted text will be restored to the default buffer style.

Tags not of the SourceTag type will not be removed by this option, and normal Gtk::TextTag priority settings apply when highlighting is enabled.

If you're not using a SourceLanguage to set the highlighting patterns in the buffer, it is recommended for performance reasons that you add all the SourceTags with highlighting disabled and enable highlighting when finished.

Sets the SourceLanguage the source buffer will use, adding SourceTags with the language's patterns and setting the escape character with set_escape_char().

Parameters:
languageThe SourceLanguage to set, or null.


Note that this will remove any SourceTags currently in the buffer's tag table. The buffer holds a reference to the language set.

void Xfc::Gtk::SourceBuffer::set_max_undo_levels ( int  max_undo_levels)

Sets the number of undo levels for user actions the buffer will track.

Parameters:
max_undo_levelsThe desired maximum number of undo levels.


If the number of user actions exceeds the limit set by this function, older actions will be discarded. A new action is started whenever the function Gtk::TextBuffer::begin_user_action() is called. In general, this happens whenever the user presses any key which modifies the buffer, but the undo manager will try to merge similar consecutive actions, such as multiple character insertions into one action. But, inserting a newline does start a new action.

Connect to the can_redo_signal; emitted whenever there is a change in the buffer's ability to redo an operation.

Connect to the can_undo_signal; emitted whenever there is a change in the buffer's ability to undo an operation.

Connect to the highlight_updated_signal; emitted whenever the syntax highlighting information has been updated, so that views can request a redraw if the region changed is visible.

Undoes the last user action which modified the buffer.

Use can_undo() to check whether a call to this method will have any effect. Actions are defined as groups of operations between a call to Gtk::TextBuffer's begin_user_action() and end_user_action() methods, or sequences of similar edits (inserts or deletes) on the same line.


The documentation for this class was generated from the following file:
Xfce Foundation Classes
Copyright © 2004-2005 The XFC Development Team XFC