diff --git a/uppsrc/Sql/src.tpp/SqlRaw$en-us.tpp b/uppsrc/Sql/src.tpp/SqlRaw$en-us.tpp index 3d7031ecc..0f4377dad 100644 --- a/uppsrc/Sql/src.tpp/SqlRaw$en-us.tpp +++ b/uppsrc/Sql/src.tpp/SqlRaw$en-us.tpp @@ -21,7 +21,7 @@ topic "class SqlRaw : public String, private AssignValueTypeNo [2 $$19,0#53580023442335529039900623488521:gap] [C2 $$20,20#70211524482531209251820423858195:class`-nested] [b50;2 $$21,21#03324558446220344731010354752573:Par] -[i448;a25;kKO9; $$22,0#37138531426314131252341829483380:structitem] +[i448;a25;kKO9;2 $$22,0#37138531426314131252341829483380:structitem] [0 $$23,0#96390100711032703541132217272105:end] [{_}%EN-US [s22;:SqlRaw`:`:class:%- [@(0.0.255) class]_[* SqlRaw]_:_[@(0.0.255) public]_[*@3 String], diff --git a/uppsrc/ide/Annotations.cpp b/uppsrc/ide/Annotations.cpp index 75db9a33f..0fb8ad619 100644 --- a/uppsrc/ide/Annotations.cpp +++ b/uppsrc/ide/Annotations.cpp @@ -118,7 +118,7 @@ void AssistEditor::SyncAnnotationPopup() int y = r.top - h - 16; if(y < GetWorkArea().top) y = r.bottom; - annotation_popup.SetRect(r.left, y, 600, h + 16); + annotation_popup.SetRect(r.left, y, 600, h + 24); annotation_popup.Ctrl::PopUp(this, false, false, true); } diff --git a/uppsrc/ide/Assist.cpp b/uppsrc/ide/Assist.cpp index 1190c1569..cfb7fb800 100644 --- a/uppsrc/ide/Assist.cpp +++ b/uppsrc/ide/Assist.cpp @@ -81,6 +81,17 @@ AssistEditor::AssistEditor() annotation_popup.Margins(6); thisback = false; + + cachedpos = INT_MAX; + cachedln = -1; + + param_line = -1; + + param_info.Margins(2); + param_info.Background(SWhite()); + param_info.SetFrame(BlackFrame()); + param_info.BackPaint(); + param_info.NoSb(); } int CppItemInfoOrder(const Value& va, const Value& vb) { @@ -108,9 +119,27 @@ String AssistEditor::ReadIdBack(int q) return id; } +void AssistEditor::DirtyFrom(int line) +{ + if(line >= cachedln) { + cachedpos = INT_MAX; + cachedline.Clear(); + cachedln = -1; + } + CodeEditor::DirtyFrom(line); +} + int AssistEditor::Ch(int i) { - return i >= 0 && i < GetLength() ? GetChar(i) : 0; + if(i >= 0 && i < GetLength()) { + if(i < cachedpos || i - cachedpos >= cachedline.GetCount()) { + cachedln = GetLine(i); + cachedline = GetWLine(cachedln); + cachedpos = GetPos(cachedln); + } + return cachedline[i - cachedpos]; + } + return 0; } int AssistEditor::ParsBack(int q) @@ -430,30 +459,12 @@ void AssistEditor::AssistInsert() { if(assist.IsCursor()) { const CppItemInfo& f = ValueTo(assist.Get(0)); + param_item = f; String txt = f.name; int l = txt.GetCount(); int pl = txt.GetCount(); - if(!thisback) { - if(f.kind >= FUNCTION && f.kind <= INLINEFRIEND) { - txt << '('; - pl = l = txt.GetCount(); - if(IsNull(f.param)) - l++; - else { - Vector p = Split(f.param, ';', false); - for(int i = 0; i < p.GetCount(); i++) { - if(i) { - txt << (inbody ? (char)184 : ','); - txt << ' '; - } - txt << p[i]; - if(i == 0) - pl = txt.GetCount(); - } - } - txt << ')'; - } - } + if(!thisback && f.kind >= FUNCTION && f.kind <= INLINEFRIEND) + txt << "()"; int cl = GetCursor(); int ch = cl; while(iscid(Ch(cl - 1))) @@ -475,6 +486,13 @@ void AssistEditor::AssistInsert() } } int n = Paste(ToUnicode(txt, CHARSET_WIN1250)); + if(!thisback && f.kind >= FUNCTION && f.kind <= INLINEFRIEND) { + SetCursor(GetCursor() - 1); + StartParamInfo(); + if(f.qptype.GetCount() == 0) + SetCursor(GetCursor() + 1); + } + else if(thisback) { if(thisbackn) SetCursor(GetCursor() - 1); diff --git a/uppsrc/ide/Browser/Browser.h b/uppsrc/ide/Browser/Browser.h index b15c1c4c8..764e3f09a 100644 --- a/uppsrc/ide/Browser/Browser.h +++ b/uppsrc/ide/Browser/Browser.h @@ -77,6 +77,7 @@ struct ItemTextPart : Moveable { int len; int type; int ii; + int pari; }; Vector ParseItemNatural(const String& name, const CppItem& m, const char *natural); @@ -187,6 +188,8 @@ struct ReferenceDlg : WithReferenceDlgLayout, CodeBrowser { #define IMAGECLASS TopicImg #include +String DecoratedItem(const String& name, const CppItem& m, const char *natural, int pari = INT_MIN); + int CharFilterID(int c); bool ParseTopicFileName(const String& fn, String& topic, int& lang); @@ -307,7 +310,7 @@ protected: void Tools(Bar& bar); void Label(String&); - String CreateQtf(const String& item, const String& name, const CppItem& m, bool onlyhdr = false); +// String CreateQtf(const String& item, const String& name, const CppItem& m, bool onlyhdr = false); void InsertItem(); void FindBrokenRef(); diff --git a/uppsrc/ide/Browser/CodeRef.cpp b/uppsrc/ide/Browser/CodeRef.cpp index 25b34946f..dd8a58796 100644 --- a/uppsrc/ide/Browser/CodeRef.cpp +++ b/uppsrc/ide/Browser/CodeRef.cpp @@ -172,19 +172,23 @@ bool IsCodeRefType(const String& type) return CodeBase().Find(type) >= 0; } -String DecoratedItem(const String& name, const CppItem& m, const char *natural) +String DecoratedItem(const String& name, const CppItem& m, const char *natural, int pari) { String qtf = "[%00-00K "; Vector n = ParseItemNatural(name, m, natural); - if(m.virt) - qtf << "[@B virtual] "; - if(m.kind == CLASSFUNCTION || m.kind == CLASSFUNCTIONTEMPLATE) - qtf << "[@B static] "; + if(pari < 0) { + if(m.virt) + qtf << "[@B virtual] "; + if(m.kind == CLASSFUNCTION || m.kind == CLASSFUNCTIONTEMPLATE) + qtf << "[@B static] "; + } Vector qt = Split(m.qptype, sSplitT, false); Vector tt = Split(m.qtype, sSplitT, false); for(int i = 0; i < n.GetCount(); i++) { ItemTextPart& p = n[i]; qtf << "["; + if(p.pari == pari) + qtf << "$C"; switch(p.type) { case ITEM_PNAME: qtf << "*"; @@ -206,10 +210,10 @@ String DecoratedItem(const String& name, const CppItem& m, const char *natural) break; default: int q = p.type - ITEM_PTYPE; - if(q >= 0 && q < qt.GetCount() && IsCodeRefType(qt[q])) + if(q >= 0 && q < qt.GetCount() && IsCodeRefType(qt[q]) && pari < 0) qtf << "_^" << qt[q] << '^'; q = p.type - ITEM_TYPE; - if(q >= 0 && q < tt.GetCount() && IsCodeRefType(tt[q])) + if(q >= 0 && q < tt.GetCount() && IsCodeRefType(tt[q]) && pari < 0) qtf << "_^" << tt[q] << '^'; break; } @@ -220,7 +224,7 @@ String DecoratedItem(const String& name, const CppItem& m, const char *natural) return qtf + "]"; } -String TopicEditor::CreateQtf(const String& item, const String& name, const CppItem& m, bool onlyhdr) +String CreateQtf(const String& item, const String& name, const CppItem& m, bool onlyhdr = false) { String qtf; bool str = m.kind == STRUCT || m.kind == STRUCTTEMPLATE; diff --git a/uppsrc/ide/Browser/Item.cpp b/uppsrc/ide/Browser/Item.cpp index 4a9e0a629..d682cf5e7 100644 --- a/uppsrc/ide/Browser/Item.cpp +++ b/uppsrc/ide/Browser/Item.cpp @@ -75,10 +75,13 @@ Vector ParseItemNatural(const String& name, const CppItem& m, cons << ", tname: " << m.tname << ", m.ctname: " << m.ctname); Vector part; bool param = false; + int pari = -1; + int par = 0; while(*s) { ItemTextPart& p = part.Add(); p.pos = (int)(s - ~m.natural); p.type = ITEM_TEXT; + p.pari = pari; int n = 1; if(*s >= '0' && *s <= '9') { while(s[n] >= '0' && s[n] <= '9') @@ -134,6 +137,27 @@ Vector ParseItemNatural(const String& name, const CppItem& m, cons } else { p.type = ITEM_SIGN; + if(pari >= 0) { + if(*s == '(') + par++; + if(*s == ')') { + par--; + if(par < 0) { + p.pari = -1; + pari = -1; + param = false; + } + } + if(*s == ',' && par == 0) { + p.pari = -1; + pari++; + } + } + else + if(*s == '(' && param) { + pari = 0; + par = 0; + } while(s[n] && !iscid(s[n])) n++; } diff --git a/uppsrc/ide/Navigator.cpp b/uppsrc/ide/Navigator.cpp index 72893f5c4..08a3639b2 100644 --- a/uppsrc/ide/Navigator.cpp +++ b/uppsrc/ide/Navigator.cpp @@ -202,6 +202,7 @@ void AssistEditor::SelectionChanged() { CodeEditor::SelectionChanged(); SyncCursor(); + SyncParamInfo(); } void AssistEditor::SearchIndex() diff --git a/uppsrc/ide/ParamInfo.cpp b/uppsrc/ide/ParamInfo.cpp new file mode 100644 index 000000000..a5a771286 --- /dev/null +++ b/uppsrc/ide/ParamInfo.cpp @@ -0,0 +1,63 @@ +#include "ide.h" + +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) + break; + par--; + } + if(ch == '(') + par++; + if(ch == ',' && par == 0) + pari++; + } + } + } + if(param_qtf != qtf) + param_info.SetQTF(qtf); + Rect r = GetLineScreenRect(GetCursorLine()); + int cx = max(GetSize().cx - 30, 300); + int h = param_info.GetHeight(cx); + h = min(h, 550); + int y = r.top - h - 6; + if(y < GetWorkArea().top) + y = r.bottom; + r = RectC(r.left, y, min(param_info.GetWidth(), cx) + 32, h + 6); + if(param_qtf != qtf || r != param_info.GetRect()) { + param_qtf = qtf; + if(IsNull(qtf)) { + if(param_info.IsOpen()) + param_info.Close(); + } + else { + param_info.SetRect(r); + if(!param_info.IsOpen()) + param_info.Ctrl::PopUp(this, false, false, false); + } + } +} + +void AssistEditor::StartParamInfo() +{ + int x = GetCursor(); + param_line = GetLinePos(x); + param_test = GetWLine(param_line).Mid(0, x); + param_editfile = theide->editfile; + SyncParamInfo(); +} diff --git a/uppsrc/ide/ide.h b/uppsrc/ide/ide.h index 59313eb08..b8a89c3f3 100644 --- a/uppsrc/ide/ide.h +++ b/uppsrc/ide/ide.h @@ -367,6 +367,7 @@ struct AssistEditor : CodeEditor { virtual void MouseWheel(Point p, int zdelta, dword keyflags); virtual void LeftDown(Point p, dword keyflags); virtual void SelectionChanged(); + virtual void DirtyFrom(int line); struct IndexItem : Moveable { String text; @@ -401,6 +402,16 @@ struct AssistEditor : CodeEditor { bool inbody; bool thisback, thisbackn; Ide *theide; + WString cachedline; + int cachedpos; + int cachedln; + + RichTextCtrl param_info; + int param_line; + WString param_test; + CppItem param_item; + String param_qtf; + String param_editfile; void PopUpAssist(bool auto_insert = false); void CloseAssist(); @@ -409,6 +420,9 @@ struct AssistEditor : CodeEditor { void SyncAssist(); void AssistInsert(); bool InCode(); + + void SyncParamInfo(); + void StartParamInfo(); void Complete(); diff --git a/uppsrc/ide/ide.upp b/uppsrc/ide/ide.upp index beffc16e3..0e15cbfcf 100644 --- a/uppsrc/ide/ide.upp +++ b/uppsrc/ide/ide.upp @@ -38,6 +38,7 @@ file t.cpp, Cpp.cpp, Assist.cpp, + ParamInfo.cpp, Navigator.cpp, Annotations.cpp, Virtuals.cpp,