gtksourceview2.View

a widget that displays the source code

## Synopsis

          gtksourceview2.View
          gtk.TextView

            gtksourceview2.View
              bufferNone

            get_auto_indent

            get_draw_spaces

            get_gutter

            get_highlight_current_line

            get_indent_on_tab

            get_indent_width

            get_insert_spaces_instead_of_tabs

            get_mark_category_background
              category

            get_mark_category_pixbuf
              category

            get_mark_category_priority
              category

            get_right_margin_position

            get_show_line_marks

            get_show_line_numbers

            get_show_right_margin

            get_smart_home_end

            get_tab_width

            set_auto_indent
              enable

            set_draw_spaces
              flags

            set_highlight_current_line
              show

            set_indent_on_tab
              enable

            set_indent_width
              width

            set_insert_spaces_instead_of_tabs
              enable

            set_mark_category_icon_from_icon_name
              category
              name

            set_mark_category_icon_from_pixbuf
              category
              pixbuf

            set_mark_category_icon_from_stock
              category
              stock_id

            set_mark_category_background
              category
              dest

            set_mark_category_pixbuf
              category
              pixbuf

            set_mark_category_priority
              category
              priority

            set_mark_category_tooltip_func
              category
              func
              user_data

            set_mark_category_tooltip_markup_func
              category
              markup_func
              user_data

            set_right_margin_position
              pos

            set_show_line_marks
              show

            set_show_line_numbers
              show

            set_show_right_margin
              show

            set_smart_home_end
              smart_he

            set_tab_width
              width

## Ancestry

    +-- gobject.GObject
        +-- gtk.Object
            +-- gtk.Widget
                +-- gtk.Container
                    +-- gtk.TextView
                        +-- gtksourceview2.View

## Virtual Methods

> `do_redo` | Method that can be overridden to implement a custom redo.
> `do_undo` | Method that can be overridden to implement a custom undo.
> `do_line_mark_activated` | Method that can be overridden to implement a custom line number activation.

## Properties

> "auto-indent" | Read-Write | If `True` enable auto indentation. Default value: False.
> "highlight-current-line" | Read-Write | Whether to highlight the current line. Default value: False.
> "indent-on-tab" | Read-Write | Whether to indent the selected text when the tab key is pressed. Default value: True.
> "indent-width" | Read-Write | Width of an indentation step expressed in number of spaces. Allowed values: [-1,32]. Default value: -1.
> "insert-spaces-instead-of-tabs" | Read-Write | If `True` spaces will be inserted instead of tabs. Default value: False
> "right-margin-position" | Read-Write | Position of the right margin. Allowed values: [1,200]. Default value: 80
> "show-line-marks" | Read-Write | If `True`, the display line marks pixbufs will be shown. Default value: False.
> "show-line-numbers" | Read-Write | If `True`, the line numbers will be shown. Default value: False.
> "show-right-margin" | Read-Write | If `True`, the right margin will be shown. Default value: False.
> "smart-home-end" | Read-Write | Set the behavior of the HOME and END keys. Default value: gtksourceview2.SMART_HOME_END_DISABLED.
> "tabs-width" | Read-Write | Width of an tab character expressed in number of spaces. Allowed values: [1,32]. Default value: 8.

## Signal Prototypes

"redo"

- `callback` `sourceview` `user_param1` `...`

"undo"

- `callback` `sourceview` `user_param1` `...`

"line-mark-activated"

- `callback` `sourceview` `iter` `event` `user_param1` `...`

## Description

A `gtksourceview2.View` is a text widget that extends the standard `gtk.TextView` It improves the `gtk.TextView` by implementing syntax highlighting and other features typical of a source editor.

## Constructor

          gtksourceview2.View
          bufferNone

`buffer` :

- a `gtksourceview2.Buffer` or `None`

Returns :

- a new `gtksourceview2.View`.

Creates a new `gtksourceview2.View` widget displaying the `gtksourceview2.Buffer` specified by `buffer`. If `buffer` is `None`, a new `gtksourceview2.Buffer` will be created. One sourcebuffer can be shared among many widgets.

## Methods

### gtksourceview2.View.get_auto_indent

            get_auto_indent

Returns :

- `True` if auto indentation is enabled, `False` otherwise.

The `get_auto_indent`() method returns whether auto indentation of text is enabled.

### gtksourceview2.View.get_draw_spaces

            get_draw_spaces

Returns :

- One of gtksourceview2.DRAW_SPACES_SPACE, gtksourceview2.DRAW_SPACES_TAB gtksourceview2.DRAW_SPACES_NEWLINE or gtksourceview2.DRAW_SPACES_ALL.

The `get_draw_spaces`() method returns one of the flags specifying if and how spaces should be displayed for this view.

### gtksourceview2.View.get_gutter

            get_gutter

Returns :

- the gtksourceview2.Gutter.

The `get_gutter`() method returns the gtksourceview2.Gutter object associated with window_type for view. Only gtk.TEXT_WINDOW_LEFT and gtk.TEXT_WINDOW_RIGHT are supported, respectively corresponding to the left and right gutter. The line numbers and mark category icons are rendered in the gutter corresponding to gtk.TEXT_WINDOW_LEFT.

### gtksourceview2.View.get_highlight_current_line

            get_highlight_current_line

Returns :

- `True` if the current line is highlighted, `False` otherwise.

The `get_highlight_current_line`() method returns whether the current line is highlighted.

### gtksourceview2.View.get_indent_on_tab

            get_indent_on_tab

Returns :

- `True` if the selection is indented when tab is pressed. `False` otherwise.

The `get_indent_on_tab`() method returns whether when the tab key is pressed the current selection should get indented instead of replaced with the \t character.

### gtksourceview2.View.get_indent_width

            get_indent_width

Returns :

- the indent width.

The `get_indent_width`() method returns the number of spaces to use for each step of indent. See `gtksourceview2.View.set_indent_width`() for details.

### gtksourceview2.View.get_insert_spaces_instead_of_tabs

            get_insert_spaces_instead_of_tabs

Returns :

- `True` if spaces are inserted instead of tabs. `False` otherwise.

The `get_insert_spaces_instead_of_tabs`() method returns whether when inserting a tabulator character it should be replaced by a group of space characters.

### gtksourceview2.View.get_mark_category_background

            get_mark_category_background
              category

`category` :

- a marker category.

Returns :

- a `gtk.gdk.Color` if found, or `None` if not found.

The `get_marker_category_pixbuf`() method gets the pixbuf which is associated with the given category.

### gtksourceview2.View.get_mark_category_pixbuf

            get_mark_category_pixbuf
              category

`category` :

- a marker category.

Returns :

- a `gtk.gdk.Pixbuf` if found, or `None` if not found.

The `get_marker_category_pixbuf`() method gets the pixbuf which is associated with the given category.

### gtksourceview2.View.get_mark_category_priority

            get_mark_category_priority
              category

`category` :

- a marker category.

Returns :

- a `gtk.gdk.Pixbuf` if found, or `None` if not found.

The `get_mark_category_priority`() method gets the priority which is associated with the given category.

### gtksourceview2.View.get_right_margin_position

            get_right_margin_position

Returns :

- the position of the right margin.

The `get_right_margin_position`() method gets the position of the right margin.

### gtksourceview2.View.get_show_line_marks

            get_show_line_marks

Returns :

- `True` if the line marks are displayed. `False` otherwise.

The `get_show_line_marks`() method returns whether line marks are displayed beside the text.

### gtksourceview2.View.get_show_line_numbers

            get_show_line_numbers

Returns :

- `True` if the line numbers are displayed. `False` otherwise.

The `get_show_line_numbers`() method returns whether line numbers are displayed beside the text.

### gtksourceview2.View.get_show_right_margin

            get_show_right_margin

Returns :

- `True` if the right margin is displayed. `False` otherwise.

The `get_show_right_margin`() method returns whether a right margin is displayed.

### gtksourceview2.View.get_smart_home_end

            get_smart_home_end

Returns :

- a GtkSourceSmartHomeEndType value specifying how the cursor will move when HOME and END keys are pressed.

The `get_smart_home_end`() method returns a value specifying how the cursor will move when HOME and END keys are pressed.

### gtksourceview2.View.get_tab_width

            get_tab_width

Returns :

- the width of tab.

The `get_tab_width`() method returns the width of tabulation in characters.

### gtksourceview2.View.set_auto_indent

            set_auto_indent
            enabled

`enabled` :

- if `True` auto indentation of text is enabled.

The `set_auto_indent`() method sets whether to enable auto indentation.

### gtksourceview2.View.set_draw_spaces

            set_draw_spaces
            flags

`flags` :

- one of gtksourceview2.DRAW_SPACES_SPACE, gtksourceview2.DRAW_SPACES_TAB gtksourceview2.DRAW_SPACES_NEWLINE or gtksourceview2.DRAW_SPACES_ALL, specifing how white spaces should be displayed.

The `set_draw_spaces`() method set if and how the spaces should be visualized. Specifying flags as 0 will disable display of spaces.

### gtksourceview2.View.set_highlight_current_line

            set_highlight_current_line
            show

`show` :

- if `True` the current line is highlighted.

The `set_highlight_current_line`() method sets whether to highlight the current line.

### gtksourceview2.View.set_indent_on_tab

            set_indent_on_tab
            enabled

`enabled` :

- if `True` indent a block when tab is pressed.

The `set_indent_on_tab`() method sets 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.

### gtksourceview2.View.set_indent_width

            set_indent_width
            width

`width` :

- indent width in characters.

The `set_indent_width`() method 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.

### gtksourceview2.View.set_insert_spaces_instead_of_tabs

            set_insert_spaces_instead_of_tabs
            enabled

`enabled` :

- if `True` insert spaces instead of tabs.

The `set_insert_spaces_instead_of_tabs`() method sets whether any tabulator character inserted is replaced by a group of space characters.

### gtksourceview2.View.set_mark_category_background

            set_mark_category_background
            category
            color

`category` :

- a marker category.

`color` :

- a `gtk.gdk.Color` or `None`.

The `set_mark_category_priority`() method sets given background color for mark category. If color is `None`, the background color is unset.

### gtksourceview2.View.set_mark_category_icon_from_icon_name

            set_mark_category_icon_from_icon_name
            category
            name

`category` :

- a marker category.

`name` :

- the themed icon name or `None`.

The `set_mark_category_icon_from_icon_name`() method sets the icon to be used for category to the named theme item name. If name is `None`, the icon is unset.

### gtksourceview2.View.set_mark_category_icon_from_pixbuf

            set_mark_category_icon_from_pixbuf
            category
            pixbuf

`category` :

- a marker category.

`pixbuf` :

- a `gtk.gdk.Pixbuf` or `None`.

The `set_mark_category_icon_from_pixbuf`() method sets the icon to be used for category to pixbuf. If pixbuf is `None`, the icon is unset.

### gtksourceview2.View.set_mark_category_icon_from_stock

            set_mark_category_icon_from_stock
            category
            stock

`category` :

- a marker category.

`simpara` :

- the stock id or `None`.

The `set_mark_category_icon_from_stock`() method sets the icon to be used for category to the stock item stock_id. If stock_id is `None`, the icon is unset.

### gtksourceview2.View.set_mark_category_pixbuf

            set_mark_category_pixbuf
            category
            pixbuf

`category` :

- a marker category.

`pixbuf` :

- a `gtk.gdk.Pixbuf` or `None`.

The `set_mark_category_priority`() method associates a given `pixbuf` with a given `category`. If pixbuf is `None`, the pixbuf is unset.

### gtksourceview2.View.set_mark_category_priority

            set_mark_category_priority
            category
            priority

`category` :

- a marker category.

`priority` :

- the priority for the category.

The `set_mark_category_priority`() method 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.

### gtksourceview2.View.set_mark_category_tooltip_func

            set_mark_category_tooltip_func
            category
            func
            user_data

`category` :

- a marker category.

`func` :

- a function or `None`.

`user_data` :

- user data which will be passed to func.

The `set_mark_category_tooltip_func`() method sets a func used to set tooltip on marks from the given mark category. If func is `None` and markup_func is `None` then tooltips will not be shown for marks from category. If markup_func is not `None` markup_func is going to be used instead of func.

        def markuptooltipfunc(mark, user_data)

Where mark is the gtksourceview2.Mark to use, user_data is the data passed to set_mark_category_tooltip_func().

### gtksourceview2.View.set_mark_category_tooltip_markup_func

            set_mark_category_tooltip_markup_func
            category
            markup_func
            user_data

`category` :

- a marker category.

`marker` :

- a function or `None`.

`user_data` :

- user data which will be passed to func.

See `gtksourceview2.View.set_mark_category_tooltip_func` for more information.

        def markuptooltipfunc(mark, user_data)

Where mark is the gtksourceview2.Mark to use, user_data is the data passed to set_mark_category_tooltip_func().

### gtksourceview2.View.set_right_margin_position

            set_right_margin_position
            pos

`pos` :

- The width in characters where to position the right margin.

The `set_right_margin_position`() method sets the position of the right margin.

### gtksourceview2.View.set_show_line_marks

            set_show_line_marks
            show

`show` :

- if `True` line marks will be displayed beside the text.

The `set_show_line_marks`() method sets whether line marks should be displayed.

### gtksourceview2.View.set_show_line_numbers

            set_show_line_numbers
            show

`show` :

- if `True` line numbers will be displayed beside the text.

The `set_show_line_numbers`() method sets whether line numbers should be displayed.

### gtksourceview2.View.set_show_right_margin

            set_show_right_margin
            show

`show` :

- if `True` line numbers will be displayed beside the text.

The `set_show_right_margin`() method sets whether to show a right margin.

### gtksourceview2.View.set_smart_home_end

            set_smart_home_end
            smart_he

`smart_he` :

- the desired behavior among GtkSourceSmartHomeEndType.

The `set_smart_home_end`() method sets the desired movement of the cursor when HOME and END keys are pressed.

### gtksourceview2.View.set_tab_width

            set_tab_width
            width

`width` :

- width of tab in characters.

The `set_tab_width`() method sets the width of tabulation in characters.

## Signals

### The "line-number-activated" gtksourceview2.View Signal

    	  callback
    	  sourceview
              iter
              event
    	  user_param1
    	  ...

`sourceview` :

- the sourceview that received the signal

`iter` :

- a `gtk.TextIter`.

`event` :

- the `gtk.gdk.Event` that activated the event.

`user_param1` :

- the first user parameter (if any) specified with the `connect`() method

`...` :

- additional user parameters (if any)

The "line-number-activated" signal is 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.

### The "redo" gtksourceview2.View Signal

    	  callback
    	  sourceview
    	  user_param1
    	  ...

`sourceview` :

- the sourceview that received the signal

`user_param1` :

- the first user parameter (if any) specified with the `connect`() method

`...` :

- additional user parameters (if any)

The "redo" signal is emitted when an action has been redone.

### The "undo" gtksourceview2.View Signal

    	  callback
    	  sourceview
    	  user_param1
    	  ...

`sourceview` :

- the sourceview that received the signal

`user_param1` :

- the first user parameter (if any) specified with the `connect`() method

`...` :

- additional user parameters (if any)

The "undo" signal is emitted when an action has been undone.