ide: New assist features

git-svn-id: svn://ultimatepp.org/upp/trunk@11190 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2017-06-21 21:16:17 +00:00
parent ee25a03523
commit df1ca3648a
7 changed files with 47 additions and 8 deletions

View file

@ -64,7 +64,7 @@ struct PPMacro : Moveable<PPMacro> {
};
struct PPFile { // contains "macro extract" of file, only info about macros defined and namespaces
Time filetime;
Time filetime;
Array<PPItem> item;
Index<String> includes;
Vector<String> keywords;

View file

@ -32,6 +32,15 @@ Value AssistEditor::AssistItemConvert::Format(const Value& q) const
return RawToValue(empty);
}
void AssistEditor::SyncNavigatorPlacement()
{
int sz = navigatorframe.GetSize();
if(navigator_right)
navigatorframe.Right(navigatorpane, sz);
else
navigatorframe.Left(navigatorpane, sz);
}
AssistEditor::AssistEditor()
{
assist_convert.editor = this;
@ -50,6 +59,7 @@ AssistEditor::AssistEditor()
auto_assist = auto_check = true;
commentdp = false;
SyncNavigatorPlacement();
navigatorframe.Left(navigatorpane, HorzLayoutZoom(140));
navigating = false;
@ -1031,7 +1041,7 @@ void AssistEditor::SyncNavigator()
Search();
SyncCursor();
}
navigatorframe.Show(navigator && theide && !theide->IsEditorMode());
SyncNavigatorShow();
}
void AssistEditor::SelectionChanged()
@ -1043,7 +1053,7 @@ void AssistEditor::SelectionChanged()
void AssistEditor::SerializeNavigator(Stream& s)
{
int version = 4;
int version = 5;
s / version;
s % navigatorframe;
s % navigator;
@ -1053,5 +1063,10 @@ void AssistEditor::SerializeNavigator(Stream& s)
}
if(version >= 4)
s % navigator_splitter;
if(version >= 5)
s % navigator_right;
Navigator(navigator);
if(s.IsLoading())
SyncNavigatorPlacement();
}

View file

@ -38,6 +38,8 @@ struct Navigator {
enum KindEnum { KIND_LINE = 123, KIND_NEST, KIND_FILE };
struct ScopeDisplay : Display {
Navigator *navigator;
int DoPaint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const;
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const;
virtual Size GetStdSize(const Value& q) const;
@ -80,6 +82,8 @@ struct Navigator {
ArrayCtrl navlines;
EditString search;
ScopeDisplay scope_display;
void TriggerSearch();
void NavGroup(bool local);
void Search();
@ -176,6 +180,8 @@ struct AssistEditor : CodeEditor, Navigator {
String current_type;
static Ptr<Ctrl> assist_ptr;
bool navigator_right = true;
void PopUpAssist(bool auto_insert = false);
@ -249,6 +255,7 @@ struct AssistEditor : CodeEditor, Navigator {
void SyncNavigatorShow();
void SyncNavigator();
void SerializeNavigator(Stream& s);
void SyncNavigatorPlacement();
Event<int> WhenFontScroll;

View file

@ -70,8 +70,9 @@ int PaintFileName(Draw& w, const Rect& r, String h, Color ink)
Navigator::Navigator()
: navidisplay(litem)
{
scope_display.navigator = this;
scope.NoHeader();
scope.AddColumn().SetDisplay(Single<ScopeDisplay>());
scope.AddColumn().SetDisplay(scope_display);
scope.NoWantFocus();
scope.WhenSel = THISBACK(Scope);
scope.WhenLeftDouble = THISBACK(ScopeDblClk);
@ -118,6 +119,8 @@ void Navigator::SyncCursor()
navigating = false;
}
SyncLines();
if(scope.IsCursor())
scope.RefreshRow(scope.GetCursor());
}
void Navigator::SyncLines()
@ -631,18 +634,29 @@ int Navigator::ScopeDisplay::DoPaint(Draw& w, const Rect& r, const Value& q, Col
{
w.DrawRect(r, paper);
if(IsNull(q)) {
const char *txt = "All";
const char *txt = "* ";
int x = 0;
w.DrawText(r.left, r.top, txt, StdFont().Bold().Italic(),
style & CURSOR ? ink : HighlightSetup::GetHlStyle(HighlightSetup::INK_KEYWORD).color);
return GetTextSize(txt, StdFont().Bold().Italic()).cx;
x += GetTextSize(txt, StdFont().Bold().Italic()).cx;
int ii = navigator->list.GetCursor();
if(ii >= 0 && ii < navigator->litem.GetCount()) {
const NavItem& m = *navigator->litem[ii];
String txt = m.nest;
if(IsCppCode(m.kind))
txt << "::" << m.name;
w.DrawText(r.left + x, r.top, txt, StdFont().Bold(), ink);
x += GetTextSize(txt, StdFont().Bold()).cx;
}
return x;
}
String h = q;
if(*h == '\xff')
return PaintFileName(w, r, h, ink);
else
h = FormatNest(h);
w.DrawText(r.left, r.top, h, StdFont().Bold(), ink);
return GetTextSize(h, StdFont().Bold()).cx;
w.DrawText(r.left, r.top, h, StdFont(), ink);
return GetTextSize(h, StdFont()).cx;
}
void Navigator::ScopeDisplay::Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const

View file

@ -473,6 +473,7 @@ void Ide::SetupFormat() {
(assist.assist, editor.auto_assist)
(assist.rescan, auto_rescan)
(assist.check, auto_check)
(assist.navigator_right, editor.navigator_right)
(ide.showtime, showtime)
(ide.show_status_bar, show_status_bar)

View file

@ -585,6 +585,7 @@ LAYOUT(SetupAssistLayout, 532, 212)
ITEM(Option, mark_lines, SetLabel(t_("Mark lines with errors, warnings and changes")).LeftPosZ(4, 252).TopPosZ(104, 16))
ITEM(Option, barline, SetLabel(t_("Highlight line in the left bar")).LeftPosZ(4, 252).TopPosZ(124, 16))
ITEM(Option, qtfsel, SetLabel(t_("QTF designer edits selection")).LeftPosZ(4, 252).TopPosZ(144, 16))
ITEM(Option, navigator_right, SetLabel(t_("Place navigator to the right")).LeftPosZ(4, 252).TopPosZ(164, 16))
ITEM(Option, header_guards, SetLabel(t_("Insert guards to new headers")).LeftPosZ(272, 252).TopPosZ(4, 16))
ITEM(Switch, insert_include, SetLabel(t_("No #include in new sources\n#include first\n#include previous")).LeftPosZ(272, 252).TopPosZ(24, 52))
END_LAYOUT

View file

@ -48,6 +48,7 @@ void Ide::SetupEditor()
if(p != HELPNAME)
p = GetActiveFilePath();
SetupEditor(f.font, f.highlight, p);
editor.SyncNavigatorPlacement();
}
void Ide::FileCursor()