|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JTextArea
org.fife.ui.rtextarea.RTextArea
org.fife.ui.rsyntaxtextarea.RSyntaxTextArea
public class RSyntaxTextArea
An extension of RTextArea
that adds syntax highlighting
of certain programming languages to its list of features. Languages
currently supported include:
RTextScrollPane
instead of a regular
JScrollPane
as this class allows you to add line numbers and
bookmarks easily to your text area.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.fife.ui.rtextarea.RTextArea |
---|
RTextArea.RTextAreaMutableCaretEvent |
Nested classes/interfaces inherited from class javax.swing.JTextArea |
---|
JTextArea.AccessibleJTextArea |
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent |
---|
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBinding |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static String |
ANIMATE_BRACKET_MATCHING_PROPERTY
|
static String |
ANTIALIAS_PROPERTY
|
static String |
AUTO_INDENT_PROPERTY
|
static String |
BACKGROUND_IMAGE_PROPERTY
|
static String |
BRACKET_MATCHING_PROPERTY
|
static String |
CLEAR_WHITESPACE_LINES_PROPERTY
|
static String |
CLOSE_CURLY_BRACES_PROPERTY
|
static String |
CLOSE_MARKUP_TAGS_PROPERTY
|
static String |
CURRENT_LINE_HIGHLIGHT_COLOR_PROPERTY
|
static String |
CURRENT_LINE_HIGHLIGHT_FADE_PROPERTY
|
static String |
EOL_VISIBLE_PROPERTY
|
static String |
FOCUSABLE_TIPS_PROPERTY
|
static String |
FRACTIONAL_FONTMETRICS_PROPERTY
|
static String |
HIGHLIGHT_CURRENT_LINE_PROPERTY
|
static String |
HYPERLINKS_ENABLED_PROPERTY
|
static String |
MARK_OCCURRENCES_PROPERTY
|
static String |
MARKED_OCCURRENCES_CHANGED_PROPERTY
|
static String |
PARSER_NOTICES_PROPERTY
|
static String |
ROUNDED_SELECTION_PROPERTY
|
static String |
SYNTAX_SCHEME_PROPERTY
|
static String |
SYNTAX_STYLE_PROPERTY
|
static String |
VISIBLE_WHITESPACE_PROPERTY
|
Fields inherited from class org.fife.ui.rtextarea.RTextArea |
---|
COPY_ACTION, CUT_ACTION, DELETE_ACTION, INSERT_MODE, MARK_ALL_COLOR_PROPERTY, OVERWRITE_MODE, PASTE_ACTION, REDO_ACTION, SELECT_ALL_ACTION, UNDO_ACTION |
Fields inherited from class javax.swing.text.JTextComponent |
---|
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.print.Printable |
---|
NO_SUCH_PAGE, PAGE_EXISTS |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
RSyntaxTextArea()
Constructor. |
|
RSyntaxTextArea(int textMode)
Creates a new RSyntaxTextArea . |
|
RSyntaxTextArea(int rows,
int cols)
Constructor. |
|
RSyntaxTextArea(RSyntaxDocument doc)
Constructor. |
|
RSyntaxTextArea(RSyntaxDocument doc,
String text,
int rows,
int cols)
Constructor. |
|
RSyntaxTextArea(String text)
Constructor. |
|
RSyntaxTextArea(String text,
int rows,
int cols)
Constructor. |
Method Summary | |
---|---|
void |
addActiveLineRangeListener(ActiveLineRangeListener l)
Adds an "active line range" listener to this text area. |
protected void |
addCurrentLineHighlightListeners()
Adds listeners that listen for changes to the current line, so we can update our "current line highlight." |
void |
addHyperlinkListener(HyperlinkListener l)
Adds a hyperlink listener to this text area. |
void |
addNotify()
Updates the font metrics the first time we're displayed. |
void |
addParser(Parser parser)
Adds the parser to "validate" the source code in this text area. |
void |
clearParsers()
Removes all parsers from this text area. |
void |
convertSpacesToTabs()
Converts all instances of a number of spaces equal to a tab size into a tab in this text area. |
void |
convertTabsToSpaces()
Converts all instances of a tab into a number of spaces equivalent to a tab in this text area. |
void |
copyAsRtf()
Copies the currently selected text to the system clipboard, with any necessary style information (font, foreground color and background color). |
protected Document |
createDefaultModel()
Returns the document to use for an RSyntaxTextArea |
protected org.fife.ui.rtextarea.RTextAreaBase.RTAMouseListener |
createMouseListener()
Returns the caret event/mouse listener for RTextArea s. |
protected RTextAreaUI |
createRTextAreaUI()
Returns the a real UI to install on this text area. |
protected void |
doBracketMatching()
If the caret is on a bracket, this method finds the matching bracket, and if it exists, highlights it. |
protected void |
fireCaretUpdate(CaretEvent e)
Notifies all listeners that a caret change has occurred. |
protected void |
forceCurrentLineHighlightRepaint()
Forces the current line highlight to be repainted. |
void |
forceReparsing(int parser)
Forces the given Parser to re-parse the content of this text
area. |
boolean |
forceReparsing(Parser parser)
Forces re-parsing with a specific parser. |
boolean |
getAnimateBracketMatching()
Returns whether bracket matching should be animated. |
Color |
getBackground()
Returns the java.awt.Color used as the background color for
this text area. |
Color |
getBackgroundForTokenType(int type)
Returns the background color for tokens of the specified type. |
Image |
getBackgroundImage()
Returns the image currently used for the background. |
Object |
getBackgroundObject()
Returns the Object representing the background for all
documents in this tabbed pane; either a java.awt.Color or a
java.lang.Image containing the image used as the background
for this text area. |
int |
getCaretLineNumber()
Gets the line number that the caret is on. |
int |
getCaretOffsetFromLineStart()
Gets the position from the beginning of the current line that the caret is on. |
boolean |
getCloseCurlyBraces()
Returns whether curly braces should be automatically closed when a newline is entered after an opening curly brace. |
boolean |
getCloseMarkupTags()
Returns whether closing markup tags should be automatically completed when " </ " is typed. |
static CodeTemplateManager |
getCodeTemplateManager()
Returns the code template manager for all instances of RSyntaxTextArea . |
Color |
getCurrentLineHighlightColor()
Returns the color being used to highlight the current line. |
static Color |
getDefaultBracketMatchBGColor()
Returns the default bracket-match background color. |
static Color |
getDefaultBracketMatchBorderColor()
Returns the default bracket-match border color. |
static Color |
getDefaultCaretColor()
Returns the default caret color. |
static Color |
getDefaultCurrentLineHighlightColor()
Returns the "default" color for highlighting the current line. |
static Font |
getDefaultFont()
Returns the default font for text areas. |
static Color |
getDefaultForeground()
Returns the default foreground color for text in this text area. |
static Color |
getDefaultMarginLineColor()
Returns the default color for the margin line. |
static int |
getDefaultMarginLinePosition()
Returns the default margin line position. |
static Color |
getDefaultSelectionColor()
Returns the default selection color for this text area. |
SyntaxScheme |
getDefaultSyntaxScheme()
Returns the "default" syntax highlighting color scheme. |
static int |
getDefaultTabSize()
Returns the default tab size, in spaces. |
boolean |
getEOLMarkersVisible()
Returns whether an EOL marker should be drawn at the end of each line. |
boolean |
getFadeCurrentLineHighlight()
Returns whether the current line highlight is faded. |
Font |
getFontForTokenType(int type)
Returns the font for tokens of the specified type. |
FontMetrics |
getFontMetricsForTokenType(int type)
Returns the font metrics for tokens of the specified type. |
Color |
getForegroundForToken(Token t)
Returns the foreground color to use when painting a token. |
Color |
getForegroundForTokenType(int type)
Returns the foreground color to use when painting a token. |
boolean |
getFractionalFontMetricsEnabled()
Returns whether fractional font metrics are enabled for this text area. |
boolean |
getHighlightCurrentLine()
Returns whether or not the current line is highlighted. |
Color |
getHyperlinkForeground()
Returns the color to use when painting hyperlinks. |
boolean |
getHyperlinksEnabled()
Returns whether hyperlinks are enabled for this text area. |
int |
getLineEndOffsetOfCurrentLine()
Returns the offset of the last character of the line that the caret is on. |
int |
getLineHeight()
Returns the height to use for a line of text in this text area. |
int |
getLineStartOffsetOfCurrentLine()
Returns the offset of the first character of the line that the caret is on. |
Color |
getMarginLineColor()
Returns the color used to paint the margin line. |
int |
getMarginLinePixelLocation()
Returns the margin line position (in pixels) from the left-hand side of the text area. |
int |
getMarginLinePosition()
Returns the margin line position (which is the number of 'm' widths in the current font the margin line is over). |
List |
getMarkedOccurrences()
Returns a list of "marked occurrences" in the text area. |
boolean |
getMarkOccurrences()
Returns whether "Mark Occurrences" is enabled. |
Color |
getMarkOccurrencesColor()
Returns the color used to "mark occurrences." |
Color |
getMatchedBracketBGColor()
Gets the color used as the background for a matched bracket. |
Color |
getMatchedBracketBorderColor()
Gets the color used as the border for a matched bracket. |
Rectangle |
getMatchRectangle()
Returns the matched bracket's rectangle, or null if there
is currently no matched bracket. |
int |
getMaxAscent()
Returns the maximum ascent of all fonts used in this text area. |
Parser |
getParser(int index)
Returns the specified parser. |
int |
getParserCount()
Returns the number of parsers operating on this text area. |
List |
getParserNotices()
Returns a list of the current parser notices for this text area. |
boolean |
getRoundedSelectionEdges()
Returns whether selection edges are rounded in this text area. |
boolean |
getShouldIndentNextLine(int line)
If auto-indent is enabled, this method returns whether a new line after this one should be indented (based on the standard indentation rules for the current programming language). |
String |
getSyntaxEditingStyle()
Returns what type of syntax highlighting this editor is doing. |
SyntaxScheme |
getSyntaxScheme()
Returns all of the colors currently being used in syntax highlighting by this text component. |
boolean |
getTabsEmulated()
Returns whether or not tabs are emulated with spaces (i.e., "soft" tabs). |
static boolean |
getTemplatesEnabled()
Returns whether or not templates are enabled for all instances of RSyntaxTextArea . |
String |
getTextAntiAliasHint()
Returns the rendering hint used when antialiasing text in this editor. |
Token |
getTokenListForLine(int line)
Returns a list of tokens representing the given line. |
String |
getToolTipText(MouseEvent e)
Returns the tool tip to display for a mouse event at the given location. |
boolean |
getUnderlineForToken(Token t)
Returns whether the specified token should be underlined. |
boolean |
getUseFocusableTips()
Returns whether "focusable" tool tips are used instead of standard ones. |
protected void |
init()
Called by constructors to initialize common properties of the text editor. |
boolean |
isAutoIndentEnabled()
Returns whether or not auto-indent is enabled. |
boolean |
isBracketMatchingEnabled()
Returns whether or not bracket matching is enabled. |
boolean |
isClearWhitespaceLinesEnabled()
Returns whether or not lines containing nothing but whitespace are made into blank lines when Enter is pressed in them. |
boolean |
isMarginLineEnabled()
Returns whether or not the margin line is being painted. |
static boolean |
isOSX()
Returns whether the OS we're running on is OS X. |
boolean |
isWhitespaceVisible()
Returns whether whitespace (spaces and tabs) is visible. |
protected void |
paintComponent(Graphics g)
The paintComponent method is overridden so we
apply any necessary rendering hints to the Graphics object. |
protected void |
possiblyUpdateCurrentLineHighlightLocation()
Updates the current line highlight location. |
protected void |
processComponentEvent(ComponentEvent e)
Overridden so we can tell when the text area is resized and update the current-line highlight, if necessary (i.e., if it is enabled and if lineWrap is enabled. |
void |
removeActiveLineRangeListener(ActiveLineRangeListener l)
Removes an "active line range" listener from this text area. |
void |
removeHyperlinkListener(HyperlinkListener l)
Removes a hyperlink listener from this text area. |
void |
removeNotify()
Overridden so we stop this text area's parsers, if any. |
boolean |
removeParser(Parser parser)
Removes a parser from this text area. |
void |
restoreDefaultSyntaxScheme()
Sets the colors used for syntax highlighting to their defaults. |
static boolean |
saveTemplates()
Attempts to save all currently-known templates to the current template directory, as set by setTemplateDirectory . |
void |
setActiveLineRange(int min,
int max)
Sets the "active line range." |
void |
setAnimateBracketMatching(boolean animate)
Sets whether bracket matching should be animated. |
void |
setAutoIndentEnabled(boolean enabled)
Sets whether or not auto-indent is enabled. |
void |
setBackground(Color bg)
Sets the background color of this text editor. |
void |
setBackgroundImage(Image image)
Sets this image as the background image. |
void |
setBackgroundObject(Object newBackground)
Makes the background into this Object . |
void |
setBracketMatchingEnabled(boolean enabled)
Sets whether bracket matching is enabled. |
void |
setClearWhitespaceLinesEnabled(boolean enabled)
Sets whether or not lines containing nothing but whitespace are made into blank lines when Enter is pressed in them. |
void |
setCloseCurlyBraces(boolean close)
Toggles whether curly braces should be automatically closed when a newline is entered after an opening curly brace. |
void |
setCloseMarkupTags(boolean close)
Sets whether closing markup tags should be automatically completed when " </ " is typed. |
void |
setCurrentLineHighlightColor(Color color)
Sets the color to use to highlight the current line. |
void |
setDocument(Document document)
Sets the document used by this text area. |
void |
setEOLMarkersVisible(boolean visible)
Sets whether EOL markers are visible at the end of each line. |
void |
setFadeCurrentLineHighlight(boolean fade)
Sets whether the current line highlight should have a "fade" effect. |
void |
setFont(Font font)
Sets the font used by this text area. |
void |
setFractionalFontMetricsEnabled(boolean enabled)
Sets whether fractional font metrics are enabled. |
void |
setHighlightCurrentLine(boolean highlight)
Sets whether or not the current line is highlighted. |
void |
setHighlighter(Highlighter h)
Sets the highlighter used by this text area. |
void |
setHyperlinkForeground(Color fg)
Sets the color to use when painting hyperlinks. |
void |
setHyperlinksEnabled(boolean enabled)
Sets whether hyperlinks are enabled for this text area. |
void |
setLineWrap(boolean wrap)
Sets whether or not word wrap is enabled. |
void |
setLinkScanningMask(int mask)
Sets the mask for the key used to toggle whether we are scanning for hyperlinks with mouse hovering. |
void |
setMarginLineColor(Color color)
Sets the color used to paint the margin line. |
void |
setMarginLineEnabled(boolean enabled)
Enables or disables the margin line. |
void |
setMarginLinePosition(int size)
Sets the number of 'm' widths the margin line is over. |
void |
setMarkOccurrences(boolean markOccurrences)
Toggles whether "mark occurrences" is enabled. |
void |
setMarkOccurrencesColor(Color color)
Sets the "mark occurrences" color. |
void |
setMatchedBracketBGColor(Color color)
Sets the color used as the background for a matched bracket. |
void |
setMatchedBracketBorderColor(Color color)
Sets the color used as the border for a matched bracket. |
protected void |
setRTextAreaUI(RTextAreaUI ui)
Sets the UI for this RTextArea . |
void |
setSyntaxEditingStyle(String styleKey)
Sets what type of syntax highlighting this editor is doing. |
void |
setSyntaxScheme(SyntaxScheme scheme)
Sets all of the colors used in syntax highlighting to the colors specified. |
void |
setTabsEmulated(boolean areEmulated)
Changes whether or not tabs should be emulated with spaces (i.e., soft tabs). |
void |
setTabSize(int size)
Workaround, since in JDK1.4 it appears that setTabSize()
doesn't work for a JTextArea unless you use the constructor
specifying the number of rows and columns... |
static boolean |
setTemplateDirectory(String dir)
If templates are enabled, all currently-known templates are forgotten and all templates are loaded from all files in the specified directory ending in "*.xml". |
static void |
setTemplatesEnabled(boolean enabled)
Enables or disables templates. |
void |
setTextAntiAliasHint(String aaHintFieldName)
Sets the rendering hint to use when anti-aliasing text in this editor. |
void |
setUseFocusableTips(boolean use)
Sets whether "focusable" tool tips are used instead of standard ones. |
void |
setWhitespaceVisible(boolean visible)
Sets whether whitespace is visible. |
protected void |
updateMarginLineX()
This is here so subclasses such as RSyntaxTextArea that
have multiple fonts can define exactly what it means, for example, for
the margin line to be "80 characters" over. |
int |
yForLineContaining(int offs)
Returns the y-coordinate of the line containing an offset. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String ANIMATE_BRACKET_MATCHING_PROPERTY
public static final String ANTIALIAS_PROPERTY
public static final String AUTO_INDENT_PROPERTY
public static final String BRACKET_MATCHING_PROPERTY
public static final String CLEAR_WHITESPACE_LINES_PROPERTY
public static final String CLOSE_CURLY_BRACES_PROPERTY
public static final String CLOSE_MARKUP_TAGS_PROPERTY
public static final String EOL_VISIBLE_PROPERTY
public static final String FOCUSABLE_TIPS_PROPERTY
public static final String FRACTIONAL_FONTMETRICS_PROPERTY
public static final String HYPERLINKS_ENABLED_PROPERTY
public static final String MARK_OCCURRENCES_PROPERTY
public static final String MARKED_OCCURRENCES_CHANGED_PROPERTY
public static final String PARSER_NOTICES_PROPERTY
public static final String SYNTAX_SCHEME_PROPERTY
public static final String SYNTAX_STYLE_PROPERTY
public static final String VISIBLE_WHITESPACE_PROPERTY
public static final String BACKGROUND_IMAGE_PROPERTY
public static final String CURRENT_LINE_HIGHLIGHT_COLOR_PROPERTY
public static final String CURRENT_LINE_HIGHLIGHT_FADE_PROPERTY
public static final String HIGHLIGHT_CURRENT_LINE_PROPERTY
public static final String ROUNDED_SELECTION_PROPERTY
Constructor Detail |
---|
public RSyntaxTextArea()
public RSyntaxTextArea(RSyntaxDocument doc)
doc
- The document for the editor.public RSyntaxTextArea(String text)
text
- The initial text to display.public RSyntaxTextArea(int rows, int cols)
rows
- The number of rows to display.cols
- The number of columns to display.
IllegalArgumentException
- If either rows
or
cols
is negative.public RSyntaxTextArea(String text, int rows, int cols)
text
- The initial text to display.rows
- The number of rows to display.cols
- The number of columns to display.
IllegalArgumentException
- If either rows
or
cols
is negative.public RSyntaxTextArea(RSyntaxDocument doc, String text, int rows, int cols)
doc
- The document for the editor.text
- The initial text to display.rows
- The number of rows to display.cols
- The number of columns to display.
IllegalArgumentException
- If either rows
or
cols
is negative.public RSyntaxTextArea(int textMode)
RSyntaxTextArea
.
textMode
- Either INSERT_MODE
or
OVERWRITE_MODE
.Method Detail |
---|
public int getMaxAscent()
RTextArea
RTextArea
, this is simply the
ascent of the current font.This value could be useful, for example, to implement a line-numbering scheme.
getMaxAscent
in class RTextArea
public void addActiveLineRangeListener(ActiveLineRangeListener l)
l
- The listener to add.removeActiveLineRangeListener(ActiveLineRangeListener)
public void addHyperlinkListener(HyperlinkListener l)
l
- The listener to add.removeHyperlinkListener(HyperlinkListener)
public void addNotify()
addNotify
in class JComponent
public void addParser(Parser parser)
parser
- The new parser. A value of null
will
do nothing.getParser(int)
,
getParserCount()
,
removeParser(Parser)
public void clearParsers()
removeParser(Parser)
public void copyAsRtf()
null
selections.
protected Document createDefaultModel()
RSyntaxTextArea
createDefaultModel
in class JTextArea
protected org.fife.ui.rtextarea.RTextAreaBase.RTAMouseListener createMouseListener()
RTextArea
s.
createMouseListener
in class RTextArea
protected RTextAreaUI createRTextAreaUI()
createRTextAreaUI
in class RTextArea
protected final void doBracketMatching()
protected void fireCaretUpdate(CaretEvent e)
fireCaretUpdate
in class RTextArea
e
- The caret event.public void forceReparsing(int parser)
Parser
to re-parse the content of this text
area.
This method can be useful when a Parser
can be configured
as to what notices it returns. For example, if a Java language parser
can be configured to set whether no serialVersionUID is a warning,
error, or ignored, this method can be called after changing the expected
notice type to have the document re-parsed.
parser
- The index of the Parser
to re-run.getParser(int)
public boolean forceReparsing(Parser parser)
parser
- The parser that should re-parse this text area's contents.
This should be installed on this text area.
forceReparsing(int)
public boolean getAnimateBracketMatching()
setAnimateBracketMatching(boolean)
public Color getBackgroundForTokenType(int type)
type
- The type of token.
null
then this token type
has no special background color.getForegroundForToken(Token)
public boolean getCloseCurlyBraces()
setCloseCurlyBraces(boolean)
public boolean getCloseMarkupTags()
</
" is typed. Note that this property is only
honored for markup languages, such as HTML, XML and PHP.
setCloseMarkupTags(boolean)
public static CodeTemplateManager getCodeTemplateManager()
RSyntaxTextArea
. The manager is lazily created.
setTemplatesEnabled(boolean)
public static final Color getDefaultBracketMatchBGColor()
getDefaultBracketMatchBorderColor()
public static final Color getDefaultBracketMatchBorderColor()
getDefaultBracketMatchBGColor()
public static Color getDefaultSelectionColor()
RSyntaxTextArea
does not change text color between selected/unselected text for
contrast like regular JTextArea
s do.
public SyntaxScheme getDefaultSyntaxScheme()
restoreDefaultSyntaxScheme()
,
getSyntaxScheme()
,
setSyntaxScheme(SyntaxScheme)
public boolean getEOLMarkersVisible()
setEOLMarkersVisible(boolean)
,
isWhitespaceVisible()
public Font getFontForTokenType(int type)
type
- The type of token.
getFontMetricsForTokenType(int)
public FontMetrics getFontMetricsForTokenType(int type)
type
- The type of token.
getFontForTokenType(int)
public Color getForegroundForToken(Token t)
t
- The token.
null
.getBackgroundForTokenType(int)
public Color getForegroundForTokenType(int type)
type
- The token type.
null
.getForegroundForToken(Token)
public boolean getFractionalFontMetricsEnabled()
setFractionalFontMetricsEnabled(boolean)
,
getTextAntiAliasHint()
public Color getHyperlinkForeground()
setHyperlinkForeground(Color)
,
getHyperlinksEnabled()
public boolean getHyperlinksEnabled()
setHyperlinksEnabled(boolean)
public int getLineHeight()
public List getMarkedOccurrences()
public boolean getMarkOccurrences()
setMarkOccurrences(boolean)
public Color getMarkOccurrencesColor()
setMarkOccurrencesColor(Color)
public Color getMatchedBracketBGColor()
setMatchedBracketBGColor(java.awt.Color)
,
getMatchedBracketBorderColor()
public Color getMatchedBracketBorderColor()
setMatchedBracketBorderColor(java.awt.Color)
,
getMatchedBracketBGColor()
public final Rectangle getMatchRectangle()
null
if there
is currently no matched bracket. Note that this shouldn't ever be
called by the user.
public Parser getParser(int index)
index
- The Parser
to retrieve.
Parser
.getParserCount()
,
addParser(Parser)
public int getParserCount()
addParser(Parser)
public List getParserNotices()
public boolean getShouldIndentNextLine(int line)
for (int i=0; i<10; i++) {the following line should be indented.
line
- The line to check.
false
.isAutoIndentEnabled()
public String getSyntaxEditingStyle()
SyntaxConstants.SYNTAX_STYLE_JAVA
.setSyntaxEditingStyle(String)
,
SyntaxConstants
public SyntaxScheme getSyntaxScheme()
SyntaxScheme
that represents
the colors currently being used for syntax highlighting.setSyntaxScheme(SyntaxScheme)
public static boolean getTemplatesEnabled()
RSyntaxTextArea
.
saveTemplates()
,
setTemplateDirectory(String)
,
setTemplatesEnabled(boolean)
public String getTextAntiAliasHint()
java.awt.RenderingHints
,
or null
if no text antialiasing is being done.setTextAntiAliasHint(String)
,
getFractionalFontMetricsEnabled()
public Token getTokenListForLine(int line)
line
- The line number to get tokens for.
public String getToolTipText(MouseEvent e)
getToolTipText
in class RTextArea
e
- The mouse event.
null
if none.RTextArea.getToolTipSupplier()
,
RTextArea.setToolTipSupplier(ToolTipSupplier)
public boolean getUnderlineForToken(Token t)
t
- The token.
public boolean getUseFocusableTips()
setUseFocusableTips(boolean)
,
FocusableTip
protected void init()
public boolean isAutoIndentEnabled()
setAutoIndentEnabled(boolean)
public final boolean isBracketMatchingEnabled()
true
iff bracket matching is enabled.setBracketMatchingEnabled(boolean)
public boolean isClearWhitespaceLinesEnabled()
setClearWhitespaceLinesEnabled(boolean)
public boolean isWhitespaceVisible()
setWhitespaceVisible(boolean)
,
getEOLMarkersVisible()
protected void paintComponent(Graphics g)
paintComponent
method is overridden so we
apply any necessary rendering hints to the Graphics object.
g
- The graphics context with which to paint.public void removeActiveLineRangeListener(ActiveLineRangeListener l)
l
- The listener to remove.removeActiveLineRangeListener(ActiveLineRangeListener)
public void removeHyperlinkListener(HyperlinkListener l)
l
- The listener to remove.addHyperlinkListener(HyperlinkListener)
public void removeNotify()
removeNotify
in class JTextComponent
public boolean removeParser(Parser parser)
parser
- The Parser
to remove.
clearParsers()
,
addParser(Parser)
,
getParser(int)
public void restoreDefaultSyntaxScheme()
setSyntaxScheme(SyntaxScheme)
,
getSyntaxScheme()
,
getDefaultSyntaxScheme()
public static boolean saveTemplates()
setTemplateDirectory
. Templates
will be saved as XML files with names equal to their abbreviations; for
example, a template that expands on the word "forb" will be saved as
forb.xml
.
setTemplateDirectory
).getTemplatesEnabled()
,
setTemplateDirectory(java.lang.String)
,
setTemplatesEnabled(boolean)
public void setActiveLineRange(int min, int max)
RSyntaxTextArea
itself does nothing with this information,
but if it is contained inside an RTextScrollPane
, the active
line range may be displayed in the icon area of the Gutter
.
Note that basic users of RSyntaxTextArea
will not call this
method directly; rather, it is usually called by instances of
LanguageSupport
in the RSTALangaugeSupport
library. See http://fifesoft.com
for more information about this library.
min
- The "minimum" line in the active line range, or
-1
if the range is being cleared.max
- The "maximum" line in the active line range, or
-1
if the range is being cleared.addActiveLineRangeListener(ActiveLineRangeListener)
public void setAnimateBracketMatching(boolean animate)
ANIMATE_BRACKET_MATCHING_PROPERTY
.
animate
- Whether to animate bracket matching.getAnimateBracketMatching()
public void setAutoIndentEnabled(boolean enabled)
AUTO_INDENT_PROPERTY
.
enabled
- Whether or not auto-indent is enabled.isAutoIndentEnabled()
public void setBracketMatchingEnabled(boolean enabled)
BRACKET_MATCHING_PROPERTY
.
enabled
- Whether or not bracket matching should be enabled.isBracketMatchingEnabled()
public void setClearWhitespaceLinesEnabled(boolean enabled)
CLEAR_WHITESPACE_LINES_PROPERTY
.
enabled
- Whether or not whitespace-only lines are cleared when
the user presses Enter on them.isClearWhitespaceLinesEnabled()
public void setCloseCurlyBraces(boolean close)
This method fires a property change event of type
CLOSE_CURLY_BRACES_PROPERTY
.
close
- Whether curly braces should be automatically closed.getCloseCurlyBraces()
public void setCloseMarkupTags(boolean close)
</
" is typed. Note that this property is only
honored for markup languages, such as HTML, XML and PHP.
This method fires a property change event of type
CLOSE_MARKUP_TAGS_PROPERTY
.
close
- Whether closing markup tags should be automatically
completed.getCloseMarkupTags()
public void setDocument(Document document)
RSyntaxDocument
are accepted; for all
others, an exception will be thrown.
setDocument
in class RTextArea
document
- The new document for this text area.
IllegalArgumentException
- If the document is not an
RSyntaxDocument
.public void setEOLMarkersVisible(boolean visible)
EOL_VISIBLE_PROPERTY
.
visible
- Whether EOL markers are visible.getEOLMarkersVisible()
,
setWhitespaceVisible(boolean)
public void setFont(Font font)
RSyntaxTextArea
since it uses
different fonts for each token type.
font
- The font.public void setFractionalFontMetricsEnabled(boolean enabled)
FRACTIONAL_FONTMETRICS_PROPERTY
.
enabled
- Whether fractional font metrics are enabled.getFractionalFontMetricsEnabled()
public void setHighlighter(Highlighter h)
setHighlighter
in class JTextComponent
h
- The highlighter.
IllegalArgumentException
- If h
is not an instance
of RSyntaxTextAreaHighlighter
.public void setHyperlinkForeground(Color fg)
fg
- The color to use when painting hyperlinks.
NullPointerException
- If fg
is null
.getHyperlinkForeground()
,
setHyperlinksEnabled(boolean)
public void setHyperlinksEnabled(boolean enabled)
HYPERLINKS_ENABLED_PROPERTY
.
enabled
- Whether hyperlinks are enabled.getHyperlinksEnabled()
public void setLinkScanningMask(int mask)
mask
- The mask to use. This should be a value such as
InputEvent.CTRL_DOWN_MASK
or
InputEvent.META_DOWN_MASK
.
For invalid values, behavior is undefined.InputEvent
public void setMarkOccurrences(boolean markOccurrences)
MARK_OCCURRENCES_PROPERTY
.
markOccurrences
- Whether "Mark Occurrences" should be enabled.getMarkOccurrences()
,
setMarkOccurrencesColor(Color)
public void setMarkOccurrencesColor(Color color)
color
- The new color. This cannot be null
.getMarkOccurrencesColor()
,
setMarkOccurrences(boolean)
public void setMatchedBracketBGColor(Color color)
color
- The color to use.getMatchedBracketBGColor()
,
setMatchedBracketBorderColor(java.awt.Color)
public void setMatchedBracketBorderColor(Color color)
color
- The color to use.getMatchedBracketBorderColor()
,
setMatchedBracketBGColor(java.awt.Color)
public void setSyntaxEditingStyle(String styleKey)
SYNTAX_STYLE_PROPERTY
.
styleKey
- The syntax editing style to use, for example,
SyntaxConstants.SYNTAX_STYLE_NONE
or
SyntaxConstants.SYNTAX_STYLE_JAVA
.getSyntaxEditingStyle()
,
SyntaxConstants
public void setSyntaxScheme(SyntaxScheme scheme)
This method fires a property change event of type
SYNTAX_SCHEME_PROPERTY
.
scheme
- The instance of SyntaxScheme
to use.getSyntaxScheme()
public static boolean setTemplateDirectory(String dir)
dir
- The directory containing files ending in extension
.xml
that contain templates to load.
true
if the load was successful;
false
if either templates aren't currently
enabled or the load failed somehow (most likely, the
directory doesn't exist).getTemplatesEnabled()
,
setTemplatesEnabled(boolean)
,
saveTemplates()
public static void setTemplatesEnabled(boolean enabled)
Templates are a set of "shorthand identifiers" that you can configure so that you only have to type a short identifier (such as "forb") to insert a larger amount of code into the document (such as:
for (<caret>) { }Templates are a shared resource among all instances of
RSyntaxTextArea
; that is, templates can only be
enabled/disabled for all text areas globally, not individually, and
all text areas have access of the same templates. This should not
be an issue; rather, it should be beneficial as it promotes
uniformity among all text areas in an application.
enabled
- Whether or not templates should be enabled.getTemplatesEnabled()
public void setTextAntiAliasHint(String aaHintFieldName)
aaHintFieldName
- The name of a field in
java.awt.RenderingHints
. If an unknown or
unsupported field name is specified (such as a 1.6+ hint
being specified when this is a 1.4/1.5 JVM), null
is used instead. A value of null
means "no
antialiasing."getTextAntiAliasHint()
public void setUseFocusableTips(boolean use)
FOCUSABLE_TIPS_PROPERTY
.
use
- Whether to use focusable tool tips.getUseFocusableTips()
,
FocusableTip
public void setWhitespaceVisible(boolean visible)
VISIBLE_WHITESPACE_PROPERTY
.
visible
- Whether whitespace should be visible.isWhitespaceVisible()
protected void addCurrentLineHighlightListeners()
public void convertSpacesToTabs()
convertTabsToSpaces()
,
getTabsEmulated()
,
setTabsEmulated(boolean)
public void convertTabsToSpaces()
convertSpacesToTabs()
,
getTabsEmulated()
,
setTabsEmulated(boolean)
protected void forceCurrentLineHighlightRepaint()
RSyntaxTextArea
.
public final Color getBackground()
java.awt.Color
used as the background color for
this text area. If a java.awt.Image
image is currently
being used instead, null
is returned.
getBackground
in class Component
null
if an image
is currently the background.public final Image getBackgroundImage()
java.awt.Color
and
not a java.awt.Image
, then null
is returned.
java.awt.Image
used for the background, or
null
if the background is not an image.setBackgroundImage(java.awt.Image)
public final Object getBackgroundObject()
Object
representing the background for all
documents in this tabbed pane; either a java.awt.Color
or a
java.lang.Image
containing the image used as the background
for this text area.
Object
used for the background.setBackgroundObject(Object newBackground)
public final int getCaretLineNumber()
public final int getCaretOffsetFromLineStart()
public Color getCurrentLineHighlightColor()
getHighlightCurrentLine()
,
setHighlightCurrentLine(boolean)
,
setCurrentLineHighlightColor(java.awt.Color)
public static final Color getDefaultCaretColor()
public static final Color getDefaultCurrentLineHighlightColor()
public static final Font getDefaultFont()
public static final Color getDefaultForeground()
public static final Color getDefaultMarginLineColor()
getMarginLineColor()
,
setMarginLineColor(Color)
public static final int getDefaultMarginLinePosition()
getMarginLinePosition()
,
setMarginLinePosition(int)
public static final int getDefaultTabSize()
public boolean getFadeCurrentLineHighlight()
setFadeCurrentLineHighlight(boolean)
public boolean getHighlightCurrentLine()
setHighlightCurrentLine(boolean)
,
getCurrentLineHighlightColor()
,
setCurrentLineHighlightColor(java.awt.Color)
public final int getLineEndOffsetOfCurrentLine()
public final int getLineStartOffsetOfCurrentLine()
public Color getMarginLineColor()
setMarginLineColor(Color)
public int getMarginLinePixelLocation()
getDefaultMarginLinePosition()
,
setMarginLinePosition(int)
public int getMarginLinePosition()
getDefaultMarginLinePosition()
,
setMarginLinePosition(int)
public boolean getRoundedSelectionEdges()
setRoundedSelectionEdges(boolean)
public boolean getTabsEmulated()
true
if tabs are emulated with spaces;
false
if they aren't.setTabsEmulated(boolean)
public boolean isMarginLineEnabled()
setMarginLineEnabled(boolean)
public static boolean isOSX()
protected void possiblyUpdateCurrentLineHighlightLocation()
protected void processComponentEvent(ComponentEvent e)
processComponentEvent
in class Component
e
- The component event about to be sent to all registered
ComponentListener
s.public void setBackground(Color bg)
setBackgroundObject(bg)
.
NOTE: the opaque property is set to true
when the
background is set to a color (by this method). When an image is used
for the background, opaque is set to false. This is because
we perform better when setOpaque is true, but if we use an
image for the background when opaque is true, we get on-screen
garbage when the user scrolls via the arrow keys. Thus we
need setOpaque to be false in that case.You never have to change the opaque property yourself; it is always done for you.
setBackground
in class JComponent
bg
- The color to use as the background color.public void setBackgroundImage(Image image)
BACKGROUND_IMAGE_PROPERTY
.
NOTE: the opaque property is set to true
when the
background is set to a color. When an image is used for the
background (by this method), opaque is set to false. This is because
we perform better when setOpaque is true, but if we use an
image for the background when opaque is true, we get on-screen
garbage when the user scrolls via the arrow keys. Thus we
need setOpaque to be false in that case.
You never have to change the opaque property yourself; it is always done for you.
image
- The image to use as this text area's background.getBackgroundImage()
public void setBackgroundObject(Object newBackground)
Object
.
newBackground
- The java.awt.Color
or
java.awt.Image
object. If newBackground
is not either of these, the background is set to plain white.public void setCurrentLineHighlightColor(Color color)
CURRENT_LINE_HIGHLIGHT_COLOR_PROPERTY
.
color
- The color to use to highlight the current line.
NullPointerException
- if color
is null
.getHighlightCurrentLine()
,
setHighlightCurrentLine(boolean)
,
getCurrentLineHighlightColor()
public void setFadeCurrentLineHighlight(boolean fade)
CURRENT_LINE_HIGHLIGHT_FADE_PROPERTY
.
fade
- Whether the fade effect should be enabled.getFadeCurrentLineHighlight()
public void setHighlightCurrentLine(boolean highlight)
HIGHLIGHT_CURRENT_LINE_PROPERTY
.
highlight
- Whether or not to highlight the current line.getHighlightCurrentLine()
,
getCurrentLineHighlightColor()
,
setCurrentLineHighlightColor(java.awt.Color)
public void setLineWrap(boolean wrap)
setLineWrap
in class JTextArea
wrap
- Whether or not word wrap should be enabled.public void setMarginLineColor(Color color)
color
- The new margin line color.getDefaultMarginLineColor()
,
getMarginLineColor()
public void setMarginLineEnabled(boolean enabled)
enabled
- Whether or not the margin line should be enabled.isMarginLineEnabled()
public void setMarginLinePosition(int size)
size
- The margin size.
#see #getDefaultMarginLinePositiongetMarginLinePosition()
protected void setRTextAreaUI(RTextAreaUI ui)
RTextArea
. Note that, for instances
of RTextArea
, setUI
only updates the popup
menu; this is because RTextArea
s' look and feels are
independent of the Java Look and Feel. This method is here so
subclasses can set a UI (subclass of RTextAreaUI
) if they
have to.
ui
- The new UI.JTextComponent.setUI(javax.swing.plaf.TextUI)
public void setTabsEmulated(boolean areEmulated)
convertTabsToSpaces()
and convertSpacesToTabs()
.
areEmulated
- Whether or not tabs should be emulated with spaces.convertSpacesToTabs()
,
convertTabsToSpaces()
,
getTabsEmulated()
public void setTabSize(int size)
setTabSize()
doesn't work for a JTextArea
unless you use the constructor
specifying the number of rows and columns...Sets the number of characters to expand tabs to. This will be multiplied by the maximum advance for variable width fonts. A PropertyChange event ("tabSize") is fired when the tab size changes.
setTabSize
in class JTextArea
size
- Number of characters to expand to.protected void updateMarginLineX()
RSyntaxTextArea
that
have multiple fonts can define exactly what it means, for example, for
the margin line to be "80 characters" over.
public int yForLineContaining(int offs) throws BadLocationException
The default implementation is equivalent to:
int line = textArea.getLineOfOffset(offs); int startOffs = textArea.getLineStartOffset(line); return modelToView(startOffs).ySubclasses that can calculate this value more quickly than traditional
JTextComponent.modelToView(int)
calls should override this method to do so.
This method may be used when the entire bounding box isn't needed, to
speed up rendering.
offs
- The offset info the document.
-1
if
this text area doesn't yet have a positive size.
BadLocationException
- If offs
isn't a valid offset
into the document.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |