| java.lang.Object org.gjt.sp.jedit.buffer.JEditBuffer org.gjt.sp.jedit.Buffer
Buffer | public class Buffer extends JEditBuffer (Code) | | 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.
author: Slava Pestov version: $Id: Buffer.java 11199 2007-12-06 18:39:23Z k_satoda $ |
Method Summary | |
public void | addBufferChangeListener(BufferChangeListener listener, int priority) | public void | addBufferChangeListener(BufferChangeListener listener) | public void | addMarker(char shortcut, int pos) Adds a marker to this buffer. | public void | addOrRemoveMarker(char shortcut, int pos) If a marker is set on the line of the position, it is removed. | public void | autosave() Autosaves this buffer. | public int | checkFileStatus(View view) Check if the buffer has changed on disk. | void | close() | void | commitTemporary() | void | editSyntaxStyle(JEditTextArea textArea) Edit the syntax style of the token under the caret. | public boolean | getAutoReload() | public boolean | getAutoReloadDialog() | public File | getAutosaveFile() Returns the autosave file for this buffer. | public String | getContextSensitiveProperty(int offset, 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). | public Object | getDefaultProperty(String name) | public String | getDirectory() Returns the directory containing this buffer. | public File | getFile() | public Icon | getIcon() Returns this buffer's icon. | public int | getIndex() Returns the position of this buffer in the buffer list. | public long | getLastModified() Returns the last time jEdit modified the file on disk. | public Marker | getMarker(char shortcut) Returns the marker with the specified shortcut. | public Marker | getMarkerAtLine(int line) Returns the first marker at the specified line, or null
if there is none. | public Marker | getMarkerInRange(int start, int end) Returns the first marker within the specified range. | public String | getMarkerNameString() Returns a string of all set markers, used by the status bar
(eg, "a b $ % ^"). | public String | getMarkerStatusPrompt(String action) Returns the status prompt for the given marker action. | public Vector<Marker> | getMarkers() Returns a vector of markers. | public String | getMarkersPath(VFS vfs) | public static String | getMarkersPath(VFS vfs, String path) | public String | getName() Returns the name of this buffer. | public Buffer | getNext() Returns the next buffer in the list. | public String | getPath() Returns the path name of this buffer. | public Buffer | getPrev() Returns the previous buffer in the list. | public String | getSymlinkPath() If this file is a symbolic link, returns the link destination.
Otherwise returns the file's path. | public VFS | getVFS() Returns the virtual filesystem responsible for loading and
saving this buffer. | public boolean | insertFile(View view, String path) Loads a file from disk, and inserts it into this buffer. | public void | insertString(int offset, String str, AttributeSet attr) | public boolean | isClosed() Returns true if this buffer has been closed with
org.gjt.sp.jedit.jEdit.closeBuffer(ViewBuffer) . | public boolean | isLoaded() Returns true if the buffer is loaded. | public boolean | isNewFile() Returns whether this buffer lacks a corresponding version on disk. | public boolean | isTemporary() Returns if this is a temporary buffer. | public boolean | isUntitled() Returns true if this file is 'untitled'. | public boolean | load(View view, boolean reload) Loads the buffer from disk. | public TokenList | markTokens(int lineIndex) | public boolean | markersChanged() | public void | propertiesChanged() Reloads settings from the properties. | public void | putBooleanProperty(String name, boolean value) | public void | putProperty(Object name, Object value) | public void | reload(View view) Reloads the buffer from disk, asking for confirmation if the buffer
has unsaved changes. | public void | removeAllMarkers() Removes all defined markers. | public void | removeAutosaveFile() Remove the autosave file. | public void | removeBufferChangeListener(BufferChangeListener listener) | public void | removeMarker(int line) Removes all markers at the specified line. | public boolean | save(View view, String path) Saves this buffer to the specified path name, or the current path
name if it's null. | public boolean | save(View view, String path, boolean rename) Saves this buffer to the specified path name, or the current path
name if it's null. | public boolean | save(View view, String path, boolean rename, boolean disableFileStatusCheck) Saves this buffer to the specified path name, or the current path
name if it's null. | public boolean | saveAs(View view, boolean rename) Prompts the user for a file to save this buffer to. | public void | setAutoReload(boolean value) | public void | setAutoReloadDialog(boolean value) | public void | setDirty(boolean d) Sets the 'dirty' (changed since last save) flag of this buffer. | public void | setLastModified(long modTime) Sets the last time jEdit modified the file on disk. | public void | setMarkersChanged(boolean changed) | public void | setMode() Sets this buffer's edit mode by calling the accept() method
of each registered edit mode. | public void | setNewFile(boolean newFile) Sets the new file flag. | public void | setWaitSocket(Socket waitSocket) This socket is closed when the buffer is closed. | public String | toString() Returns a string representation of this buffer. | public void | toggleLineSeparator(View view) Toggles the line separator between the three available settings. | public void | toggleWordWrap(View view) Toggles word wrap between the three available modes. | public boolean | updateMarkersFile(View view) Save the markers file, or delete it when there are mo markers left
Handling markers is now independent from saving the buffer. |
BACKED_UP | final public static String BACKED_UP(Code) | | Backed up property.
since: jEdit 3.2pre2 |
CARET | final public static String CARET(Code) | | Caret info properties.
since: jEdit 3.2pre1 |
CARET_POSITIONED | final public static String CARET_POSITIONED(Code) | | |
ENCODING_AUTODETECT | final public static String ENCODING_AUTODETECT(Code) | | Should jEdit try to set the encoding based on a UTF8, UTF16 or
XML signature at the beginning of the file?
|
FILE_CHANGED | final public static int FILE_CHANGED(Code) | | |
FILE_DELETED | final public static int FILE_DELETED(Code) | | |
FILE_NOT_CHANGED | final public static int FILE_NOT_CHANGED(Code) | | |
GZIPPED | final public static String GZIPPED(Code) | | This property is set to 'true' if the file should be GZipped.
since: jEdit 4.0pre4 |
SCROLL_VERT | final public static String SCROLL_VERT(Code) | | 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)
|
TRAILING_EOL | final public static String TRAILING_EOL(Code) | | This property is set to 'true' if the file has a trailing newline.
since: jEdit 4.0pre1 |
addMarker | public void addMarker(char shortcut, int pos)(Code) | | Adds a marker to this buffer.
Parameters: pos - The position of the marker Parameters: shortcut - The shortcut ('\0' if none) since: jEdit 3.2pre1 |
addOrRemoveMarker | public void addOrRemoveMarker(char shortcut, int pos)(Code) | | 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 Parameters: shortcut - The shortcut ('\0' if none) since: jEdit 3.2pre5 |
autosave | public void autosave()(Code) | | Autosaves this buffer.
|
checkFileStatus | public int checkFileStatus(View view)(Code) | | Check if the buffer has changed on disk.
One of NOT_CHANGED , CHANGED , orDELETED . since: jEdit 4.2pre1 |
commitTemporary | void commitTemporary()(Code) | | |
editSyntaxStyle | void editSyntaxStyle(JEditTextArea textArea)(Code) | | Edit the syntax style of the token under the caret.
Parameters: textArea - the textarea where your caret is since: jEdit 4.3pre11 |
getAutoReload | public boolean getAutoReload()(Code) | | Returns the status of the AUTORELOAD flag
If true, reload changed files automatically
|
getAutoReloadDialog | public boolean getAutoReloadDialog()(Code) | | Returns the status of the AUTORELOAD_DIALOG flag
If true, prompt for reloading or notify user
when the file has changed on disk
|
getAutosaveFile | public File getAutosaveFile()(Code) | | Returns the autosave file for this buffer. This may be null if
the file is non-local.
|
getContextSensitiveProperty | public String getContextSensitiveProperty(int offset, String name)(Code) | | 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 Parameters: name - The property name since: jEdit 4.0pre3 |
getDirectory | public String getDirectory()(Code) | | Returns the directory containing this buffer.
since: jEdit 4.1pre11 |
getIcon | public Icon getIcon()(Code) | | Returns this buffer's icon.
since: jEdit 2.6pre6 |
getIndex | public int getIndex()(Code) | | Returns the position of this buffer in the buffer list.
|
getLastModified | public long getLastModified()(Code) | | Returns the last time jEdit modified the file on disk.
This method is thread-safe.
|
getMarker | public Marker getMarker(char shortcut)(Code) | | Returns the marker with the specified shortcut.
Parameters: shortcut - The shortcut since: jEdit 3.2pre2 |
getMarkerAtLine | public Marker getMarkerAtLine(int line)(Code) | | Returns the first marker at the specified line, or null
if there is none.
Parameters: line - The line number since: jEdit 3.2pre2 |
getMarkerInRange | public Marker getMarkerInRange(int start, int end)(Code) | | Returns the first marker within the specified range.
Parameters: start - The start offset Parameters: end - The end offset since: jEdit 4.0pre4 |
getMarkerNameString | public String getMarkerNameString()(Code) | | Returns a string of all set markers, used by the status bar
(eg, "a b $ % ^").
since: jEdit 4.2pre2 |
getMarkerStatusPrompt | public String getMarkerStatusPrompt(String action)(Code) | | Returns the status prompt for the given marker action. Only
intended to be called from actions.xml .
since: jEdit 4.2pre2 |
getMarkers | public Vector<Marker> getMarkers()(Code) | | Returns a vector of markers.
since: jEdit 3.2pre1 |
getMarkersPath | public static String getMarkersPath(VFS vfs, String path)(Code) | | Returns the path for this buffer's markers file
Parameters: vfs - The appropriate VFS Parameters: path - the path of the buffer, it can be different from the fieldwhen using save-as since: jEdit 4.3pre10 |
getName | public String getName()(Code) | | Returns the name of this buffer. This method is thread-safe.
|
getNext | public Buffer getNext()(Code) | | Returns the next buffer in the list.
|
getPath | public String getPath()(Code) | | Returns the path name of this buffer. This method is thread-safe.
|
getPrev | public Buffer getPrev()(Code) | | Returns the previous buffer in the list.
|
getSymlinkPath | public String getSymlinkPath()(Code) | | 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 |
getVFS | public VFS getVFS()(Code) | | Returns the virtual filesystem responsible for loading and
saving this buffer. This method is thread-safe.
|
insertFile | public boolean insertFile(View view, String path)(Code) | | Loads a file from disk, and inserts it into this buffer.
Parameters: view - The view Parameters: path - the path of the file to insert since: 4.0pre1 |
isLoaded | public boolean isLoaded()(Code) | | Returns true if the buffer is loaded. This method is thread-safe.
|
isNewFile | public boolean isNewFile()(Code) | | Returns whether this buffer lacks a corresponding version on disk.
This method is thread-safe.
|
isUntitled | public boolean isUntitled()(Code) | | Returns true if this file is 'untitled'. This method is thread-safe.
|
load | public boolean load(View view, boolean reload)(Code) | | Loads the buffer from disk.
Parameters: view - The view Parameters: reload - If true, user will not be asked to recover autosavefile, if any since: 2.5pre1 |
markTokens | public TokenList markTokens(int lineIndex)(Code) | | |
markersChanged | public boolean markersChanged()(Code) | | Return true when markers have changed and the markers file needs
to be updated
since: jEdit 4.3pre7 |
propertiesChanged | public void propertiesChanged()(Code) | | Reloads settings from the properties. This should be called
after the syntax or folding
buffer-local properties are changed.
|
putBooleanProperty | public void putBooleanProperty(String name, boolean value)(Code) | | |
reload | public void reload(View view)(Code) | | Reloads the buffer from disk, asking for confirmation if the buffer
has unsaved changes.
Parameters: view - The view since: jEdit 2.7pre2 |
removeAllMarkers | public void removeAllMarkers()(Code) | | Removes all defined markers.
since: jEdit 2.6pre1 |
removeAutosaveFile | public void removeAutosaveFile()(Code) | | Remove the autosave file.
since: jEdit 4.3pre12 |
removeMarker | public void removeMarker(int line)(Code) | | Removes all markers at the specified line.
Parameters: line - The line number since: jEdit 3.2pre2 |
save | public boolean save(View view, String path)(Code) | | Saves this buffer to the specified path name, or the current path
name if it's null.
Parameters: view - The view Parameters: path - The path name to save the buffer to, or null to usethe existing path |
save | public boolean save(View view, String path, boolean rename)(Code) | | Saves this buffer to the specified path name, or the current path
name if it's null.
Parameters: view - The view Parameters: path - The path name to save the buffer to, or null to usethe existing path Parameters: rename - True if the buffer's path should be changed, falseif only a copy should be saved to the specified filename since: jEdit 2.6pre5 |
save | public boolean save(View view, String path, boolean rename, boolean disableFileStatusCheck)(Code) | | Saves this buffer to the specified path name, or the current path
name if it's null.
Parameters: view - The view Parameters: path - The path name to save the buffer to, or null to usethe existing path Parameters: rename - True if the buffer's path should be changed, falseif only a copy should be saved to the specified filename Parameters: disableFileStatusCheck - Disables file status checkingregardless of the state of the checkFileStatus property |
saveAs | public boolean saveAs(View view, boolean rename)(Code) | | Prompts the user for a file to save this buffer to.
Parameters: view - The view Parameters: rename - True if the buffer's path should be changed, falseif only a copy should be saved to the specified filename since: jEdit 2.6pre5 |
setAutoReload | public void setAutoReload(boolean value)(Code) | | Sets the status of the AUTORELOAD flag
Parameters: value - # If true, reload changed files automatically |
setAutoReloadDialog | public void setAutoReloadDialog(boolean value)(Code) | | Sets the status of the AUTORELOAD_DIALOG flag
Parameters: value - # If true, prompt for reloading or notify userwhen the file has changed on disk |
setDirty | public void setDirty(boolean d)(Code) | | Sets the 'dirty' (changed since last save) flag of this buffer.
|
setLastModified | public void setLastModified(long modTime)(Code) | | Sets the last time jEdit modified the file on disk.
Parameters: modTime - The new modification time |
setMarkersChanged | public void setMarkersChanged(boolean changed)(Code) | | Sets/unsets the MARKERS_CHANGED flag
since: jEdit 4.3pre7 |
setMode | public void setMode()(Code) | | Sets this buffer's edit mode by calling the accept() method
of each registered edit mode.
|
setNewFile | public void setNewFile(boolean newFile)(Code) | | Sets the new file flag.
Parameters: newFile - The new file flag |
setWaitSocket | public void setWaitSocket(Socket waitSocket)(Code) | | This socket is closed when the buffer is closed.
|
toString | public String toString()(Code) | | Returns a string representation of this buffer.
This simply returns the path name.
|
toggleLineSeparator | public void toggleLineSeparator(View view)(Code) | | 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 |
toggleWordWrap | public void toggleWordWrap(View view)(Code) | | 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 |
updateMarkersFile | public boolean updateMarkersFile(View view)(Code) | | Save the markers file, or delete it when there are mo markers left
Handling markers is now independent from saving the buffer.
Changing markers will not set the buffer dirty any longer.
Parameters: view - The current view since: jEdit 4.3pre7 |
Methods inherited from org.gjt.sp.jedit.buffer.JEditBuffer | public void addBufferListener(BufferListener listener, int priority)(Code)(Java Doc) public void addBufferListener(BufferListener listener)(Code)(Java Doc) public void beginCompoundEdit()(Code)(Java Doc) public Position createPosition(int offset)(Code)(Java Doc) public void endCompoundEdit()(Code)(Java Doc) protected void fireBufferLoaded()(Code)(Java Doc) protected void fireContentInserted(int startLine, int offset, int numLines, int length)(Code)(Java Doc) protected void fireContentRemoved(int startLine, int offset, int numLines, int length)(Code)(Java Doc) protected void fireFoldHandlerChanged()(Code)(Java Doc) protected void fireFoldLevelChanged(int start, int end)(Code)(Java Doc) protected void firePreContentInserted(int startLine, int offset, int numLines, int length)(Code)(Java Doc) protected void firePreContentRemoved(int startLine, int offset, int numLines, int length)(Code)(Java Doc) protected void fireTransactionComplete()(Code)(Java Doc) public boolean getBooleanProperty(String name)(Code)(Java Doc) public BufferListener[] getBufferListeners()(Code)(Java Doc) public String getContextSensitiveProperty(int offset, String name)(Code)(Java Doc) public int getCurrentIndentForLine(int lineIndex, int[] whitespaceChars)(Code)(Java Doc) public Object getDefaultProperty(String key)(Code)(Java Doc) public int[] getFoldAtLine(int line)(Code)(Java Doc) public FoldHandler getFoldHandler()(Code)(Java Doc) public int getFoldLevel(int line)(Code)(Java Doc) public int getIdealIndentForLine(int lineIndex)(Code)(Java Doc) public int getIndentSize()(Code)(Java Doc) public int getIntegerProperty(String name, int defaultValue)(Code)(Java Doc) public KeywordMap getKeywordMapAtOffset(int offset)(Code)(Java Doc) public int getLength()(Code)(Java Doc) public int getLineCount()(Code)(Java Doc) public int getLineEndOffset(int line)(Code)(Java Doc) public int getLineLength(int line)(Code)(Java Doc) public int getLineOfOffset(int offset)(Code)(Java Doc) public int getLineStartOffset(int line)(Code)(Java Doc) public String getLineText(int line)(Code)(Java Doc) public void getLineText(int line, Segment segment)(Code)(Java Doc) public Mode getMode()(Code)(Java Doc) public int getOffsetOfVirtualColumn(int line, int column, int[] totalVirtualWidth)(Code)(Java Doc) public Pattern getPatternProperty(String name, int flags)(Code)(Java Doc) public int getPriorNonEmptyLine(int lineIndex)(Code)(Java Doc) public Object getProperty(Object name)(Code)(Java Doc) public ParserRuleSet getRuleSetAtOffset(int offset)(Code)(Java Doc) public String getStringProperty(String name)(Code)(Java Doc) public int getTabSize()(Code)(Java Doc) public String getText(int start, int length)(Code)(Java Doc) public void getText(int start, int length, Segment seg)(Code)(Java Doc) public TokenMarker getTokenMarker()(Code)(Java Doc) public int getVirtualWidth(int line, int column)(Code)(Java Doc) public boolean indentLine(int lineIndex, boolean canIncreaseIndent, boolean canDecreaseIndent)(Code)(Java Doc) public boolean indentLine(int lineIndex, boolean canDecreaseIndent)(Code)(Java Doc) public void indentLines(int start, int end)(Code)(Java Doc) public void indentLines(int[] lines)(Code)(Java Doc) public void insert(int offset, String str)(Code)(Java Doc) public void insert(int offset, Segment seg)(Code)(Java Doc) public void insertAtColumn(int line, int col, String str)(Code)(Java Doc) public int insertIndented(int offset, String text)(Code)(Java Doc) public boolean insideCompoundEdit()(Code)(Java Doc) public void invalidateCachedFoldLevels()(Code)(Java Doc) protected void invalidateFoldLevels()(Code)(Java Doc) public boolean isDirty()(Code)(Java Doc) public boolean isEditable()(Code)(Java Doc) public boolean isElectricKey(char ch)(Code)(Java Doc) public boolean isElectricKey(char ch, int line)(Code)(Java Doc) protected boolean isFileReadOnly()(Code)(Java Doc) public boolean isFoldEnd(int line)(Code)(Java Doc) public boolean isFoldStart(int line)(Code)(Java Doc) public boolean isLoading()(Code)(Java Doc) public boolean isPerformingIO()(Code)(Java Doc) public boolean isReadOnly()(Code)(Java Doc) public boolean isTransactionInProgress()(Code)(Java Doc) public boolean isUndoInProgress()(Code)(Java Doc) protected void loadText(Segment seg, IntegerArray endOffsets)(Code)(Java Doc) public void markTokens(int lineIndex, TokenHandler tokenHandler)(Code)(Java Doc) protected void parseBufferLocalProperties()(Code)(Java Doc) public void propertiesChanged()(Code)(Java Doc) public void readLock()(Code)(Java Doc) public void readUnlock()(Code)(Java Doc) public void redo(TextArea textArea)(Code)(Java Doc) public void remove(int offset, int length)(Code)(Java Doc) public void removeBufferListener(BufferListener listener)(Code)(Java Doc) public void removeTrailingWhiteSpace(int[] lines)(Code)(Java Doc) public void resetCachedProperties()(Code)(Java Doc) public void setBooleanProperty(String name, boolean value)(Code)(Java Doc) public void setDefaultProperty(String name, Object value)(Code)(Java Doc) public void setDirty(boolean d)(Code)(Java Doc) protected void setFileReadOnly(boolean readOnly)(Code)(Java Doc) public void setFoldHandler(FoldHandler foldHandler)(Code)(Java Doc) public void setIntegerProperty(String name, int value)(Code)(Java Doc) public void setLoading(boolean loading)(Code)(Java Doc) public void setMode(String mode)(Code)(Java Doc) public void setMode(Mode mode)(Code)(Java Doc) public void setPerformingIO(boolean io)(Code)(Java Doc) public void setProperty(String name, Object value)(Code)(Java Doc) public void setReadOnly(boolean readOnly)(Code)(Java Doc) public void setStringProperty(String name, String value)(Code)(Java Doc) public void setTokenMarker(TokenMarker tokenMarker)(Code)(Java Doc) public void shiftIndentLeft(int[] lines)(Code)(Java Doc) public void shiftIndentRight(int[] lines)(Code)(Java Doc) public void undo(TextArea textArea)(Code)(Java Doc) public void unsetProperty(String name)(Code)(Java Doc) public void writeLock()(Code)(Java Doc) public void writeUnlock()(Code)(Java Doc)
|
|
|