org.gnome.sourceview

## Class SourceBuffer

- Object
- - org.freedesktop.bindings.Pointer
  - - org.freedesktop.bindings.Proxy
    - - org.gnome.glib.Object
      - - org.gnome.gtk.TextBuffer
        - - org.gnome.sourceview.SourceBuffer

-     public class SourceBuffer
      extends TextBuffer

  SourceBuffer is the model used in a `SourceView`. It extends GTK's `TextBuffer` and adds features typical for text editors. SourceBuffer contains the actual text that is displayed in the view and allows its manipulation.

  ## Usage

  The following example shows how a SourceBuffer is created and its initial content is set:

       TextTagTable table;
       SourceBuffer buffer;
       ...

       table = new TextTagTable();
       buffer = new SourceBuffer();
       buffer.setText("Insert text here...");

  The language used for syntax highlighting has to be obtained from the LanguageManager:

       manager = LanguageManager.getDefault();
       language = manager.getLanguage("java");
       buffer.setLanguage(language);

  Since:
    4.0.12
  Author:
    Stefan Schweizer

- - ### Nested Class Summary

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

      `TextBuffer.ApplyTag, TextBuffer.BeginUserAction, TextBuffer.Changed, TextBuffer.DeleteRange, TextBuffer.EndUserAction, TextBuffer.InsertText, TextBuffer.MarkSet, TextBuffer.NotifyCursorPosition, TextBuffer.RemoveTag`

  - ### Field Summary

    - ### Fields inherited from class org.gnome.gtk.TextBuffer

      `OBJECT_REPLACEMENT_CHARACTER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SourceBuffer()` Create a new SourceBuffer.
    `SourceBuffer(TextTagTable tags)` Create a new SourceBuffer using the given TextTagTable.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `beginNotUndoableAction()` Indicate the beginning of an action that cannot be undone.
    `boolean` | `canRedo()` Return `true` if an operation can be redone.
    `boolean` | `canUndo()` Return `true` if an operation can be undone.
    `void` | `endNotUndoableAction()` Indicate the end of an action that cannot be undone.
    `boolean` | `getHighlightMatchingBrackets()` Return whether matching brackets are highlighted.
    `boolean` | `getHighlightSyntax()` Return whether syntax highlighting is enabled or not.
    `Language` | `getLanguage()` Get the Language that is used for syntax highlighting.
    `StyleScheme` | `getStyleScheme()` Get the `StyleScheme` that is used.
    `void` | `redo()` Redo the last undone operation.
    `void` | `setHighlightMatchingBrackets(boolean highlight)` Enable or disable highlighting of matching brackets.
    `void` | `setHighlightSyntax(boolean highlight)` Enable/disable syntax higlighting.
    `void` | `setLanguage(Language language)` Set the Language that is used for syntax highlighting.
    `void` | `setStyleScheme(StyleScheme scheme)` Set the `StyleScheme` that is used.
    `void` | `undo()` Undo the last operation.

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

      `applyTag, applyTag, beginUserAction, connect, connect, connect, connect, connect, connect, connect, connect, connect, connectAfter, createMark, delete, deleteInteractive, endUserAction, getCharCount, getCursorPosition, getHasSelection, getInsert, getIter, getIter, getIterEnd, getIterStart, getLineCount, getModified, getSelectionBound, getSlice, getText, getText, insert, insert, insert, insert, insert, insert, insertAtCursor, insertInteractive, moveMark, placeCursor, removeAllTags, removeTag, selectRange, setModified, setText, stopDeleteRange, stopInsertText`

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

      `toString`

    - ### Methods inherited from class Object

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

- - ### Constructor Detail

    - #### SourceBuffer

          public SourceBuffer()

      Create a new SourceBuffer. This uses the same default TextTagTable as used by the no-arg TextTags; see the no-arg TextBuffer `<init>()` for details.
      Since:
        4.0.12

    - #### SourceBuffer

          public SourceBuffer(TextTagTable tags)

      Create a new SourceBuffer using the given TextTagTable.
      Since:
        4.0.12

  - ### Method Detail

    - #### beginNotUndoableAction

          public void beginNotUndoableAction()

      Indicate the beginning of an action that cannot be undone. This is especially useful when setting the initial content of the buffer.
      Since:
        4.0.12

    - #### canRedo

          public boolean canRedo()

      Return `true` if an operation can be redone.
      Since:
        4.0.12

    - #### canUndo

          public boolean canUndo()

      Return `true` if an operation can be undone.
      Since:
        4.0.12

    - #### endNotUndoableAction

          public void endNotUndoableAction()

      Indicate the end of an action that cannot be undone.
      Since:
        4.0.12

    - #### getHighlightMatchingBrackets

          public boolean getHighlightMatchingBrackets()

      Return whether matching brackets are highlighted.
      Since:
        4.0.12

    - #### getHighlightSyntax

          public boolean getHighlightSyntax()

      Return whether syntax highlighting is enabled or not.
      Since:
        4.0.12

    - #### getLanguage

          public Language getLanguage()

      Get the Language that is used for syntax highlighting.
      Since:
        4.0.12

    - #### getStyleScheme

          public StyleScheme getStyleScheme()

      Get the `StyleScheme` that is used.
      Since:
        4.1.2

    - #### redo

          public void redo()

      Redo the last undone operation. You should only call this method if there is an operation that can be redone. This can be checked with `canRedo()`.
      Since:
        4.0.12

    - #### setHighlightMatchingBrackets

          public void setHighlightMatchingBrackets(boolean highlight)

      Enable or disable highlighting of matching brackets. Enabled by default.
      Since:
        4.0.12

    - #### setHighlightSyntax

          public void setHighlightSyntax(boolean highlight)

      Enable/disable syntax higlighting. The SourceLangage is configured with `setLanguage`. Highlighting is enabled by default.
      Since:
        4.0.12

    - #### setLanguage

          public void setLanguage(Language language)

      Set the Language that is used for syntax highlighting.
      Since:
        4.0.12

    - #### setStyleScheme

          public void setStyleScheme(StyleScheme scheme)

      Set the `StyleScheme` that is used.
      Since:
        4.1.2

    - #### undo

          public void undo()

      Undo the last operation. You should only call this method if there is an operation that can be undone. This can be checked with `canUndo()`.
      Since:
        4.0.12