A++ - param info tip improved to support nested assists, Esc closes the tip

git-svn-id: svn://ultimatepp.org/upp/trunk@665 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2008-11-23 15:30:09 +00:00
parent 803866298a
commit 29ac096dcc
4 changed files with 69 additions and 36 deletions

View file

@ -86,7 +86,7 @@ AssistEditor::AssistEditor()
cachedpos = INT_MAX;
cachedln = -1;
param_line = -1;
parami = 0;
param_info.Margins(2);
param_info.Background(SWhite());
@ -460,7 +460,6 @@ void AssistEditor::AssistInsert()
{
if(assist.IsCursor()) {
const CppItemInfo& f = ValueTo<CppItemInfo>(assist.Get(0));
param_item = f;
String txt = f.name;
int l = txt.GetCount();
int pl = txt.GetCount();
@ -489,7 +488,7 @@ void AssistEditor::AssistInsert()
int n = Paste(ToUnicode(txt, CHARSET_WIN1250));
if(!thisback && f.kind >= FUNCTION && f.kind <= INLINEFRIEND) {
SetCursor(GetCursor() - 1);
StartParamInfo();
StartParamInfo(f);
if(f.qptype.GetCount() == 0)
SetCursor(GetCursor() + 1);
}
@ -996,3 +995,20 @@ void Ide::IdeGotoCodeRef(String coderef)
if(q >= 0)
JumpToDefinition(n, q);
}
bool AssistEditor::Esc()
{
bool r = false;
if(assist.IsOpen()) {
CloseAssist();
r = true;
}
if(param_info.IsOpen()) {
for(int i = 0; i < PARAMN; i++)
param[i].line = -1;
param_info.Close();
r = true;
}
return r;
}

View file

@ -197,10 +197,8 @@ bool Ide::IsBottomShown() const
void Ide::SwapBottom()
{
if(editor.assist.IsOpen()) {
editor.CloseAssist();
if(editor.Esc())
return;
}
if(editor.IsFindOpen())
editor.FindClose();
else

View file

@ -3,29 +3,36 @@
void AssistEditor::SyncParamInfo()
{
String qtf;
int i = GetCursorLine();
if(param_line >= 0 && param_line < GetLineCount() && i >= param_line && i < param_line + 10
&& param_editfile == theide->editfile && GetWLine(param_line).StartsWith(param_test)) {
int c = GetCursor();
i = GetPos(param_line) + param_test.GetCount();
if(c >= i) {
int par = 0;
int pari = 0;
for(;;) {
int ch = Ch(i++);
if(i > c) {
qtf = "[A1 " + DecoratedItem(param_item.name, param_item, param_item.natural, pari);
break;
}
if(ch == ')') {
if(par <= 0)
int mpar = INT_MAX;
for(int q = 0; q < PARAMN; q++) {
ParamInfo& m = param[q];
int i = GetCursorLine();
if(m.line >= 0 && m.line < GetLineCount() && i >= m.line && i < m.line + 10
&& m.editfile == theide->editfile && GetWLine(m.line).StartsWith(m.test)) {
int c = GetCursor();
i = GetPos(m.line) + m.test.GetCount();
if(c >= i) {
int par = 0;
int pari = 0;
for(;;) {
int ch = Ch(i++);
if(i > c) {
if(par < mpar) {
qtf = "[A1 " + DecoratedItem(m.item.name, m.item, m.item.natural, pari);
mpar = par;
}
break;
par--;
}
if(ch == ')') {
if(par <= 0)
break;
par--;
}
if(ch == '(')
par++;
if(ch == ',' && par == 0)
pari++;
}
if(ch == '(')
par++;
if(ch == ',' && par == 0)
pari++;
}
}
}
@ -53,11 +60,14 @@ void AssistEditor::SyncParamInfo()
}
}
void AssistEditor::StartParamInfo()
void AssistEditor::StartParamInfo(const CppItem& m)
{
int x = GetCursor();
param_line = GetLinePos(x);
param_test = GetWLine(param_line).Mid(0, x);
param_editfile = theide->editfile;
ParamInfo& f = param[parami];
f.line = GetLinePos(x);
f.test = GetWLine(f.line).Mid(0, x);
f.item = m;
f.editfile = theide->editfile;
SyncParamInfo();
parami = (parami + 1) % PARAMN;
}

View file

@ -407,11 +407,18 @@ struct AssistEditor : CodeEditor {
int cachedln;
RichTextCtrl param_info;
int param_line;
WString param_test;
CppItem param_item;
String param_qtf;
String param_editfile;
struct ParamInfo {
int line;
WString test;
CppItem item;
String editfile;
ParamInfo() { line = -1; }
};
enum { PARAMN = 16 };
ParamInfo param[PARAMN];
int parami;
void PopUpAssist(bool auto_insert = false);
void CloseAssist();
@ -422,7 +429,7 @@ struct AssistEditor : CodeEditor {
bool InCode();
void SyncParamInfo();
void StartParamInfo();
void StartParamInfo(const CppItem& m);
void Complete();
@ -482,6 +489,8 @@ struct AssistEditor : CodeEditor {
void OpenTopic(String topic, String create, bool before);
void NewTopic(String group, String coderef);
bool Esc();
void SerializeNavigator(Stream& s);
typedef AssistEditor CLASSNAME;