Пример #1
0
void ctlSQLBox::OnPositionStc(wxStyledTextEvent& event)
{
    int pos = GetCurrentPos();
    wxChar ch = GetCharAt(pos-1);
    int st = GetStyleAt(pos-1);
    int match;


    // Line numbers
    UpdateLineNumber();

    // Clear all highlighting
    BraceBadLight(wxSTC_INVALID_POSITION);

    // Check for braces that aren't in comment styles,
    // double quoted styles or single quoted styles
    if ((ch == '{' || ch == '}' ||
         ch == '[' || ch == ']' ||
         ch == '(' || ch == ')') &&
         st != 2 && st != 6 && st != 7) 
    {
        match = BraceMatch(pos-1);
        if (match != wxSTC_INVALID_POSITION)
            BraceHighlight(pos-1, match);
    }

    // Roll back through the doc and highlight any unmatched braces
    while ((pos--) >= 0)
    {
        ch = GetCharAt(pos);
        st = GetStyleAt(pos);

        if ((ch == '{' || ch == '}' ||
             ch == '[' || ch == ']' ||
             ch == '(' || ch == ')') &&
             st != 2 && st != 6 && st != 7)
        {
            match = BraceMatch(pos);
            if (match == wxSTC_INVALID_POSITION)
            {
                BraceBadLight(pos);
                break;
            }
        }
    }
    
    event.Skip();
}
Пример #2
0
void CodeEditor::HighlightBraces()
{
	int currPos = GetCurrentPos();
	int newPos = BraceMatch(currPos);
	if (newPos == wxSCI_INVALID_POSITION)
	{
		if(currPos > 0)
			newPos = BraceMatch(--currPos);
	}

	wxChar ch = GetCharAt(currPos);
	if (ch == wxT('{') || ch == wxT('[') || ch == wxT('(') ||
		ch == wxT('}') || ch == wxT(']') || ch == wxT(')'))
	{
		if (newPos != wxSCI_INVALID_POSITION)
		{
			BraceHighlight(currPos, newPos);
		}
		else
		{
			BraceBadLight(currPos);
		}
	}
	else BraceHighlight(-1, -1);

	Refresh(false);
}
Пример #3
0
void Edit::OnBraceMatch (wxCommandEvent &WXUNUSED(event)) {
    int min = GetCurrentPos ();
    int max = BraceMatch (min);
    if (max > (min+1)) {
        BraceHighlight (min+1, max);
        SetSelection (min+1, max);
    }else{
        BraceBadLight (min);
    }
}