View
Subclass of class@Gtk.TextView.
GtkSourceView
is the main class of the GtkSourceView library. Use a class@Buffer to display text with a GtkSourceView
.
This class provides:
Show the line numbers;
Show a right margin;
Highlight the current line;
Indentation settings;
Configuration for the Home and End keyboard keys;
Configure and show line marks;
And a few other things.
An easy way to test all these features is to use the test-widget mini-program provided in the GtkSourceView repository, in the tests/ directory.
GtkSourceView as GtkBuildable
The GtkSourceView implementation of the iface@Gtk.Buildable interface exposes the property@View:completion object with the internal-child "completion".
An example of a UI definition fragment with GtkSourceView:
<object class="GtkSourceView" id="source_view">
<property name="tab-width">4</property>
<property name="auto-indent">True</property>
<child internal-child="completion">
<object class="GtkSourceCompletion">
<property name="select-on-show">False</property>
</object>
</child>
</object>
Changing the Font
Gtk CSS provides the best way to change the font for a GtkSourceView
in a manner that allows for components like class@Map to scale the desired font.
GtkCssProvider *provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider,
"textview { font-family: Monospace; font-size: 8pt; }",
-1,
NULL);
gtk_style_context_add_provider (gtk_widget_get_style_context (view),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
If you need to adjust the font or size of font within a portion of the document only, you should use a class@Gtk.TextTag with the property@Gtk.TextTag:family or property@Gtk.TextTag:scale set so that the font size may be scaled relative to the default font set in CSS.
Skipped during bindings generation
method
get_gutter
: C function gtk_source_view_get_gutter is ignoredparameter
priority
: Unsupported pointer to primitive typesignal
push-snippet
: Unsupported parameterlocation
: location: In/Out parameter is not supported
Inheritors
Constructors
Properties
Draw a specific background pattern on the view.
The completion object associated with the view
The property denotes if snippets should be expanded when the user presses Tab after having typed a word matching the snippets found in class@SnippetManager.
Width of an indentation step expressed in number of spaces.
Position of the right margin.
Whether to display line mark pixbufs
Whether to display line numbers
Whether to display the right margin.
Whether smart Backspace should be used.
Set the behavior of the HOME and END keys.
The class@SpaceDrawer object associated with the view.4
Functions
Keybinding signal to change case of the text at the current cursor position.
Keybinding signal to edit a number at the current cursor position.
Keybinding signal to join the lines currently selected.
Emitted when a line mark has been activated (for instance when there was a button press in the line marks gutter).
The signal is a keybinding which gets emitted when the user initiates moving a line.
Keybinding signal to move the cursor to the matching bracket.
The signal is a keybinding which gets emitted when the user initiates moving a word.
The signal is a key binding signal which gets emitted when the user requests a completion, by pressing
Emitted when a the cursor was moved according to the smart home end setting.
Returns whether auto-indentation of text is enabled.
Returns the #GtkSourceBackgroundPatternType specifying if and how the background pattern should be displayed for this @view.
Gets the class@Completion associated with @view.
Gets the property@View:enable-snippets property.
Returns whether the current line is highlighted.
Gets the property@View:indenter property.
Returns whether when the tab key is pressed the current selection should get indented instead of replaced with the \t
character.
Returns the number of spaces to use for each step of indent.
Returns whether when inserting a tabulator character it should be replaced by a group of space characters.
Gets the position of the right margin in the given @view.
Returns whether line marks are displayed beside the text.
Returns whether line numbers are displayed beside the text.
Returns whether a right margin is displayed.
Returns true if pressing the Backspace key will try to delete spaces up to the previous tab stop.
Returns a enum@SmartHomeEndType end value specifying how the cursor will move when HOME and END keys are pressed.
Gets the class@SpaceDrawer associated with @view.
Returns the width of tabulation in characters.
Determines the visual column at @iter taking into consideration the property@View:tab-width of @view.
Inserts one indentation level at the beginning of the specified lines. The empty lines are not indented.
Inserts a new snippet at @location
If true auto-indentation of text is enabled.
Set if and how the background pattern should be displayed.
Sets the property@View:enable-snippets property.
If @highlight is true the current line will be highlighted.
Sets the indenter for @view to @indenter.
If true, when the tab key is pressed when several lines are selected, the selected lines are indented of one level instead of being replaced with a \t
character. Shift+Tab unindents the selection.
Sets the number of spaces to use for each step of indent when the tab key is pressed.
If true a tab key pressed is replaced by a group of space characters.
Sets attributes and priority for the @category.
Sets the position of the right margin in the given @view.
If true line marks will be displayed beside the text.
If true line numbers will be displayed beside the text.
If true a right margin is displayed.
When set to true, pressing the Backspace key will try to delete spaces up to the previous tab stop.
Set the desired movement of the cursor when HOME and END keys are pressed.
Sets the width of tabulation in characters.
Removes one indentation level at the beginning of the specified lines.