Patch #2962 2010-03-29 00:53

loaden

Patch, Auto add a semicolon for '{}' auto-complete
Download
2962-Patch_Auto_add.patch (1.3 KB)
Category
Application::FeatureAdd
Status
Accepted
Close date
2010-10-13 13:00
Assigned to
 
Index: src/sdk/cbeditor.cpp
===================================================================
--- src/sdk/cbeditor.cpp    (revision 6195)
+++ src/sdk/cbeditor.cpp    (working copy)
@@ -414,6 +414,23 @@
             control->GotoPos(pos);
             if (ch == _T('{'))
             {
+                int curLine = control->GetCurrentLine();
+                int keyLine = curLine;
+                wxString text;
+                do
+                {
+                    int keyPos = control->GetLineIndentPosition(keyLine);
+                    int start = control->WordStartPosition(keyPos, true);
+                    int end = control->WordEndPosition(keyPos, true);
+                    text = control->GetTextRange(start, end);
+                }
+                while ((text.IsEmpty() || text == _T("public") || text == _T("protected") || text == _T("private"))
+                       && text != _T("namespace")
+                       && (--keyLine));
+
+                if (text == _T("class") || text == _T("struct") || text == _T("enum") || text == _T("union"))
+                    control->InsertText(control->GetLineEndPosition(curLine), _T(";"));
+
                 const wxRegEx reg(_T("^[ \t]*{}[ \t]*"));
                 if (reg.Matches(control->GetCurLine()))
                 {
loaden 2010-03-29 00:54