|  |  |  | GtkSourceView 2 Reference Manual |  | 
|---|---|---|---|---|
| Top | Description | Object Hierarchy | Implemented Interfaces | Properties | Signals | ||||
#include <gtksourceview/gtksourceview.h>
                    GtkSourceView;
                    GtkSourceViewClass;
enum                GtkSourceSmartHomeEndType;
enum                GtkSourceDrawSpacesFlags;
GtkWidget *         gtk_source_view_new                 (void);
GtkWidget *         gtk_source_view_new_with_buffer     (GtkSourceBuffer *buffer);
void                gtk_source_view_set_auto_indent     (GtkSourceView *view,
                                                         gboolean enable);
gboolean            gtk_source_view_get_auto_indent     (GtkSourceView *view);
void                gtk_source_view_set_indent_on_tab   (GtkSourceView *view,
                                                         gboolean enable);
gboolean            gtk_source_view_get_indent_on_tab   (GtkSourceView *view);
void                gtk_source_view_set_indent_width    (GtkSourceView *view,
                                                         gint width);
gint                gtk_source_view_get_indent_width    (GtkSourceView *view);
void                gtk_source_view_set_insert_spaces_instead_of_tabs
                                                        (GtkSourceView *view,
                                                         gboolean enable);
gboolean            gtk_source_view_get_insert_spaces_instead_of_tabs
                                                        (GtkSourceView *view);
void                gtk_source_view_set_smart_home_end  (GtkSourceView *view,
                                                         GtkSourceSmartHomeEndType smart_he);
GtkSourceSmartHomeEndType  gtk_source_view_get_smart_home_end
                                                        (GtkSourceView *view);
void                gtk_source_view_set_mark_category_priority
                                                        (GtkSourceView *view,
                                                         const gchar *category,
                                                         gint priority);
gint                gtk_source_view_get_mark_category_priority
                                                        (GtkSourceView *view,
                                                         const gchar *category);
void                gtk_source_view_set_mark_category_pixbuf
                                                        (GtkSourceView *view,
                                                         const gchar *category,
                                                         GdkPixbuf *pixbuf);
GdkPixbuf *         gtk_source_view_get_mark_category_pixbuf
                                                        (GtkSourceView *view,
                                                         const gchar *category);
gboolean            gtk_source_view_get_mark_category_background
                                                        (GtkSourceView *view,
                                                         const gchar *category,
                                                         GdkColor *dest);
void                gtk_source_view_set_mark_category_background
                                                        (GtkSourceView *view,
                                                         const gchar *category,
                                                         const GdkColor *color);
void                gtk_source_view_set_highlight_current_line
                                                        (GtkSourceView *view,
                                                         gboolean show);
gboolean            gtk_source_view_get_highlight_current_line
                                                        (GtkSourceView *view);
void                gtk_source_view_set_show_line_marks (GtkSourceView *view,
                                                         gboolean show);
gboolean            gtk_source_view_get_show_line_marks (GtkSourceView *view);
void                gtk_source_view_set_show_line_numbers
                                                        (GtkSourceView *view,
                                                         gboolean show);
gboolean            gtk_source_view_get_show_line_numbers
                                                        (GtkSourceView *view);
void                gtk_source_view_set_show_right_margin
                                                        (GtkSourceView *view,
                                                         gboolean show);
gboolean            gtk_source_view_get_show_right_margin
                                                        (GtkSourceView *view);
void                gtk_source_view_set_right_margin_position
                                                        (GtkSourceView *view,
                                                         guint pos);
guint               gtk_source_view_get_right_margin_position
                                                        (GtkSourceView *view);
void                gtk_source_view_set_tab_width       (GtkSourceView *view,
                                                         guint width);
guint               gtk_source_view_get_tab_width       (GtkSourceView *view);
void                gtk_source_view_set_draw_spaces     (GtkSourceView *view,
                                                         GtkSourceDrawSpacesFlags flags);
GtkSourceDrawSpacesFlags  gtk_source_view_get_draw_spaces
                                                        (GtkSourceView *view);
  GObject
   +----GInitiallyUnowned
         +----GtkObject
               +----GtkWidget
                     +----GtkContainer
                           +----GtkTextView
                                 +----GtkSourceView
"auto-indent" gboolean : Read / Write "draw-spaces" GtkSourceDrawSpacesFlags : Read / Write "highlight-current-line" gboolean : Read / Write "indent-on-tab" gboolean : Read / Write "indent-width" gint : Read / Write "insert-spaces-instead-of-tabs" gboolean : Read / Write "right-margin-position" guint : Read / Write "show-line-marks" gboolean : Read / Write "show-line-numbers" gboolean : Read / Write "show-right-margin" gboolean : Read / Write "smart-home-end" GtkSourceSmartHomeEndType : Read / Write "tab-width" guint : Read / Write
GtkSourceView is the main object of the gtksourceview library. It provides a text view which syntax highlighting, undo/redo and text marks. Use a GtkSourceBuffer to display text with a GtkSourceView.
typedef struct {
	GtkTextViewClass parent_class;
	void (*undo) (GtkSourceView *view);
	void (*redo) (GtkSourceView *view);
	/* Padding for future expansion */
	void (*_gtk_source_reserved1) (void);
	void (*_gtk_source_reserved2) (void);
	void (*_gtk_source_reserved3) (void);
	void (*_gtk_source_reserved4) (void);
} GtkSourceViewClass;
typedef enum
{
	GTK_SOURCE_SMART_HOME_END_DISABLED,
	GTK_SOURCE_SMART_HOME_END_BEFORE,
	GTK_SOURCE_SMART_HOME_END_AFTER,
	GTK_SOURCE_SMART_HOME_END_ALWAYS
} GtkSourceSmartHomeEndType;
| smart-home-end disabled. | |
| move to the first/last non-whitespace character on the first press of the HOME/END keys and to the beginning/end of the line on the second press. | |
| move to the beginning/end of the line on the first press of the HOME/END keys and to the first/last non-whitespace character on the second press. | |
| always move to the first/last non-whitespace character when the HOME/END keys are pressed. | 
typedef enum
{
	GTK_SOURCE_DRAW_SPACES_SPACE      = 1 << 0,
	GTK_SOURCE_DRAW_SPACES_TAB        = 1 << 1,
	GTK_SOURCE_DRAW_SPACES_NEWLINE    = 1 << 2,
	GTK_SOURCE_DRAW_SPACES_NBSP       = 1 << 3,
	GTK_SOURCE_DRAW_SPACES_ALL        = (GTK_SOURCE_DRAW_SPACES_SPACE   | \
	                                     GTK_SOURCE_DRAW_SPACES_TAB     | \
	                                     GTK_SOURCE_DRAW_SPACES_NEWLINE | \
	                                     GTK_SOURCE_DRAW_SPACES_NBSP)
} GtkSourceDrawSpacesFlags;
GtkSourceDrawSpacesFlags determine what kind of spaces whould be drawn.
| whether the space character should be drawn. | |
| whether the tab character should be drawn. | |
| whether the line breaks should be drawn. | |
| whether the non-breaking whitespaces should be drawn. | |
| wheter all kind of spaces should be drawn. | 
GtkWidget * gtk_source_view_new (void);
Creates a new GtkSourceView. An empty default buffer will be
created for you. If you want to specify your own buffer, consider
gtk_source_view_new_with_buffer().
| Returns : | a new GtkSourceView | 
GtkWidget * gtk_source_view_new_with_buffer (GtkSourceBuffer *buffer);
Creates a new GtkSourceView widget displaying the buffer
buffer. One buffer can be shared among many widgets.
| 
 | a GtkSourceBuffer. | 
| Returns : | a new GtkTextView. | 
void gtk_source_view_set_auto_indent (GtkSourceView *view, gboolean enable);
If TRUE auto indentation of text is enabled.
| 
 | a GtkSourceView. | 
| 
 | whether to enable auto indentation. | 
gboolean gtk_source_view_get_auto_indent (GtkSourceView *view);
Returns whether auto indentation of text is enabled.
| 
 | a GtkSourceView. | 
| Returns : | TRUEif auto indentation is enabled. | 
void gtk_source_view_set_indent_on_tab (GtkSourceView *view, gboolean enable);
If TRUE, when the tab key is pressed and there is a selection, the
selected text is indented of one level instead of being replaced with
the \t characters. Shift+Tab unindents the selection.
| 
 | a GtkSourceView. | 
| 
 | whether to indent a block when tab is pressed. | 
Since 1.8
gboolean gtk_source_view_get_indent_on_tab (GtkSourceView *view);
Returns whether when the tab key is pressed the current selection should get indented instead of replaced with the \t character.
| 
 | a GtkSourceView. | 
| Returns : | TRUEif the selection is indented when tab is pressed. | 
Since 1.8
void gtk_source_view_set_indent_width (GtkSourceView *view, gint width);
Sets the number of spaces to use for each step of indent.
If width is -1, the value of the GtkSourceView::tab-width property
will be used.
| 
 | a GtkSourceView. | 
| 
 | indent width in characters. | 
gint gtk_source_view_get_indent_width (GtkSourceView *view);
Returns the number of spaces to use for each step of indent.
See gtk_source_view_set_indent_width() for details.
| 
 | a GtkSourceView. | 
| Returns : | indent width. | 
void                gtk_source_view_set_insert_spaces_instead_of_tabs
                                                        (GtkSourceView *view,
                                                         gboolean enable);
If TRUE any tabulator character inserted is replaced by a group
of space characters.
| 
 | a GtkSourceView. | 
| 
 | whether to insert spaces instead of tabs. | 
gboolean            gtk_source_view_get_insert_spaces_instead_of_tabs
                                                        (GtkSourceView *view);
Returns whether when inserting a tabulator character it should be replaced by a group of space characters.
| 
 | a GtkSourceView. | 
| Returns : | TRUEif spaces are inserted instead of tabs. | 
void gtk_source_view_set_smart_home_end (GtkSourceView *view, GtkSourceSmartHomeEndType smart_he);
Set the desired movement of the cursor when HOME and END keys are pressed.
| 
 | a GtkSourceView. | 
| 
 | the desired behavior among GtkSourceSmartHomeEndType. | 
GtkSourceSmartHomeEndType gtk_source_view_get_smart_home_end (GtkSourceView *view);
Returns a GtkSourceSmartHomeEndType end value specifying how the cursor will move when HOME and END keys are pressed.
| 
 | a GtkSourceView. | 
| Returns : | a GtkSourceSmartHomeEndTypeend value. | 
void                gtk_source_view_set_mark_category_priority
                                                        (GtkSourceView *view,
                                                         const gchar *category,
                                                         gint priority);
Set the priority for the given mark category. When there are
multiple marks on the same line, marks of categories with
higher priorities will be drawn on top.
| 
 | a GtkSourceView. | 
| 
 | a mark category. | 
| 
 | the priority for the category | 
Since 2.2
gint                gtk_source_view_get_mark_category_priority
                                                        (GtkSourceView *view,
                                                         const gchar *category);
Gets the priority which is associated with the given category.
| 
 | a GtkSourceView. | 
| 
 | a mark category. | 
| Returns : | the priority or if categoryexists but no priority was set, it defaults to 0. | 
Since 2.2
void                gtk_source_view_set_mark_category_pixbuf
                                                        (GtkSourceView *view,
                                                         const gchar *category,
                                                         GdkPixbuf *pixbuf);
Associates a given pixbuf with a given mark category.
If pixbuf is NULL, the pixbuf is unset.
| 
 | a GtkSourceView. | 
| 
 | a mark category. | 
| 
 | a GdkPixbuf or NULL. | 
Since 2.2
GdkPixbuf *         gtk_source_view_get_mark_category_pixbuf
                                                        (GtkSourceView *view,
                                                         const gchar *category);
Gets the pixbuf which is associated with the given mark category.
| 
 | a GtkSourceView. | 
| 
 | a mark category. | 
| Returns : | the associated GdkPixbuf, or NULLif not found. | 
Since 2.2
gboolean            gtk_source_view_get_mark_category_background
                                                        (GtkSourceView *view,
                                                         const gchar *category,
                                                         GdkColor *dest);
Gets the background color associated with given category.
| 
 | a GtkSourceView. | 
| 
 | a mark category. | 
| 
 | destination GdkColor structure to fill in. | 
| Returns : | TRUEif background color forcategorywas set
anddestis set to a valid color, orFALSEotherwise. | 
Since 2.4
void                gtk_source_view_set_mark_category_background
                                                        (GtkSourceView *view,
                                                         const gchar *category,
                                                         const GdkColor *color);
Sets given background color for mark category.
If color is NULL, the background color is unset.
| 
 | a GtkSourceView. | 
| 
 | a mark category. | 
| 
 | background color or NULLto unset it. | 
Since 2.4
void                gtk_source_view_set_highlight_current_line
                                                        (GtkSourceView *view,
                                                         gboolean show);
If show is TRUE the current line is highlighted.
| 
 | a GtkSourceView | 
| 
 | whether to highlight the current line | 
gboolean            gtk_source_view_get_highlight_current_line
                                                        (GtkSourceView *view);
Returns whether the current line is highlighted
| 
 | a GtkSourceView | 
| Returns : | TRUEif the current line is highlighted. | 
void gtk_source_view_set_show_line_marks (GtkSourceView *view, gboolean show);
If TRUE line marks will be displayed beside the text.
| 
 | a GtkSourceView. | 
| 
 | whether line marks should be displayed. | 
Since 2.2
gboolean gtk_source_view_get_show_line_marks (GtkSourceView *view);
Returns whether line marks are displayed beside the text.
| 
 | a GtkSourceView. | 
| Returns : | TRUEif the line marks are displayed. | 
Since 2.2
void                gtk_source_view_set_show_line_numbers
                                                        (GtkSourceView *view,
                                                         gboolean show);
If TRUE line numbers will be displayed beside the text.
| 
 | a GtkSourceView. | 
| 
 | whether line numbers should be displayed. | 
gboolean            gtk_source_view_get_show_line_numbers
                                                        (GtkSourceView *view);
Returns whether line numbers are displayed beside the text.
| 
 | a GtkSourceView. | 
| Returns : | TRUEif the line numbers are displayed. | 
void                gtk_source_view_set_show_right_margin
                                                        (GtkSourceView *view,
                                                         gboolean show);
If TRUE a right margin is displayed
| 
 | a GtkSourceView. | 
| 
 | whether to show a right margin. | 
gboolean            gtk_source_view_get_show_right_margin
                                                        (GtkSourceView *view);
Returns whether a right margin is displayed.
| 
 | a GtkSourceView. | 
| Returns : | TRUEif the right margin is shown. | 
void                gtk_source_view_set_right_margin_position
                                                        (GtkSourceView *view,
                                                         guint pos);
Sets the position of the right margin in the given view.
| 
 | a GtkSourceView. | 
| 
 | the width in characters where to position the right margin. | 
guint               gtk_source_view_get_right_margin_position
                                                        (GtkSourceView *view);
Gets the position of the right margin in the given view.
| 
 | a GtkSourceView. | 
| Returns : | the position of the right margin. | 
void gtk_source_view_set_tab_width (GtkSourceView *view, guint width);
Sets the width of tabulation in characters.
| 
 | a GtkSourceView. | 
| 
 | width of tab in characters. | 
guint gtk_source_view_get_tab_width (GtkSourceView *view);
Returns the width of tabulation in characters.
| 
 | a GtkSourceView. | 
| Returns : | width of tab. | 
void gtk_source_view_set_draw_spaces (GtkSourceView *view, GtkSourceDrawSpacesFlags flags);
Set if and how the spaces should be visualized. Specifying flags as 0 will
disable display of spaces.
| 
 | a GtkSourceView. | 
| 
 | GtkSourceDrawSpacesFlags specifing how white spaces should be displayed | 
GtkSourceDrawSpacesFlags gtk_source_view_get_draw_spaces (GtkSourceView *view);
Returns the GtkSourceDrawSpacesFlags specifying if and how spaces
should be displayed for this view.
| 
 | a GtkSourceView | 
| Returns : | the GtkSourceDrawSpacesFlags, 0 if no spaces should be drawn. | 
"auto-indent" property"auto-indent" gboolean : Read / Write
Whether to enable auto indentation.
Default value: FALSE
"draw-spaces" property"draw-spaces" GtkSourceDrawSpacesFlags : Read / Write
Set if and how the spaces should be visualized.
Since 2.4
"highlight-current-line" property"highlight-current-line" gboolean : Read / Write
Whether to highlight the current line.
Default value: FALSE
"indent-on-tab" property"indent-on-tab" gboolean : Read / Write
Whether to indent the selected text when the tab key is pressed.
Default value: TRUE
"indent-width" property"indent-width" gint : Read / Write
Width of an indentation step expressed in number of spaces.
Allowed values: [G_MAXULONG,32]
Default value: -1
"insert-spaces-instead-of-tabs" property"insert-spaces-instead-of-tabs" gboolean : Read / Write
Whether to insert spaces instead of tabs.
Default value: FALSE
"right-margin-position" property"right-margin-position" guint : Read / Write
Position of the right margin.
Allowed values: [1,200]
Default value: 80
"show-line-marks" property"show-line-marks" gboolean : Read / Write
Whether to display line mark pixbufs
Default value: FALSE
"show-line-numbers" property"show-line-numbers" gboolean : Read / Write
Whether to display line numbers
Default value: FALSE
"show-right-margin" property"show-right-margin" gboolean : Read / Write
Whether to display the right margin.
Default value: FALSE
"smart-home-end" property"smart-home-end" GtkSourceSmartHomeEndType : Read / Write
Set the behavior of the HOME and END keys.
Default value: GTK_SOURCE_SMART_HOME_END_DISABLED
Since 2.0
"redo" signalvoid user_function (GtkSourceView *sourceview, gpointer user_data) : Run Last / Action
| 
 | the object which received the signal. | 
| 
 | user data set when the signal handler was connected. | 
"undo" signalvoid user_function (GtkSourceView *sourceview, gpointer user_data) : Run Last / Action
| 
 | the object which received the signal. | 
| 
 | user data set when the signal handler was connected. |