mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
ide: Complete identifier improved
git-svn-id: svn://ultimatepp.org/upp/trunk@8579 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
1fdc10a781
commit
e895fc2adf
4 changed files with 35 additions and 41 deletions
|
|
@ -540,27 +540,53 @@ void AssistEditor::PopUpAssist(bool auto_insert)
|
|||
popup.Ctrl::PopUp(this, false, false, true);
|
||||
}
|
||||
|
||||
Vector<String> AssistEditor::GetFileIds()
|
||||
bool sILess(const String& a, const String& b)
|
||||
{
|
||||
Index<String> id;
|
||||
return ToUpper(a) < ToUpper(b);
|
||||
}
|
||||
|
||||
void AssistEditor::Complete()
|
||||
{
|
||||
CloseAssist();
|
||||
|
||||
Index<String> ids;
|
||||
int l = GetCursorLine() - 1;
|
||||
while(l >= 0) {
|
||||
String x = GetUtf8Line(l);
|
||||
CParser p(x);
|
||||
while(!p.IsEof())
|
||||
if(p.IsId())
|
||||
id.FindAdd(p.ReadId());
|
||||
ids.FindAdd(p.ReadId());
|
||||
else
|
||||
p.SkipTerm();
|
||||
l--;
|
||||
}
|
||||
return id.PickKeys();
|
||||
}
|
||||
|
||||
Vector<String> id = ids.PickKeys();
|
||||
Upp::Sort(id, sILess);
|
||||
|
||||
void AssistEditor::Complete()
|
||||
{
|
||||
CloseAssist();
|
||||
Vector<String> id = GetFileIds();
|
||||
int c = GetCursor();
|
||||
String q = IdBack(c);
|
||||
if(q.GetCount()) {
|
||||
String h;
|
||||
for(int i = 0; i < id.GetCount(); i++) {
|
||||
String s = id[i];
|
||||
if(s.StartsWith(q)) {
|
||||
if(IsNull(h))
|
||||
h = s;
|
||||
else {
|
||||
s.Trim(min(s.GetCount(), h.GetCount()));
|
||||
for(int j = 0; j < s.GetCount(); j++)
|
||||
if(s[j] != h[j]) {
|
||||
h.Trim(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(h.GetCount() > q.GetCount())
|
||||
Paste(h.Mid(q.GetCount()).ToWString());
|
||||
}
|
||||
for(int i = 0; i < id.GetCount(); i++) {
|
||||
CppItemInfo& f = assist_item.Add();
|
||||
f.name = id[i];
|
||||
|
|
@ -572,34 +598,6 @@ void AssistEditor::Complete()
|
|||
PopUpAssist(true);
|
||||
}
|
||||
|
||||
void AssistEditor::Complete2()
|
||||
{
|
||||
CloseAssist();
|
||||
int c = GetCursor();
|
||||
String q = IdBack(c);
|
||||
if(IsNull(q))
|
||||
return;
|
||||
String h;
|
||||
Vector<String> id = GetFileIds();
|
||||
for(int i = 0; i < id.GetCount(); i++) {
|
||||
String s = id[i];
|
||||
if(s.StartsWith(q)) {
|
||||
if(IsNull(h))
|
||||
h = s;
|
||||
else {
|
||||
s.Trim(min(s.GetCount(), h.GetCount()));
|
||||
for(int j = 0; j < s.GetCount(); j++)
|
||||
if(s[j] != h[j]) {
|
||||
h.Trim(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(h.GetCount() > q.GetCount())
|
||||
Paste(h.Mid(q.GetCount()).ToWString());
|
||||
}
|
||||
|
||||
void AssistEditor::Abbr()
|
||||
{
|
||||
CloseAssist();
|
||||
|
|
|
|||
|
|
@ -186,9 +186,7 @@ struct AssistEditor : CodeEditor, Navigator {
|
|||
void SyncParamInfo();
|
||||
void StartParamInfo(const CppItem& m, int pos);
|
||||
|
||||
Vector<String> GetFileIds();
|
||||
void Complete();
|
||||
void Complete2();
|
||||
void Abbr();
|
||||
|
||||
void Context(Parser& parser, int pos);
|
||||
|
|
|
|||
|
|
@ -103,7 +103,6 @@ KEY(TOGGLEINDEX, "File index", K_CTRL_F12)
|
|||
KEY(SEARCHINDEX, "File index search", K_F12)
|
||||
//KEY2(SEARCHCODE, "Search symbol", K_CTRL_U, K_CTRL_Y|K_SHIFT)
|
||||
KEY(COMPLETE, "Complete identifier with list", K_CTRL_COMMA)
|
||||
KEY(COMPLETE2, "Complete identifier", K_CTRL_M)
|
||||
|
||||
KEY(TOUPPER, "To uppercase", 0)
|
||||
KEY(TOLOWER, "To lowercase", 0)
|
||||
|
|
|
|||
|
|
@ -573,7 +573,6 @@ void Ide::BrowseMenu(Bar& menu)
|
|||
menu.Add(!designer, AK_VIRTUALS, callback(&editor, &AssistEditor::Virtuals));
|
||||
menu.Add(!designer, AK_THISBACKS, callback(&editor, &AssistEditor::Thisbacks));
|
||||
menu.Add(!designer, AK_COMPLETE, callback(&editor, &AssistEditor::Complete));
|
||||
menu.Add(!designer, AK_COMPLETE2, callback(&editor, &AssistEditor::Complete2));
|
||||
menu.Add(!designer, AK_ABBR, callback(&editor, &AssistEditor::Abbr));
|
||||
menu.Add(!designer, "Insert", THISBACK(InsertMenu));
|
||||
menu.MenuSeparator();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue