newCaretPosition--; Segment lineSegment = painter.currentLine; getText(newCaretPosition,1,lineSegment); char ch = lineSegment.array[lineSegment.offset]; int[] match; switch(ch) { case '(': match = TextUtilities.locateBracketForward( document,newCaretPosition,'(',')'); bracket = ')'; break; case ')': match = TextUtilities.locateBracketBackward( document,newCaretPosition,'(',')'); bracket = '('; break; case '[': match = TextUtilities.locateBracketForward( document,newCaretPosition,'[',']'); bracket = ']'; break; case ']': match = TextUtilities.locateBracketBackward( document,newCaretPosition,'[',']'); bracket = '['; break; case '{': match = TextUtilities.locateBracketForward( document,newCaretPosition,'{','}'); bracket = '}'; break; case '}': match = TextUtilities.locateBracketBackward( document,newCaretPosition,'{','}'); bracket = '{'; break; default: match = null; bracket = '\0'; break; } if(match != null) { bracketLine = match[0]; bracketPosition = match[1]; return; }
bracketLine = getLineOfOffset(offset); bracketPosition = offset - getLineStartOffset(bracketLine); return;
	protected void updateBracketHighlight(int newCaretPosition)	{		try		{			if(newCaretPosition != 0)			{				newCaretPosition--;				Segment lineSegment = painter.currentLine;				getText(newCaretPosition,1,lineSegment);				char ch = lineSegment.array[lineSegment.offset];				int[] match;				switch(ch)				{				case '(':					match = TextUtilities.locateBracketForward(						document,newCaretPosition,'(',')');					bracket = ')';					break;				case ')':					match = TextUtilities.locateBracketBackward(						document,newCaretPosition,'(',')');					bracket = '(';					break;				case '[':					match = TextUtilities.locateBracketForward(						document,newCaretPosition,'[',']');					bracket = ']';					break;				case ']':					match = TextUtilities.locateBracketBackward(						document,newCaretPosition,'[',']');					bracket = '[';					break;				case '{':					match = TextUtilities.locateBracketForward(						document,newCaretPosition,'{','}');					bracket = '}';					break;				case '}':					match = TextUtilities.locateBracketBackward(						document,newCaretPosition,'{','}');					bracket = '{';					break;				default:					match = null;					bracket = '\0';					break;				}				if(match != null)				{					bracketLine = match[0];					bracketPosition = match[1];					return;				}			}		}		catch(BadLocationException bl)		{			bl.printStackTrace();		}		bracketLine = bracketPosition = -1;	}