mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-19 22:04:01 -06:00
A++ inserting function now shows popup instead of inserting parameters into text
git-svn-id: svn://ultimatepp.org/upp/trunk@662 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
a65e1b76b3
commit
470473a3f9
10 changed files with 161 additions and 33 deletions
|
|
@ -21,7 +21,7 @@ topic "class SqlRaw : public String, private AssignValueTypeNo<SqlRaw, SQLRAW_V>
|
|||
[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],
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<CppItemInfo>(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<String> 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);
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ struct ItemTextPart : Moveable<ItemTextPart> {
|
|||
int len;
|
||||
int type;
|
||||
int ii;
|
||||
int pari;
|
||||
};
|
||||
|
||||
Vector<ItemTextPart> ParseItemNatural(const String& name, const CppItem& m, const char *natural);
|
||||
|
|
@ -187,6 +188,8 @@ struct ReferenceDlg : WithReferenceDlgLayout<TopWindow>, CodeBrowser {
|
|||
#define IMAGECLASS TopicImg
|
||||
#include <Draw/iml_header.h>
|
||||
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -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<ItemTextPart> 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<String> qt = Split(m.qptype, sSplitT, false);
|
||||
Vector<String> 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;
|
||||
|
|
|
|||
|
|
@ -75,10 +75,13 @@ Vector<ItemTextPart> ParseItemNatural(const String& name, const CppItem& m, cons
|
|||
<< ", tname: " << m.tname << ", m.ctname: " << m.ctname);
|
||||
Vector<ItemTextPart> 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<ItemTextPart> 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++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,6 +202,7 @@ void AssistEditor::SelectionChanged()
|
|||
{
|
||||
CodeEditor::SelectionChanged();
|
||||
SyncCursor();
|
||||
SyncParamInfo();
|
||||
}
|
||||
|
||||
void AssistEditor::SearchIndex()
|
||||
|
|
|
|||
63
uppsrc/ide/ParamInfo.cpp
Normal file
63
uppsrc/ide/ParamInfo.cpp
Normal file
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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<IndexItem> {
|
||||
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();
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ file
|
|||
t.cpp,
|
||||
Cpp.cpp,
|
||||
Assist.cpp,
|
||||
ParamInfo.cpp,
|
||||
Navigator.cpp,
|
||||
Annotations.cpp,
|
||||
Virtuals.cpp,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue