Reference Manual
Inti Logo
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

Inti::Gtk::SourceBuffer Class Reference

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

#include <inti/gtk-sourceview/sourcebuffer.h>

List of all members.

Public Member Functions

Constructors
Accessors
Methods
Property Proxies
Signal Proxies

Protected Member Functions

Constructors
Signal Handlers

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

Inti::Gtk::SourceBuffer::SourceBuffer GtkSourceBuffer *  buffer,
bool  reference = false
[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).

Inti::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.

Inti::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

void Inti::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.

bool Inti::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.

bool Inti::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.

SourceMarker* Inti::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 Inti::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.

void Inti::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.

bool Inti::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.

G::Unichar Inti::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.

SourceMarker* Inti::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.

bool Inti::Gtk::SourceBuffer::get_highlight  )  const
 

Determines whether text highlighting is activated in the source buffer.

Returns:
true if highlighting is enabled.

TextIter Inti::Gtk::SourceBuffer::get_iter_at_marker const SourceMarker marker  )  const
 

Obtains an initialized iterator to the location of marker.

Returns:
The initialized iterator.

SourceLanguage* Inti::Gtk::SourceBuffer::get_language  )  const
 

Determines the SourceLanguage used by the buffer.

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

SourceMarker* Inti::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.

SourceMarker* Inti::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*> Inti::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.

int Inti::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.

SourceMarker* Inti::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* Inti::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().

SourceTagTable* Inti::Gtk::SourceBuffer::get_source_tag_table  )  const
 

Get the SourceTagTable associated with the buffer.

Returns:
The buffer's tag table.

void Inti::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.

virtual void Inti::Gtk::SourceBuffer::on_can_redo bool  can_redo  )  [protected, virtual]
 

Called whenever there is a change in the buffer's ability to redo an operation.

Parameters:
can_redo Will be true if the buffer can now perform a redo.

This signal can be used to change the sensitivity of the Redo menu item or toolbar button.

virtual void Inti::Gtk::SourceBuffer::on_can_undo bool  can_undo  )  [protected, virtual]
 

Called whenever there is a change in the buffer's ability to undo an operation.

Parameters:
can_undo Will be true if the buffer can now perform an undo.

This signal can be used to change the sensitivity of the Undo menu item or toolbar button.

virtual void Inti::Gtk::SourceBuffer::on_highlight_updated TextIter &  start,
TextIter &  end
[protected, virtual]
 

Called whenever the syntax highlighting information has been updated, so that views can request a redraw if the region changed is visible.

Parameters:
start The start position of the updated region in the buffer.
end The end position of the updated region in the buffer.

Usually only view widgets displaying the buffer will be interested in this signal.

virtual void Inti::Gtk::SourceBuffer::on_marker_updated TextIter &  where  )  [protected, virtual]
 

Called whenever a marker of sourcebuffer has changed and needs to be redisplayed by the view.

Parameters:
where The position in the buffer where the change occurred.

A change in a marker's type or location can trigger this signal. Note that moving a marker causes the emission of this signal twice: once for the old location and once for the new.

void Inti::Gtk::SourceBuffer::redo  ) 
 

Redoes the last undo operation.

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

void Inti::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 Inti::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 Inti::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 Inti::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 Inti::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 Inti::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 Inti::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.


The documentation for this class was generated from the following file: Main Page - Footer


Generated on Wed Aug 27 21:17:27 2003 for Inti-SourceView by doxygen 1.3.2 written by Dimitri van Heesch, © 1997-2002