From 116a01ebb8ded765376b2ea541349e2542ab74a4 Mon Sep 17 00:00:00 2001 From: Mirek Fidler Date: Fri, 22 Jul 2022 01:15:29 +0200 Subject: [PATCH] developing navigator --- uppsrc/CtrlLib/EditField.cpp | 2 -- uppsrc/ide/Core/Hdepend.cpp | 3 --- uppsrc/ide/Navigator.cpp | 2 -- uppsrc/ide/Navigator2.cpp | 51 +++++++++++++++++++----------------- uppsrc/ide/clang/Indexer.cpp | 15 +++++++++++ uppsrc/ide/clang/clang.cpp | 2 -- uppsrc/ide/clang/clang.h | 2 +- uppsrc/ide/clang/todo.txt | 17 ++++++++++-- uppsrc/ide/ide.cpp | 4 --- 9 files changed, 58 insertions(+), 40 deletions(-) diff --git a/uppsrc/CtrlLib/EditField.cpp b/uppsrc/CtrlLib/EditField.cpp index 6fce07bd4..f816b9d16 100644 --- a/uppsrc/CtrlLib/EditField.cpp +++ b/uppsrc/CtrlLib/EditField.cpp @@ -296,7 +296,6 @@ Color EditField::GetPaper() { bool enabled = IsShowEnabled(); Color paper = GetColorAttr(ATTR_BACKGROUND); - DDUMP(paper); if(IsNull(paper)) paper = enabled && !IsReadOnly() ? (HasFocus() ? style->focus : style->paper) @@ -1081,7 +1080,6 @@ EditField& EditField::SetColor(Color c) EditField& EditField::SetBackground(Color c) { - DDUMP(c); if(GetColorAttr(ATTR_BACKGROUND) != c) { SetColorAttr(ATTR_BACKGROUND, c); Refresh(); diff --git a/uppsrc/ide/Core/Hdepend.cpp b/uppsrc/ide/Core/Hdepend.cpp index 9a234cbe2..be4d899a6 100644 --- a/uppsrc/ide/Core/Hdepend.cpp +++ b/uppsrc/ide/Core/Hdepend.cpp @@ -51,7 +51,6 @@ void Hdepend::AddDependency(const String& file, const String& dep) } void Hdepend::Include(const char *s, Hdepend::Info& info, const String& filedir, bool bydefine) { - DLOG("#include " << s); while(*s == ' ' || *s == '\t') s++; if(iscib(*s)) { // #include MACRO @@ -62,7 +61,6 @@ void Hdepend::Include(const char *s, Hdepend::Info& info, const String& filedir, } else { // normal include String fn = FindIncludeFile(s, filedir); - DDUMP(fn); if(!IsNull(fn)) { info.depend.Add(File(fn)); info.bydefine.Add(bydefine); @@ -87,7 +85,6 @@ static const char *SkipComment(const char *s) { void Hdepend::ScanFile(const String& path, int map_index) { - DDUMP(path); Info& info = map[map_index]; info.depend.Clear(); info.bydefine.Clear(); diff --git a/uppsrc/ide/Navigator.cpp b/uppsrc/ide/Navigator.cpp index 506fc08ff..c0898b208 100644 --- a/uppsrc/ide/Navigator.cpp +++ b/uppsrc/ide/Navigator.cpp @@ -67,8 +67,6 @@ void DrawFileName(Draw& w, const Rect& r, const String& h, Color ink) int PaintFileName(Draw& w, const Rect& r, String h, Color ink) { - if(*h == '\xff') - h.Remove(0, 1); return DrawFileName0(w, r, h, ink, 0); } diff --git a/uppsrc/ide/Navigator2.cpp b/uppsrc/ide/Navigator2.cpp index e5ceaa434..caceaecb5 100644 --- a/uppsrc/ide/Navigator2.cpp +++ b/uppsrc/ide/Navigator2.cpp @@ -352,9 +352,9 @@ void Navigator::NavigatorDisplay::PaintBackground(Draw& w, const Rect& r, const return; const NavItem& m = *item[ii]; bool focuscursor = (style & (FOCUS|CURSOR)) == (FOCUS|CURSOR) || (style & SELECT); - if(findarg(m.kind, KIND_FILE, KIND_NEST) >= 0) - w.DrawRect(r, focuscursor ? paper : m.kind == KIND_NEST ? Blend(SColorMark, SColorPaper, 220) - : SColorFace); + if(findarg(m.kind, KIND_NEST) >= 0) + w.DrawRect(r, focuscursor ? paper : m.pretty.Find('\xff') >= 0 ? SColorFace() + : Blend(SColorMark, SColorPaper, 220)); else w.DrawRect(r, paper); } @@ -369,16 +369,16 @@ int Navigator::NavigatorDisplay::DoPaint(Draw& w, const Rect& r, const Value& q, bool focuscursor = (style & (FOCUS|CURSOR)) == (FOCUS|CURSOR) || (style & SELECT); int x = r.left; - int y = (r.GetHeight() - Draw::GetStdFontCy()) / 2; - - if(findarg(m.kind, KIND_FILE, KIND_NEST) >= 0) { - w.DrawRect(r, focuscursor ? paper : m.kind == KIND_NEST ? Blend(SColorMark, SColorPaper, 220) - : SColorFace); - if(findarg(m.kind, KIND_FILE) >= 0) + int y = r.top + (r.GetHeight() - Draw::GetStdFontCy()) / 2; + + if(m.kind == KIND_NEST) { + bool fn = m.pretty.Find('\xff') >= 0; + w.DrawRect(r, focuscursor ? paper : fn ? SColorFace() + : Blend(SColorMark(), SColorPaper(), 220)); + if(fn) return PaintFileName(w, r, m.pretty, ink); - String h = FormatNest(m.pretty); - w.DrawText(x, y, h, StdFont().Bold(), ink); - return GetTextSize(h, StdFont().Bold()).cx; + w.DrawText(x, y, m.pretty, StdFont().Bold(), ink); + return GetTextSize(m.pretty, StdFont().Bold()).cx; } w.DrawRect(r, paper); @@ -439,15 +439,18 @@ void Navigator::Search() int lineno = StrInt(s); nitem.Clear(); Index nests; - if(IsNull(theide->editfile)) - return; int fileii = GetSourceFileIndex(theide->editfile); + auto Nest = [&](const AnnotationItem& m, const String& path) { + if(m.nspace == m.nest) + return m.nest + "\xff" + path; + return m.nest; + }; + nests.Add(Null); if(!IsNull(lineno)) { NavItem& m = nitem.Add(); m.pretty = "Go to line " + AsString(lineno); m.kind = KIND_LINE; m.line = lineno; - nests.Add(Null); } else if(IsNull(s) && !sorting) { @@ -457,7 +460,7 @@ void Navigator::Search() for(const AnnotationItem& m : theide->editor.annotations) { NavItem& n = nitem.Add(); (AnnotationItem&)n = m; - nests.FindAdd(n.nest); + nests.FindAdd(n.nest = Nest(m, theide->editfile)); } SortIndex(nests); } @@ -482,7 +485,7 @@ void Navigator::Search() visited.Add(m.id); NavItem& n = nitem.Add(); (AnnotationItem&)n = m; - nests.FindAdd(n.nest); + nests.FindAdd(n.nest = Nest(m, theide->editfile)); } } @@ -498,13 +501,13 @@ void Navigator::Search() m.pretty = wspc[i] + "/" + p[j]; m.id = SourcePath(wspc[i], p[j]); m.line = 0; - nests.FindAdd(""); + m.nest = ""; + nests.FindAdd(m.nest); } } } } scope.Clear(); - scope.Add(Null); for(String n : nests) scope.Add(n); scope.ScrollTo(sc); @@ -533,7 +536,7 @@ int Navigator::ScopeDisplay::DoPaint(Draw& w, const Rect& r, const Value& q, Col return x; } String h = q; - if(*h == '\xff') // TODO + if(h.Find('\xff') >= 0) // TODO return PaintFileName(w, r, h, ink); else h = FormatNest(h); @@ -560,17 +563,17 @@ void Navigator::Scope() linefo.Clear(); String sc = scope.GetKey(); String nest; - for(const NavItem& n : nitem) { + for(const NavItem& n : nitem) if(IsNull(sc) || n.nest == sc) { if(!sorting && n.nest != nest) { NavItem& m = nest_item.Add(); - m.kind = KIND_NEST; // TODO: KIND_FILE + m.kind = KIND_NEST; nest = m.pretty = n.nest; + DDUMP(n.nest); litem.Add(&m); } litem.Add(&n); } - } // TODO sorting @@ -584,7 +587,7 @@ void Navigator::ListLineEnabled(int i, bool& b) { if(i >= 0 && i < litem.GetCount()) { int kind = litem[i]->kind; - if(findarg(kind, KIND_FILE, KIND_NEST) >= 0) + if(findarg(kind, KIND_NEST) >= 0) b = false; } } diff --git a/uppsrc/ide/clang/Indexer.cpp b/uppsrc/ide/clang/Indexer.cpp index c74195011..be141c585 100644 --- a/uppsrc/ide/clang/Indexer.cpp +++ b/uppsrc/ide/clang/Indexer.cpp @@ -4,6 +4,21 @@ #define LTIMESTOP(x) #define LLOG(x) +void AnnotationItem::Serialize(Stream& s) +{ + s % kind + % line + % definition + % name + % id + % pretty + % nspace + % uname + % nest + % unest; + +} + struct BlitzMaker { Time time; String blitz; diff --git a/uppsrc/ide/clang/clang.cpp b/uppsrc/ide/clang/clang.cpp index 9da9fc481..420787627 100644 --- a/uppsrc/ide/clang/clang.cpp +++ b/uppsrc/ide/clang/clang.cpp @@ -84,8 +84,6 @@ bool Clang::Parse(const String& filename, const String& content, const String& i cmdline << filename << " -DflagDEBUG -DflagDEBUG_FULL -DflagMAIN -xc++ -std=c++17 "; - DDUMP(cmdline); - cmdline << RedefineMacros(); String includes = includes_; diff --git a/uppsrc/ide/clang/clang.h b/uppsrc/ide/clang/clang.h index f6495f74d..738190160 100644 --- a/uppsrc/ide/clang/clang.h +++ b/uppsrc/ide/clang/clang.h @@ -87,7 +87,7 @@ struct AnnotationItem : Moveable { String nest; // Upp::Class String unest; // UPP::CLASS - ~AnnotationItem() { DHITCOUNT("AnnotationItem"); } + void Serialize(Stream& s); }; struct CurrentFileContext { diff --git a/uppsrc/ide/clang/todo.txt b/uppsrc/ide/clang/todo.txt index 9cbe9865c..a12d0b5b7 100644 --- a/uppsrc/ide/clang/todo.txt +++ b/uppsrc/ide/clang/todo.txt @@ -20,8 +20,6 @@ - QTF :\1label\1: -- autocomplete templates ? - - recognized headers slow - unrecognized headers slow @@ -66,6 +64,17 @@ - immediate reparse (probably Update?) +- Navigator -> (constructor does not have return value) + +- local file navigation off by 1 line + +- global navigation not working + +- operator bool - wrong nest (Core/Speller.cpp) + +- constructor - worng nest(Core/Speller.cpp) + + LATER: - slow .txt @@ -94,3 +103,7 @@ DONE: - ide/Core.h - no annotations +REJECTED: + +- autocomplete templates ? + diff --git a/uppsrc/ide/ide.cpp b/uppsrc/ide/ide.cpp index fb6445b79..c57a7eda5 100644 --- a/uppsrc/ide/ide.cpp +++ b/uppsrc/ide/ide.cpp @@ -659,7 +659,6 @@ void Ide::SyncClang() animator = 20; else animator -= 3; - DDUMP(animator); return Blend(IsDarkTheme() ? GrayColor(70) : SColorLtFace(), Color(198, 170, 0), animator); }; Color bg = Animate(animate_current_file, animate_current_file_dir, editor.annotating || IsCurrentFileParsing()); @@ -669,9 +668,6 @@ void Ide::SyncClang() a.Add(i > cx - DPI(6) ? bg : Null); } editor.AnimateBar(pick(a)); - DDUMP(IsIndexing()); - DDUMP(Animate(animate_indexer, animate_indexer_dir, IsIndexing())); - DDUMP(Animate(animate_autocomplete, animate_autocomplete_dir, IsAutocompleteParsing())); editor.search.SetBackground(Animate(animate_indexer, animate_indexer_dir, IsIndexing())); display.Animate(Animate(animate_autocomplete, animate_autocomplete_dir, IsAutocompleteParsing())); animate_phase = phase;