public class RSyntaxTextArea extends RTextArea implements SyntaxConstants
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.TextEditorPane
,
序列化表格RTextArea.RTextAreaMutableCaretEvent
COPY_ACTION, CUT_ACTION, DELETE_ACTION, INSERT_MODE, MARK_ALL_COLOR_PROPERTY, MARK_ALL_OCCURRENCES_CHANGED_PROPERTY, OVERWRITE_MODE, PASTE_ACTION, REDO_ACTION, SELECT_ALL_ACTION, UNDO_ACTION
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
SYNTAX_STYLE_ACTIONSCRIPT, SYNTAX_STYLE_ASSEMBLER_X86, SYNTAX_STYLE_BBCODE, SYNTAX_STYLE_C, SYNTAX_STYLE_CLOJURE, SYNTAX_STYLE_CPLUSPLUS, SYNTAX_STYLE_CSHARP, SYNTAX_STYLE_CSS, SYNTAX_STYLE_DELPHI, SYNTAX_STYLE_DTD, SYNTAX_STYLE_FORMULA, SYNTAX_STYLE_FORTRAN, SYNTAX_STYLE_GROOVY, SYNTAX_STYLE_HTACCESS, SYNTAX_STYLE_HTML, SYNTAX_STYLE_JAVA, SYNTAX_STYLE_JAVASCRIPT, SYNTAX_STYLE_JSON, SYNTAX_STYLE_JSP, SYNTAX_STYLE_LATEX, SYNTAX_STYLE_LISP, SYNTAX_STYLE_LUA, SYNTAX_STYLE_MAKEFILE, SYNTAX_STYLE_MXML, SYNTAX_STYLE_NONE, SYNTAX_STYLE_NSIS, SYNTAX_STYLE_PERL, SYNTAX_STYLE_PHP, SYNTAX_STYLE_PROPERTIES_FILE, SYNTAX_STYLE_PYTHON, SYNTAX_STYLE_RUBY, SYNTAX_STYLE_SAS, SYNTAX_STYLE_SCALA, SYNTAX_STYLE_SQL, SYNTAX_STYLE_TCL, SYNTAX_STYLE_UNIX_SHELL, SYNTAX_STYLE_VISUAL_BASIC, SYNTAX_STYLE_WINDOWS_BATCH, SYNTAX_STYLE_XML
构造器和说明 |
---|
RSyntaxTextArea()
Constructor.
|
RSyntaxTextArea(int textMode)
Creates a new
RSyntaxTextArea . |
RSyntaxTextArea(int rows,
int cols)
Constructor.
|
RSyntaxTextArea(RSyntaxDocument doc)
Constructor.
|
RSyntaxTextArea(RSyntaxDocument doc,
java.lang.String text,
int rows,
int cols)
Constructor.
|
RSyntaxTextArea(java.lang.String text)
Constructor.
|
RSyntaxTextArea(java.lang.String text,
int rows,
int cols)
Constructor.
|
限定符和类型 | 方法和说明 |
---|---|
void |
addActiveLineRangeListener(ActiveLineRangeListener l)
Adds an "active line range" listener to this text area.
|
void |
addHyperlinkListener(javax.swing.event.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.
|
protected void |
appendFoldingMenu(javax.swing.JPopupMenu popup)
Appends a submenu with code folding options to this text component's
popup menu.
|
void |
clearParsers()
Removes all parsers from this text area.
|
protected void |
configurePopupMenu(javax.swing.JPopupMenu popupMenu)
Overridden to toggle the enabled state of various
RSyntaxTextArea-specific menu items.
|
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 javax.swing.text.Document |
createDefaultModel()
Returns the document to use for an
RSyntaxTextArea |
protected com.fr.design.gui.syntax.ui.rtextarea.RTextAreaBase.RTAMouseListener |
createMouseListener()
Returns the caret event/mouse listener for
RTextArea s. |
protected javax.swing.JPopupMenu |
createPopupMenu()
Overridden to add menu items related to cold folding.
|
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(javax.swing.event.CaretEvent e)
Notifies all listeners that a caret change has occurred.
|
void |
foldToggled(Fold fold)
Called whenever a fold is collapsed or expanded.
|
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.
|
boolean |
getAntiAliasingEnabled()
Returns whether anti-aliasing is enabled in this editor.
|
java.awt.Color |
getBackground()
Returns the
java.awt.Color used as the background color for
this text area. |
java.awt.Color |
getBackgroundForToken(Token token)
Returns the background color for a token.
|
java.awt.Image |
getBackgroundImage()
Returns the image currently used for the background.
|
java.lang.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 . |
java.awt.Color |
getCurrentLineHighlightColor()
Returns the color being used to highlight the current line.
|
static java.awt.Color |
getDefaultBracketMatchBGColor()
Returns the default bracket-match background color.
|
static java.awt.Color |
getDefaultBracketMatchBorderColor()
Returns the default bracket-match border color.
|
static java.awt.Color |
getDefaultCaretColor()
Returns the default caret color.
|
static java.awt.Color |
getDefaultCurrentLineHighlightColor()
Returns the "default" color for highlighting the current line.
|
static java.awt.Font |
getDefaultFont()
Returns the default font for text areas.
|
static java.awt.Color |
getDefaultForeground()
Returns the default foreground color for text in this text area.
|
static java.awt.Color |
getDefaultMarginLineColor()
Returns the default color for the margin line.
|
static int |
getDefaultMarginLinePosition()
Returns the default margin line position.
|
static java.awt.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.
|
FoldManager |
getFoldManager()
Returns the fold manager for this text area.
|
java.awt.Font |
getFontForTokenType(int type)
Returns the font for tokens of the specified type.
|
java.awt.FontMetrics |
getFontMetricsForTokenType(int type)
Returns the font metrics for tokens of the specified type.
|
java.awt.Color |
getForegroundForToken(Token t)
Returns the foreground color to use when painting a token.
|
java.awt.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.
|
boolean |
getHighlightSecondaryLanguages()
Returns whether "secondary" languages should have their backgrounds
colored differently to visually differentiate them.
|
java.awt.Color |
getHyperlinkForeground()
Returns the color to use when painting hyperlinks.
|
boolean |
getHyperlinksEnabled()
Returns whether hyperlinks are enabled for this text area.
|
int |
getLastVisibleOffset()
Returns the last visible offset in 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.
|
LinkGenerator |
getLinkGenerator() |
java.awt.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).
|
java.util.List<DocumentRange> |
getMarkAllHighlightRanges()
Returns a list of "mark all" highlights in the text area.
|
java.util.List<DocumentRange> |
getMarkedOccurrences()
Returns a list of "marked occurrences" in the text area.
|
boolean |
getMarkOccurrences()
Returns whether "Mark Occurrences" is enabled.
|
java.awt.Color |
getMarkOccurrencesColor()
Returns the color used to "mark occurrences."
|
java.awt.Color |
getMatchedBracketBGColor()
Gets the color used as the background for a matched bracket.
|
java.awt.Color |
getMatchedBracketBorderColor()
Gets the color used as the border for a matched bracket.
|
int |
getMaxAscent()
Overridden to return the max ascent for any font used in the editor.
|
boolean |
getPaintMarkOccurrencesBorder()
Returns whether a border is painted around marked occurrences.
|
boolean |
getPaintMatchedBracketPair()
Returns whether the bracket at the caret position is painted as a
"match" when a matched bracket is found.
|
boolean |
getPaintTabLines()
Returns whether tab lines are painted.
|
Parser |
getParser(int index)
Returns the specified parser.
|
int |
getParserCount()
Returns the number of parsers operating on this text area.
|
java.util.List<ParserNotice> |
getParserNotices()
Returns a list of the current parser notices for this text area.
|
int |
getRightHandSideCorrection()
Workaround for JTextComponents allowing the caret to be rendered
entirely off-screen if the entire "previous" character fit entirely.
|
boolean |
getRoundedSelectionEdges()
Returns whether selection edges are rounded in this text area.
|
java.awt.Color |
getSecondaryLanguageBackground(int index)
Returns the background color for the specified secondary language.
|
int |
getSecondaryLanguageCount()
Returns the number of secondary language backgrounds.
|
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).
|
java.lang.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.
|
java.awt.Color |
getTabLineColor()
Returns the color used to paint tab lines.
|
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 . |
Token |
getTokenListForLine(int line)
Returns a list of tokens representing the given line.
|
java.lang.String |
getToolTipText(java.awt.event.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.
|
boolean |
getUseSelectedTextColor()
Returns whether selected text should use the "selected text color"
property set via
JTextComponent.setSelectedTextColor(Color) . |
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 |
isCodeFoldingEnabled()
Returns whether code folding is enabled.
|
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.
|
Token |
modelToToken(int offs)
Returns the token at the specified position in the model.
|
protected void |
paintComponent(java.awt.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(java.awt.event.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(javax.swing.event.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 |
setAntiAliasingEnabled(boolean enabled)
Sets whether anti-aliasing is enabled in this editor.
|
void |
setAutoIndentEnabled(boolean enabled)
Sets whether or not auto-indent is enabled.
|
void |
setBackground(java.awt.Color bg)
Sets the background color of this text editor.
|
void |
setBackgroundImage(java.awt.Image image)
Sets this image as the background image.
|
void |
setBackgroundObject(java.lang.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 |
setCodeFoldingEnabled(boolean enabled)
Sets whether code folding is enabled.
|
void |
setCurrentLineHighlightColor(java.awt.Color color)
Sets the color to use to highlight the current line.
|
void |
setDocument(javax.swing.text.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(java.awt.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(javax.swing.text.Highlighter h)
Sets the highlighter used by this text area.
|
void |
setHighlightSecondaryLanguages(boolean highlight)
Sets whether "secondary" languages should have their backgrounds
colored differently to visually differentiate them.
|
void |
setHyperlinkForeground(java.awt.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 |
setLinkGenerator(LinkGenerator generator) |
void |
setLinkScanningMask(int mask)
Sets the mask for the key used to toggle whether we are scanning for
hyperlinks with mouse hovering.
|
void |
setMargin(java.awt.Insets insets)
Overridden to update the current line highlight location.
|
void |
setMarginLineColor(java.awt.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(java.awt.Color color)
Sets the "mark occurrences" color.
|
void |
setMatchedBracketBGColor(java.awt.Color color)
Sets the color used as the background for a matched bracket.
|
void |
setMatchedBracketBorderColor(java.awt.Color color)
Sets the color used as the border for a matched bracket.
|
void |
setPaintMarkOccurrencesBorder(boolean paintBorder)
Toggles whether a border should be painted around marked occurrences.
|
void |
setPaintMatchedBracketPair(boolean paintPair)
Sets whether the bracket at the caret position is painted as a "match"
when a matched bracket is found.
|
void |
setPaintTabLines(boolean paint)
Toggles whether tab lines are painted.
|
void |
setRightHandSideCorrection(int rhsCorrection)
Applications typically have no need to modify this value.
|
protected void |
setRTextAreaUI(RTextAreaUI ui)
Sets the UI for this
RTextArea . |
void |
setSecondaryLanguageBackground(int index,
java.awt.Color color)
Sets the background color to use for a secondary language.
|
void |
setSyntaxEditingStyle(java.lang.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 |
setTabLineColor(java.awt.Color c)
Sets the color use to paint tab lines.
|
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(java.lang.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 |
setUseFocusableTips(boolean use)
Sets whether "focusable" tool tips are used instead of standard ones.
|
void |
setUseSelectedTextColor(boolean use)
Sets whether selected text should use the "selected text color" property
(set via
JTextComponent.setSelectedTextColor(Color) ). |
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. |
Token |
viewToToken(java.awt.Point p)
Returns the token at the specified position in the view.
|
int |
yForLine(int line)
Returns the y-coordinate of the specified line.
|
int |
yForLineContaining(int offs)
Returns the y-coordinate of the line containing an offset.
|
addLineHighlight, beginAtomicEdit, beginRecordingMacro, canRedo, canUndo, createPopupMenuItem, createUndoManager, discardAllEdits, endAtomicEdit, endRecordingMacro, getAction, getCurrentMacro, getDefaultMarkAllHighlightColor, getIconGroup, getMarkAllHighlightColor, getPopupMenu, getSelectedOccurrenceText, getTextMode, getToolTipSupplier, handleReplaceSelection, isRecordingMacro, loadMacro, paste, playbackLastMacro, print, read, redoLastAction, removeAllLineHighlights, removeLineHighlight, replaceRange, replaceSelection, setActionProperties, setActionProperties, setCaret, setCaretStyle, setIconGroup, setMarkAllHighlightColor, setPopupMenu, setRoundedSelectionEdges, setSelectedOccurrenceText, setTextMode, setToolTipSupplier, setUI, undoLastAction
append, getAccessibleContext, getColumns, getColumnWidth, getLineCount, getLineEndOffset, getLineOfOffset, getLineStartOffset, getLineWrap, getPreferredScrollableViewportSize, getPreferredSize, getRowHeight, getRows, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getTabSize, getUIClassID, getWrapStyleWord, insert, paramString, setColumns, setRows, setWrapStyleWord
addCaretListener, addInputMethodListener, addKeymap, copy, cut, getActions, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPrintable, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, print, print, print, processInputMethodEvent, removeCaretListener, removeKeymap, restoreComposedText, saveComposedText, select, selectAll, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setKeymap, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, updateUI, viewToModel, write
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final java.lang.String ANIMATE_BRACKET_MATCHING_PROPERTY
public static final java.lang.String ANTIALIAS_PROPERTY
public static final java.lang.String AUTO_INDENT_PROPERTY
public static final java.lang.String BRACKET_MATCHING_PROPERTY
public static final java.lang.String CLEAR_WHITESPACE_LINES_PROPERTY
public static final java.lang.String CLOSE_CURLY_BRACES_PROPERTY
public static final java.lang.String CLOSE_MARKUP_TAGS_PROPERTY
public static final java.lang.String CODE_FOLDING_PROPERTY
public static final java.lang.String EOL_VISIBLE_PROPERTY
public static final java.lang.String FOCUSABLE_TIPS_PROPERTY
public static final java.lang.String FRACTIONAL_FONTMETRICS_PROPERTY
public static final java.lang.String HIGHLIGHT_SECONDARY_LANGUAGES_PROPERTY
public static final java.lang.String HYPERLINKS_ENABLED_PROPERTY
public static final java.lang.String MARK_OCCURRENCES_PROPERTY
public static final java.lang.String MARKED_OCCURRENCES_CHANGED_PROPERTY
public static final java.lang.String PAINT_MATCHED_BRACKET_PAIR_PROPERTY
public static final java.lang.String PARSER_NOTICES_PROPERTY
public static final java.lang.String SYNTAX_SCHEME_PROPERTY
public static final java.lang.String SYNTAX_STYLE_PROPERTY
public static final java.lang.String TAB_LINE_COLOR_PROPERTY
public static final java.lang.String TAB_LINES_PROPERTY
public static final java.lang.String USE_SELECTED_TEXT_COLOR_PROPERTY
public static final java.lang.String VISIBLE_WHITESPACE_PROPERTY
public static final java.lang.String BACKGROUND_IMAGE_PROPERTY
public static final java.lang.String CURRENT_LINE_HIGHLIGHT_COLOR_PROPERTY
public static final java.lang.String CURRENT_LINE_HIGHLIGHT_FADE_PROPERTY
public static final java.lang.String HIGHLIGHT_CURRENT_LINE_PROPERTY
public static final java.lang.String ROUNDED_SELECTION_PROPERTY
public RSyntaxTextArea()
public RSyntaxTextArea(RSyntaxDocument doc)
doc
- The document for the editor.public RSyntaxTextArea(java.lang.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.java.lang.IllegalArgumentException
- If either rows
or
cols
is negative.public RSyntaxTextArea(java.lang.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.java.lang.IllegalArgumentException
- If either rows
or
cols
is negative.public RSyntaxTextArea(RSyntaxDocument doc, java.lang.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.java.lang.IllegalArgumentException
- If either rows
or
cols
is negative.public RSyntaxTextArea(int textMode)
RSyntaxTextArea
.textMode
- Either INSERT_MODE
or
OVERWRITE_MODE
.public void addActiveLineRangeListener(ActiveLineRangeListener l)
l
- The listener to add.removeActiveLineRangeListener(ActiveLineRangeListener)
public void addHyperlinkListener(javax.swing.event.HyperlinkListener l)
l
- The listener to add.removeHyperlinkListener(HyperlinkListener)
public void addNotify()
addNotify
在类中 javax.swing.JComponent
public void addParser(Parser parser)
parser
- The new parser. A value of null
will
do nothing.getParser(int)
,
getParserCount()
,
removeParser(Parser)
protected void appendFoldingMenu(javax.swing.JPopupMenu popup)
popup
- The popup menu to append to.createPopupMenu()
public void clearParsers()
removeParser(Parser)
protected void configurePopupMenu(javax.swing.JPopupMenu popupMenu)
RTextArea.setPopupMenu(JPopupMenu)
, you
will want to override this method, especially if you removed any of the
menu items in the default popup menu.configurePopupMenu
在类中 RTextArea
popupMenu
- The popup menu. This will never be null
.createPopupMenu()
,
RTextArea.setPopupMenu(JPopupMenu)
public void copyAsRtf()
null
selections.protected javax.swing.text.Document createDefaultModel()
RSyntaxTextArea
createDefaultModel
在类中 RTextArea
protected com.fr.design.gui.syntax.ui.rtextarea.RTextAreaBase.RTAMouseListener createMouseListener()
RTextArea
s.createMouseListener
在类中 RTextArea
protected javax.swing.JPopupMenu createPopupMenu()
createPopupMenu
在类中 RTextArea
appendFoldingMenu(JPopupMenu)
protected RTextAreaUI createRTextAreaUI()
createRTextAreaUI
在类中 RTextArea
protected final void doBracketMatching()
protected void fireCaretUpdate(javax.swing.event.CaretEvent e)
fireCaretUpdate
在类中 RTextArea
e
- The caret event.public void foldToggled(Fold fold)
fold
- The fold that was collapsed or expanded.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 boolean getAntiAliasingEnabled()
setAntiAliasingEnabled(boolean)
,
getFractionalFontMetricsEnabled()
public java.awt.Color getBackgroundForToken(Token token)
token
- The token.null
then this token 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 java.awt.Color getDefaultBracketMatchBGColor()
getDefaultBracketMatchBorderColor()
public static final java.awt.Color getDefaultBracketMatchBorderColor()
getDefaultBracketMatchBGColor()
public static java.awt.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 FoldManager getFoldManager()
public java.awt.Font getFontForTokenType(int type)
type
- The type of token.getFontMetricsForTokenType(int)
public java.awt.FontMetrics getFontMetricsForTokenType(int type)
type
- The type of token.getFontForTokenType(int)
public java.awt.Color getForegroundForToken(Token t)
t
- The token.null
.getBackgroundForToken(Token)
public java.awt.Color getForegroundForTokenType(int type)
type
- The token type.null
.getForegroundForToken(Token)
public boolean getFractionalFontMetricsEnabled()
setFractionalFontMetricsEnabled(boolean)
,
getAntiAliasingEnabled()
public boolean getHighlightSecondaryLanguages()
setHighlightSecondaryLanguages(boolean)
,
getSecondaryLanguageBackground(int)
,
getSecondaryLanguageCount()
,
setSecondaryLanguageBackground(int, Color)
public java.awt.Color getHyperlinkForeground()
setHyperlinkForeground(Color)
,
getHyperlinksEnabled()
public boolean getHyperlinksEnabled()
setHyperlinksEnabled(boolean)
public int getLastVisibleOffset()
public int getLineHeight()
public LinkGenerator getLinkGenerator()
public java.util.List<DocumentRange> getMarkAllHighlightRanges()
public java.util.List<DocumentRange> getMarkedOccurrences()
public boolean getMarkOccurrences()
setMarkOccurrences(boolean)
public java.awt.Color getMarkOccurrencesColor()
setMarkOccurrencesColor(Color)
public java.awt.Color getMatchedBracketBGColor()
null
, no special
background is painted behind a matched bracket.setMatchedBracketBGColor(java.awt.Color)
,
getMatchedBracketBorderColor()
public java.awt.Color getMatchedBracketBorderColor()
setMatchedBracketBorderColor(java.awt.Color)
,
getMatchedBracketBGColor()
public int getMaxAscent()
getMaxAscent
在类中 RTextArea
public boolean getPaintMatchedBracketPair()
isBracketMatchingEnabled()
returns
false
.setPaintMatchedBracketPair(boolean)
,
isBracketMatchingEnabled()
,
setBracketMatchingEnabled(boolean)
public boolean getPaintTabLines()
setPaintTabLines(boolean)
,
getTabLineColor()
public Parser getParser(int index)
index
- The Parser
to retrieve.Parser
.getParserCount()
,
addParser(Parser)
public int getParserCount()
addParser(Parser)
public java.util.List<ParserNotice> getParserNotices()
public int getRightHandSideCorrection()
setRightHandSideCorrection(int)
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 java.lang.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 java.awt.Color getTabLineColor()
setTabLineColor(Color)
,
getPaintTabLines()
,
setPaintTabLines(boolean)
public boolean getPaintMarkOccurrencesBorder()
setPaintMarkOccurrencesBorder(boolean)
,
getMarkOccurrencesColor()
,
getMarkOccurrences()
public java.awt.Color getSecondaryLanguageBackground(int index)
index
- The language index. Note that these are 1-based, not
0-based, and should be in the range
1-getSecondaryLanguageCount()
, inclusive.null
if none.getSecondaryLanguageCount()
,
setSecondaryLanguageBackground(int, Color)
,
getHighlightSecondaryLanguages()
public int getSecondaryLanguageCount()
getSecondaryLanguageBackground(int)
,
setSecondaryLanguageBackground(int, Color)
,
getHighlightSecondaryLanguages()
public static boolean getTemplatesEnabled()
RSyntaxTextArea
.For more flexible boilerplate code insertion, consider using the TemplateCompletion class in the AutoComplete add-on library.
saveTemplates()
,
setTemplateDirectory(String)
,
setTemplatesEnabled(boolean)
public Token getTokenListForLine(int line)
line
- The line number to get tokens for.public java.lang.String getToolTipText(java.awt.event.MouseEvent e)
getToolTipText
在类中 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
public boolean getUseSelectedTextColor()
JTextComponent.setSelectedTextColor(Color)
. This is the
typical behavior of text components. By default, RSyntaxTextArea does
not do this, so that token styles are visible even in selected regions
of text.setUseSelectedTextColor(boolean)
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 isCodeFoldingEnabled()
setCodeFoldingEnabled(boolean)
public boolean isWhitespaceVisible()
setWhitespaceVisible(boolean)
,
getEOLMarkersVisible()
public Token modelToToken(int offs)
offs
- The position in the model.null
if no token is at that
position.viewToToken(Point)
protected void paintComponent(java.awt.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(javax.swing.event.HyperlinkListener l)
l
- The listener to remove.addHyperlinkListener(HyperlinkListener)
public void removeNotify()
removeNotify
在类中 javax.swing.text.JTextComponent
public boolean removeParser(Parser parser)
parser
- The Parser
to remove.clearParsers()
,
addParser(Parser)
,
getParser(int)
public void restoreDefaultSyntaxScheme()
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 setAntiAliasingEnabled(boolean enabled)
ANTIALIAS_PROPERTY
.enabled
- Whether anti-aliasing is enabled.getAntiAliasingEnabled()
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 setCodeFoldingEnabled(boolean enabled)
This method fires a property change event of type
CODE_FOLDING_PROPERTY
.
enabled
- Whether code folding should be enabled.isCodeFoldingEnabled()
public void setDocument(javax.swing.text.Document document)
RSyntaxDocument
are accepted; for all
others, an exception will be thrown.setDocument
在类中 RTextArea
document
- The new document for this text area.java.lang.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(java.awt.Font font)
SyntaxScheme
.font
- The font.SyntaxScheme.getStyle(int)
public void setFractionalFontMetricsEnabled(boolean enabled)
FRACTIONAL_FONTMETRICS_PROPERTY
.enabled
- Whether fractional font metrics are enabled.getFractionalFontMetricsEnabled()
public void setHighlighter(javax.swing.text.Highlighter h)
setHighlighter
在类中 javax.swing.text.JTextComponent
h
- The highlighter.java.lang.IllegalArgumentException
- If h
is not an instance
of RSyntaxTextAreaHighlighter
.public void setHighlightSecondaryLanguages(boolean highlight)
HIGHLIGHT_SECONDARY_LANGUAGES_PROPERTY
.public void setHyperlinkForeground(java.awt.Color fg)
fg
- The color to use when painting hyperlinks.java.lang.NullPointerException
- If fg
is null
.getHyperlinkForeground()
,
setHyperlinksEnabled(boolean)
public void setHyperlinksEnabled(boolean enabled)
HYPERLINKS_ENABLED_PROPERTY
.enabled
- Whether hyperlinks are enabled.getHyperlinksEnabled()
public void setLinkGenerator(LinkGenerator generator)
public void setLinkScanningMask(int mask)
CTRL_DOWN_MASK
.mask
- The mask to use. This should be some bitwise combination of
InputEvent.CTRL_DOWN_MASK
,
InputEvent.ALT_DOWN_MASK
,
InputEvent.SHIFT_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(java.awt.Color color)
color
- The new color. This cannot be null
.getMarkOccurrencesColor()
,
setMarkOccurrences(boolean)
public void setMatchedBracketBGColor(java.awt.Color color)
color
- The color to use. If this is null
, then no
special background is painted behind a matched bracket.getMatchedBracketBGColor()
,
setMatchedBracketBorderColor(java.awt.Color)
,
setPaintMarkOccurrencesBorder(boolean)
public void setMatchedBracketBorderColor(java.awt.Color color)
color
- The color to use.getMatchedBracketBorderColor()
,
setMatchedBracketBGColor(java.awt.Color)
public void setPaintMarkOccurrencesBorder(boolean paintBorder)
paintBorder
- Whether to paint a border.getPaintMarkOccurrencesBorder()
,
setMarkOccurrencesColor(Color)
,
setMarkOccurrences(boolean)
public void setPaintMatchedBracketPair(boolean paintPair)
isBracketMatchingEnabled()
returns false
.
This method fires a property change event of type
PAINT_MATCHED_BRACKET_PAIR_PROPERTY
.
paintPair
- Whether both brackets in a bracket pair should be
highlighted when bracket matching is enabled.getPaintMatchedBracketPair()
,
isBracketMatchingEnabled()
,
setBracketMatchingEnabled(boolean)
public void setPaintTabLines(boolean paint)
TAB_LINES_PROPERTY
.paint
- Whether tab lines are painted.getPaintTabLines()
,
setTabLineColor(Color)
public void setRightHandSideCorrection(int rhsCorrection)
Workaround for JTextComponents allowing the caret to be rendered entirely off-screen if the entire "previous" character fit entirely.
rhsCorrection
- The amount of space to add to the x-axis preferred
span. This should be non-negative.getRightHandSideCorrection()
public void setSecondaryLanguageBackground(int index, java.awt.Color color)
index
- The language index. Note that these are 1-based, not
0-based, and should be in the range
1-getSecondaryLanguageCount()
, inclusive.color
- The new color, or null
for none.getSecondaryLanguageBackground(int)
,
getSecondaryLanguageCount()
public void setSyntaxEditingStyle(java.lang.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(java.lang.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.For more flexible boilerplate code insertion, consider using the TemplateCompletion class in the AutoComplete add-on library.
enabled
- Whether or not templates should be enabled.getTemplatesEnabled()
public void setTabLineColor(java.awt.Color c)
TAB_LINE_COLOR_PROPERTY
.c
- The color. If this value is null
, the default
(gray) is used.getTabLineColor()
,
setPaintTabLines(boolean)
,
getPaintTabLines()
public void setUseFocusableTips(boolean use)
FOCUSABLE_TIPS_PROPERTY
.use
- Whether to use focusable tool tips.getUseFocusableTips()
,
FocusableTip
public void setUseSelectedTextColor(boolean use)
JTextComponent.setSelectedTextColor(Color)
). This is the typical
behavior of text components. By default, RSyntaxTextArea does not do
this, so that token styles are visible even in selected regions of text.
This method fires a property change event of type
USE_SELECTED_TEXT_COLOR_PROPERTY
.use
- Whether to use the "selected text" color when painting text
in selected regions.getUseSelectedTextColor()
public void setWhitespaceVisible(boolean visible)
VISIBLE_WHITESPACE_PROPERTY
.visible
- Whether whitespace should be visible.isWhitespaceVisible()
public Token viewToToken(java.awt.Point p)
p
- The position in the view.null
if no token is at that
position.modelToToken(int)
public void convertSpacesToTabs()
public void convertTabsToSpaces()
protected void forceCurrentLineHighlightRepaint()
RSyntaxTextArea
.public final java.awt.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
在类中 java.awt.Component
null
if an image
is currently the background.public final java.awt.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 java.lang.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 java.awt.Color getCurrentLineHighlightColor()
getHighlightCurrentLine()
,
setHighlightCurrentLine(boolean)
,
setCurrentLineHighlightColor(java.awt.Color)
public static final java.awt.Color getDefaultCaretColor()
public static final java.awt.Color getDefaultCurrentLineHighlightColor()
public static final java.awt.Font getDefaultFont()
public static final java.awt.Color getDefaultForeground()
public static final java.awt.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 java.awt.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(java.awt.event.ComponentEvent e)
processComponentEvent
在类中 java.awt.Component
e
- The component event about to be sent to all registered
ComponentListener
s.public void setBackground(java.awt.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
在类中 javax.swing.JComponent
bg
- The color to use as the background color.public void setBackgroundImage(java.awt.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(java.lang.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(java.awt.Color color)
CURRENT_LINE_HIGHLIGHT_COLOR_PROPERTY
.color
- The color to use to highlight the current line.java.lang.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
在类中 javax.swing.JTextArea
wrap
- Whether or not word wrap should be enabled.public void setMargin(java.awt.Insets insets)
setMargin
在类中 javax.swing.text.JTextComponent
insets
- The new insets.public void setMarginLineColor(java.awt.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
在类中 javax.swing.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 yForLine(int line) throws javax.swing.text.BadLocationException
line
- The line number.-1
if
this text area doesn't yet have a positive size or the line is
hidden (i.e. from folding).javax.swing.text.BadLocationException
- If line
isn't a valid line
number for this document.public int yForLineContaining(int offs) throws javax.swing.text.BadLocationException
offs
- The offset info the document.-1
if
this text area doesn't yet have a positive size or the line is
hidden (i.e. from folding).javax.swing.text.BadLocationException
- If offs
isn't a valid offset
into the document.