com.cburch.editor
Class BracketMatcher

java.lang.Object
  extended by com.cburch.editor.BracketMatcher

public class BracketMatcher
extends java.lang.Object

Handles parenthesis matching, both in highlighting unmatched parentheses and in displaying the matches of the parenthesis under the caret. (It works equally well for parentheses, braces, and brackets. We can use the terms interchangably here.)

Version:
0.1 2005-05-31
Author:
Carl Burch

Constructor Summary
BracketMatcher(Editor editor, TokenType openType, TokenType closeType, java.lang.String errorMessage)
          Constructs a matcher for a particular editor.
 
Method Summary
 boolean isCaretMatchHighlighted()
          Returns true if the editor should display the bracket matching the bracket underneath the caret.
 boolean isUnmatchedHighlighted()
          Returns true if unmatched brackets should be highlighted as "errors."
 void setCaretMatchHighlighted(boolean value)
          Controls whether the matcher will display the bracket matching the bracket underneath the caret.
 void setUnmatchedHighlighted(boolean value)
          Controls whether the matcher will highlight unmatched brackets.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BracketMatcher

public BracketMatcher(Editor editor,
                      TokenType openType,
                      TokenType closeType,
                      java.lang.String errorMessage)
Constructs a matcher for a particular editor.

Parameters:
editor - The editor we should listen to.
openType - The token category used for opening brackets.
closeType - The token category used for closing brackets.
Method Detail

isCaretMatchHighlighted

public boolean isCaretMatchHighlighted()
Returns true if the editor should display the bracket matching the bracket underneath the caret.

Returns:
true if the matches are displayed.

setCaretMatchHighlighted

public void setCaretMatchHighlighted(boolean value)
Controls whether the matcher will display the bracket matching the bracket underneath the caret.

Parameters:
value - true if the current match should be highlighted, false if it should not be.

isUnmatchedHighlighted

public boolean isUnmatchedHighlighted()
Returns true if unmatched brackets should be highlighted as "errors."

Returns:
true if the unmatched brackets are highlighted, false if they are not.

setUnmatchedHighlighted

public void setUnmatchedHighlighted(boolean value)
Controls whether the matcher will highlight unmatched brackets.

Parameters:
value - true if the matcher should highlight unmatched brackets, false if it should not.