|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.gjt.sp.jedit.buffer.JEditBuffer
org.gjt.sp.jedit.Buffer
public class Buffer
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:
Nested Class Summary | |
---|---|
static class |
Buffer.TokenList
Deprecated. Use org.gjt.sp.jedit.syntax.DefaultTokenHandler instead |
Nested classes/interfaces inherited from class org.gjt.sp.jedit.buffer.JEditBuffer |
---|
JEditBuffer.PropValue |
Field Summary | |
---|---|
static java.lang.String |
BACKED_UP
Backed up property. |
static java.lang.String |
CARET
Caret info properties. |
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 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
Stores a List of Selection instances. |
static java.lang.String |
TRAILING_EOL
This property is set to 'true' if the file has a trailing newline. |
Fields inherited from class org.gjt.sp.jedit.buffer.JEditBuffer |
---|
ENCODING, HIGH_PRIORITY, LINESEP, NORMAL_PRIORITY, seg, textMode, undoMgr |
Method Summary | |
---|---|
void |
addBufferChangeListener(BufferChangeListener listener)
Deprecated. Call JEditBuffer.addBufferListener(BufferListener) . |
void |
addBufferChangeListener(BufferChangeListener listener,
int priority)
Deprecated. Call JEditBuffer.addBufferListener(BufferListener,int) . |
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. |
int |
checkFileStatus(View view)
Check if the buffer has changed on disk. |
java.io.File |
getAutosaveFile()
Returns the autosave file for this buffer. |
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). |
java.lang.Object |
getDefaultProperty(java.lang.String name)
|
java.lang.String |
getDirectory()
Returns the directory containing this buffer. |
java.io.File |
getFile()
Deprecated. Do not call this method, use getPath()
instead. |
javax.swing.Icon |
getIcon()
Returns this buffer's icon. |
int |
getIndex()
Returns the position of this buffer in the buffer list. |
long |
getLastModified()
Returns the last time jEdit modified the file on disk. |
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. |
java.lang.String |
getPath()
Returns the path name of this buffer. |
Buffer |
getPrev()
Returns the previous buffer in the list. |
java.lang.String |
getSymlinkPath()
If this file is a symbolic link, returns the link destination. |
VFS |
getVFS()
Returns the virtual filesystem responsible for loading and saving this buffer. |
boolean |
insertFile(View view,
java.lang.String path)
Loads a file from disk, and inserts it into this buffer. |
void |
insertString(int offset,
java.lang.String str,
javax.swing.text.AttributeSet attr)
Deprecated. Call insert() instead. |
boolean |
isClosed()
Returns true if this buffer has been closed with jEdit.closeBuffer(View,Buffer) . |
boolean |
isLoaded()
Returns true if the buffer is loaded. |
boolean |
isNewFile()
Returns whether this buffer lacks a corresponding version on disk. |
boolean |
isTemporary()
Returns if this is a temporary buffer. |
boolean |
isUntitled()
Returns true if this file is 'untitled'. |
boolean |
load(View view,
boolean reload)
Loads the buffer from disk. |
Buffer.TokenList |
markTokens(int lineIndex)
Deprecated. Use the other form of markTokens() instead |
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 |
reload(View view)
Reloads the buffer from disk, asking for confirmation if the buffer has unsaved changes. |
void |
removeAllMarkers()
Removes all defined markers. |
void |
removeBufferChangeListener(BufferChangeListener listener)
Deprecated. Call JEditBuffer.removeBufferListener(BufferListener) . |
void |
removeMarker(int line)
Removes all markers at the specified line. |
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 |
setDirty(boolean d)
Sets the 'dirty' (changed since last save) flag of this buffer. |
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 |
setWaitSocket(java.net.Socket waitSocket)
This socket is closed when the buffer is closed. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String BACKED_UP
public static final java.lang.String CARET
public static final java.lang.String SELECTION
Selection
instances.
public static final java.lang.String SCROLL_VERT
public static final java.lang.String SCROLL_HORIZ
public static final java.lang.String ENCODING_AUTODETECT
public static final java.lang.String TRAILING_EOL
public static final java.lang.String GZIPPED
public static final int FILE_NOT_CHANGED
public static final int FILE_CHANGED
public static final int FILE_DELETED
Method Detail |
---|
public void reload(View view)
view
- The viewpublic boolean load(View view, boolean reload)
view
- The viewreload
- If true, user will not be asked to recover autosave
file, if anypublic boolean insertFile(View view, java.lang.String path)
view
- The viewpublic void autosave()
public boolean saveAs(View view, boolean rename)
view
- The viewrename
- True if the buffer's path should be changed, false
if only a copy should be saved to the specified filenamepublic boolean save(View view, java.lang.String path)
view
- The viewpath
- The path name to save the buffer to, or null to use
the existing pathpublic boolean save(View view, java.lang.String path, boolean rename)
view
- The viewpath
- The path name to save the buffer to, or null to use
the existing pathrename
- True if the buffer's path should be changed, false
if only a copy should be saved to the specified filenamepublic int checkFileStatus(View view)
NOT_CHANGED
, CHANGED
, or
DELETED
.public long getLastModified()
public void setLastModified(long modTime)
modTime
- The new modification timepublic VFS getVFS()
public java.io.File getAutosaveFile()
public java.lang.String getName()
public java.lang.String getPath()
public java.lang.String getSymlinkPath()
public java.lang.String getDirectory()
public boolean isClosed()
jEdit.closeBuffer(View,Buffer)
.
This method is thread-safe.
public boolean isLoaded()
public boolean isNewFile()
public void setNewFile(boolean newFile)
newFile
- The new file flagpublic boolean isUntitled()
public void setDirty(boolean d)
setDirty
in class JEditBuffer
public boolean isTemporary()
jEdit.openTemporary(View,String,String,boolean)
,
jEdit.commitTemporary(Buffer)
public javax.swing.Icon getIcon()
public void addBufferChangeListener(BufferChangeListener listener, int priority)
JEditBuffer.addBufferListener(BufferListener,int)
.
public void addBufferChangeListener(BufferChangeListener listener)
JEditBuffer.addBufferListener(BufferListener)
.
public void removeBufferChangeListener(BufferChangeListener listener)
JEditBuffer.removeBufferListener(BufferListener)
.
public void propertiesChanged()
syntax
or folding
buffer-local properties are changed.
public java.lang.Object getDefaultProperty(java.lang.String name)
getDefaultProperty
in class JEditBuffer
public void toggleWordWrap(View view)
view
- We show a message in the view's status barpublic void toggleLineSeparator(View view)
view
- We show a message in the view's status barpublic java.lang.String getContextSensitiveProperty(int offset, java.lang.String name)
getContextSensitiveProperty
in class JEditBuffer
offset
- The offsetname
- The property namepublic Mode getMode()
public void setMode(java.lang.String mode)
mode
- The mode namepublic void setMode(Mode mode)
mode
- The modepublic void setMode()
public void putProperty(java.lang.Object name, java.lang.Object value)
setProperty()
instead.
public void putBooleanProperty(java.lang.String name, boolean value)
setBooleanProperty()
instead
public Buffer.TokenList markTokens(int lineIndex)
markTokens()
instead
public void insertString(int offset, java.lang.String str, javax.swing.text.AttributeSet attr)
insert()
instead.
public java.io.File getFile()
getPath()
instead.
public java.util.Vector getMarkers()
public java.lang.String getMarkerStatusPrompt(java.lang.String action)
actions.xml
.
public java.lang.String getMarkerNameString()
public void addOrRemoveMarker(char shortcut, int pos)
pos
- The position of the markershortcut
- The shortcut ('\0' if none)public void addMarker(char shortcut, int pos)
pos
- The position of the markershortcut
- The shortcut ('\0' if none)public Marker getMarkerInRange(int start, int end)
start
- The start offsetend
- The end offsetpublic Marker getMarkerAtLine(int line)
null
if there is none.
line
- The line numberpublic void removeMarker(int line)
line
- The line numberpublic void removeAllMarkers()
public Marker getMarker(char shortcut)
shortcut
- The shortcutpublic void setWaitSocket(java.net.Socket waitSocket)
public Buffer getNext()
public Buffer getPrev()
public int getIndex()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |