org.fife.ui.rsyntaxtextarea
Class RSyntaxTextArea

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.text.JTextComponent
                  extended by javax.swing.JTextArea
                      extended by org.fife.ui.rtextarea.RTextArea
                          extended by org.fife.ui.rsyntaxtextarea.RSyntaxTextArea
All Implemented Interfaces:
ImageObserver, MenuContainer, Printable, Serializable, Accessible, Scrollable, SyntaxConstants
Direct Known Subclasses:
TextEditorPane

public class RSyntaxTextArea
extends RTextArea
implements SyntaxConstants

An extension of RTextArea that adds syntax highlighting of certain programming languages to its list of features. Languages currently supported include:

Other added features include: It is recommended that you use an instance of RTextScrollPane instead of a regular JScrollPane as this class allows you to add line numbers and bookmarks easily to your text area.

Version:
1.3
Author:
Robert Futrell
See Also:
Serialized Form

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 org.fife.ui.rsyntaxtextarea.SyntaxConstants
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_FORTRAN, SYNTAX_STYLE_GROOVY, SYNTAX_STYLE_HTML, SYNTAX_STYLE_JAVA, SYNTAX_STYLE_JAVASCRIPT, SYNTAX_STYLE_JSP, SYNTAX_STYLE_LISP, SYNTAX_STYLE_LUA, SYNTAX_STYLE_MAKEFILE, SYNTAX_STYLE_MXML, SYNTAX_STYLE_NONE, 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_WINDOWS_BATCH, SYNTAX_STYLE_XML
 
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 RTextAreas.
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 org.fife.ui.rtextarea.RTextArea
addLineHighlight, beginAtomicEdit, beginRecordingMacro, canRedo, canUndo, clearMarkAllHighlights, configurePopupMenu, createPopupMenu, discardAllEdits, endAtomicEdit, endRecordingMacro, getAction, getCurrentMacro, getDefaultMarkAllHighlightColor, getIconGroup, getMarkAllHighlightColor, getPopupMenu, getTextMode, getToolTipSupplier, handleReplaceSelection, isRecordingMacro, loadMacro, markAll, paste, playbackLastMacro, print, read, redoLastAction, removeAllLineHighlights, removeLineHighlight, replaceRange, replaceSelection, setActionProperties, setActionProperties, setCaret, setCaretStyle, setIconGroup, setMarkAllHighlightColor, setPopupMenu, setRoundedSelectionEdges, setTextMode, setToolTipSupplier, setUI, undoLastAction
 
Methods inherited from class javax.swing.JTextArea
append, getAccessibleContext, getColumns, getColumnWidth, getLineCount, getLineEndOffset, getLineOfOffset, getLineStartOffset, getLineWrap, getPreferredScrollableViewportSize, getPreferredSize, getRowHeight, getRows, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getTabSize, getUIClassID, getWrapStyleWord, insert, paramString, setColumns, setRows, setWrapStyleWord
 
Methods inherited from class javax.swing.text.JTextComponent
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, select, selectAll, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, updateUI, viewToModel, write
 
Methods inherited from class javax.swing.JComponent
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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
 
Methods inherited from class java.awt.Container
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
 
Methods inherited from class java.awt.Component
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, hide, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ANIMATE_BRACKET_MATCHING_PROPERTY

public static final String ANIMATE_BRACKET_MATCHING_PROPERTY
See Also:
Constant Field Values

ANTIALIAS_PROPERTY

public static final String ANTIALIAS_PROPERTY
See Also:
Constant Field Values

AUTO_INDENT_PROPERTY

public static final String AUTO_INDENT_PROPERTY
See Also:
Constant Field Values

BRACKET_MATCHING_PROPERTY

public static final String BRACKET_MATCHING_PROPERTY
See Also:
Constant Field Values

CLEAR_WHITESPACE_LINES_PROPERTY

public static final String CLEAR_WHITESPACE_LINES_PROPERTY
See Also:
Constant Field Values

CLOSE_CURLY_BRACES_PROPERTY

public static final String CLOSE_CURLY_BRACES_PROPERTY
See Also:
Constant Field Values

CLOSE_MARKUP_TAGS_PROPERTY

public static final String CLOSE_MARKUP_TAGS_PROPERTY
See Also:
Constant Field Values

EOL_VISIBLE_PROPERTY

public static final String EOL_VISIBLE_PROPERTY
See Also:
Constant Field Values

FOCUSABLE_TIPS_PROPERTY

public static final String FOCUSABLE_TIPS_PROPERTY
See Also:
Constant Field Values

FRACTIONAL_FONTMETRICS_PROPERTY

public static final String FRACTIONAL_FONTMETRICS_PROPERTY
See Also:
Constant Field Values

HYPERLINKS_ENABLED_PROPERTY

public static final String HYPERLINKS_ENABLED_PROPERTY
See Also:
Constant Field Values

MARK_OCCURRENCES_PROPERTY

public static final String MARK_OCCURRENCES_PROPERTY
See Also:
Constant Field Values

MARKED_OCCURRENCES_CHANGED_PROPERTY

public static final String MARKED_OCCURRENCES_CHANGED_PROPERTY
See Also:
Constant Field Values

PARSER_NOTICES_PROPERTY

public static final String PARSER_NOTICES_PROPERTY
See Also:
Constant Field Values

SYNTAX_SCHEME_PROPERTY

public static final String SYNTAX_SCHEME_PROPERTY
See Also:
Constant Field Values

SYNTAX_STYLE_PROPERTY

public static final String SYNTAX_STYLE_PROPERTY
See Also:
Constant Field Values

VISIBLE_WHITESPACE_PROPERTY

public static final String VISIBLE_WHITESPACE_PROPERTY
See Also:
Constant Field Values

BACKGROUND_IMAGE_PROPERTY

public static final String BACKGROUND_IMAGE_PROPERTY
See Also:
Constant Field Values

CURRENT_LINE_HIGHLIGHT_COLOR_PROPERTY

public static final String CURRENT_LINE_HIGHLIGHT_COLOR_PROPERTY
See Also:
Constant Field Values

CURRENT_LINE_HIGHLIGHT_FADE_PROPERTY

public static final String CURRENT_LINE_HIGHLIGHT_FADE_PROPERTY
See Also:
Constant Field Values

HIGHLIGHT_CURRENT_LINE_PROPERTY

public static final String HIGHLIGHT_CURRENT_LINE_PROPERTY
See Also:
Constant Field Values

ROUNDED_SELECTION_PROPERTY

public static final String ROUNDED_SELECTION_PROPERTY
See Also:
Constant Field Values
Constructor Detail

RSyntaxTextArea

public RSyntaxTextArea()
Constructor.


RSyntaxTextArea

public RSyntaxTextArea(RSyntaxDocument doc)
Constructor.

Parameters:
doc - The document for the editor.

RSyntaxTextArea

public RSyntaxTextArea(String text)
Constructor.

Parameters:
text - The initial text to display.

RSyntaxTextArea

public RSyntaxTextArea(int rows,
                       int cols)
Constructor.

Parameters:
rows - The number of rows to display.
cols - The number of columns to display.
Throws:
IllegalArgumentException - If either rows or cols is negative.

RSyntaxTextArea

public RSyntaxTextArea(String text,
                       int rows,
                       int cols)
Constructor.

Parameters:
text - The initial text to display.
rows - The number of rows to display.
cols - The number of columns to display.
Throws:
IllegalArgumentException - If either rows or cols is negative.

RSyntaxTextArea

public RSyntaxTextArea(RSyntaxDocument doc,
                       String text,
                       int rows,
                       int cols)
Constructor.

Parameters:
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.
Throws:
IllegalArgumentException - If either rows or cols is negative.

RSyntaxTextArea

public RSyntaxTextArea(int textMode)
Creates a new RSyntaxTextArea.

Parameters:
textMode - Either INSERT_MODE or OVERWRITE_MODE.
Method Detail

getMaxAscent

public int getMaxAscent()
Description copied from class: RTextArea
Returns the maximum ascent of all fonts used in this text area. In the case of a standard RTextArea, this is simply the ascent of the current font.

This value could be useful, for example, to implement a line-numbering scheme.

Overrides:
getMaxAscent in class RTextArea
Returns:
The ascent of the current font.

addActiveLineRangeListener

public void addActiveLineRangeListener(ActiveLineRangeListener l)
Adds an "active line range" listener to this text area.

Parameters:
l - The listener to add.
See Also:
removeActiveLineRangeListener(ActiveLineRangeListener)

addHyperlinkListener

public void addHyperlinkListener(HyperlinkListener l)
Adds a hyperlink listener to this text area.

Parameters:
l - The listener to add.
See Also:
removeHyperlinkListener(HyperlinkListener)

addNotify

public void addNotify()
Updates the font metrics the first time we're displayed.

Overrides:
addNotify in class JComponent

addParser

public void addParser(Parser parser)
Adds the parser to "validate" the source code in this text area. This can be anything from a spell checker to a "compiler" that verifies source code.

Parameters:
parser - The new parser. A value of null will do nothing.
See Also:
getParser(int), getParserCount(), removeParser(Parser)

clearParsers

public void clearParsers()
Removes all parsers from this text area.

See Also:
removeParser(Parser)

copyAsRtf

public void copyAsRtf()
Copies the currently selected text to the system clipboard, with any necessary style information (font, foreground color and background color). Does nothing for null selections.


createDefaultModel

protected Document createDefaultModel()
Returns the document to use for an RSyntaxTextArea

Overrides:
createDefaultModel in class JTextArea
Returns:
The document.

createMouseListener

protected org.fife.ui.rtextarea.RTextAreaBase.RTAMouseListener createMouseListener()
Returns the caret event/mouse listener for RTextAreas.

Overrides:
createMouseListener in class RTextArea
Returns:
The caret event/mouse listener.

createRTextAreaUI

protected RTextAreaUI createRTextAreaUI()
Returns the a real UI to install on this text area.

Overrides:
createRTextAreaUI in class RTextArea
Returns:
The UI.

doBracketMatching

protected final void doBracketMatching()
If the caret is on a bracket, this method finds the matching bracket, and if it exists, highlights it.


fireCaretUpdate

protected void fireCaretUpdate(CaretEvent e)
Notifies all listeners that a caret change has occurred.

Overrides:
fireCaretUpdate in class RTextArea
Parameters:
e - The caret event.

forceReparsing

public void forceReparsing(int parser)
Forces the given 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.

Parameters:
parser - The index of the Parser to re-run.
See Also:
getParser(int)

forceReparsing

public boolean forceReparsing(Parser parser)
Forces re-parsing with a specific parser. Note that if this parser is not installed on this text area, nothing will happen.

Parameters:
parser - The parser that should re-parse this text area's contents. This should be installed on this text area.
Returns:
Whether the parser was installed on this text area.
See Also:
forceReparsing(int)

getAnimateBracketMatching

public boolean getAnimateBracketMatching()
Returns whether bracket matching should be animated.

Returns:
Whether bracket matching should be animated.
See Also:
setAnimateBracketMatching(boolean)

getBackgroundForTokenType

public Color getBackgroundForTokenType(int type)
Returns the background color for tokens of the specified type.

Parameters:
type - The type of token.
Returns:
The background color to use for that token type. If this value is null then this token type has no special background color.
See Also:
getForegroundForToken(Token)

getCloseCurlyBraces

public boolean getCloseCurlyBraces()
Returns whether curly braces should be automatically closed when a newline is entered after an opening curly brace. Note that this property is only honored for languages that use curly braces to denote code blocks.

Returns:
Whether curly braces should be automatically closed.
See Also:
setCloseCurlyBraces(boolean)

getCloseMarkupTags

public boolean getCloseMarkupTags()
Returns whether closing markup tags should be automatically completed when "</" is typed. Note that this property is only honored for markup languages, such as HTML, XML and PHP.

Returns:
Whether closing markup tags should be automatically completed.
See Also:
setCloseMarkupTags(boolean)

getCodeTemplateManager

public static CodeTemplateManager getCodeTemplateManager()
Returns the code template manager for all instances of RSyntaxTextArea. The manager is lazily created.

Returns:
The code template manager.
See Also:
setTemplatesEnabled(boolean)

getDefaultBracketMatchBGColor

public static final Color getDefaultBracketMatchBGColor()
Returns the default bracket-match background color.

Returns:
The color.
See Also:
getDefaultBracketMatchBorderColor()

getDefaultBracketMatchBorderColor

public static final Color getDefaultBracketMatchBorderColor()
Returns the default bracket-match border color.

Returns:
The color.
See Also:
getDefaultBracketMatchBGColor()

getDefaultSelectionColor

public static Color getDefaultSelectionColor()
Returns the default selection color for this text area. This color was chosen because it's light and RSyntaxTextArea does not change text color between selected/unselected text for contrast like regular JTextAreas do.

Returns:
The default selection color.

getDefaultSyntaxScheme

public SyntaxScheme getDefaultSyntaxScheme()
Returns the "default" syntax highlighting color scheme. The colors used are somewhat standard among syntax highlighting text editors.

Returns:
The default syntax highlighting color scheme.
See Also:
restoreDefaultSyntaxScheme(), getSyntaxScheme(), setSyntaxScheme(SyntaxScheme)

getEOLMarkersVisible

public boolean getEOLMarkersVisible()
Returns whether an EOL marker should be drawn at the end of each line.

Returns:
Whether EOL markers should be visible.
See Also:
setEOLMarkersVisible(boolean), isWhitespaceVisible()

getFontForTokenType

public Font getFontForTokenType(int type)
Returns the font for tokens of the specified type.

Parameters:
type - The type of token.
Returns:
The font to use for that token type.
See Also:
getFontMetricsForTokenType(int)

getFontMetricsForTokenType

public FontMetrics getFontMetricsForTokenType(int type)
Returns the font metrics for tokens of the specified type.

Parameters:
type - The type of token.
Returns:
The font metrics to use for that token type.
See Also:
getFontForTokenType(int)

getForegroundForToken

public Color getForegroundForToken(Token t)
Returns the foreground color to use when painting a token.

Parameters:
t - The token.
Returns:
The foreground color to use for that token. This value is never null.
See Also:
getBackgroundForTokenType(int)

getForegroundForTokenType

public Color getForegroundForTokenType(int type)
Returns the foreground color to use when painting a token. This does not take into account whether the token is a hyperlink.

Parameters:
type - The token type.
Returns:
The foreground color to use for that token. This value is never null.
See Also:
getForegroundForToken(Token)

getFractionalFontMetricsEnabled

public boolean getFractionalFontMetricsEnabled()
Returns whether fractional font metrics are enabled for this text area.

Returns:
Whether fractional font metrics are enabled.
See Also:
setFractionalFontMetricsEnabled(boolean), getTextAntiAliasHint()

getHyperlinkForeground

public Color getHyperlinkForeground()
Returns the color to use when painting hyperlinks.

Returns:
The color to use when painting hyperlinks.
See Also:
setHyperlinkForeground(Color), getHyperlinksEnabled()

getHyperlinksEnabled

public boolean getHyperlinksEnabled()
Returns whether hyperlinks are enabled for this text area.

Returns:
Whether hyperlinks are enabled for this text area.
See Also:
setHyperlinksEnabled(boolean)

getLineHeight

public int getLineHeight()
Returns the height to use for a line of text in this text area.

Returns:
The height of a line of text in this text area.

getMarkedOccurrences

public List getMarkedOccurrences()
Returns a list of "marked occurrences" in the text area. If there are no marked occurrences, this will be an empty list.

Returns:
The list of marked occurrences.

getMarkOccurrences

public boolean getMarkOccurrences()
Returns whether "Mark Occurrences" is enabled.

Returns:
Whether "Mark Occurrences" is enabled.
See Also:
setMarkOccurrences(boolean)

getMarkOccurrencesColor

public Color getMarkOccurrencesColor()
Returns the color used to "mark occurrences."

Returns:
The mark occurrences color.
See Also:
setMarkOccurrencesColor(Color)

getMatchedBracketBGColor

public Color getMatchedBracketBGColor()
Gets the color used as the background for a matched bracket.

Returns:
The color used.
See Also:
setMatchedBracketBGColor(java.awt.Color), getMatchedBracketBorderColor()

getMatchedBracketBorderColor

public Color getMatchedBracketBorderColor()
Gets the color used as the border for a matched bracket.

Returns:
The color used.
See Also:
setMatchedBracketBorderColor(java.awt.Color), getMatchedBracketBGColor()

getMatchRectangle

public final Rectangle getMatchRectangle()
Returns the matched bracket's rectangle, or null if there is currently no matched bracket. Note that this shouldn't ever be called by the user.

Returns:
The rectangle surrounding the matched bracket.

getParser

public Parser getParser(int index)
Returns the specified parser.

Parameters:
index - The Parser to retrieve.
Returns:
The Parser.
See Also:
getParserCount(), addParser(Parser)

getParserCount

public int getParserCount()
Returns the number of parsers operating on this text area.

Returns:
The parser count.
See Also:
addParser(Parser)

getParserNotices

public List getParserNotices()
Returns a list of the current parser notices for this text area. This method (like most Swing methods) should only be called on the EDT.

Returns:
The list of notices. This will be an empty list if there are none.

getShouldIndentNextLine

public 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). For example, in Java, for a line containing:
 for (int i=0; i<10; i++) {
 
the following line should be indented.

Parameters:
line - The line to check.
Returns:
Whether a line inserted after this one should be auto-indented. If auto-indentation is disabled, this will always return false.
See Also:
isAutoIndentEnabled()

getSyntaxEditingStyle

public String getSyntaxEditingStyle()
Returns what type of syntax highlighting this editor is doing.

Returns:
The style being used, such as SyntaxConstants.SYNTAX_STYLE_JAVA.
See Also:
setSyntaxEditingStyle(String), SyntaxConstants

getSyntaxScheme

public SyntaxScheme getSyntaxScheme()
Returns all of the colors currently being used in syntax highlighting by this text component.

Returns:
An instance of SyntaxScheme that represents the colors currently being used for syntax highlighting.
See Also:
setSyntaxScheme(SyntaxScheme)

getTemplatesEnabled

public static boolean getTemplatesEnabled()
Returns whether or not templates are enabled for all instances of RSyntaxTextArea.

Returns:
Whether templates are enabled.
See Also:
saveTemplates(), setTemplateDirectory(String), setTemplatesEnabled(boolean)

getTextAntiAliasHint

public String getTextAntiAliasHint()
Returns the rendering hint used when antialiasing text in this editor.

Returns:
The name of a field in java.awt.RenderingHints, or null if no text antialiasing is being done.
See Also:
setTextAntiAliasHint(String), getFractionalFontMetricsEnabled()

getTokenListForLine

public Token getTokenListForLine(int line)
Returns a list of tokens representing the given line.

Parameters:
line - The line number to get tokens for.
Returns:
A linked list of tokens representing the line's text.

getToolTipText

public String getToolTipText(MouseEvent e)
Returns the tool tip to display for a mouse event at the given location. This method is overridden to give a registered parser a chance to display a tool tip (such as an error description when the mouse is over an error highlight).

Overrides:
getToolTipText in class RTextArea
Parameters:
e - The mouse event.
Returns:
The tool tip text, or null if none.
See Also:
RTextArea.getToolTipSupplier(), RTextArea.setToolTipSupplier(ToolTipSupplier)

getUnderlineForToken

public boolean getUnderlineForToken(Token t)
Returns whether the specified token should be underlined. A token is underlined if its syntax style includes underlining, or if it is a hyperlink and hyperlinks are enabled.

Parameters:
t - The token.
Returns:
Whether the specified token should be underlined.

getUseFocusableTips

public boolean getUseFocusableTips()
Returns whether "focusable" tool tips are used instead of standard ones. Focusable tool tips are tool tips that the user can click on, resize, copy from, and click links in.

Returns:
Whether to use focusable tool tips.
See Also:
setUseFocusableTips(boolean), FocusableTip

init

protected void init()
Called by constructors to initialize common properties of the text editor.


isAutoIndentEnabled

public boolean isAutoIndentEnabled()
Returns whether or not auto-indent is enabled.

Returns:
Whether or not auto-indent is enabled.
See Also:
setAutoIndentEnabled(boolean)

isBracketMatchingEnabled

public final boolean isBracketMatchingEnabled()
Returns whether or not bracket matching is enabled.

Returns:
true iff bracket matching is enabled.
See Also:
setBracketMatchingEnabled(boolean)

isClearWhitespaceLinesEnabled

public boolean isClearWhitespaceLinesEnabled()
Returns whether or not lines containing nothing but whitespace are made into blank lines when Enter is pressed in them.

Returns:
Whether or not whitespace-only lines are cleared when the user presses Enter on them.
See Also:
setClearWhitespaceLinesEnabled(boolean)

isWhitespaceVisible

public boolean isWhitespaceVisible()
Returns whether whitespace (spaces and tabs) is visible.

Returns:
Whether whitespace is visible.
See Also:
setWhitespaceVisible(boolean), getEOLMarkersVisible()

paintComponent

protected void paintComponent(Graphics g)
The paintComponent method is overridden so we apply any necessary rendering hints to the Graphics object.

Parameters:
g - The graphics context with which to paint.

removeActiveLineRangeListener

public void removeActiveLineRangeListener(ActiveLineRangeListener l)
Removes an "active line range" listener from this text area.

Parameters:
l - The listener to remove.
See Also:
removeActiveLineRangeListener(ActiveLineRangeListener)

removeHyperlinkListener

public void removeHyperlinkListener(HyperlinkListener l)
Removes a hyperlink listener from this text area.

Parameters:
l - The listener to remove.
See Also:
addHyperlinkListener(HyperlinkListener)

removeNotify

public void removeNotify()
Overridden so we stop this text area's parsers, if any.

Overrides:
removeNotify in class JTextComponent

removeParser

public boolean removeParser(Parser parser)
Removes a parser from this text area.

Parameters:
parser - The Parser to remove.
Returns:
Whether the parser was found and removed.
See Also:
clearParsers(), addParser(Parser), getParser(int)

restoreDefaultSyntaxScheme

public void restoreDefaultSyntaxScheme()
Sets the colors used for syntax highlighting to their defaults.

See Also:
setSyntaxScheme(SyntaxScheme), getSyntaxScheme(), getDefaultSyntaxScheme()

saveTemplates

public static boolean saveTemplates()
Attempts to save all currently-known templates to the current template directory, as set by 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.

Returns:
Whether or not the save was successful. The save will be unsuccessful if the template directory does not exist or if it has not been set (i.e., you have not yet called setTemplateDirectory).
See Also:
getTemplatesEnabled(), setTemplateDirectory(java.lang.String), setTemplatesEnabled(boolean)

setActiveLineRange

public void setActiveLineRange(int min,
                               int max)
Sets the "active line range." Note that this 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.

Parameters:
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.
See Also:
addActiveLineRangeListener(ActiveLineRangeListener)

setAnimateBracketMatching

public void setAnimateBracketMatching(boolean animate)
Sets whether bracket matching should be animated. This fires a property change event of type ANIMATE_BRACKET_MATCHING_PROPERTY.

Parameters:
animate - Whether to animate bracket matching.
See Also:
getAnimateBracketMatching()

setAutoIndentEnabled

public void setAutoIndentEnabled(boolean enabled)
Sets whether or not auto-indent is enabled. This fires a property change event of type AUTO_INDENT_PROPERTY.

Parameters:
enabled - Whether or not auto-indent is enabled.
See Also:
isAutoIndentEnabled()

setBracketMatchingEnabled

public void setBracketMatchingEnabled(boolean enabled)
Sets whether bracket matching is enabled. This fires a property change event of type BRACKET_MATCHING_PROPERTY.

Parameters:
enabled - Whether or not bracket matching should be enabled.
See Also:
isBracketMatchingEnabled()

setClearWhitespaceLinesEnabled

public void setClearWhitespaceLinesEnabled(boolean enabled)
Sets whether or not lines containing nothing but whitespace are made into blank lines when Enter is pressed in them. This method fires a property change event of type CLEAR_WHITESPACE_LINES_PROPERTY.

Parameters:
enabled - Whether or not whitespace-only lines are cleared when the user presses Enter on them.
See Also:
isClearWhitespaceLinesEnabled()

setCloseCurlyBraces

public void setCloseCurlyBraces(boolean close)
Toggles whether curly braces should be automatically closed when a newline is entered after an opening curly brace. Note that this property is only honored for languages that use curly braces to denote code blocks.

This method fires a property change event of type CLOSE_CURLY_BRACES_PROPERTY.

Parameters:
close - Whether curly braces should be automatically closed.
See Also:
getCloseCurlyBraces()

setCloseMarkupTags

public void setCloseMarkupTags(boolean close)
Sets whether closing markup tags should be automatically completed when "</" 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.

Parameters:
close - Whether closing markup tags should be automatically completed.
See Also:
getCloseMarkupTags()

setDocument

public void setDocument(Document document)
Sets the document used by this text area. This is overridden so that only instances of RSyntaxDocument are accepted; for all others, an exception will be thrown.

Overrides:
setDocument in class RTextArea
Parameters:
document - The new document for this text area.
Throws:
IllegalArgumentException - If the document is not an RSyntaxDocument.

setEOLMarkersVisible

public void setEOLMarkersVisible(boolean visible)
Sets whether EOL markers are visible at the end of each line. This method fires a property change of type EOL_VISIBLE_PROPERTY.

Parameters:
visible - Whether EOL markers are visible.
See Also:
getEOLMarkersVisible(), setWhitespaceVisible(boolean)

setFont

public void setFont(Font font)
Sets the font used by this text area. Note that this method does not alter the appearance of an RSyntaxTextArea since it uses different fonts for each token type.

Parameters:
font - The font.

setFractionalFontMetricsEnabled

public void setFractionalFontMetricsEnabled(boolean enabled)
Sets whether fractional font metrics are enabled. This method fires a property change event of type FRACTIONAL_FONTMETRICS_PROPERTY.

Parameters:
enabled - Whether fractional font metrics are enabled.
See Also:
getFractionalFontMetricsEnabled()

setHighlighter

public void setHighlighter(Highlighter h)
Sets the highlighter used by this text area.

Overrides:
setHighlighter in class JTextComponent
Parameters:
h - The highlighter.
Throws:
IllegalArgumentException - If h is not an instance of RSyntaxTextAreaHighlighter.

setHyperlinkForeground

public void setHyperlinkForeground(Color fg)
Sets the color to use when painting hyperlinks.

Parameters:
fg - The color to use when painting hyperlinks.
Throws:
NullPointerException - If fg is null.
See Also:
getHyperlinkForeground(), setHyperlinksEnabled(boolean)

setHyperlinksEnabled

public void setHyperlinksEnabled(boolean enabled)
Sets whether hyperlinks are enabled for this text area. This method fires a property change event of type HYPERLINKS_ENABLED_PROPERTY.

Parameters:
enabled - Whether hyperlinks are enabled.
See Also:
getHyperlinksEnabled()

setLinkScanningMask

public void setLinkScanningMask(int mask)
Sets the mask for the key used to toggle whether we are scanning for hyperlinks with mouse hovering.

Parameters:
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.
See Also:
InputEvent

setMarkOccurrences

public void setMarkOccurrences(boolean markOccurrences)
Toggles whether "mark occurrences" is enabled. This method fires a property change event of type MARK_OCCURRENCES_PROPERTY.

Parameters:
markOccurrences - Whether "Mark Occurrences" should be enabled.
See Also:
getMarkOccurrences(), setMarkOccurrencesColor(Color)

setMarkOccurrencesColor

public void setMarkOccurrencesColor(Color color)
Sets the "mark occurrences" color.

Parameters:
color - The new color. This cannot be null.
See Also:
getMarkOccurrencesColor(), setMarkOccurrences(boolean)

setMatchedBracketBGColor

public void setMatchedBracketBGColor(Color color)
Sets the color used as the background for a matched bracket.

Parameters:
color - The color to use.
See Also:
getMatchedBracketBGColor(), setMatchedBracketBorderColor(java.awt.Color)

setMatchedBracketBorderColor

public void setMatchedBracketBorderColor(Color color)
Sets the color used as the border for a matched bracket.

Parameters:
color - The color to use.
See Also:
getMatchedBracketBorderColor(), setMatchedBracketBGColor(java.awt.Color)

setSyntaxEditingStyle

public void setSyntaxEditingStyle(String styleKey)
Sets what type of syntax highlighting this editor is doing. This method fires a property change of type SYNTAX_STYLE_PROPERTY.

Parameters:
styleKey - The syntax editing style to use, for example, SyntaxConstants.SYNTAX_STYLE_NONE or SyntaxConstants.SYNTAX_STYLE_JAVA.
See Also:
getSyntaxEditingStyle(), SyntaxConstants

setSyntaxScheme

public void setSyntaxScheme(SyntaxScheme scheme)
Sets all of the colors used in syntax highlighting to the colors specified. This uses a shallow copy of the color scheme so that multiple text areas can share the same color scheme and have their properties changed simultaneously.

This method fires a property change event of type SYNTAX_SCHEME_PROPERTY.

Parameters:
scheme - The instance of SyntaxScheme to use.
See Also:
getSyntaxScheme()

setTemplateDirectory

public 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". If templates aren't enabled, nothing happens.

Parameters:
dir - The directory containing files ending in extension .xml that contain templates to load.
Returns:
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).
See Also:
getTemplatesEnabled(), setTemplatesEnabled(boolean), saveTemplates()

setTemplatesEnabled

public static void setTemplatesEnabled(boolean enabled)
Enables or disables templates.

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.

Parameters:
enabled - Whether or not templates should be enabled.
See Also:
getTemplatesEnabled()

setTextAntiAliasHint

public void setTextAntiAliasHint(String aaHintFieldName)
Sets the rendering hint to use when anti-aliasing text in this editor.

Parameters:
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."
See Also:
getTextAntiAliasHint()

setUseFocusableTips

public void setUseFocusableTips(boolean use)
Sets whether "focusable" tool tips are used instead of standard ones. Focusable tool tips are tool tips that the user can click on, resize, copy from, and clink links in. This method fires a property change event of type FOCUSABLE_TIPS_PROPERTY.

Parameters:
use - Whether to use focusable tool tips.
See Also:
getUseFocusableTips(), FocusableTip

setWhitespaceVisible

public void setWhitespaceVisible(boolean visible)
Sets whether whitespace is visible. This method fires a property change of type VISIBLE_WHITESPACE_PROPERTY.

Parameters:
visible - Whether whitespace should be visible.
See Also:
isWhitespaceVisible()

addCurrentLineHighlightListeners

protected void addCurrentLineHighlightListeners()
Adds listeners that listen for changes to the current line, so we can update our "current line highlight." This is needed only because of an apparent difference between the JRE 1.4.2 and 1.5.0 (needed on 1.4.2, not needed on 1.5.0).


convertSpacesToTabs

public void convertSpacesToTabs()
Converts all instances of a number of spaces equal to a tab size into a tab in this text area.

See Also:
convertTabsToSpaces(), getTabsEmulated(), setTabsEmulated(boolean)

convertTabsToSpaces

public void convertTabsToSpaces()
Converts all instances of a tab into a number of spaces equivalent to a tab in this text area.

See Also:
convertSpacesToTabs(), getTabsEmulated(), setTabsEmulated(boolean)

forceCurrentLineHighlightRepaint

protected void forceCurrentLineHighlightRepaint()
Forces the current line highlight to be repainted. This hack is necessary for those situations when the view (appearance) changes but the caret's location hasn't (and thus the current line highlight coordinates won't get changed). Examples of this are when word wrap is toggled and when syntax styles are changed in an RSyntaxTextArea.


getBackground

public final Color getBackground()
Returns the 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.

Overrides:
getBackground in class Component
Returns:
The current background color, or null if an image is currently the background.

getBackgroundImage

public final Image getBackgroundImage()
Returns the image currently used for the background. If the current background is currently a java.awt.Color and not a java.awt.Image, then null is returned.

Returns:
A java.awt.Image used for the background, or null if the background is not an image.
See Also:
setBackgroundImage(java.awt.Image)

getBackgroundObject

public final 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.

Returns:
The Object used for the background.
See Also:
setBackgroundObject(Object newBackground)

getCaretLineNumber

public final int getCaretLineNumber()
Gets the line number that the caret is on.

Returns:
The zero-based line number that the caret is on.

getCaretOffsetFromLineStart

public final int getCaretOffsetFromLineStart()
Gets the position from the beginning of the current line that the caret is on.

Returns:
The zero-based position from the beginning of the current line that the caret is on.

getCurrentLineHighlightColor

public Color getCurrentLineHighlightColor()
Returns the color being used to highlight the current line. Note that if highlighting the current line is turned off, you will not be seeing this highlight.

Returns:
The color being used to highlight the current line.
See Also:
getHighlightCurrentLine(), setHighlightCurrentLine(boolean), setCurrentLineHighlightColor(java.awt.Color)

getDefaultCaretColor

public static final Color getDefaultCaretColor()
Returns the default caret color.

Returns:
The default caret color.

getDefaultCurrentLineHighlightColor

public static final Color getDefaultCurrentLineHighlightColor()
Returns the "default" color for highlighting the current line. Note that this color was chosen only because it looks nice (to me) against a white background.

Returns:
The default color for highlighting the current line.

getDefaultFont

public static final Font getDefaultFont()
Returns the default font for text areas.

Returns:
The default font.

getDefaultForeground

public static final Color getDefaultForeground()
Returns the default foreground color for text in this text area.

Returns:
The default foreground color.

getDefaultMarginLineColor

public static final Color getDefaultMarginLineColor()
Returns the default color for the margin line.

Returns:
The default margin line color.
See Also:
getMarginLineColor(), setMarginLineColor(Color)

getDefaultMarginLinePosition

public static final int getDefaultMarginLinePosition()
Returns the default margin line position.

Returns:
The default margin line position.
See Also:
getMarginLinePosition(), setMarginLinePosition(int)

getDefaultTabSize

public static final int getDefaultTabSize()
Returns the default tab size, in spaces.

Returns:
The default tab size.

getFadeCurrentLineHighlight

public boolean getFadeCurrentLineHighlight()
Returns whether the current line highlight is faded.

Returns:
Whether the current line highlight is faded.
See Also:
setFadeCurrentLineHighlight(boolean)

getHighlightCurrentLine

public boolean getHighlightCurrentLine()
Returns whether or not the current line is highlighted.

Returns:
Whether or the current line is highlighted.
See Also:
setHighlightCurrentLine(boolean), getCurrentLineHighlightColor(), setCurrentLineHighlightColor(java.awt.Color)

getLineEndOffsetOfCurrentLine

public final int getLineEndOffsetOfCurrentLine()
Returns the offset of the last character of the line that the caret is on.

Returns:
The last offset of the line that the caret is currently on.

getLineStartOffsetOfCurrentLine

public final int getLineStartOffsetOfCurrentLine()
Returns the offset of the first character of the line that the caret is on.

Returns:
The first offset of the line that the caret is currently on.

getMarginLineColor

public Color getMarginLineColor()
Returns the color used to paint the margin line.

Returns:
The margin line color.
See Also:
setMarginLineColor(Color)

getMarginLinePixelLocation

public int getMarginLinePixelLocation()
Returns the margin line position (in pixels) from the left-hand side of the text area.

Returns:
The margin line position.
See Also:
getDefaultMarginLinePosition(), setMarginLinePosition(int)

getMarginLinePosition

public int getMarginLinePosition()
Returns the margin line position (which is the number of 'm' widths in the current font the margin line is over).

Returns:
The margin line position.
See Also:
getDefaultMarginLinePosition(), setMarginLinePosition(int)

getRoundedSelectionEdges

public boolean getRoundedSelectionEdges()
Returns whether selection edges are rounded in this text area.

Returns:
Whether selection edges are rounded.
See Also:
setRoundedSelectionEdges(boolean)

getTabsEmulated

public boolean getTabsEmulated()
Returns whether or not tabs are emulated with spaces (i.e., "soft" tabs).

Returns:
true if tabs are emulated with spaces; false if they aren't.
See Also:
setTabsEmulated(boolean)

isMarginLineEnabled

public boolean isMarginLineEnabled()
Returns whether or not the margin line is being painted.

Returns:
Whether or not the margin line is being painted.
See Also:
setMarginLineEnabled(boolean)

isOSX

public static boolean isOSX()
Returns whether the OS we're running on is OS X.

Returns:
Whether the OS we're running on is OS X.

possiblyUpdateCurrentLineHighlightLocation

protected void possiblyUpdateCurrentLineHighlightLocation()
Updates the current line highlight location.


processComponentEvent

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.

Overrides:
processComponentEvent in class Component
Parameters:
e - The component event about to be sent to all registered ComponentListeners.

setBackground

public void setBackground(Color bg)
Sets the background color of this text editor. Note that this is equivalent to calling 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.

Overrides:
setBackground in class JComponent
Parameters:
bg - The color to use as the background color.

setBackgroundImage

public void setBackgroundImage(Image image)
Sets this image as the background image. This method fires a property change event of type 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.

Parameters:
image - The image to use as this text area's background.
See Also:
getBackgroundImage()

setBackgroundObject

public void setBackgroundObject(Object newBackground)
Makes the background into this Object.

Parameters:
newBackground - The java.awt.Color or java.awt.Image object. If newBackground is not either of these, the background is set to plain white.

setCurrentLineHighlightColor

public void setCurrentLineHighlightColor(Color color)
Sets the color to use to highlight the current line. Note that if highlighting the current line is turned off, you will not be able to see this highlight. This method fires a property change of type CURRENT_LINE_HIGHLIGHT_COLOR_PROPERTY.

Parameters:
color - The color to use to highlight the current line.
Throws:
NullPointerException - if color is null.
See Also:
getHighlightCurrentLine(), setHighlightCurrentLine(boolean), getCurrentLineHighlightColor()

setFadeCurrentLineHighlight

public void setFadeCurrentLineHighlight(boolean fade)
Sets whether the current line highlight should have a "fade" effect. This method fires a property change event of type CURRENT_LINE_HIGHLIGHT_FADE_PROPERTY.

Parameters:
fade - Whether the fade effect should be enabled.
See Also:
getFadeCurrentLineHighlight()

setHighlightCurrentLine

public void setHighlightCurrentLine(boolean highlight)
Sets whether or not the current line is highlighted. This method fires a property change of type HIGHLIGHT_CURRENT_LINE_PROPERTY.

Parameters:
highlight - Whether or not to highlight the current line.
See Also:
getHighlightCurrentLine(), getCurrentLineHighlightColor(), setCurrentLineHighlightColor(java.awt.Color)

setLineWrap

public void setLineWrap(boolean wrap)
Sets whether or not word wrap is enabled. This is overridden so that the "current line highlight" gets updated if it needs to be.

Overrides:
setLineWrap in class JTextArea
Parameters:
wrap - Whether or not word wrap should be enabled.

setMarginLineColor

public void setMarginLineColor(Color color)
Sets the color used to paint the margin line.

Parameters:
color - The new margin line color.
See Also:
getDefaultMarginLineColor(), getMarginLineColor()

setMarginLineEnabled

public void setMarginLineEnabled(boolean enabled)
Enables or disables the margin line.

Parameters:
enabled - Whether or not the margin line should be enabled.
See Also:
isMarginLineEnabled()

setMarginLinePosition

public void setMarginLinePosition(int size)
Sets the number of 'm' widths the margin line is over.

Parameters:
size - The margin size. #see #getDefaultMarginLinePosition
See Also:
getMarginLinePosition()

setRTextAreaUI

protected void setRTextAreaUI(RTextAreaUI ui)
Sets the UI for this RTextArea. Note that, for instances of RTextArea, setUI only updates the popup menu; this is because RTextAreas' 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.

Parameters:
ui - The new UI.
See Also:
JTextComponent.setUI(javax.swing.plaf.TextUI)

setTabsEmulated

public void setTabsEmulated(boolean areEmulated)
Changes whether or not tabs should be emulated with spaces (i.e., soft tabs). Note that this affects all tabs inserted AFTER this call, not tabs already in the document. For that, see convertTabsToSpaces() and convertSpacesToTabs().

Parameters:
areEmulated - Whether or not tabs should be emulated with spaces.
See Also:
convertSpacesToTabs(), convertTabsToSpaces(), getTabsEmulated()

setTabSize

public 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...

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.

Overrides:
setTabSize in class JTextArea
Parameters:
size - Number of characters to expand to.

updateMarginLineX

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.


yForLineContaining

public int yForLineContaining(int offs)
                       throws BadLocationException
Returns the y-coordinate of the line containing an offset.

The default implementation is equivalent to:

 int line = textArea.getLineOfOffset(offs);
 int startOffs = textArea.getLineStartOffset(line);
 return modelToView(startOffs).y
 
Subclasses 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.

Parameters:
offs - The offset info the document.
Returns:
The y-coordinate of the top of the offset, or -1 if this text area doesn't yet have a positive size.
Throws:
BadLocationException - If offs isn't a valid offset into the document.