Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
Patch for auto cancel indent when type 'public:' or 'protected:' or 'private:'
Loaden:
When type ':', determine whether the need to add a new line.
--- Code: ---Index: src/plugins/codecompletion/codecompletion.cpp
===================================================================
--- src/plugins/codecompletion/codecompletion.cpp (revision 6204)
+++ src/plugins/codecompletion/codecompletion.cpp (working copy)
@@ -2080,6 +2080,33 @@
}
}
+ if (event.GetEventType() == wxEVT_SCI_CHARADDED)
+ {
+ if (event.GetKey() == _T(':'))
+ {
+ if (control->AutoCompActive()) control->AutoCompCancel();
+ wxString text = control->GetCurLine().Trim(false);
+ text = text.Remove(text.Find(_T(':'), true));
+ text = text.Trim();
+ if (text == _T("public") || text == _T("protected") || text == _T("private"))
+ {
+ int curLine = control->GetCurrentLine();
+ control->GotoPos(control->PositionFromLine(curLine));
+ control->BackTab();
+ const int column = control->GetColumn(control->GetCurrentPos());
+ control->GotoPos(control->GetLineEndPosition(curLine));
+ if (control->GetLineCount() > curLine)
+ {
+ if (control->GetColumn(control->GetLineIndentPosition(curLine + 1)) == column)
+ {
+ control->NewLine();
+ control->Tab();
+ }
+ }
+ }
+ }
+ }
+
Parser* parser = m_NativeParser.GetParserPtr();
if ( parser && parser->Options().whileTyping
&& ( (event.GetModificationType() & wxSCI_MOD_INSERTTEXT)
--- End code ---
[attachment deleted by admin]
thynson:
In my opinion, a label(included'public:', 'private:' and 'protected')should not be indented to keep it easy to be find.
I think the parser could do it like this way: when the ENTER is pressed, check the prev line, if there is just a label, then cancel indent.
BTW, I think when we typed a '{' or '}', the indent should be adjusted automatically. For example, when we may write
for(vector<int>::iterator i = v.begin();
i != v.end();
++i)
Then we would type ENTER, and the CodeBlocks will generate '{' and '}' for us, but it looks like that:
for(vector<int>::iterator i = v.begin();
i != v.end();
++i)
{
}
This is not what we want. Could someone solve this problem?
Loaden:
--- Quote from: thynson on May 29, 2010, 01:08:56 pm ---In my opinion, a label(included'public:', 'private:' and 'protected')should not be indented to keep it easy to be find.
I think the parser could do it like this way: when the ENTER is pressed, check the prev line, if there is just a label, then cancel indent.
BTW, I think when we typed a '{' or '}', the indent should be adjusted automatically. For example, when we may write
for(vector<int>::iterator i = v.begin();
i != v.end();
++i)
Then we would type ENTER, and the CodeBlocks will generate '{' and '}' for us, but it looks like that:
for(vector<int>::iterator i = v.begin();
i != v.end();
++i)
{
}
This is not what we want. Could someone solve this problem?
--- End quote ---
The feature added in cc_branch. :lol:
danselmi:
I still believe that this code should go to cbEditor, to where the other indent related code resides! Am I wrong?
MortenMacFly:
--- Quote from: danselmi on May 31, 2010, 08:40:00 pm ---I still believe that this code should go to cbEditor, to where the other indent related code resides!
--- End quote ---
That is actually true. I'd second that.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version