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


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

Accessors
Methods
Property Proxies
Signal Proxies

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:
buffer A pointer to a GtkSourceBuffer.
reference Set 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:
table A 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:
language The source language.

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

Construct a new SourceBuffer from an existing GtkSourceBuffer.

Parameters:
buffer A pointer to a GtkSourceBuffer.
reference Set 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:
table A 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:
language The source language.


Member Function Documentation

SourceTagTable* Xfc::Gtk::SourceBuffer::get_source_tag_table (  )  const

Get the SourceTagTable associated with the buffer.

Returns:
The buffer's tag table.

bool Xfc::Gtk::SourceBuffer::get_check_brackets (  )  const

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

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

bool Xfc::Gtk::SourceBuffer::get_highlight (  )  const

Determines whether text highlighting is activated in the source buffer.

Returns:
true if highlighting is enabled.

int Xfc::Gtk::SourceBuffer::get_max_undo_levels (  )  const

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

Returns:
The maximum number of possible undo levels.

SourceLanguage* Xfc::Gtk::SourceBuffer::get_language (  )  const

Determines the SourceLanguage used by the buffer.

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

G::Unichar Xfc::Gtk::SourceBuffer::get_escape_char (  )  const

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.

bool Xfc::Gtk::SourceBuffer::can_undo (  )  const

Determines whether a source buffer can undo the last action.

Returns:
true if it's possible to undo the last action.

bool Xfc::Gtk::SourceBuffer::can_redo (  )  const

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

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

SourceMarker* Xfc::Gtk::SourceBuffer::get_marker ( const String name  )  const

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

Parameters:
name The 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:
start The beginning of the range.
end The end of the range.
Returns:
A vector of SourceMarker pointers inside the range.

SourceMarker* Xfc::Gtk::SourceBuffer::get_first_marker (  )  const

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.

SourceMarker* Xfc::Gtk::SourceBuffer::get_last_marker (  )  const

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.

TextIter Xfc::Gtk::SourceBuffer::get_iter_at_marker ( const SourceMarker marker  )  const

Obtains an initialized iterator to the location of marker.

Returns:
The initialized iterator.

SourceMarker* Xfc::Gtk::SourceBuffer::get_next_marker ( TextIter iter  )  const

Gets the nearest marker to the right of iter.

Parameters:
iter The 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().

SourceMarker* Xfc::Gtk::SourceBuffer::get_prev_marker ( TextIter iter  )  const

Gets the nearest marker to the left of iter.

Parameters:
iter The 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().

void Xfc::Gtk::SourceBuffer::set_check_brackets ( bool  check_brackets  ) 

Controls the bracket match highlighting function in the buffer.

Parameters:
check_brackets Set 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.

void Xfc::Gtk::SourceBuffer::set_bracket_match_style ( const SourceTagStyle style  ) 

Sets the style used for highlighting matching brackets.

Parameters:
style The SourceTagStyle that specifies the color and text attributes to use.

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

Controls whether text is highlighted in the buffer.

Parameters:
highlight Set 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.

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_levels The 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.

void Xfc::Gtk::SourceBuffer::set_language ( const SourceLanguage language  ) 

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:
language The 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_escape_char ( G::Unichar  escape_char  ) 

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

Parameters:
escape_char A 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::undo (  ) 

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.

void Xfc::Gtk::SourceBuffer::redo (  ) 

Redoes the last undo operation.

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

void Xfc::Gtk::SourceBuffer::begin_not_undoable_action (  ) 

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.

void Xfc::Gtk::SourceBuffer::end_not_undoable_action (  ) 

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.

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:
name The name of the marker, or null for an anonymous marker.
type A String defining the marker type, or null.
where The 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..

void Xfc::Gtk::SourceBuffer::move_marker ( SourceMarker marker,
const TextIter where 
)

Moves marker to the new location where.

Parameters:
marker A SourceMarker.
where The new location for marker in the buffer.

void Xfc::Gtk::SourceBuffer::delete_marker ( SourceMarker marker  ) 

Deletes marker from the source buffer.

Parameters:
marker A 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.


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