Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!
Index: src/sdk/cbeditor.cpp===================================================================--- src/sdk/cbeditor.cpp (revision 6196)+++ src/sdk/cbeditor.cpp (working copy)@@ -414,6 +414,21 @@ 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() && --keyLine);++ if (text == _T("class") || text == _T("struct"))+ control->InsertText(control->GetLineEndPosition(curLine), _T(";"));+ const wxRegEx reg(_T("^[ \t]*{}[ \t]*")); if (reg.Matches(control->GetCurLine())) {
class A {|}class B{ |}struct A {|}struct B{ |}
class A {|};class B{ |};struct A {|};struct B{ |};
{|}or{ |}
Index: src/sdk/cbeditor.cpp===================================================================--- src/sdk/cbeditor.cpp (revision 6196)+++ src/sdk/cbeditor.cpp (working copy)@@ -414,6 +414,21 @@ 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() && --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())) {
{ | }
What happens in my whole file looks like:Code{ | }You don't check for the first line / character in the editor being reached, or am I wrong?!If so, your code my result in an infinite loop, maybe even in a crash.
while (text.IsEmpty() && --keyLine);
Loaden use this for condition below:Codewhile (text.IsEmpty() && --keyLine);Look at the variable: keyLine, when it reaches zero, the loop will break, so, there will never be a infinite loop.
namespace blah{}; ?
Quote from: ollydbg on March 24, 2010, 04:24:40 pmLoaden use this for condition below:Codewhile (text.IsEmpty() && --keyLine);Look at the variable: keyLine, when it reaches zero, the loop will break, so, there will never be a infinite loop.Indeed. I missed that. C++ style calculations inside an if/while statement - I don't allow such in my coding style, so I am not used to it.
class A{
Please test this demo:Codeclass A{If not use "do/while", when type '{', it can not judge the class type.
do { int keyPos = control->GetLineIndentPosition(keyLine); int start = control->WordStartPosition(keyPos, true); int end = control->WordEndPosition(keyPos, true); text = control->GetTextRange(start, end) text.Trim(); --keyLine; } while ( text.IsEmpty() && (keyLine>0) );
Strange. I did not apply in my copy yet, but what if you use:Code do { int keyPos = control->GetLineIndentPosition(keyLine); int start = control->WordStartPosition(keyPos, true); int end = control->WordEndPosition(keyPos, true); text = control->GetTextRange(start, end) text.Trim(); --keyLine; } while ( text.IsEmpty() && (keyLine>0) );Notice: This is untested.
But noone will write this kind of code, search to the previous line is enough.
class A : public B1, public B2, public B3, public B4{ |};
namespace my{}; <--- here the semicolon is not needed!