## org.gjt.sp.jedit
Class Buffer

    java.lang.Object
      org.gjt.sp.jedit.Buffer

public class Buffer
extends java.lang.Object

A `Buffer` 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).

In a BeanShell script, you can obtain the current buffer instance from the `buffer` variable.

This class does not have a public constructor. Buffers can be opened and closed using methods in the `jEdit` class.

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

- Changes to a buffer can only be made from the AWT thread.
- When accessing the buffer from another thread, you must grab a read lock if you plan on performing more than one call, 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.

Version:
  $Id: Buffer.java,v 1.218 2004/06/04 00:18:34 spestov Exp $
Author:
  Slava Pestov

Nested Class Summary
`static class` `Buffer.TokenList` Deprecated. Use org.gjt.sp.jedit.syntax.DefaultTokenHandler instead

Field Summary
`static java.lang.String` `BACKED_UP` Backed up property.
`static java.lang.String` `CARET` Caret info properties.
`static java.lang.String` `ENCODING` Character encoding used when loading and saving.
`static java.lang.String` `ENCODING_AUTODETECT` Should jEdit try to set the encoding based on a UTF8, UTF16 or XML signature at the beginning of the file?
`static int` `FILE_CHANGED`
`static int` `FILE_DELETED`
`static int` `FILE_NOT_CHANGED`
`static java.lang.String` `GZIPPED` This property is set to 'true' if the file should be GZipped.
`static int` `HIGH_PRIORITY`
`static java.lang.String` `LINESEP` Line separator property.
`static int` `NORMAL_PRIORITY`
`static java.lang.String` `SCROLL_HORIZ`
`static java.lang.String` `SCROLL_VERT` This should be a physical line number, so that the scroll position is preserved correctly across reloads (which will affect virtual line numbers, due to fold being reset)
`static java.lang.String` `SELECTION`
`static java.lang.String` `TRAILING_EOL` This property is set to 'true' if the file has a trailing newline.

Method Summary
`LineManager` `_getLineManager()` Plugins and macros should not call this method.
`void` `addBufferChangeListener(BufferChangeListener listener)` Adds a buffer change listener.
`void` `addBufferChangeListener(BufferChangeListener listener, int priority)` Adds a buffer change listener.
`void` `addMarker(char shortcut, int pos)` Adds a marker to this buffer.
`void` `addOrRemoveMarker(char shortcut, int pos)` If a marker is set on the line of the position, it is removed.
`void` `autosave()` Autosaves this buffer.
`void` `beginCompoundEdit()` Starts a compound edit.
`int` `checkFileStatus(View view)` Check if the buffer has changed on disk.
`javax.swing.text.Position` `createPosition(int offset)` Creates a floating position.
`void` `endCompoundEdit()` Ends a compound edit.
`java.io.File` `getAutosaveFile()` Returns the autosave file for this buffer.
`boolean` `getBooleanProperty(java.lang.String name)` Returns the value of a boolean property.
`BufferChangeListener[]` `getBufferChangeListeners()` Returns an array of registered buffer change listeners.
`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` `getCurrentIdentForLine(int lineIndex, int[] whitespaceChars)` Deprecated. Use the correctly spelled getCurrentIndentForLine() instead.
`int` `getCurrentIndentForLine(int lineIndex, int[] whitespaceChars)` Returns the line's current leading indent.
`javax.swing.text.Element` `getDefaultRootElement()` Deprecated. Use `getLineOfOffset()`, `getLineStartOffset()`, and `getLineEndOffset()` instead.
`java.lang.String` `getDirectory()` Returns the directory containing this buffer.
`java.io.File` `getFile()` Deprecated. Do not call this method, use `getPath()` instead.
`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.
`javax.swing.Icon` `getIcon()` Returns this buffer's icon.
`int` `getIdealIndentForLine(int lineIndex)` Returns the ideal leading indent for the specified line.
`int` `getIndentSize()` Returns the indent size used in this buffer.
`int` `getIndex()` Returns the position of this buffer in the buffer list.
`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.
`long` `getLastModified()` Returns the last time jEdit modified the file on disk.
`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.
`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, javax.swing.text.Segment segment)` Returns the specified line in a `Segment`.
`Marker` `getMarker(char shortcut)` Returns the marker with the specified shortcut.
`Marker` `getMarkerAtLine(int line)` Returns the first marker at the specified line, or `null` if there is none.
`Marker` `getMarkerInRange(int start, int end)` Returns the first marker within the specified range.
`java.lang.String` `getMarkerNameString()` Returns a string of all set markers, used by the status bar (eg, "a b $ % ^").
`java.util.Vector` `getMarkers()` Returns a vector of markers.
`java.lang.String` `getMarkerStatusPrompt(java.lang.String action)` Returns the status prompt for the given marker action.
`Mode` `getMode()` Returns this buffer's edit mode.
`java.lang.String` `getName()` Returns the name of this buffer.
`Buffer` `getNext()` Returns the next buffer in the list.
`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.
`javax.swing.text.Element` `getParagraphElement(int offset)` Deprecated.
`java.lang.String` `getPath()` Returns the path name of this buffer.
`Buffer` `getPrev()` Returns the previous buffer in the list.
`java.lang.Object` `getProperty(java.lang.Object name)` Returns the value of a buffer-local property.
`RE` `getRegexpProperty(java.lang.String name, int cflags, RESyntax syntax)` Returns the value of a property as a regular expression.
`javax.swing.text.Element[]` `getRootElements()` Deprecated.
`ParserRuleSet` `getRuleSetAtOffset(int offset)` Returns the syntax highlighting ruleset at the specified offset.
`java.lang.String` `getStringProperty(java.lang.String name)` Returns the value of a string property.
`java.lang.String` `getSymlinkPath()` If this file is a symbolic link, returns the link destination.
`int` `getTabSize()` Returns the tab size used in this buffer.
`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`.
`VFS` `getVFS()` Returns the virtual filesystem responsible for loading and saving this buffer.
`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.
`boolean` `indentLine(int lineIndex, boolean canIncreaseIndent, boolean canDecreaseIndent)` Deprecated. Use `indentLine(int,boolean)` instead.
`void` `indentLines(int[] lines)` Indents all specified lines.
`void` `indentLines(int start, int end)` Indents all specified lines.
`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.
`boolean` `insertFile(View view, java.lang.String path)` Loads a file from disk, and inserts it into this buffer.
`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.
`void` `insertString(int offset, java.lang.String str, javax.swing.text.AttributeSet attr)` Deprecated. Call `insert()` instead.
`boolean` `insideCompoundEdit()` Returns if a compound edit is currently active.
`void` `invalidateCachedFoldLevels()` Invalidates all cached fold level information.
`void` `invalidateCachedScreenLineCounts()` Invalidates all cached screen line count information.
`boolean` `isClosed()` Returns true if this buffer has been closed with `jEdit.closeBuffer(View,Buffer)`.
`boolean` `isDirty()` Returns whether there have been unsaved changes to this buffer.
`boolean` `isEditable()` Returns true if this file is editable, false otherwise.
`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` `isLoaded()` Returns true if the buffer is loaded.
`boolean` `isNewFile()` Returns whether this buffer lacks a corresponding version on disk.
`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` `isTemporary()` Returns if this is a temporary buffer.
`boolean` `isTransactionInProgress()` Returns if an undo or compound edit is currently in progress.
`boolean` `isUntitled()` Returns true if this file is 'untitled'.
`boolean` `load(View view, boolean reload)` Loads the buffer from disk, even if it is loaded already.
`Buffer.TokenList` `markTokens(int lineIndex)` Deprecated. Use the other form of `markTokens()` instead
`void` `markTokens(int lineIndex, TokenHandler tokenHandler)` Returns the syntax tokens for the specified line.
`void` `propertiesChanged()` Reloads settings from the properties.
`void` `putBooleanProperty(java.lang.String name, boolean value)` Deprecated. Call `setBooleanProperty()` instead
`void` `putProperty(java.lang.Object name, java.lang.Object value)` Deprecated. Call `setProperty()` instead.
`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(JEditTextArea textArea)` Redoes the most recently undone edit.
`void` `reload(View view)` Reloads the buffer from disk, asking for confirmation if the buffer has unsaved changes.
`void` `remove(int offset, int length)` Removes the specified rang efrom the buffer.
`void` `removeAllMarkers()` Removes all defined markers.
`void` `removeBufferChangeListener(BufferChangeListener listener)` Removes a buffer change listener.
`void` `removeMarker(int line)` Removes all markers at the specified line.
`void` `removeTrailingWhiteSpace(int[] lines)` Removes trailing whitespace from all lines in the specified list.
`boolean` `save(View view, java.lang.String path)` Saves this buffer to the specified path name, or the current path name if it's null.
`boolean` `save(View view, java.lang.String path, boolean rename)` Saves this buffer to the specified path name, or the current path name if it's null.
`boolean` `saveAs(View view, boolean rename)` Prompts the user for a file to save this buffer to.
`void` `setBooleanProperty(java.lang.String name, boolean value)` Sets a boolean property.
`void` `setDirty(boolean d)` Sets the 'dirty' (changed since last save) flag of this buffer.
`void` `setFoldHandler(FoldHandler foldHandler)` Sets the buffer's fold handler.
`void` `setIntegerProperty(java.lang.String name, int value)` Sets an integer property.
`void` `setLastModified(long modTime)` Sets the last time jEdit modified the file on disk.
`void` `setMode()` Sets this buffer's edit mode by calling the accept() method of each registered edit mode.
`void` `setMode(Mode mode)` Sets this buffer's edit mode.
`void` `setMode(java.lang.String mode)` Sets this buffer's edit mode.
`void` `setNewFile(boolean newFile)` Sets the new file flag.
`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` `setWaitSocket(java.net.Socket waitSocket)` This socket is closed when the buffer is closed.
`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` `toggleLineSeparator(View view)` Toggles the line separator between the three available settings.
`void` `toggleWordWrap(View view)` Toggles word wrap between the three available modes.
`java.lang.String` `toString()` Returns a string representation of this buffer.
`void` `undo(JEditTextArea textArea)` Undoes the most recent edit.
`void` `unsetProperty(java.lang.String name)` Clears the value of a buffer-local property.
`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, wait, wait, wait`

Field Detail

### LINESEP

    public static final java.lang.String LINESEP

  Line separator property.

  See Also:
    Constant Field Values

### BACKED_UP

    public static final java.lang.String BACKED_UP

  Backed up property.

  Since:
    jEdit 3.2pre2
  See Also:
    Constant Field Values

### CARET

    public static final java.lang.String CARET

  Caret info properties.

  Since:
    jEdit 3.2pre1
  See Also:
    Constant Field Values

### SELECTION

    public static final java.lang.String SELECTION

See Also:
  Constant Field Values

### SCROLL_VERT

    public static final java.lang.String SCROLL_VERT

  This should be a physical line number, so that the scroll position is preserved correctly across reloads (which will affect virtual line numbers, due to fold being reset)

  See Also:
    Constant Field Values

### SCROLL_HORIZ

    public static final java.lang.String SCROLL_HORIZ

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

### ENCODING_AUTODETECT

    public static final java.lang.String ENCODING_AUTODETECT

  Should jEdit try to set the encoding based on a UTF8, UTF16 or XML signature at the beginning of the file?

  See Also:
    Constant Field Values

### TRAILING_EOL

    public static final java.lang.String TRAILING_EOL

  This property is set to 'true' if the file has a trailing newline.

  Since:
    jEdit 4.0pre1
  See Also:
    Constant Field Values

### GZIPPED

    public static final java.lang.String GZIPPED

  This property is set to 'true' if the file should be GZipped.

  Since:
    jEdit 4.0pre4
  See Also:
    Constant Field Values

### FILE_NOT_CHANGED

    public static final int FILE_NOT_CHANGED

See Also:
  Constant Field Values

### FILE_CHANGED

    public static final int FILE_CHANGED

See Also:
  Constant Field Values

### FILE_DELETED

    public static final int FILE_DELETED

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

Method Detail

### reload

    public void reload(View view)

  Reloads the buffer from disk, asking for confirmation if the buffer has unsaved changes.

  Parameters:
    `view` - The view
  Since:
    jEdit 2.7pre2

### load

    public boolean load(View view,
                        boolean reload)

  Loads the buffer from disk, even if it is loaded already.

  Parameters:
    `view` - The view
    `reload` - If true, user will not be asked to recover autosave file, if any
  Since:
    2.5pre1

### insertFile

    public boolean insertFile(View view,
                              java.lang.String path)

  Loads a file from disk, and inserts it into this buffer.

  Parameters:
    `view` - The view
  Since:
    4.0pre1

### autosave

    public void autosave()

  Autosaves this buffer.

### saveAs

    public boolean saveAs(View view,
                          boolean rename)

  Prompts the user for a file to save this buffer to.

  Parameters:
    `view` - The view
    `rename` - True if the buffer's path should be changed, false if only a copy should be saved to the specified filename
  Since:
    jEdit 2.6pre5

### save

    public boolean save(View view,
                        java.lang.String path)

  Saves this buffer to the specified path name, or the current path name if it's null.

  Parameters:
    `view` - The view
    `path` - The path name to save the buffer to, or null to use the existing path

### save

    public boolean save(View view,
                        java.lang.String path,
                        boolean rename)

  Saves this buffer to the specified path name, or the current path name if it's null.

  Parameters:
    `view` - The view
    `path` - The path name to save the buffer to, or null to use the existing path
    `rename` - True if the buffer's path should be changed, false if only a copy should be saved to the specified filename
  Since:
    jEdit 2.6pre5

### checkFileStatus

    public int checkFileStatus(View view)

  Check if the buffer has changed on disk.

  Returns:
    One of `NOT_CHANGED`, `CHANGED`, or `DELETED`.
  Since:
    jEdit 4.2pre1

### getLastModified

    public long getLastModified()

  Returns the last time jEdit modified the file on disk. This method is thread-safe.

### setLastModified

    public void setLastModified(long modTime)

  Sets the last time jEdit modified the file on disk.

  Parameters:
    `modTime` - The new modification time

### getVFS

    public VFS getVFS()

  Returns the virtual filesystem responsible for loading and saving this buffer. This method is thread-safe.

### getAutosaveFile

    public java.io.File getAutosaveFile()

  Returns the autosave file for this buffer. This may be null if the file is non-local.

### getName

    public java.lang.String getName()

  Returns the name of this buffer. This method is thread-safe.

### getPath

    public java.lang.String getPath()

  Returns the path name of this buffer. This method is thread-safe.

### getSymlinkPath

    public java.lang.String getSymlinkPath()

  If this file is a symbolic link, returns the link destination. Otherwise returns the file's path. This method is thread-safe.

  Since:
    jEdit 4.2pre1

### getDirectory

    public java.lang.String getDirectory()

  Returns the directory containing this buffer.

  Since:
    jEdit 4.1pre11

### isClosed

    public boolean isClosed()

  Returns true if this buffer has been closed with `jEdit.closeBuffer(View,Buffer)`. This method is thread-safe.

### isLoaded

    public boolean isLoaded()

  Returns true if the buffer is loaded. This method is thread-safe.

### isPerformingIO

    public boolean isPerformingIO()

  Returns true if the buffer is currently performing I/O. This method is thread-safe.

  Since:
    jEdit 2.7pre1

### isNewFile

    public boolean isNewFile()

  Returns whether this buffer lacks a corresponding version on disk. This method is thread-safe.

### setNewFile

    public void setNewFile(boolean newFile)

  Sets the new file flag.

  Parameters:
    `newFile` - The new file flag

### isUntitled

    public boolean isUntitled()

  Returns true if this file is 'untitled'. This method is thread-safe.

### isDirty

    public boolean isDirty()

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

### isReadOnly

    public boolean isReadOnly()

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

### 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

### 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.

### isTemporary

    public boolean isTemporary()

  Returns if this is a temporary buffer. This method is thread-safe.

  Since:
    jEdit 2.2pre7
  See Also:
    `jEdit.openTemporary(View,String,String,boolean)`, `jEdit.commitTemporary(Buffer)`

### getIcon

    public javax.swing.Icon getIcon()

  Returns this buffer's icon.

  Since:
    jEdit 2.6pre6

### readLock

    public void readLock()

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

### 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()`.

### 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
  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 invalid.
  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

### invalidateCachedScreenLineCounts

    public void invalidateCachedScreenLineCounts()

  Invalidates all cached screen line count information.

  Since:
    jEdit 4.2pre7.

### 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 <classname>Segment</classname> is generally more efficient than using a <classname>String</classname> because it results in less memory allocation and array copying.

  This method is thread-safe.

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

### 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 void getText(int start,
                        int length,
                        javax.swing.text.Segment seg)

  Returns the specified text range in a `Segment`.

  Using a <classname>Segment</classname> is generally more efficient than using a <classname>String</classname> 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

### 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

### 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

### undo

    public void undo(JEditTextArea textArea)

  Undoes the most recent edit.

  Since:
    jEdit 4.0pre1

### redo

    public void redo(JEditTextArea 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 `BufferChangeListener.transactionComplete(Buffer)` 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(JEditTextArea)`.

  See Also:
    `beginCompoundEdit()`

### insideCompoundEdit

    public boolean insideCompoundEdit()

  Returns if a compound edit is currently active.

  Since:
    jEdit 3.1pre1

### addBufferChangeListener

    public void addBufferChangeListener(BufferChangeListener 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.2pre2

### addBufferChangeListener

    public void addBufferChangeListener(BufferChangeListener listener)

  Adds a buffer change listener.

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

### removeBufferChangeListener

    public void removeBufferChangeListener(BufferChangeListener listener)

  Removes a buffer change listener.

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

### getBufferChangeListeners

    public BufferChangeListener[] getBufferChangeListeners()

  Returns an array of registered buffer change listeners.

  Since:
    jEdit 4.1pre3

### 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)`
  - `getRegexpProperty(String,int,gnu.regexp.RESyntax)`
  This method is thread-safe.

  Parameters:
    `name` - The property name. For backwards compatibility, this is an `Object`, not a `String`.

### 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

### 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

### 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

### 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

### getRegexpProperty

    public RE getRegexpProperty(java.lang.String name,
                                int cflags,
                                RESyntax syntax)
                         throws REException

  Returns the value of a property as a regular expression. This method is thread-safe.

  Parameters:
    `name` - The property name
    `cflags` - Regular expression compilation flags
    `syntax` - Regular expression syntax
  Throws:
    `REException`
  Since:
    jEdit 4.1pre9

### 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

### toggleWordWrap

    public void toggleWordWrap(View view)

  Toggles word wrap between the three available modes. This is used by the status bar.

  Parameters:
    `view` - We show a message in the view's status bar
  Since:
    jEdit 4.1pre3

### toggleLineSeparator

    public void toggleLineSeparator(View view)

  Toggles the line separator between the three available settings. This is used by the status bar.

  Parameters:
    `view` - We show a message in the view's status bar
  Since:
    jEdit 4.1pre3

### 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()

  Sets this buffer's edit mode by calling the accept() method of each registered edit mode.

### 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

### 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

### indentLine

    public boolean indentLine(int lineIndex,
                              boolean canIncreaseIndent,
                              boolean canDecreaseIndent)

  Deprecated. Use `indentLine(int,boolean)` instead.

### 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

### putProperty

    public void putProperty(java.lang.Object name,
                            java.lang.Object value)

  Deprecated. Call `setProperty()` instead.

### putBooleanProperty

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

  Deprecated. Call `setBooleanProperty()` instead

### markTokens

    public Buffer.TokenList markTokens(int lineIndex)

  Deprecated. Use the other form of `markTokens()` instead

### getRootElements

    public javax.swing.text.Element[] getRootElements()

  Deprecated.

### getParagraphElement

    public javax.swing.text.Element getParagraphElement(int offset)

  Deprecated.

### getDefaultRootElement

    public javax.swing.text.Element getDefaultRootElement()

  Deprecated. Use `getLineOfOffset()`, `getLineStartOffset()`, and `getLineEndOffset()` instead.

### insertString

    public void insertString(int offset,
                             java.lang.String str,
                             javax.swing.text.AttributeSet attr)

  Deprecated. Call `insert()` instead.

### getFile

    public java.io.File getFile()

  Deprecated. Do not call this method, use `getPath()` instead.

### getCurrentIdentForLine

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

  Deprecated. Use the correctly spelled getCurrentIndentForLine() instead.

### 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

    public FoldHandler getFoldHandler()

  Returns the current buffer's fold handler.

  Since:
    jEdit 4.2pre1

### setFoldHandler

    public void setFoldHandler(FoldHandler foldHandler)

  Sets the buffer's fold handler.

  Since:
    jEdit 4.2pre2

### createPosition

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

  Creates a floating position.

  Parameters:
    `offset` - The offset

### getMarkers

    public java.util.Vector getMarkers()

  Returns a vector of markers.

  Since:
    jEdit 3.2pre1

### getMarkerStatusPrompt

    public java.lang.String getMarkerStatusPrompt(java.lang.String action)

  Returns the status prompt for the given marker action. Only intended to be called from `actions.xml`.

  Since:
    jEdit 4.2pre2

### getMarkerNameString

    public java.lang.String getMarkerNameString()

  Returns a string of all set markers, used by the status bar (eg, "a b $ % ^").

  Since:
    jEdit 4.2pre2

### addOrRemoveMarker

    public void addOrRemoveMarker(char shortcut,
                                  int pos)

  If a marker is set on the line of the position, it is removed. Otherwise a new marker with the specified shortcut is added.

  Parameters:
    `pos` - The position of the marker
    `shortcut` - The shortcut ('\0' if none)
  Since:
    jEdit 3.2pre5

### addMarker

    public void addMarker(char shortcut,
                          int pos)

  Adds a marker to this buffer.

  Parameters:
    `pos` - The position of the marker
    `shortcut` - The shortcut ('\0' if none)
  Since:
    jEdit 3.2pre1

### getMarkerInRange

    public Marker getMarkerInRange(int start,
                                   int end)

  Returns the first marker within the specified range.

  Parameters:
    `start` - The start offset
    `end` - The end offset
  Since:
    jEdit 4.0pre4

### getMarkerAtLine

    public Marker getMarkerAtLine(int line)

  Returns the first marker at the specified line, or `null` if there is none.

  Parameters:
    `line` - The line number
  Since:
    jEdit 3.2pre2

### removeMarker

    public void removeMarker(int line)

  Removes all markers at the specified line.

  Parameters:
    `line` - The line number
  Since:
    jEdit 3.2pre2

### removeAllMarkers

    public void removeAllMarkers()

  Removes all defined markers.

  Since:
    jEdit 2.6pre1

### getMarker

    public Marker getMarker(char shortcut)

  Returns the marker with the specified shortcut.

  Parameters:
    `shortcut` - The shortcut
  Since:
    jEdit 3.2pre2

### setWaitSocket

    public void setWaitSocket(java.net.Socket waitSocket)

  This socket is closed when the buffer is closed.

### getNext

    public Buffer getNext()

  Returns the next buffer in the list.

### getPrev

    public Buffer getPrev()

  Returns the previous buffer in the list.

### getIndex

    public int getIndex()

  Returns the position of this buffer in the buffer list.

### toString

    public java.lang.String toString()

  Returns a string representation of this buffer. This simply returns the path name.

### _getLineManager

    public LineManager _getLineManager()

  Plugins and macros should not call this method.

  Since:
    jEdit 4.2pre3