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

about bracecompletion

<< < (2/6) > >>

blueshake:
I think mariocup is right.
so these codes can be changed to be so.add a ) will work.

--- Code: ---const wxString unWant(_T(")\n\r\t\b "));
--- End code ---
see my attachment.
snap1 is new one , the {} will stay in the some line.
snap3 is old one, the {} will stay in twol line.
snap2 is example ,the next char is m ,so bracecompletion will not work.it will work if next one is  enter whitesapce , tab or ) (new added).

[attachment deleted by admin]

killerbot:
and what will happen in your code when :


--- Code: ---int main
{

--- End code ---
Will the closing '}' end up on the next line ? I think it should.

blueshake:
yes,it will work like below.

--- Code: ---int main
{
}
--- End code ---

hi, killerbot, have any plan to on this patch.

killerbot:
I just applied it to my local copy, and will test it out.

blueshake:
nice to hear that ,
here is my new patch.
the opening { work like this now ,it is more like what visual assist do.
see the attachment.

--- Code: ---Index: cbeditor.cpp
===================================================================
--- cbeditor.cpp (revision 5731)
+++ cbeditor.cpp (working copy)
@@ -331,19 +331,25 @@
         }
         if ( IsCharacterOrString(style) )
             return;
-        wxString leftBrace(_T("([{"));
-        wxString rightBrace(_T(")]}"));
+        const wxString leftBrace(_T("([{"));
+        const wxString rightBrace(_T(")]}"));
         int index = leftBrace.find(ch);
-        if (index != wxNOT_FOUND)
+        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('{'))
-            {
-                control->NewLine();
+                control->AddText(rightBrace.GetChar(index));
                 control->GotoPos(pos);
-                return;
-            }
+                if (ch == _T('{'))
+                {
+                    const wxRegEx reg(_T("^[ \t]*{}[ \t]*"));
+                    if (reg.Matches(control->GetCurLine()))
+                    {
+                        control->NewLine();
+                        control->GotoPos(pos);
+                        control->NewLine();
+                        return;
+                    }
+                }
         }
         else
         {

--- End code ---


[attachment deleted by admin]

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version