Package 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.ObjectAJEditBufferrepresents 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 Description protected static classJEditBuffer.PropValue
-
Field Summary
Fields Modifier and Type Field Description java.lang.ObjectcolumnBlockLockprotected booleancontextInsensitiveIf true the syntax highlight is context insensitive.booleanelasticTabstopsOnThis field should be read instead of "elasticTabstops" property when efficiency matters.static java.lang.StringENCODINGCharacter encoding used when loading and saving.static intHIGH_PRIORITYstatic java.lang.StringLINESEPLine separator property.protected ModemodeThe edit mode of the buffer.static intNORMAL_PRIORITYprotected TokenMarkertokenMarkerprotected UndoManagerundoMgr
-
Constructor Summary
Constructors Constructor Description JEditBuffer()Create a new JEditBuffer.JEditBuffer(java.util.Map props)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBufferListener(BufferListener listener)Adds a buffer change listener.voidaddBufferListener(BufferListener listener, int priority)Adds a buffer change listener.voidbeginCompoundEdit()Starts a compound edit.booleancanRedo()booleancanUndo()javax.swing.text.PositioncreatePosition(int offset)Creates a floating position (javax.swing.text.Position).voidendCompoundEdit()Ends a compound edit.protected voidfireBeginRedo()protected voidfireBeginUndo()protected voidfireBufferLoaded()protected voidfireContentInserted(int startLine, int offset, int numLines, int length)protected voidfireContentRemoved(int startLine, int offset, int numLines, int length)protected voidfireEndRedo()protected voidfireEndUndo()protected voidfireFoldHandlerChanged()protected voidfireFoldLevelChanged(int start, int end)protected voidfirePreContentInserted(int startLine, int offset, int numLines, int length)protected voidfirePreContentRemoved(int startLine, int offset, int numLines, int length)protected voidfireTransactionComplete()booleangetBooleanProperty(java.lang.String name)booleangetBooleanProperty(java.lang.String name, boolean def)BufferListener[]getBufferListeners()ColumnBlockgetColumnBlock()java.lang.StringgetContextSensitiveProperty(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).intgetCurrentIndentForLine(int lineIndex, int[] whitespaceChars)java.lang.ObjectgetDefaultProperty(java.lang.String key)int[]getFoldAtLine(int line)FoldHandlergetFoldHandler()intgetFoldLevel(int line)intgetIdealIndentForLine(int lineIndex)intgetIndentSize()intgetIntegerProperty(java.lang.String name, int defaultValue)KeywordMapgetKeywordMapAtOffset(int offset)intgetLength()TokenMarker.LineContextgetLineContext(int line)Returns the line context of the token marker for the specified line.intgetLineCount()intgetLineEndOffset(int line)Returns the end offset of the specified line.intgetLineLength(int line)intgetLineOfOffset(int offset)Returns the line containing the specified offset.java.lang.CharSequencegetLineSegment(int line)Returns the text on the specified line.intgetLineStartOffset(int line)Returns the start offset of the specified line.java.lang.StringgetLineText(int line)Returns the text on the specified line.voidgetLineText(int line, int relativeStartOffset, javax.swing.text.Segment segment)Returns the specified line from the starting point passed in relativeStartOffset in aSegment.voidgetLineText(int line, javax.swing.text.Segment segment)Returns the specified line in aSegment.ModegetMode()intgetOffsetOfVirtualColumn(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.PatterngetPatternProperty(java.lang.String name, int flags)intgetPriorNonEmptyLine(int lineIndex)Auto indent needs this.java.lang.ObjectgetProperty(java.lang.Object name)ParserRuleSetgetRuleSetAtOffset(int offset)java.lang.CharSequencegetSegment(int start, int length)Returns the specified text range.java.lang.StringgetStringProperty(java.lang.String name)intgetTabSize()intgetTabStopPosition(javax.swing.text.Segment seg)java.lang.StringgetText()java.lang.StringgetText(int start, int length)voidgetText(int start, int length, javax.swing.text.Segment seg)Returns the specified text range in aSegment.TokenMarkergetTokenMarker()java.lang.ObjectgetUndoId()intgetVirtualWidth(int line, int column)booleanhasProperty(java.lang.Object name)booleanindentLine(int lineIndex, boolean canDecreaseIndent)Indents the specified line.voidindentLines(int[] lines)Indents all specified lines.voidindentLines(int start, int end)Indents all specified lines.voidindentUsingElasticTabstops()voidinsert(int offset, java.lang.CharSequence seq)Inserts a string into the buffer.voidinsert(int offset, java.lang.String str)Inserts a string into the buffer.voidinsert(int offset, javax.swing.text.Segment seg)Inserts a string into the buffer.voidinsertAtColumn(int line, int col, java.lang.String str)Like theinsert(int,String)method, but inserts the string at the specified virtual column.intinsertIndented(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.booleaninsideCompoundEdit()voidinvalidateCachedFoldLevels()Invalidates all cached fold level information.protected voidinvalidateFoldLevels()booleanisContextInsensitive()Returns true if the buffer highlight is not sensitive to the context.booleanisDirty()booleanisEditable()booleanisElectricKey(char ch, int line)Should inserting this character trigger a re-indent of the current line?protected booleanisFileReadOnly()booleanisFoldEnd(int line)booleanisFoldStart(int line)booleanisLoading()booleanisPerformingIO()booleanisReadOnly()booleanisTransactionInProgress()booleanisUndoInProgress()protected voidloadText(javax.swing.text.Segment seg, IntegerArray endOffsets)voidmarkTokens(int lineIndex, TokenHandler tokenHandler)Returns the syntax tokens for the specified line.protected TokenMarker.LineContextmarkTokens(javax.swing.text.Segment seg, TokenMarker.LineContext prevContext, TokenHandler _tokenHandler)protected voidparseBufferLocalProperties()voidpropertiesChanged()Reloads settings from the properties.voidreadLock()The buffer is guaranteed not to change between calls toreadLock()andreadUnlock().voidreadUnlock()The buffer is guaranteed not to change between calls toreadLock()andreadUnlock().voidredo(TextArea textArea)Redoes the most recently undone edit.voidremove(int offset, int length)Removes the specified rang efrom the buffer.voidremoveBufferListener(BufferListener listener)Removes a buffer change listener.voidremoveTrailingWhiteSpace(int[] lines)Removes trailing whitespace from all lines in the specified list.voidresetCachedProperties()voidsetBooleanProperty(java.lang.String name, boolean value)Sets a boolean property.voidsetContextInsensitive(boolean contextInsensitive)Set the buffer to be insensitive to the context during highlight.voidsetDefaultProperty(java.lang.String name, java.lang.Object value)voidsetDirty(boolean d)voidsetEditable(boolean editable)protected voidsetFileReadOnly(boolean readOnly)voidsetFoldHandler(FoldHandler foldHandler)Sets the buffer's fold handler.voidsetIntegerProperty(java.lang.String name, int value)Sets an integer property.voidsetLoading(boolean loading)voidsetMode(java.lang.String mode)Sets this buffer's edit mode.voidsetMode(Mode mode)Sets this buffer's edit mode.voidsetMode(Mode mode, boolean forceContextInsensitive)Sets this buffer's edit mode.voidsetPerformingIO(boolean io)voidsetProperty(java.lang.String name, java.lang.Object value)Sets the value of a buffer-local property.voidsetReadOnly(boolean readOnly)Sets the read only flag.voidsetStringProperty(java.lang.String name, java.lang.String value)Sets a string property.voidsetTokenMarker(TokenMarker tokenMarker)voidsetUndoLimit(int limit)Set the undo limit of the Undo Manager.voidshiftIndentLeft(int[] lines)Shifts the indent of each line in the specified list to the left.voidshiftIndentRight(int[] lines)Shifts the indent of each line in the specified list to the right.voidsimpleIndentLine(int lineIndex)Simply indents the given line to the same level as the previous nonempty linevoidundo(TextArea textArea)Undoes the most recent edit.voidunsetProperty(java.lang.String name)Clears the value of a buffer-local property.voidupdateColumnBlocks(int startLine, int endLine, int startColumn, Node parent)voidwriteLock()Attempting to obtain read lock will block between calls towriteLock()andwriteUnlock().voidwriteUnlock()Attempting to obtain read lock will block between calls towriteLock()andwriteUnlock().
-
-
-
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
-
-
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)
- Parameters:
io- 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
-
setEditable
public void setEditable(boolean editable)
- Parameters:
editable-trueto set the buffer editable,falseotherwise. Default istrue. This does not change the read only flag on the file, just makes the buffer editable or not.
-
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)
- Parameters:
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 toreadLock()andreadUnlock(). Calls to this method may be nested.
-
readUnlock
public void readUnlock()
The buffer is guaranteed not to change between calls toreadLock()andreadUnlock().
-
writeLock
public void writeLock()
Attempting to obtain read lock will block between calls towriteLock()andwriteUnlock(). Calls to this method may be nested.
-
writeUnlock
public void writeUnlock()
Attempting to obtain read lock will block between calls towriteLock()andwriteUnlock().
-
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- Returns:
- the line of 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 returnxbutx+1. - Since:
- jEdit 4.0pre1
-
getLineLength
public int getLineLength(int line)
- Parameters:
line- The line- Returns:
- the length of the specified line. This method is thread-safe.
- Since:
- jEdit 4.0pre1
-
getPriorNonEmptyLine
public int getPriorNonEmptyLine(int lineIndex)
Auto indent needs this.- Parameters:
lineIndex- the line- Returns:
- the previous non-empty line
-
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 aSegment.Using a
Segmentis generally more efficient than using aStringbecause it results in less memory allocation and array copying.This method is thread-safe.
- Parameters:
line- The linesegment- the segment- 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 aSegment.Using a
Segmentis generally more efficient than using aStringbecause it results in less memory allocation and array copying.This method is thread-safe.
- Parameters:
line- The linesegment- the segmentrelativeStartOffset- the relative start offset- 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)- Parameters:
start- The start offsetlength- The number of characters to get- Returns:
- the specified text range. This method is thread-safe.
-
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 aSegment.Using a
Segmentis generally more efficient than using aStringbecause it results in less memory allocation and array copying.This method is thread-safe.
- Parameters:
start- The start offsetlength- The number of characters to getseg- 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 offsetlength- 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 offsetstr- 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 offsetseg- 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 offsetseq- 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 offsetlength- 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 indentend- 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 indentcanDecreaseIndent- 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)- Parameters:
lineIndex- The line numberwhitespaceChars- If this is non-null, the number of whitespace characters is stored at the 0 index- Returns:
- the line's current leading indent.
- Since:
- jEdit 4.2pre2
-
getIdealIndentForLine
public int getIdealIndentForLine(int lineIndex)
- Parameters:
lineIndex- The line number- Returns:
- the ideal leading indent for the specified line. This will apply the various auto-indent rules.
-
getVirtualWidth
public int getVirtualWidth(int line, int column)- Parameters:
line- The line numbercolumn- The column number- Returns:
- the virtual column number (taking tabs into account) of the specified position.
- 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 numbercolumn- The virtual column numbertotalVirtualWidth- 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 theinsert(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 numbercol- The virtual column numberstr- 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 offsettext- 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?- Parameters:
ch- a characterline- the line- Returns:
- true if is electric key
- Since:
- jEdit 4.3pre9
-
getLineContext
public TokenMarker.LineContext getLineContext(int line)
Returns the line context of the token marker for the specified line.
-
markTokens
public void markTokens(int lineIndex, TokenHandler tokenHandler)Returns the syntax tokens for the specified line.- Parameters:
lineIndex- The line numbertokenHandler- 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- Returns:
- the position
-
propertiesChanged
public void propertiesChanged()
Reloads settings from the properties. This should be called after thesyntaxorfoldingbuffer-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)
- Parameters:
name- The property name. For backwards compatibility, this is anObject, not aString.- Returns:
- the value of a buffer-local property.
Using this method is generally discouraged, because it returns an
Objectwhich 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:
This method is thread-safe.
-
hasProperty
public boolean hasProperty(java.lang.Object name)
- Parameters:
name- The property name. For backwards compatibility, this is anObject, not aString.- Returns:
- true if the buffer local property exists. This method is thread-safe.
- Since:
- jEdit 5.6pre1
-
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 namevalue- 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)
- Parameters:
name- The property name- Returns:
- the value of a string property. This method is thread-safe.
- Since:
- jEdit 4.0pre1
-
setStringProperty
public void setStringProperty(java.lang.String name, java.lang.String value)Sets a string property.- Parameters:
name- The property namevalue- The value- Since:
- jEdit 4.0pre1
-
getBooleanProperty
public boolean getBooleanProperty(java.lang.String name)
- Parameters:
name- The property name- Returns:
- the value of a boolean property. This method is thread-safe.
- Since:
- jEdit 4.0pre1
-
getBooleanProperty
public boolean getBooleanProperty(java.lang.String name, boolean def)- Parameters:
name- The property namedef- The default value- Returns:
- the value of a boolean property. This method is thread-safe.
- Since:
- jEdit 4.3pre17
-
setBooleanProperty
public void setBooleanProperty(java.lang.String name, boolean value)Sets a boolean property.- Parameters:
name- The property namevalue- The value- Since:
- jEdit 4.0pre1
-
getIntegerProperty
public int getIntegerProperty(java.lang.String name, int defaultValue)- Parameters:
name- The property namedefaultValue- the default value to use- Returns:
- the value of an integer property. This method is thread-safe.
- Since:
- jEdit 4.0pre1
-
setIntegerProperty
public void setIntegerProperty(java.lang.String name, int value)Sets an integer property.- Parameters:
name- The property namevalue- The value- Since:
- jEdit 4.0pre1
-
getPatternProperty
public java.util.regex.Pattern getPatternProperty(java.lang.String name, int flags)- Parameters:
name- The property nameflags- Regular expression compilation flags- Returns:
- the value of a property as a regular expression. This method is thread-safe.
- Since:
- jEdit 4.3pre5
-
getRuleSetAtOffset
public ParserRuleSet getRuleSetAtOffset(int offset)
- Parameters:
offset- the offset- Returns:
- the syntax highlighting ruleset at the specified offset.
- Since:
- jEdit 4.1pre1
-
getKeywordMapAtOffset
public KeywordMap getKeywordMapAtOffset(int offset)
- Parameters:
offset- The offset- Returns:
- the syntax highlighting keyword map in effect at the specified offset. Used by the Complete Word command to complete keywords.
- 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 offsetname- The property name- Returns:
- the property value
- 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(@Nonnull 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(@Nonnull 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 modeforceContextInsensitive- 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)
- Parameters:
line- the line- Returns:
- if the specified line begins a fold.
- Since:
- jEdit 3.1pre1
-
isFoldEnd
public boolean isFoldEnd(int line)
- Parameters:
line- the 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)
- Parameters:
line- A physical line index- Returns:
- the fold level of the specified line.
- Since:
- jEdit 3.1pre1
-
getFoldAtLine
public int[] getFoldAtLine(int line)
- Parameters:
line- The line number- 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.
- 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.- Parameters:
foldHandler- the fold handler- Since:
- jEdit 4.2pre2
-
undo
public void undo(TextArea textArea)
Undoes the most recent edit.- Parameters:
textArea- the text area- Since:
- jEdit 4.0pre1
-
redo
public void redo(TextArea textArea)
Redoes the most recently undone edit.- Parameters:
textArea- the textArea- 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 untilendCompoundEdit()are called will be merged into one. This can be used to make a complex operation undoable in one step. Nested calls tobeginCompoundEdit()behave as expected, requiring the same number ofendCompoundEdit()calls to end the edit.- See Also:
endCompoundEdit()
-
endCompoundEdit
public void endCompoundEdit()
Ends a compound edit. All edits performed sincebeginCompoundEdit()was called can now be undone in one step by callingundo(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 listenerpriority- 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()
-
-