ide: Fixed problem with Remove found lines, CodeEditor::GotoLine renamed to GotoBarLine, Navigator now shows number of items in the nest

This commit is contained in:
Mirek Fidler 2025-11-27 09:48:43 +01:00
parent 985e5b8ab0
commit 46a4b30509
8 changed files with 40 additions and 25 deletions

View file

@ -1294,7 +1294,7 @@ void CodeEditor::ForwardWhenBreakpoint(int i) {
WhenBreakpoint(i);
}
void CodeEditor::GotoLine(int line)
void CodeEditor::GotoBarLine(int line)
{
SetCursor(GetPos64(GetLineNo(line)));
}

View file

@ -502,7 +502,7 @@ public:
void SetBreakpoint(int line, const String& b) { bar.SetBreakpoint(line, b); }
void ClearEdited() { bar.ClearEdited(); }
int GetUndoCount() { return undo.GetCount(); }
void GotoLine(int line);
void GotoBarLine(int line);
void EnableBreakpointing() { bar.EnableBreakpointing(true); }
void DisableBreakpointing() { bar.EnableBreakpointing(false); }
void Renumber2();

View file

@ -9,6 +9,8 @@ uint64 cmask16__(uint16x8_t mask) {
return matches;
}
// force_inline uint64 cmask16__(uint16x8_t mask) { return vreinterpretq_s16_u16(mask); }
const uint64 cmask_all__ = 0xffffffffffffffffull;
struct f32x4 {

View file

@ -1216,7 +1216,7 @@ void LineEdit::DeleteLine()
}
int i = GetLine(cursor);
int p = GetPos32(i);
Remove((int)p, GetLineLength(i) + 1);
Remove(p, GetLineLength(i) + 1);
PlaceCaret(p);
Action();
}

View file

@ -599,7 +599,7 @@ void Ide::DeleteFound(ArrayCtrl& list)
Sort(lines, [](const Tuple<int, String>& a, Tuple<int, String>& b) { return a.a > b.a; });
for(const auto& m : lines) {
if(m.a < editor.GetLineCount() && m.b == editor.GetUtf8Line(m.a) && !editor.IsReadOnly() && !editor.IsView()) {
editor.GotoLine(m.a);
editor.SetCursor(editor.GetPos(m.a));
editor.DeleteLine();
}
else

View file

@ -78,7 +78,7 @@ Navigator::Navigator()
list.WhenLeftClick = THISBACK(NavigatorClick);
scope.NoHeader();
scope.AddColumn().SetDisplay(Single<ScopeDisplay>());
scope.AddColumn().AddIndex().SetDisplay(Single<ScopeDisplay>());
scope.SetLineCy(max(16, GetStdFontCy()));
scope.NoWantFocus();
scope.WhenSel = [=] { SetList(); };
@ -306,24 +306,32 @@ Size Navigator::NavigatorDisplay::GetStdSize(const Value& q) const
return Size(DoPaint(w, Size(999999, 999999), q, White(), White(), 0), Draw::GetStdFontCy());
}
int Navigator::ScopeDisplay::DoPaint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
int Navigator::ScopeDisplay::DoPaint(Draw& w, const Rect& r, const Value& qa, Color ink, Color paper, dword style) const
{
ValueArray va = qa;
Value q = va[0];
w.DrawRect(r, paper);
int x = 0;
if(IsNull(q) || q == "*") {
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);
x += GetTextSize(txt, StdFont().Bold().Italic()).cx;
return x;
}
String h = q;
if(h.Find('\xff') >= 0)
return PaintFileName(w, r, h, ink);
else
x = PaintFileName(w, r, h, ink);
else {
h = FormatNest(h);
w.DrawText(r.left, r.top, h, StdFont(), ink);
return GetTextSize(h, StdFont()).cx;
w.DrawText(r.left, r.top, h, StdFont(), ink);
x = GetTextSize(h, StdFont()).cx;
}
String ntxt = " (" + AsString(va[1]) + ")";
w.DrawText(r.left + x, r.top, ntxt, StdFont(), Gray());
x += GetTextSize(ntxt, StdFont()).cx;
return x;
}
void Navigator::ScopeDisplay::Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
@ -364,13 +372,14 @@ void Navigator::Search()
int lineno = StrInt(s);
nitem.Clear();
litem.Clear();
Index<String> nests;
VectorMap<String, int> nests;
auto Nest = [&](const AnnotationItem& m, const String& path) {
if(m.nspace == m.nest)
return m.nest + "\xff" + path;
return m.nest;
};
nests.Add(Null);
nests.Add(Null, 0);
int all_count = 0;
String usearch_nest = ToUpper(search_nest);
String usearch_name = ToUpper(search_name);
if(!IsNull(lineno)) {
@ -388,9 +397,10 @@ void Navigator::Search()
NavItem& n = nitem.Add();
(AnnotationItem&)n = m;
n.path = theide->editfile;
nests.FindAdd(n.nest = Nest(m, theide->editfile));
all_count++;
nests.GetAdd(n.nest = Nest(m, theide->editfile), 0)++;
}
SortIndex(nests);
SortByKey(nests);
}
else {
navigator_global = true;
@ -414,14 +424,15 @@ void Navigator::Search()
NavItem& n = nitem.Add();
(AnnotationItem&)n = m;
n.path = f.key;
nests.FindAdd(n.nest = Nest(m, f.key));
all_count++;
nests.GetAdd(n.nest = Nest(m, f.key), 0)++;
set.Add(m.id);
}
}
}
}
SortIndex(nests);
SortByKey(nests);
const Workspace& wspc = GetIdeWorkspace();
String s = ToUpper(TrimBoth(~search));
for(int i = 0; i < wspc.GetCount(); i++) {
@ -435,7 +446,8 @@ void Navigator::Search()
m.pos = Point(0, 0);
m.nest = "<files>";
m.uname = ToUpper(p[j]);
nests.FindAdd(m.nest);
all_count++;
nests.GetAdd(m.nest, 0)++;
}
}
}
@ -443,16 +455,17 @@ void Navigator::Search()
String k = scope.GetKey();
scope.Clear();
scope.Add("*");
scope.Add("*", all_count);
Index<String> set;
for(int nest_pass = 0; nest_pass < 3; nest_pass++)
for(String s : nests) {
for(auto kv : ~nests) {
String s = kv.key;
if(s.GetCount() &&
set.Find(s) < 0 &&
(nest_pass == 2 ? ToUpper(s).Find(usearch_nest) >= 0 :
nest_pass == 1 ? s.Find(search_nest) >= 0 :
s == search_nest)) {
scope.Add(s);
scope.Add(s, kv.value);
set.Add(s);
}
}

View file

@ -757,11 +757,11 @@ void Ide::EditAsText()
layout = "LAYOUT(" + layout + ",";
for(int i = 0; i < editor.GetLineCount(); i++)
if(TrimBoth(editor.GetUtf8Line(i)).StartsWith(layout)) {
editor.GotoLine(i);
editor.GotoBarLine(i);
if(item.GetCount())
for(int j = i + 1; j < editor.GetLineCount(); j++)
if(GetLayItemId(editor.GetUtf8Line(j)) == item) {
editor.GotoLine(j);
editor.GotoBarLine(j);
break;
}
break;

View file

@ -223,7 +223,7 @@ void Ide::IdeSetDebugPos(const String& file, int line, const Image& img, int i)
posline[i] = line;
posimg[i] = img;
EditFile(file);
editor.GotoLine(line);
editor.GotoBarLine(line);
PosSync();
Size sz = editor.GetPageSize();
Point p = editor.GetScrollPos();