Index: src/plugins/codecompletion/codecompletion.cpp
===================================================================
--- src/plugins/codecompletion/codecompletion.cpp (revision 6196)
+++ src/plugins/codecompletion/codecompletion.cpp (working copy)
@@ -2106,6 +2106,29 @@
}
}
}
+
+ if (event.GetEventType() == wxEVT_SCI_CHARADDED)
+ {
+ wxChar ch = event.GetKey();
+ if (ch == _T(':'))
+ {
+ if (control->AutoCompActive()) control->AutoCompCancel();
+ int origPos = control->GetCurrentPos() - 1;
+ int start = control->WordStartPosition(origPos, true);
+ int end = control->WordEndPosition(origPos, true);
+ const wxString text = control->GetTextRange(start, end);
+ if (text == _T("public") || text == _T("protected") || text == _T("private"))
+ {
+ control->CharLeft();
+ control->WordLeft();
+ control->BackTab();
+ control->WordRight();
+ control->CharRight();
+ control->NewLine();
+ control->Tab();
+ }
+ }
+ }
Parser* parser = m_NativeParser.GetParserPtr();
if ( parser && parser->Options().whileTyping
OLD:
class A
{
public:
void test()
{
int i = 0;
}
private:
int good()
{
}
protected:
};
AFTER PATCH:
class A
{
public:
void test()
{
int i = 0;
}
private:
int good()
{
}
protected:
};
EDIT: support 'case'/ 'default'.
[attachment deleted by admin]
A better implementation, to prevent mistaken judgments.
Index: src/plugins/codecompletion/codecompletion.cpp
===================================================================
--- src/plugins/codecompletion/codecompletion.cpp (revision 6195)
+++ src/plugins/codecompletion/codecompletion.cpp (working copy)
@@ -2106,6 +2106,26 @@
}
}
}
+
+ 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->GetLineIndentPosition(curLine));
+ control->BackTab();
+ control->GotoPos(control->GetLineEndPosition(curLine));
+ control->NewLine();
+ control->Tab();
+ }
+ }
+ }
Parser* parser = m_NativeParser.GetParserPtr();
if ( parser && parser->Options().whileTyping
[attachment deleted by admin]
I believe this code fits better somewhere in void cbEditor::OnEditorCharAdded(wxScintillaEvent& event)
since all other indent related code is there too.
Additionally it should check the currently set lexer and needs to be configurable.
When type ':', determine whether the need to add a new line.
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)
[attachment deleted by admin]