org.gjt.sp.jedit.buffer

## Class JEditBuffer

- java.lang.Object
- - org.gjt.sp.jedit.buffer.JEditBuffer

- Direct Known Subclasses:
    Buffer

      public class JEditBuffer
      extends java.lang.Object

  A `JEditBuffer` represents the contents of an open text file as it is maintained in the computer's memory (as opposed to how it may be stored on a disk).

  This class is partially thread-safe, however you must pay attention to two very important guidelines:

  - Operations such as insert() and remove(), undo(), change Buffer data in a writeLock(), and must be called from the AWT thread.
  - When accessing the buffer from another thread, you must call readLock() before and readUnLock() after, if you plan on performing more than one read, to ensure that the buffer contents are not changed by the AWT thread for the duration of the lock. Only methods whose descriptions specify thread safety can be invoked from other threads.
  Since:
    jEdit 4.3pre3

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `JEditBuffer.PropValue`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `java.lang.Object` | `columnBlockLock`
    `protected boolean` | `contextInsensitive` If true the syntax highlight is context insensitive.
    `boolean` | `elasticTabstopsOn` This field should be read instead of "elasticTabstops" property when efficiency matters.
    `static java.lang.String` | `ENCODING` Character encoding used when loading and saving.
    `static int` | `HIGH_PRIORITY`
    `static java.lang.String` | `LINESEP` Line separator property.
    `protected Mode` | `mode` The edit mode of the buffer.
    `static int` | `NORMAL_PRIORITY`
    `protected TokenMarker` | `tokenMarker`
    `protected UndoManager` | `undoMgr`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JEditBuffer()` Create a new JEditBuffer.
    `JEditBuffer(java.util.Map props)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addBufferListener(BufferListener listener)` Adds a buffer change listener.
    `void` | `addBufferListener(BufferListener listener, int priority)` Adds a buffer change listener.
    `void` | `beginCompoundEdit()` Starts a compound edit.
    `boolean` | `canRedo()` Returns true if a redo operation can be performed.
    `boolean` | `canUndo()` Returns true if an undo operation can be performed.
    `javax.swing.text.Position` | `createPosition(int offset)` Creates a floating position (`javax.swing.text.Position`).
    `void` | `endCompoundEdit()` Ends a compound edit.
    `protected void` | `fireBeginRedo()`
    `protected void` | `fireBeginUndo()`
    `protected void` | `fireBufferLoaded()`
    `protected void` | `fireContentInserted(int startLine, int offset, int numLines, int length)`
    `protected void` | `fireContentRemoved(int startLine, int offset, int numLines, int length)`
    `protected void` | `fireEndRedo()`
    `protected void` | `fireEndUndo()`
    `protected void` | `fireFoldHandlerChanged()`
    `protected void` | `fireFoldLevelChanged(int start, int end)`
    `protected void` | `firePreContentInserted(int startLine, int offset, int numLines, int length)`
    `protected void` | `firePreContentRemoved(int startLine, int offset, int numLines, int length)`
    `protected void` | `fireTransactionComplete()`
    `boolean` | `getBooleanProperty(java.lang.String name)` Returns the value of a boolean property.
    `boolean` | `getBooleanProperty(java.lang.String name, boolean def)` Returns the value of a boolean property.
    `BufferListener[]` | `getBufferListeners()` Returns an array of registered buffer change listeners.
    `ColumnBlock` | `getColumnBlock()`
    `java.lang.String` | `getContextSensitiveProperty(int offset, java.lang.String name)` Some settings, like comment start and end strings, can vary between different parts of a buffer (HTML text and inline JavaScript, for example).
    `int` | `getCurrentIndentForLine(int lineIndex, int[] whitespaceChars)` Returns the line's current leading indent.
    `java.lang.Object` | `getDefaultProperty(java.lang.String key)`
    `int[]` | `getFoldAtLine(int line)` Returns an array.
    `FoldHandler` | `getFoldHandler()` Returns the current buffer's fold handler.
    `int` | `getFoldLevel(int line)` Returns the fold level of the specified line.
    `int` | `getIdealIndentForLine(int lineIndex)` Returns the ideal leading indent for the specified line.
    `int` | `getIndentSize()` Returns the indent size used in this buffer.
    `int` | `getIntegerProperty(java.lang.String name, int defaultValue)` Returns the value of an integer property.
    `KeywordMap` | `getKeywordMapAtOffset(int offset)` Returns the syntax highlighting keyword map in effect at the specified offset.
    `int` | `getLength()` Returns the number of characters in the buffer.
    `int` | `getLineCount()` Returns the number of physical lines in the buffer.
    `int` | `getLineEndOffset(int line)` Returns the end offset of the specified line.
    `int` | `getLineLength(int line)` Returns the length of the specified line.
    `int` | `getLineOfOffset(int offset)` Returns the line containing the specified offset.
    `java.lang.CharSequence` | `getLineSegment(int line)` Returns the text on the specified line.
    `int` | `getLineStartOffset(int line)` Returns the start offset of the specified line.
    `java.lang.String` | `getLineText(int line)` Returns the text on the specified line.
    `void` | `getLineText(int line, int relativeStartOffset, javax.swing.text.Segment segment)` Returns the specified line from the starting point passed in relativeStartOffset in a `Segment`.
    `void` | `getLineText(int line, javax.swing.text.Segment segment)` Returns the specified line in a `Segment`.
    `Mode` | `getMode()` Returns this buffer's edit mode.
    `int` | `getOffsetOfVirtualColumn(int line, int column, int[] totalVirtualWidth)` Returns the offset of a virtual column number (taking tabs into account) relative to the start of the line in question.
    `java.util.regex.Pattern` | `getPatternProperty(java.lang.String name, int flags)` Returns the value of a property as a regular expression.
    `int` | `getPriorNonEmptyLine(int lineIndex)` Auto indent needs this.
    `java.lang.Object` | `getProperty(java.lang.Object name)` Returns the value of a buffer-local property.
    `ParserRuleSet` | `getRuleSetAtOffset(int offset)` Returns the syntax highlighting ruleset at the specified offset.
    `java.lang.CharSequence` | `getSegment(int start, int length)` Returns the specified text range.
    `java.lang.String` | `getStringProperty(java.lang.String name)` Returns the value of a string property.
    `int` | `getTabSize()` Returns the tab size used in this buffer.
    `int` | `getTabStopPosition(javax.swing.text.Segment seg)`
    `java.lang.String` | `getText()` Returns the full buffer content.
    `java.lang.String` | `getText(int start, int length)` Returns the specified text range.
    `void` | `getText(int start, int length, javax.swing.text.Segment seg)` Returns the specified text range in a `Segment`.
    `TokenMarker` | `getTokenMarker()`
    `java.lang.Object` | `getUndoId()` Returns an object that identifies the undo operation to which the current content change belongs.
    `int` | `getVirtualWidth(int line, int column)` Returns the virtual column number (taking tabs into account) of the specified position.
    `boolean` | `indentLine(int lineIndex, boolean canDecreaseIndent)` Indents the specified line.
    `void` | `indentLines(int[] lines)` Indents all specified lines.
    `void` | `indentLines(int start, int end)` Indents all specified lines.
    `void` | `indentUsingElasticTabstops()`
    `void` | `insert(int offset, java.lang.CharSequence seq)` Inserts a string into the buffer.
    `void` | `insert(int offset, javax.swing.text.Segment seg)` Inserts a string into the buffer.
    `void` | `insert(int offset, java.lang.String str)` Inserts a string into the buffer.
    `void` | `insertAtColumn(int line, int col, java.lang.String str)` Like the `insert(int,String)` method, but inserts the string at the specified virtual column.
    `int` | `insertIndented(int offset, java.lang.String text)` Inserts a string into the buffer, indenting each line of the string to match the indent of the first line.
    `boolean` | `insideCompoundEdit()` Returns if a compound edit is currently active.
    `void` | `invalidateCachedFoldLevels()` Invalidates all cached fold level information.
    `protected void` | `invalidateFoldLevels()`
    `boolean` | `isContextInsensitive()` Returns true if the buffer highlight is not sensitive to the context.
    `boolean` | `isDirty()` Returns whether there have been unsaved changes to this buffer.
    `boolean` | `isEditable()` Returns true if this file is editable, false otherwise.
    `boolean` | `isElectricKey(char ch, int line)` Should inserting this character trigger a re-indent of the current line?
    `protected boolean` | `isFileReadOnly()`
    `boolean` | `isFoldEnd(int line)` Returns if the specified line ends a fold.
    `boolean` | `isFoldStart(int line)` Returns if the specified line begins a fold.
    `boolean` | `isLoading()`
    `boolean` | `isPerformingIO()` Returns true if the buffer is currently performing I/O.
    `boolean` | `isReadOnly()` Returns true if this file is read only, false otherwise.
    `boolean` | `isTransactionInProgress()` Returns if an undo or compound edit is currently in progress.
    `boolean` | `isUndoInProgress()` Returns if an undo or redo is currently being performed.
    `protected void` | `loadText(javax.swing.text.Segment seg, IntegerArray endOffsets)`
    `void` | `markTokens(int lineIndex, TokenHandler tokenHandler)` Returns the syntax tokens for the specified line.
    `protected TokenMarker.LineContext` | `markTokens(javax.swing.text.Segment seg, TokenMarker.LineContext prevContext, TokenHandler _tokenHandler)`
    `protected void` | `parseBufferLocalProperties()`
    `void` | `propertiesChanged()` Reloads settings from the properties.
    `void` | `readLock()` The buffer is guaranteed not to change between calls to `readLock()` and `readUnlock()`.
    `void` | `readUnlock()` The buffer is guaranteed not to change between calls to `readLock()` and `readUnlock()`.
    `void` | `redo(TextArea textArea)` Redoes the most recently undone edit.
    `void` | `remove(int offset, int length)` Removes the specified rang efrom the buffer.
    `void` | `removeBufferListener(BufferListener listener)` Removes a buffer change listener.
    `void` | `removeTrailingWhiteSpace(int[] lines)` Removes trailing whitespace from all lines in the specified list.
    `void` | `resetCachedProperties()`
    `void` | `setBooleanProperty(java.lang.String name, boolean value)` Sets a boolean property.
    `void` | `setContextInsensitive(boolean contextInsensitive)` Set the buffer to be insensitive to the context during highlight.
    `void` | `setDefaultProperty(java.lang.String name, java.lang.Object value)`
    `void` | `setDirty(boolean d)` Sets the 'dirty' (changed since last save) flag of this buffer.
    `protected void` | `setFileReadOnly(boolean readOnly)`
    `void` | `setFoldHandler(FoldHandler foldHandler)` Sets the buffer's fold handler.
    `void` | `setIntegerProperty(java.lang.String name, int value)` Sets an integer property.
    `void` | `setLoading(boolean loading)`
    `void` | `setMode(Mode mode)` Sets this buffer's edit mode.
    `void` | `setMode(Mode mode, boolean forceContextInsensitive)` Sets this buffer's edit mode.
    `void` | `setMode(java.lang.String mode)` Sets this buffer's edit mode.
    `void` | `setPerformingIO(boolean io)` Returns true if the buffer is currently performing I/O.
    `void` | `setProperty(java.lang.String name, java.lang.Object value)` Sets the value of a buffer-local property.
    `void` | `setReadOnly(boolean readOnly)` Sets the read only flag.
    `void` | `setStringProperty(java.lang.String name, java.lang.String value)` Sets a string property.
    `void` | `setTokenMarker(TokenMarker tokenMarker)`
    `void` | `setUndoLimit(int limit)` Set the undo limit of the Undo Manager.
    `void` | `shiftIndentLeft(int[] lines)` Shifts the indent of each line in the specified list to the left.
    `void` | `shiftIndentRight(int[] lines)` Shifts the indent of each line in the specified list to the right.
    `void` | `simpleIndentLine(int lineIndex)` Simply indents the given line to the same level as the previous nonempty line
    `void` | `undo(TextArea textArea)` Undoes the most recent edit.
    `void` | `unsetProperty(java.lang.String name)` Clears the value of a buffer-local property.
    `void` | `updateColumnBlocks(int startLine, int endLine, int startColumn, Node parent)`
    `void` | `writeLock()` Attempting to obtain read lock will block between calls to `writeLock()` and `writeUnlock()`.
    `void` | `writeUnlock()` Attempting to obtain read lock will block between calls to `writeLock()` and `writeUnlock()`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### LINESEP

          public static final java.lang.String LINESEP

      Line separator property.
      See Also:
        Constant Field Values

    - #### ENCODING

          public static final java.lang.String ENCODING

      Character encoding used when loading and saving.
      Since:
        jEdit 3.2pre4
      See Also:
        Constant Field Values

    - #### NORMAL_PRIORITY

          public static final int NORMAL_PRIORITY

      See Also:
        Constant Field Values

    - #### HIGH_PRIORITY

          public static final int HIGH_PRIORITY

      See Also:
        Constant Field Values

    - #### mode

          protected Mode mode

      The edit mode of the buffer.

    - #### contextInsensitive

          protected boolean contextInsensitive

      If true the syntax highlight is context insensitive. To highlight a line we don't keed the context of the previous line.

    - #### undoMgr

          protected UndoManager undoMgr

    - #### tokenMarker

          protected TokenMarker tokenMarker

    - #### elasticTabstopsOn

          public boolean elasticTabstopsOn

      This field should be read instead of "elasticTabstops" property when efficiency matters.

    - #### columnBlockLock

          public final java.lang.Object columnBlockLock

  - ### Constructor Detail

    - #### JEditBuffer

          public JEditBuffer(java.util.Map props)

    - #### JEditBuffer

          public JEditBuffer()

      Create a new JEditBuffer. It is used by independent textarea only

  - ### Method Detail

    - #### isDirty

          public boolean isDirty()

      Returns whether there have been unsaved changes to this buffer. This method is thread-safe.

    - #### isLoading

          public boolean isLoading()

    - #### setLoading

          public void setLoading(boolean loading)

    - #### isPerformingIO

          public boolean isPerformingIO()

      Returns true if the buffer is currently performing I/O. This method is thread-safe.
      Since:
        jEdit 2.7pre1

    - #### setPerformingIO

          public void setPerformingIO(boolean io)

      Returns true if the buffer is currently performing I/O. This method is thread-safe.
      Since:
        jEdit 2.7pre1

    - #### isEditable

          public boolean isEditable()

      Returns true if this file is editable, false otherwise. A file may become uneditable if it is read only, or if I/O is in progress. This method is thread-safe.
      Since:
        jEdit 2.7pre1

    - #### isReadOnly

          public boolean isReadOnly()

      Returns true if this file is read only, false otherwise. This method is thread-safe.

    - #### setReadOnly

          public void setReadOnly(boolean readOnly)

      Sets the read only flag.
      Parameters:
        `readOnly` - The read only flag

    - #### setDirty

          public void setDirty(boolean d)

      Sets the 'dirty' (changed since last save) flag of this buffer.

    - #### readLock

          public void readLock()

      The buffer is guaranteed not to change between calls to `readLock()` and `readUnlock()`. Calls to this method may be nested.

    - #### readUnlock

          public void readUnlock()

      The buffer is guaranteed not to change between calls to `readLock()` and `readUnlock()`.

    - #### writeLock

          public void writeLock()

      Attempting to obtain read lock will block between calls to `writeLock()` and `writeUnlock()`. Calls to this method may be nested.

    - #### writeUnlock

          public void writeUnlock()

      Attempting to obtain read lock will block between calls to `writeLock()` and `writeUnlock()`.

    - #### getLength

          public int getLength()

      Returns the number of characters in the buffer. This method is thread-safe.

    - #### getLineCount

          public int getLineCount()

      Returns the number of physical lines in the buffer. This method is thread-safe.
      Since:
        jEdit 3.1pre1

    - #### getLineOfOffset

          public int getLineOfOffset(int offset)

      Returns the line containing the specified offset. This method is thread-safe.
      Parameters:
        `offset` - The offset
      Since:
        jEdit 4.0pre1

    - #### getLineStartOffset

          public int getLineStartOffset(int line)

      Returns the start offset of the specified line. This method is thread-safe.
      Parameters:
        `line` - The line
      Returns:
        The start offset of the specified line, that is the offset after the end-of-line character before that line.
      Since:
        jEdit 4.0pre1

    - #### getLineEndOffset

          public int getLineEndOffset(int line)

      Returns the end offset of the specified line. This method is thread-safe.
      Parameters:
        `line` - The line
      Returns:
        The end offset of the specified line, that is the offset after the end-of-line character. Note that `buffer.getLineOfOffset(buffer.getLineEndOffset(x))` does not return `x` but `x+1`.
      Since:
        jEdit 4.0pre1

    - #### getLineLength

          public int getLineLength(int line)

      Returns the length of the specified line. This method is thread-safe.
      Parameters:
        `line` - The line
      Since:
        jEdit 4.0pre1

    - #### getPriorNonEmptyLine

          public int getPriorNonEmptyLine(int lineIndex)

      Auto indent needs this.

    - #### getLineText

          public java.lang.String getLineText(int line)

      Returns the text on the specified line. This method is thread-safe.
      Parameters:
        `line` - The line
      Returns:
        The text, or null if the line is invalid
      Since:
        jEdit 4.0pre1

    - #### getLineText

          public void getLineText(int line,
                         javax.swing.text.Segment segment)

      Returns the specified line in a `Segment`.

      Using a Segment is generally more efficient than using a String because it results in less memory allocation and array copying.

      This method is thread-safe.

      Parameters:
        `line` - The line
      Since:
        jEdit 4.0pre1

    - #### getLineText

          public void getLineText(int line,
                         int relativeStartOffset,
                         javax.swing.text.Segment segment)

      Returns the specified line from the starting point passed in relativeStartOffset in a `Segment`.

      Using a Segment is generally more efficient than using a String because it results in less memory allocation and array copying.

      This method is thread-safe.

      Parameters:
        `line` - The line
      Since:
        jEdit 4.0pre1

    - #### getLineSegment

          public java.lang.CharSequence getLineSegment(int line)

      Returns the text on the specified line. This method is thread-safe.
      Parameters:
        `line` - The line index.
      Returns:
        The text, or null if the line is invalid
      Since:
        jEdit 4.3pre15

    - #### getText

          public java.lang.String getText(int start,
                                 int length)

      Returns the specified text range. This method is thread-safe.
      Parameters:
        `start` - The start offset
        `length` - The number of characters to get

    - #### getText

          public java.lang.String getText()

      Returns the full buffer content. This method is thread-safe
      Since:
        4.4.1

    - #### getText

          public void getText(int start,
                     int length,
                     javax.swing.text.Segment seg)

      Returns the specified text range in a `Segment`.

      Using a Segment is generally more efficient than using a String because it results in less memory allocation and array copying.

      This method is thread-safe.

      Parameters:
        `start` - The start offset
        `length` - The number of characters to get
        `seg` - The segment to copy the text to

    - #### getSegment

          public java.lang.CharSequence getSegment(int start,
                                          int length)

      Returns the specified text range. This method is thread-safe. It doesn't copy the text
      Parameters:
        `start` - The start offset
        `length` - The number of characters to get
      Returns:
        a CharSequence that contains the text wanted text
      Since:
        jEdit 4.3pre15

    - #### insert

          public void insert(int offset,
                    java.lang.String str)

      Inserts a string into the buffer.
      Parameters:
        `offset` - The offset
        `str` - The string
      Since:
        jEdit 4.0pre1

    - #### insert

          public void insert(int offset,
                    javax.swing.text.Segment seg)

      Inserts a string into the buffer.
      Parameters:
        `offset` - The offset
        `seg` - The segment
      Since:
        jEdit 4.0pre1

    - #### insert

          public void insert(int offset,
                    java.lang.CharSequence seq)

      Inserts a string into the buffer.
      Parameters:
        `offset` - The offset
        `seq` - The charsequence
      Since:
        jEdit 5.0pre1

    - #### remove

          public void remove(int offset,
                    int length)

      Removes the specified rang efrom the buffer.
      Parameters:
        `offset` - The start offset
        `length` - The number of characters to remove

    - #### removeTrailingWhiteSpace

          public void removeTrailingWhiteSpace(int[] lines)

      Removes trailing whitespace from all lines in the specified list.
      Parameters:
        `lines` - The line numbers
      Since:
        jEdit 3.2pre1

    - #### shiftIndentLeft

          public void shiftIndentLeft(int[] lines)

      Shifts the indent of each line in the specified list to the left.
      Parameters:
        `lines` - The line numbers
      Since:
        jEdit 3.2pre1

    - #### shiftIndentRight

          public void shiftIndentRight(int[] lines)

      Shifts the indent of each line in the specified list to the right.
      Parameters:
        `lines` - The line numbers
      Since:
        jEdit 3.2pre1

    - #### indentLines

          public void indentLines(int start,
                         int end)

      Indents all specified lines.
      Parameters:
        `start` - The first line to indent
        `end` - The last line to indent
      Since:
        jEdit 3.1pre3

    - #### indentLines

          public void indentLines(int[] lines)

      Indents all specified lines.
      Parameters:
        `lines` - The line numbers
      Since:
        jEdit 3.2pre1

    - #### simpleIndentLine

          public void simpleIndentLine(int lineIndex)

      Simply indents the given line to the same level as the previous nonempty line
      Parameters:
        `lineIndex` - The line number to indent
      Since:
        jEdit 5.0

    - #### indentLine

          public boolean indentLine(int lineIndex,
                           boolean canDecreaseIndent)

      Indents the specified line.
      Parameters:
        `lineIndex` - The line number to indent
        `canDecreaseIndent` - If true, the indent can be decreased as a result of this. Set this to false for Tab key.
      Returns:
        true If indentation took place, false otherwise.
      Since:
        jEdit 4.2pre2

    - #### getCurrentIndentForLine

          public int getCurrentIndentForLine(int lineIndex,
                                    int[] whitespaceChars)

      Returns the line's current leading indent.
      Parameters:
        `lineIndex` - The line number
        `whitespaceChars` - If this is non-null, the number of whitespace characters is stored at the 0 index
      Since:
        jEdit 4.2pre2

    - #### getIdealIndentForLine

          public int getIdealIndentForLine(int lineIndex)

      Returns the ideal leading indent for the specified line. This will apply the various auto-indent rules.
      Parameters:
        `lineIndex` - The line number

    - #### getVirtualWidth

          public int getVirtualWidth(int line,
                            int column)

      Returns the virtual column number (taking tabs into account) of the specified position.
      Parameters:
        `line` - The line number
        `column` - The column number
      Since:
        jEdit 4.1pre1

    - #### getOffsetOfVirtualColumn

          public int getOffsetOfVirtualColumn(int line,
                                     int column,
                                     int[] totalVirtualWidth)

      Returns the offset of a virtual column number (taking tabs into account) relative to the start of the line in question.
      Parameters:
        `line` - The line number
        `column` - The virtual column number
        `totalVirtualWidth` - If this array is non-null, the total virtual width will be stored in its first location if this method returns -1.
      Returns:
        -1 if the column is out of bounds
      Since:
        jEdit 4.1pre1

    - #### insertAtColumn

          public void insertAtColumn(int line,
                            int col,
                            java.lang.String str)

      Like the `insert(int,String)` method, but inserts the string at the specified virtual column. Inserts spaces as appropriate if the line is shorter than the column.
      Parameters:
        `line` - The line number
        `col` - The virtual column number
        `str` - The string

    - #### insertIndented

          public int insertIndented(int offset,
                           java.lang.String text)

      Inserts a string into the buffer, indenting each line of the string to match the indent of the first line.
      Parameters:
        `offset` - The offset
        `text` - The text
      Returns:
        The number of characters of indent inserted on each new line. This is used by the abbreviations code.
      Since:
        jEdit 4.2pre14

    - #### isElectricKey

          public boolean isElectricKey(char ch,
                              int line)

      Should inserting this character trigger a re-indent of the current line?
      Since:
        jEdit 4.3pre9

    - #### markTokens

          public void markTokens(int lineIndex,
                        TokenHandler tokenHandler)

      Returns the syntax tokens for the specified line.
      Parameters:
        `lineIndex` - The line number
        `tokenHandler` - The token handler that will receive the syntax tokens
      Since:
        jEdit 4.1pre1

    - #### getTokenMarker

          public TokenMarker getTokenMarker()

    - #### setTokenMarker

          public void setTokenMarker(TokenMarker tokenMarker)

    - #### createPosition

          public javax.swing.text.Position createPosition(int offset)

      Creates a floating position (`javax.swing.text.Position`). The position is retained despite text editions.

      No explicit removal of position is necessary, only dereferencing it.

      Parameters:
        `offset` - The offset

    - #### propertiesChanged

          public void propertiesChanged()

      Reloads settings from the properties. This should be called after the `syntax` or `folding` buffer-local properties are changed.

    - #### getTabSize

          public int getTabSize()

      Returns the tab size used in this buffer. This is equivalent to calling `getProperty("tabSize")`. This method is thread-safe.

    - #### getIndentSize

          public int getIndentSize()

      Returns the indent size used in this buffer. This is equivalent to calling `getProperty("indentSize")`. This method is thread-safe.
      Since:
        jEdit 2.7pre1

    - #### getProperty

          public java.lang.Object getProperty(java.lang.Object name)

      Returns the value of a buffer-local property.

      Using this method is generally discouraged, because it returns an `Object` which must be cast to another type in order to be useful, and this can cause problems if the object is of a different type than what the caller expects.

      The following methods should be used instead:

      - `getStringProperty(String)`
      - `getBooleanProperty(String)`
      - `getIntegerProperty(String,int)`
      This method is thread-safe.
      Parameters:
        `name` - The property name. For backwards compatibility, this is an `Object`, not a `String`.

    - #### getDefaultProperty

          public java.lang.Object getDefaultProperty(java.lang.String key)

    - #### setProperty

          public void setProperty(java.lang.String name,
                         java.lang.Object value)

      Sets the value of a buffer-local property.
      Parameters:
        `name` - The property name
        `value` - The property value
      Since:
        jEdit 4.0pre1

    - #### setDefaultProperty

          public void setDefaultProperty(java.lang.String name,
                                java.lang.Object value)

    - #### unsetProperty

          public void unsetProperty(java.lang.String name)

      Clears the value of a buffer-local property.
      Parameters:
        `name` - The property name
      Since:
        jEdit 4.0pre1

    - #### resetCachedProperties

          public void resetCachedProperties()

    - #### getStringProperty

          public java.lang.String getStringProperty(java.lang.String name)

      Returns the value of a string property. This method is thread-safe.
      Parameters:
        `name` - The property name
      Since:
        jEdit 4.0pre1

    - #### setStringProperty

          public void setStringProperty(java.lang.String name,
                               java.lang.String value)

      Sets a string property.
      Parameters:
        `name` - The property name
        `value` - The value
      Since:
        jEdit 4.0pre1

    - #### getBooleanProperty

          public boolean getBooleanProperty(java.lang.String name)

      Returns the value of a boolean property. This method is thread-safe.
      Parameters:
        `name` - The property name
      Since:
        jEdit 4.0pre1

    - #### getBooleanProperty

          public boolean getBooleanProperty(java.lang.String name,
                                   boolean def)

      Returns the value of a boolean property. This method is thread-safe.
      Parameters:
        `name` - The property name
        `def` - The default value
      Since:
        jEdit 4.3pre17

    - #### setBooleanProperty

          public void setBooleanProperty(java.lang.String name,
                                boolean value)

      Sets a boolean property.
      Parameters:
        `name` - The property name
        `value` - The value
      Since:
        jEdit 4.0pre1

    - #### getIntegerProperty

          public int getIntegerProperty(java.lang.String name,
                               int defaultValue)

      Returns the value of an integer property. This method is thread-safe.
      Parameters:
        `name` - The property name
      Since:
        jEdit 4.0pre1

    - #### setIntegerProperty

          public void setIntegerProperty(java.lang.String name,
                                int value)

      Sets an integer property.
      Parameters:
        `name` - The property name
        `value` - The value
      Since:
        jEdit 4.0pre1

    - #### getPatternProperty

          public java.util.regex.Pattern getPatternProperty(java.lang.String name,
                                                   int flags)

      Returns the value of a property as a regular expression. This method is thread-safe.
      Parameters:
        `name` - The property name
        `flags` - Regular expression compilation flags
      Since:
        jEdit 4.3pre5

    - #### getRuleSetAtOffset

          public ParserRuleSet getRuleSetAtOffset(int offset)

      Returns the syntax highlighting ruleset at the specified offset.
      Since:
        jEdit 4.1pre1

    - #### getKeywordMapAtOffset

          public KeywordMap getKeywordMapAtOffset(int offset)

      Returns the syntax highlighting keyword map in effect at the specified offset. Used by the Complete Word command to complete keywords.
      Parameters:
        `offset` - The offset
      Since:
        jEdit 4.0pre3

    - #### getContextSensitiveProperty

          public java.lang.String getContextSensitiveProperty(int offset,
                                                     java.lang.String name)

      Some settings, like comment start and end strings, can vary between different parts of a buffer (HTML text and inline JavaScript, for example).
      Parameters:
        `offset` - The offset
        `name` - The property name
      Since:
        jEdit 4.0pre3

    - #### getMode

          public Mode getMode()

      Returns this buffer's edit mode. This method is thread-safe.

    - #### setMode

          public void setMode(java.lang.String mode)

      Sets this buffer's edit mode. Note that calling this before a buffer is loaded will have no effect; in that case, set the "mode" property to the name of the mode. A bit inelegant, I know...
      Parameters:
        `mode` - The mode name
      Since:
        jEdit 4.2pre1

    - #### setMode

          public void setMode(Mode mode)

      Sets this buffer's edit mode. Note that calling this before a buffer is loaded will have no effect; in that case, set the "mode" property to the name of the mode. A bit inelegant, I know...
      Parameters:
        `mode` - The mode

    - #### setMode

          public void setMode(Mode mode,
                     boolean forceContextInsensitive)

      Sets this buffer's edit mode. Note that calling this before a buffer is loaded will have no effect; in that case, set the "mode" property to the name of the mode. A bit inelegant, I know...
      Parameters:
        `mode` - The mode
        `forceContextInsensitive` - true if you want to force the buffer to be insensitive to the context. Careful it can break syntax highlight. Default value is false
      Since:
        jEdit 4.5pre1

    - #### isFoldStart

          public boolean isFoldStart(int line)

      Returns if the specified line begins a fold.
      Since:
        jEdit 3.1pre1

    - #### isFoldEnd

          public boolean isFoldEnd(int line)

      Returns if the specified line ends a fold.
      Since:
        jEdit 4.2pre5

    - #### invalidateCachedFoldLevels

          public void invalidateCachedFoldLevels()

      Invalidates all cached fold level information.
      Since:
        jEdit 4.1pre11

    - #### getFoldLevel

          public int getFoldLevel(int line)

      Returns the fold level of the specified line.
      Parameters:
        `line` - A physical line index
      Since:
        jEdit 3.1pre1

    - #### getFoldAtLine

          public int[] getFoldAtLine(int line)

      Returns an array. The first element is the start line, the second element is the end line, of the fold containing the specified line number.
      Parameters:
        `line` - The line number
      Since:
        jEdit 4.0pre3

    - #### getFoldHandler

          @Nonnull
          public FoldHandler getFoldHandler()

      Returns the current buffer's fold handler.
      Since:
        jEdit 4.2pre1

    - #### setFoldHandler

          public void setFoldHandler(@Nonnull
                            FoldHandler foldHandler)

      Sets the buffer's fold handler.
      Since:
        jEdit 4.2pre2

    - #### undo

          public void undo(TextArea textArea)

      Undoes the most recent edit.
      Since:
        jEdit 4.0pre1

    - #### redo

          public void redo(TextArea textArea)

      Redoes the most recently undone edit.
      Since:
        jEdit 2.7pre2

    - #### isTransactionInProgress

          public boolean isTransactionInProgress()

      Returns if an undo or compound edit is currently in progress. If this method returns true, then eventually a `BufferListener.transactionComplete(JEditBuffer)` buffer event will get fired.
      Since:
        jEdit 4.0pre6

    - #### beginCompoundEdit

          public void beginCompoundEdit()

      Starts a compound edit. All edits from now on until `endCompoundEdit()` are called will be merged into one. This can be used to make a complex operation undoable in one step. Nested calls to `beginCompoundEdit()` behave as expected, requiring the same number of `endCompoundEdit()` calls to end the edit.
      See Also:
        `endCompoundEdit()`

    - #### endCompoundEdit

          public void endCompoundEdit()

      Ends a compound edit. All edits performed since `beginCompoundEdit()` was called can now be undone in one step by calling `undo(TextArea)`.
      See Also:
        `beginCompoundEdit()`

    - #### insideCompoundEdit

          public boolean insideCompoundEdit()

      Returns if a compound edit is currently active.
      Since:
        jEdit 3.1pre1

    - #### isUndoInProgress

          public boolean isUndoInProgress()

      Returns if an undo or redo is currently being performed.
      Since:
        jEdit 4.3pre3

    - #### getUndoId

          public java.lang.Object getUndoId()

      Returns an object that identifies the undo operation to which the current content change belongs. This method can be used by buffer listeners during content changes (contentInserted/contentRemoved) to find out which content changes belong to the same "undo" operation. The same undoId object will be returned for all content changes belonging to the same undo operation. Only the identity of the undoId can be used, by comparing it with a previously-returned undoId using "==".
      Since:
        jEdit 4.3pre18

    - #### addBufferListener

          public void addBufferListener(BufferListener listener,
                               int priority)

      Adds a buffer change listener.
      Parameters:
        `listener` - The listener
        `priority` - Listeners with HIGH_PRIORITY get the event before listeners with NORMAL_PRIORITY
      Since:
        jEdit 4.3pre3

    - #### addBufferListener

          public void addBufferListener(BufferListener listener)

      Adds a buffer change listener.
      Parameters:
        `listener` - The listener
      Since:
        jEdit 4.3pre3

    - #### removeBufferListener

          public void removeBufferListener(BufferListener listener)

      Removes a buffer change listener.
      Parameters:
        `listener` - The listener
      Since:
        jEdit 4.3pre3

    - #### getBufferListeners

          public BufferListener[] getBufferListeners()

      Returns an array of registered buffer change listeners.
      Since:
        jEdit 4.3pre3

    - #### setUndoLimit

          public void setUndoLimit(int limit)

      Set the undo limit of the Undo Manager.
      Parameters:
        `limit` - the new limit
      Since:
        jEdit 4.3pre16

    - #### canUndo

          public boolean canUndo()

      Returns true if an undo operation can be performed.
      Since:
        jEdit 4.3pre18

    - #### canRedo

          public boolean canRedo()

      Returns true if a redo operation can be performed.
      Since:
        jEdit 4.3pre18

    - #### isContextInsensitive

          public boolean isContextInsensitive()

      Returns true if the buffer highlight is not sensitive to the context.
      Returns:
        true if the highlight is insensitive to the context
      Since:
        jEdit 4.5pre1

    - #### setContextInsensitive

          public void setContextInsensitive(boolean contextInsensitive)

      Set the buffer to be insensitive to the context during highlight.
      Parameters:
        `contextInsensitive` - the new contextInsensitive value the context
      Since:
        jEdit 4.5pre1

    - #### fireFoldLevelChanged

          protected void fireFoldLevelChanged(int start,
                                  int end)

    - #### fireContentInserted

          protected void fireContentInserted(int startLine,
                                 int offset,
                                 int numLines,
                                 int length)

    - #### fireContentRemoved

          protected void fireContentRemoved(int startLine,
                                int offset,
                                int numLines,
                                int length)

    - #### firePreContentInserted

          protected void firePreContentInserted(int startLine,
                                    int offset,
                                    int numLines,
                                    int length)

    - #### firePreContentRemoved

          protected void firePreContentRemoved(int startLine,
                                   int offset,
                                   int numLines,
                                   int length)

    - #### fireBeginUndo

          protected void fireBeginUndo()

    - #### fireEndUndo

          protected void fireEndUndo()

    - #### fireBeginRedo

          protected void fireBeginRedo()

    - #### fireEndRedo

          protected void fireEndRedo()

    - #### fireTransactionComplete

          protected void fireTransactionComplete()

    - #### fireFoldHandlerChanged

          protected void fireFoldHandlerChanged()

    - #### fireBufferLoaded

          protected void fireBufferLoaded()

    - #### isFileReadOnly

          protected boolean isFileReadOnly()

    - #### setFileReadOnly

          protected void setFileReadOnly(boolean readOnly)

    - #### loadText

          protected void loadText(javax.swing.text.Segment seg,
                      IntegerArray endOffsets)

    - #### invalidateFoldLevels

          protected void invalidateFoldLevels()

    - #### parseBufferLocalProperties

          protected void parseBufferLocalProperties()

    - #### markTokens

          protected TokenMarker.LineContext markTokens(javax.swing.text.Segment seg,
                                           TokenMarker.LineContext prevContext,
                                           TokenHandler _tokenHandler)

    - #### updateColumnBlocks

          public void updateColumnBlocks(int startLine,
                                int endLine,
                                int startColumn,
                                Node parent)

    - #### getTabStopPosition

          public int getTabStopPosition(javax.swing.text.Segment seg)

    - #### indentUsingElasticTabstops

          public void indentUsingElasticTabstops()

    - #### getColumnBlock

          public ColumnBlock getColumnBlock()