Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

about bracecompletion

<< < (3/6) > >>

killerbot:
updated my copy with your change.

I already have a first point of feedback :

the following no longer works :

--- Code: ---if( --> if()
--- End code ---
then I change this into:

--- Code: ---if(true &&)
--- End code ---
All is still OK, but now it goes wrong

--- Code: ---if(true && ()
--- End code ---
--> I don't get the closing one !!! And in this case I do want it.

blueshake:
hi,killerbot,it work for me,
see my attachment.
when i type if( and closing ) will automaticlly add.

--- Code: ---if(true && |)
--- End code ---
in the "|" positon ,i type ( and it work too.
can you just give me more informations?

[attachment deleted by admin]

killerbot:
I just tried it again, and again I end up with :

--- Code: ---if(true && ()
--- End code ---

could you copy paste here the codesnippet you have of the method you changed, so not as a patch, but just plain code. Maybe I didn't apply your patch correctly ...

blueshake:
hi,killerbot,i paste the the codes,and upload the file as a attachment.


--- Code: ---    void DoBraceCompletion(const wxChar& ch)
    {
        cbStyledTextCtrl* control = m_pOwner->GetControl();
        int pos = control->GetCurrentPos();
        int style = control->GetStyleAt(pos);
        if ( IsComment(style) || IsPreprocessor(style) )
            return;
        if ( ch == _T('\'') )
        {
            if ( control->GetCharAt(pos) == ch && pos > 1 && control->GetCharAt(pos-2) != _T('\\') )
            {
                control->DeleteBack();
                control->GotoPos(pos);
            }
            else
            {
                if ( control->GetCharAt(pos-2) == _T('\\') || IsCharacterOrString(style) )
                    return;
                control->AddText(ch);
                control->GotoPos(pos);
            }
            return;
        }
        if ( ch == _T('"') )
        {
            if (control->GetCharAt(pos) == ch && pos > 1 && control->GetCharAt(pos-2) != _T('\\') )
            {
                control->DeleteBack();
                control->GotoPos(pos);
            }
            else
            {
                if ( control->GetCharAt(pos-2) == _T('\\') || IsCharacter(style) )
                    return;
                control->AddText(ch);
                control->GotoPos(pos);
            }
            return;
        }
        if ( IsCharacterOrString(style) )
            return;
        const wxString leftBrace(_T("([{"));
        const wxString rightBrace(_T(")]}"));
        int index = leftBrace.find(ch);
        const wxString unWant(_T(")\n\r\t\b "));
        if (index != wxNOT_FOUND && unWant.find(control->GetCharAt(pos)) != wxNOT_FOUND)
        {
                control->AddText(rightBrace.GetChar(index));
                control->GotoPos(pos);
                if (ch == _T('{'))
                {
                    const wxRegEx reg(_T("^[ \t]*{}[ \t]*"));
                    if (reg.Matches(control->GetCurLine()))
                    {
                        control->NewLine();
                        control->GotoPos(pos);
                        control->NewLine();
                        return;
                    }
                }
        }
        else
        {
            index = rightBrace.find(ch);
            if (index != wxNOT_FOUND)
            {
                if (control->GetCharAt(pos) == ch)
                {
                    control->DeleteBack();
                    control->GotoPos(pos);
                    return;
                }
            }
        }
    }
--- End code ---

[attachment deleted by admin]

killerbot:
I can confirm it works now.
I didn't have the ')' in :

--- Code: ---const wxString unWant(_T(")\n\r\t\b "));
--- End code ---
   :oops:

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version