GtkSource.View¶
| Subclasses: | GtkSource.Map | 
|---|
Methods¶
Virtual Methods¶
| Inherited: | Gtk.TextView (13), Gtk.Container (10), Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10), Gtk.Scrollable (1) | 
|---|
| do_line_mark_activated(iter, event) | |
| do_move_lines(copy, step) | |
| do_move_words(step) | |
| do_redo() | |
| do_show_completion() | |
| do_undo() | 
Properties¶
| Inherited: | Gtk.TextView (21), Gtk.Container (3), Gtk.Widget (39), Gtk.Scrollable (4) | 
|---|
| Name | Type | Flags | Short Description | 
|---|---|---|---|
| auto-indent | bool | r/w | Whether to enable auto indentation | 
| background-pattern | GtkSource.BackgroundPatternType | r/w | Draw a specific background pattern on the view | 
| completion | GtkSource.Completion | r | The completion object associated with the view | 
| draw-spaces | GtkSource.DrawSpacesFlags | d/r/w | Set if and how the spaces should be visualized deprecated | 
| highlight-current-line | bool | r/w | Whether to highlight the current line | 
| indent-on-tab | bool | r/w | Whether to indent the selected text when the tab key is pressed | 
| indent-width | int | r/w | Number of spaces to use for each step of indent | 
| insert-spaces-instead-of-tabs | bool | r/w | Whether to insert spaces instead of tabs | 
| right-margin-position | int | r/w | Position of the right margin | 
| show-line-marks | bool | r/w | Whether to display line mark pixbufs | 
| show-line-numbers | bool | r/w | Whether to display line numbers | 
| show-right-margin | bool | r/w | Whether to display the right margin | 
| smart-backspace | bool | r/w | |
| smart-home-end | GtkSource.SmartHomeEndType | r/w | HOME and END keys move to first/last non whitespace characters on line before going to the start/end of the line | 
| space-drawer | GtkSource.SpaceDrawer | r | |
| tab-width | int | r/w | Width of a tab character expressed in spaces | 
Style Properties¶
| Inherited: | Gtk.TextView (1), Gtk.Widget (17) | 
|---|
Signals¶
| Inherited: | Gtk.TextView (16), Gtk.Container (4), Gtk.Widget (69), GObject.Object (1) | 
|---|
| Name | Short Description | 
|---|---|
| change-case | Keybinding signal to change case of the text at the current cursor position. | 
| change-number | Keybinding signal to edit a number at the current cursor position. | 
| join-lines | Keybinding signal to join the lines currently selected. | 
| line-mark-activated | Emitted when a line mark has been activated (for instance when there was a button press in the line marks gutter). | 
| move-lines | The ::move-linessignal is a keybinding which gets emitted when the user initiates moving a line. | 
| move-to-matching-bracket | Keybinding signal to move the cursor to the matching bracket. | 
| move-words | The ::move-wordssignal is a keybinding which gets emitted when the user initiates moving a word. | 
| redo | |
| show-completion | The ::show-completionsignal is a key binding signal which gets emitted when the user requests a completion, by pressing  Control + space. | 
| smart-home-end | Emitted when a the cursor was moved according to the smart home end setting. | 
| undo | 
Fields¶
| Inherited: | Gtk.TextView (16), Gtk.Container (4), Gtk.Widget (69), GObject.Object (1) | 
|---|
| Name | Type | Access | Description | 
|---|---|---|---|
| parent | Gtk.TextView | r | 
Class Details¶
- 
class GtkSource.View(**kwargs)¶
- Bases: - Gtk.TextView- Abstract: - No - Structure: - GtkSource.ViewClass- 
classmethod new()¶
- Returns: - a new - GtkSource.View.- Return type: - Gtk.Widget- Creates a new - GtkSource.View.- By default, an empty - GtkSource.Bufferwill be lazily created and can be retrieved with- Gtk.TextView.get_buffer().- If you want to specify your own buffer, either override the - Gtk.TextViewClasscreate_buffer factory method, or use- GtkSource.View.new_with_buffer().
 - 
classmethod new_with_buffer(buffer)¶
- Parameters: - buffer ( - GtkSource.Buffer) – a- GtkSource.Buffer.- Returns: - a new - GtkSource.View.- Return type: - Gtk.Widget- Creates a new - GtkSource.Viewwidget displaying the buffer buffer. One buffer can be shared among many widgets.
 - 
get_auto_indent()¶
- Returns: - Trueif auto indentation is enabled.- Return type: - bool- Returns whether auto-indentation of text is enabled. 
 - 
get_background_pattern()¶
- Returns: - the - GtkSource.BackgroundPatternType.- Return type: - GtkSource.BackgroundPatternType- Returns the - GtkSource.BackgroundPatternTypespecifying if and how the background pattern should be displayed for this self.- New in version 3.16. 
 - 
get_completion()¶
- Returns: - the - GtkSource.Completionassociated with self.- Return type: - GtkSource.Completion- Gets the - GtkSource.Completionassociated with self. The returned object is guaranteed to be the same for the lifetime of self. Each- GtkSource.Viewobject has a different- GtkSource.Completion.
 - 
get_draw_spaces()¶
- Returns: - the - GtkSource.DrawSpacesFlags, 0 if no spaces should be drawn.- Return type: - GtkSource.DrawSpacesFlags- Returns the - GtkSource.DrawSpacesFlagsspecifying if and how spaces should be displayed for this self.- Deprecated since version 3.24: Use - GtkSource.SpaceDrawer.get_types_for_locations() instead.
 - 
get_gutter(window_type)¶
- Parameters: - window_type ( - Gtk.TextWindowType) – the gutter window type.- Returns: - the - GtkSource.Gutter.- Return type: - GtkSource.Gutter- Returns the - GtkSource.Gutterobject associated with window_type for self. Only- Gtk.TextWindowType.LEFTand- Gtk.TextWindowType.RIGHTare supported, respectively corresponding to the left and right gutter. The line numbers and mark category icons are rendered in the left gutter.- New in version 2.8. 
 - 
get_highlight_current_line()¶
- Returns: - Trueif the current line is highlighted.- Return type: - bool- Returns whether the current line is highlighted. 
 - 
get_indent_on_tab()¶
- Returns: - Trueif the selection is indented when tab is pressed.- Return type: - bool- Returns whether when the tab key is pressed the current selection should get indented instead of replaced with the \t character. 
 - 
get_indent_width()¶
- Returns: - indent width. - Return type: - int- Returns the number of spaces to use for each step of indent. See - GtkSource.View.set_indent_width() for details.
 - 
get_insert_spaces_instead_of_tabs()¶
- Returns: - Trueif spaces are inserted instead of tabs.- Return type: - bool- Returns whether when inserting a tabulator character it should be replaced by a group of space characters. 
 - 
get_mark_attributes(category, priority)¶
- Parameters: - Returns: - GtkSource.MarkAttributesfor the category. The object belongs to self, so it must not be unreffed.- Return type: - Gets attributes and priority for the category. 
 - 
get_right_margin_position()¶
- Returns: - the position of the right margin. - Return type: - int- Gets the position of the right margin in the given self. 
 - 
get_show_line_marks()¶
- Returns: - Trueif the line marks are displayed.- Return type: - bool- Returns whether line marks are displayed beside the text. - New in version 2.2. 
 - 
get_show_line_numbers()¶
- Returns: - Trueif the line numbers are displayed.- Return type: - bool- Returns whether line numbers are displayed beside the text. 
 - 
get_show_right_margin()¶
- Returns: - Trueif the right margin is shown.- Return type: - bool- Returns whether a right margin is displayed. 
 - 
get_smart_backspace()¶
- Returns: - Trueif smart Backspace handling is enabled.- Return type: - bool- Returns - Trueif pressing the Backspace key will try to delete spaces up to the previous tab stop.- New in version 3.18. 
 - 
get_smart_home_end()¶
- Returns: - a - GtkSource.SmartHomeEndTypevalue.- Return type: - GtkSource.SmartHomeEndType- Returns a - GtkSource.SmartHomeEndTypeend value specifying how the cursor will move when HOME and END keys are pressed.
 - 
get_space_drawer()¶
- Returns: - the - GtkSource.SpaceDrawerassociated with self.- Return type: - GtkSource.SpaceDrawer- Gets the - GtkSource.SpaceDrawerassociated with self. The returned object is guaranteed to be the same for the lifetime of self. Each- GtkSource.Viewobject has a different- GtkSource.SpaceDrawer.- New in version 3.24. 
 - 
get_tab_width()¶
- Returns: - width of tab. - Return type: - int- Returns the width of tabulation in characters. 
 - 
get_visual_column(iter)¶
- Parameters: - iter ( - Gtk.TextIter) – a position in self.- Returns: - the visual column at iter. - Return type: - int- Determines the visual column at iter taking into consideration the - GtkSource.View- :tab-widthof self.
 - 
indent_lines(start, end)¶
- Parameters: - start (Gtk.TextIter) –Gtk.TextIterof the first line to indent
- end (Gtk.TextIter) –Gtk.TextIterof the last line to indent
 - Inserts one indentation level at the beginning of the specified lines. The empty lines are not indented. - New in version 3.16. 
- start (
 - 
set_auto_indent(enable)¶
- Parameters: - enable ( - bool) – whether to enable auto indentation.- If - Trueauto-indentation of text is enabled.- When Enter is pressed to create a new line, the auto-indentation inserts the same indentation as the previous line. This is not a “smart indentation” where an indentation level is added or removed depending on the context. 
 - 
set_background_pattern(background_pattern)¶
- Parameters: - background_pattern ( - GtkSource.BackgroundPatternType) – the- GtkSource.BackgroundPatternType.- Set if and how the background pattern should be displayed. - New in version 3.16. 
 - 
set_draw_spaces(flags)¶
- Parameters: - flags ( - GtkSource.DrawSpacesFlags) –- GtkSource.DrawSpacesFlagsspecifing how white spaces should be displayed- Set if and how the spaces should be visualized. Specifying flags as 0 will disable display of spaces. - For a finer-grained method, there is also the - GtkSource.Tag’s- GtkSource.Tag- :draw-spacesproperty.- Deprecated since version 3.24: Use - GtkSource.SpaceDrawer.set_types_for_locations() instead.
 - 
set_highlight_current_line(highlight)¶
- Parameters: - highlight ( - bool) – whether to highlight the current line.- If highlight is - Truethe current line will be highlighted.
 - 
set_indent_on_tab(enable)¶
- Parameters: - enable ( - bool) – whether to indent a block when tab is pressed.- 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.- If the first or last line is not selected completely, it is also indented or unindented. - When the selection doesn’t span several lines, the tab key always replaces the selection with a normal \t character. 
 - 
set_indent_width(width)¶
- Parameters: - width ( - int) – indent width in characters.- Sets the number of spaces to use for each step of indent when the tab key is pressed. If width is -1, the value of the - GtkSource.View- :tab-widthproperty will be used.- The - GtkSource.View- :indent-widthinteracts with the- GtkSource.View- :insert-spaces-instead-of-tabsproperty and- GtkSource.View- :tab-width. An example will be clearer: if the- GtkSource.View- :indent-widthis 4 and- GtkSource.View- :tab-widthis 8 and- GtkSource.View- :insert-spaces-instead-of-tabsis- False, then pressing the tab key at the beginning of a line will insert 4 spaces. So far so good. Pressing the tab key a second time will remove the 4 spaces and insert a \t character instead (since- GtkSource.View- :tab-widthis 8). On the other hand, if- GtkSource.View- :insert-spaces-instead-of-tabsis- True, the second tab key pressed will insert 4 more spaces for a total of 8 spaces in the- Gtk.TextBuffer.- The test-widget program (available in the - GtkSource.Viewrepository) may be useful to better understand the indentation settings (enable the space drawing!).
 - 
set_insert_spaces_instead_of_tabs(enable)¶
- Parameters: - enable ( - bool) – whether to insert spaces instead of tabs.- If - Truea tab key pressed is replaced by a group of space characters. Of course it is still possible to insert a real \t programmatically with the- Gtk.TextBufferAPI.
 - 
set_mark_attributes(category, attributes, priority)¶
- Parameters: - category (str) – the category.
- attributes (GtkSource.MarkAttributes) – mark attributes.
- priority (int) – priority of the category.
 - Sets attributes and priority for the category. 
- category (
 - 
set_right_margin_position(pos)¶
- Parameters: - pos ( - int) – the width in characters where to position the right margin.- Sets the position of the right margin in the given self. 
 - 
set_show_line_marks(show)¶
- Parameters: - show ( - bool) – whether line marks should be displayed.- If - Trueline marks will be displayed beside the text.- New in version 2.2. 
 - 
set_show_line_numbers(show)¶
- Parameters: - show ( - bool) – whether line numbers should be displayed.- If - Trueline numbers will be displayed beside the text.
 - 
set_show_right_margin(show)¶
- Parameters: - show ( - bool) – whether to show a right margin.- If - Truea right margin is displayed.
 - 
set_smart_backspace(smart_backspace)¶
- Parameters: - smart_backspace ( - bool) – whether to enable smart Backspace handling.- When set to - True, pressing the Backspace key will try to delete spaces up to the previous tab stop.- New in version 3.18. 
 - 
set_smart_home_end(smart_home_end)¶
- Parameters: - smart_home_end ( - GtkSource.SmartHomeEndType) – the desired behavior among- GtkSource.SmartHomeEndType.- Set the desired movement of the cursor when HOME and END keys are pressed. 
 - 
set_tab_width(width)¶
- Parameters: - width ( - int) – width of tab in characters.- Sets the width of tabulation in characters. The - Gtk.TextBufferstill contains \t characters, but they can take a different visual width in a- GtkSource.Viewwidget.
 - 
unindent_lines(start, end)¶
- Parameters: - start (Gtk.TextIter) –Gtk.TextIterof the first line to indent
- end (Gtk.TextIter) –Gtk.TextIterof the last line to indent
 - Removes one indentation level at the beginning of the specified lines. - New in version 3.16. 
- start (
 - 
do_line_mark_activated(iter, event) virtual¶
- Parameters: - iter (Gtk.TextIter) –
- event (Gdk.Event) –
 
- iter (
 - 
do_redo() virtual¶
 - 
do_show_completion() virtual¶
 - 
do_undo() virtual¶
 
- 
classmethod 
Signal Details¶
- 
GtkSource.View.signals.change_case(view, case_type)¶
- Signal Name: - change-case- Flags: - Parameters: - view (GtkSource.View) – The object which received the signal
- case_type (GtkSource.ChangeCaseType) – the case to use
 - Keybinding signal to change case of the text at the current cursor position. - New in version 3.16. 
- view (
- 
GtkSource.View.signals.change_number(view, count)¶
- Signal Name: - change-number- Flags: - Parameters: - view (GtkSource.View) – The object which received the signal
- count (int) – the number to add to the number at the current position
 - Keybinding signal to edit a number at the current cursor position. - New in version 3.16. 
- view (
- 
GtkSource.View.signals.join_lines(view)¶
- Signal Name: - join-lines- Flags: - RUN_LAST,- ACTION- Parameters: - view ( - GtkSource.View) – The object which received the signal- Keybinding signal to join the lines currently selected. - New in version 3.16. 
- 
GtkSource.View.signals.line_mark_activated(view, iter, event)¶
- Signal Name: - line-mark-activated- Flags: - Parameters: - view (GtkSource.View) – The object which received the signal
- iter (Gtk.TextIter) – aGtk.TextIter
- event (Gdk.Event) – theGdk.Eventthat activated the event
 - Emitted when a line mark has been activated (for instance when there was a button press in the line marks gutter). You can use iter to determine on which line the activation took place. 
- view (
- 
GtkSource.View.signals.move_lines(view, copy, count)¶
- Signal Name: - move-lines- Flags: - Parameters: - view (GtkSource.View) – The object which received the signal
- copy (bool) –Trueif the line should be copied,Falseif it should be moved. This parameter is deprecated and will be removed in a later version, it should be alwaysFalse.
- count (int) – the number of lines to move over. Only 1 and -1 are supported.
 - The - ::move-linessignal is a keybinding which gets emitted when the user initiates moving a line. The default binding key is Alt+Up/Down arrow. And moves the currently selected lines, or the current line by count. For the moment, only count of -1 or 1 is valid.- The copy parameter is deprecated, it has never been used by - GtkSource.View(the value is always- False) and was buggy.- New in version 2.10. 
- view (
- 
GtkSource.View.signals.move_to_matching_bracket(view, extend_selection)¶
- Signal Name: - move-to-matching-bracket- Flags: - Parameters: - view (GtkSource.View) – The object which received the signal
- extend_selection (bool) –Trueif the move should extend the selection
 - Keybinding signal to move the cursor to the matching bracket. - New in version 3.16. 
- view (
- 
GtkSource.View.signals.move_words(view, count)¶
- Signal Name: - move-words- Flags: - Parameters: - view (GtkSource.View) – The object which received the signal
- count (int) – the number of words to move over
 - The - ::move-wordssignal is a keybinding which gets emitted when the user initiates moving a word. The default binding key is Alt+Left/Right Arrow and moves the current selection, or the current word by one word.- New in version 3.0. 
- view (
- 
GtkSource.View.signals.redo(view)¶
- Signal Name: - redo- Flags: - RUN_LAST,- ACTION- Parameters: - view ( - GtkSource.View) – The object which received the signal
- 
GtkSource.View.signals.show_completion(view)¶
- Signal Name: - show-completion- Flags: - RUN_LAST,- ACTION- Parameters: - view ( - GtkSource.View) – The object which received the signal- The - ::show-completionsignal is a key binding signal which gets emitted when the user requests a completion, by pressing- Control + space. This will create a - GtkSource.CompletionContextwith the activation type as- GtkSource.CompletionActivation.USER_REQUESTED.- Applications should not connect to it, but may emit it with g_signal_emit_by_name() if they need to activate the completion by another means, for example with another key binding or a menu entry. 
- 
GtkSource.View.signals.smart_home_end(view, iter, count)¶
- Signal Name: - smart-home-end- Flags: - Parameters: - view (GtkSource.View) – The object which received the signal
- iter (Gtk.TextIter) – aGtk.TextIter
- count (int) – the count
 - Emitted when a the cursor was moved according to the smart home end setting. The signal is emitted after the cursor is moved, but during the - Gtk.TextView- ::move-cursoraction. This can be used to find out whether the cursor was moved by a normal home/end or by a smart home/end.- New in version 3.0. 
- view (
- 
GtkSource.View.signals.undo(view)¶
- Signal Name: - undo- Flags: - RUN_LAST,- ACTION- Parameters: - view ( - GtkSource.View) – The object which received the signal
Property Details¶
- 
GtkSource.View.props.auto_indent¶
- Name: - auto-indent- Type: - bool- Default Value: - False- Flags: - READABLE,- WRITABLE- Whether to enable auto indentation 
- 
GtkSource.View.props.background_pattern¶
- Name: - background-pattern- Type: - GtkSource.BackgroundPatternType- Default Value: - GtkSource.BackgroundPatternType.NONE- Flags: - READABLE,- WRITABLE- Draw a specific background pattern on the view. - New in version 3.16. 
- 
GtkSource.View.props.completion¶
- Name: - completion- Type: - GtkSource.Completion- Default Value: - None- Flags: - READABLE- The completion object associated with the view 
- 
GtkSource.View.props.draw_spaces¶
- Name: - draw-spaces- Type: - GtkSource.DrawSpacesFlags- Default Value: - 0- Flags: - DEPRECATED,- READABLE,- WRITABLE- Set if and how the spaces should be visualized. - For a finer-grained method, there is also the - GtkSource.Tag’s- GtkSource.Tag- :draw-spacesproperty.- New in version 2.4. - Deprecated since version 3.24: Use the - GtkSource.SpaceDrawer- :matrixproperty instead.
- 
GtkSource.View.props.highlight_current_line¶
- Name: - highlight-current-line- Type: - bool- Default Value: - False- Flags: - READABLE,- WRITABLE- Whether to highlight the current line 
- 
GtkSource.View.props.indent_on_tab¶
- Name: - indent-on-tab- Type: - bool- Default Value: - True- Flags: - READABLE,- WRITABLE- Whether to indent the selected text when the tab key is pressed 
- 
GtkSource.View.props.indent_width¶
- Name: - indent-width- Type: - int- Default Value: - -1- Flags: - READABLE,- WRITABLE- Width of an indentation step expressed in number of spaces. 
- 
GtkSource.View.props.insert_spaces_instead_of_tabs¶
- Name: - insert-spaces-instead-of-tabs- Type: - bool- Default Value: - False- Flags: - READABLE,- WRITABLE- Whether to insert spaces instead of tabs 
- 
GtkSource.View.props.right_margin_position¶
- Name: - right-margin-position- Type: - int- Default Value: - 80- Flags: - READABLE,- WRITABLE- Position of the right margin. 
- 
GtkSource.View.props.show_line_marks¶
- Name: - show-line-marks- Type: - bool- Default Value: - False- Flags: - READABLE,- WRITABLE- Whether to display line mark pixbufs 
- 
GtkSource.View.props.show_line_numbers¶
- Name: - show-line-numbers- Type: - bool- Default Value: - False- Flags: - READABLE,- WRITABLE- Whether to display line numbers 
- 
GtkSource.View.props.show_right_margin¶
- Name: - show-right-margin- Type: - bool- Default Value: - False- Flags: - READABLE,- WRITABLE- Whether to display the right margin. 
- 
GtkSource.View.props.smart_backspace¶
- Name: - smart-backspace- Type: - bool- Default Value: - False- Flags: - READABLE,- WRITABLE- Whether smart Backspace should be used. - New in version 3.18. 
- 
GtkSource.View.props.smart_home_end¶
- Name: - smart-home-end- Type: - GtkSource.SmartHomeEndType- Default Value: - GtkSource.SmartHomeEndType.DISABLED- Flags: - READABLE,- WRITABLE- Set the behavior of the HOME and END keys. - New in version 2.0. 
- 
GtkSource.View.props.space_drawer¶
- Name: - space-drawer- Type: - GtkSource.SpaceDrawer- Default Value: - None- Flags: - READABLE- The - GtkSource.SpaceDrawerobject associated with the view.- New in version 3.24.