org.gnome.sourceview

## Class SourceView

- Object
- - org.freedesktop.bindings.Pointer
  - - org.freedesktop.bindings.Proxy
    - - org.gnome.glib.Object
      - - org.gnome.gtk.Widget
        - - org.gnome.gtk.Container
          - - org.gnome.gtk.TextView
            - - org.gnome.sourceview.SourceView

-     public class SourceView
      extends TextView

  A text Widget for displaying and editing source code.

  GtkSourceView extends GTK's `TextView` and adds features that are useful for building text or source-code editors. It provides syntax highlighting for various languages, undo/redo, control over indentation and more.

  SourceView is the view part of the GtkSourceView library and is always used together with a `SourceBuffer` as its model.

  ## Usage

  To create a SourceView a previously instantiated SourceBuffer is needed, that is passed to the constructor:

       SourceBuffer buffer;
       SourceView view;
       ...

       view = new SourceView(buffer);

  Since:
    4.0.12
  Author:
    Stefan Schweizer

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `SourceView.Redo` The handler interface used for redo signals.
    `static interface` | `SourceView.Undo` The handler interface used for undo signals.

    - ### Nested classes/interfaces inherited from class org.gnome.gtk.TextView

      `TextView.PopulatePopup`

    - ### Nested classes/interfaces inherited from class org.gnome.gtk.Widget

      `Widget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.Destroy, Widget.Draw, Widget.EnterNotifyEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.QueryTooltip, Widget.ScrollEvent, Widget.SizeAllocate, Widget.UnmapEvent, Widget.VisibilityNotifyEvent`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SourceView(SourceBuffer buffer)` Create a new SourceView that displays the SourceBuffer.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `connect(SourceView.Redo handler)` Connect a handler to receive `SourceView.Redo` signals.
    `void` | `connect(SourceView.Undo handler)` Connect a handler to receive `SourceView.Undo` signals.
    `boolean` | `getAutoIndent()` Return whether audo-indentation is enabled of not.
    `boolean` | `getHighlightCurrentLine()` Returns whether the current line is highlighted or not.
    `boolean` | `getInsertSpacesInsteadOfTabs()` Returns whether spaces are used instead of the tab character.
    `int` | `getRightMarginPosition()` Return the position of the line that indicates the right margin of the text.
    `boolean` | `getShowLineNumbers()` Returns whether line numbers are shown next to the text or not.
    `boolean` | `getShowRightMargin()` Returns whether the line indicating the right margin is shown or not.
    `int` | `getTabWidth()` Return the number of spaces that are used for the tab character.
    `void` | `setAutoIndent(boolean enable)` Enable/disable auto-indentation.
    `void` | `setHighlightCurrentLine(boolean highlight)` Enable or disable the highlighting of the current line.
    `void` | `setInsertSpacesInsteadOfTabs(boolean enable)` Insert spaces instead of the tab character.
    `void` | `setRightMarginPosition(int position)` Set the position of the line that indicates the right margin of the text.
    `void` | `setShowLineNumbers(boolean show)` Enable or disable the display of line numbers next to the text.
    `void` | `setShowRightMargin(boolean show)` Show a line that indicates the right margin of the text.
    `void` | `setTabWidth(int width)` Set the number of spaces that are used for the tab character.

    - ### Methods inherited from class org.gnome.gtk.TextView

      `add, add, attachSpell, attachSpell, connect, convertBufferToWindowCoordsX, convertBufferToWindowCoordsY, convertWindowToBufferCoordsX, convertWindowToBufferCoordsY, getBuffer, getCursorVisible, getEditable, getIterAtLocation, getLineRange, getLineY, getLocation, getSpell, getVisibleRectangle, getWindow, getWrapMode, moveChild, placeCursorOnscreen, scrollTo, scrollTo, scrollTo, scrollTo, setAcceptsTab, setBorderWindowSize, setBuffer, setCursorVisible, setEditable, setJustify, setMarginLeft, setMarginRight, setPaddingAboveParagraph, setPaddingBelowParagraph, setPaddingInsideParagraph, setWrapMode`

    - ### Methods inherited from class org.gnome.gtk.Container

      `add, getChildren, remove, setBorderWidth`

    - ### Methods inherited from class org.gnome.gtk.Widget

      `activate, addEvents, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, destroy, getAllocatedHeight, getAllocatedWidth, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getPreferredHeightForWidthMinimum, getPreferredHeightForWidthNatural, getPreferredHeightMinimum, getPreferredHeightNatural, getPreferredWidthForHeightMinimum, getPreferredWidthForHeightNatural, getPreferredWidthMinimum, getPreferredWidthNatural, getRequestMode, getRequisition, getSensitive, getStyleContext, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, isSensitive, overrideBackground, overrideColor, overrideFont, queueDraw, queueDrawArea, realize, setAlignHorizontal, setAlignVertical, setCanDefault, setCanFocus, setEvents, setExpandHorizontal, setExpandVertical, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll`

    - ### Methods inherited from class org.freedesktop.bindings.Pointer

      `toString`

    - ### Methods inherited from class Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### SourceView

          public SourceView(SourceBuffer buffer)

      Create a new SourceView that displays the SourceBuffer.
      Since:
        4.0.12

  - ### Method Detail

    - #### connect

          public void connect(SourceView.Redo handler)

      Connect a handler to receive `SourceView.Redo` signals. It is emitted whenever something is redone in the editor window, e.g. by hitting `Shift+Ctrl+Z`.
      Since:
        4.0.12

    - #### connect

          public void connect(SourceView.Undo handler)

      Connect a handler to receive `SourceView.Undo` signals. It is emitted whenever something is undone in the editor window, e.g. by hitting Ctrl+Z.
      Since:
        4.0.12

    - #### getAutoIndent

          public boolean getAutoIndent()

      Return whether audo-indentation is enabled of not.
      Since:
        4.0.12

    - #### getHighlightCurrentLine

          public boolean getHighlightCurrentLine()

      Returns whether the current line is highlighted or not. Disabled by default.
      Since:
        4.0.12

    - #### getInsertSpacesInsteadOfTabs

          public boolean getInsertSpacesInsteadOfTabs()

      Returns whether spaces are used instead of the tab character.
      Since:
        4.0.12

    - #### getRightMarginPosition

          public int getRightMarginPosition()

      Return the position of the line that indicates the right margin of the text.
      Since:
        4.0.12

    - #### getShowLineNumbers

          public boolean getShowLineNumbers()

      Returns whether line numbers are shown next to the text or not.
      Since:
        4.0.12

    - #### getShowRightMargin

          public boolean getShowRightMargin()

      Returns whether the line indicating the right margin is shown or not.
      Since:
        4.0.12

    - #### getTabWidth

          public int getTabWidth()

      Return the number of spaces that are used for the tab character.
      Since:
        4.0.12

    - #### setAutoIndent

          public void setAutoIndent(boolean enable)

      Enable/disable auto-indentation. If enabled, a new line will have the same indentation as the current line. Disabled by default.
      Since:
        4.0.12

    - #### setHighlightCurrentLine

          public void setHighlightCurrentLine(boolean highlight)

      Enable or disable the highlighting of the current line. Disabled by default.
      Since:
        4.0.12

    - #### setInsertSpacesInsteadOfTabs

          public void setInsertSpacesInsteadOfTabs(boolean enable)

      Insert spaces instead of the tab character. Disabled by default.
      Since:
        4.0.12

    - #### setRightMarginPosition

          public void setRightMarginPosition(int position)

      Set the position of the line that indicates the right margin of the text. The default position is 80.
      Since:
        4.0.12

    - #### setShowLineNumbers

          public void setShowLineNumbers(boolean show)

      Enable or disable the display of line numbers next to the text. The display is disabled by default.
      Since:
        4.0.12

    - #### setShowRightMargin

          public void setShowRightMargin(boolean show)

      Show a line that indicates the right margin of the text. Disabled by default.
      Since:
        4.0.12

    - #### setTabWidth

          public void setTabWidth(int width)

      Set the number of spaces that are used for the tab character.
      Since:
        4.0.12