ide: Select pacckage 'Recent' cosmetics, CtrlLib, RichText: SingleLine option

This commit is contained in:
Mirek Fidler 2025-04-03 17:18:38 +02:00
parent 0f591276b8
commit f471079229
6 changed files with 34 additions and 22 deletions

View file

@ -34,6 +34,7 @@ private:
bool shrink_oversized_objects;
bool icursor = true;
bool copy_with_tabs = false;
bool single_line = false;
void EndSizeTracking();
void SetSb();
@ -120,6 +121,7 @@ public:
RichTextView& ICursor(bool b = true) { icursor = b; return *this; }
RichTextView& NoICursor() { return ICursor(false); }
RichTextView& CopyWithTabs(bool b = true) { copy_with_tabs = b; return *this; }
RichTextView& SingleLine(bool b = true) { single_line = b; return *this; }
void operator=(const char *qtf) { SetQTF(qtf); }

View file

@ -66,6 +66,7 @@ void RichTextView::Paint(Draw& w)
pi.sizetracking = sizetracking;
pi.shrink_oversized_objects = shrink_oversized_objects;
pi.darktheme = IsDarkTheme();
pi.single_line = single_line;
Rect pg = GetPage();
pg.top = TopY();
text.Paint(pw, pg, pi);
@ -152,7 +153,10 @@ int RichTextView::GetPointPos(Point p) const
sz.cx -= margin.left + margin.right;
sz.cy -= margin.top + margin.bottom;
p = GetTextPoint(p);
return text.GetPos(p.x, PageY(0, p.y), GetPage());
Rect pg = GetPage();
if(single_line)
pg.right = INT_MAX / 2;
return text.GetPos(p.x, PageY(0, p.y), pg);
}
String RichTextView::GetLink(int pos, Point p) const

View file

@ -375,6 +375,8 @@ void RichPara::Paint(PageDraw& pw, RichContext rc, const PaintInfo& pi,
hg++;
}
rc.py.y += linecy;
if(pi.single_line)
break;
}
Size sz = RichTextImg::EndParaChar().GetSize();
if(sz.cy < z * lineascent && !IsNull(pi.showcodes))

View file

@ -290,6 +290,7 @@ struct PaintInfo {
void *context;
bool showlabels;
bool shrink_oversized_objects;
bool single_line = false; // draw just one line (special usecase)
void (*DrawSelection)(Draw& w, int x, int y, int cx, int cy);
Color ResolveInk(Color ink) const;

View file

@ -203,26 +203,29 @@ SelectPackageDlg::SelectPackageDlg(const char *title, bool selectvars_, bool mai
parent.Add(list.SizePos());
parent.AddFrame(splitter.Left(base, Zx(170)));
recent.NoSb().NoHyperlinkDecoration();
if(main) {
LoadLRU();
if(lru.GetCount()) {
String text;
for(int i = 0; i < lru.GetCount(); i++) {
const auto& m = lru[i];
MergeWith(text, ", ", "[^" + AsString(i) + "^ \1" + m.a + "\1" + ":_[* \1" + m.b + "\1]]");
}
recent <<= "[g [@K/ Recent:] " + text;
recent.WhenLink = [=](const String& s) {
int i = Atoi(s);
if(i >= 0 && lru.GetCount()) {
selected = lru[i].b;
LoadVars(lru[i].a);
selected_nest = GetPackagePathNest(PackagePath(selected));
Break(IDYES);
}
};
recent.NoSb().NoHyperlinkDecoration().SingleLine();
LoadLRU();
if(main && selectvars && lru.GetCount()) {
String text;
for(int i = 0; i < lru.GetCount(); i++) {
const auto& m = lru[i];
MergeWith(text, ", ", "[^" + AsString(i) + "^ \1" + m.a + "\1" + ":_[* \1" + m.b + "\1]]");
}
recent <<= "[g [@K/ Recent:] " + text;
recent.WhenLink = [=](const String& s) {
int i = Atoi(s);
if(i >= 0 && lru.GetCount()) {
selected = lru[i].b;
LoadVars(lru[i].a);
selected_nest = GetPackagePathNest(PackagePath(selected));
Break(IDYES);
}
};
}
else {
LogPos p = parent.GetPos();
p.y.SetA(recent.GetPos().y.GetA());
parent.SetPos(p);
}
if (!selectvars)

View file

@ -1,6 +1,6 @@
LAYOUT(SelectPackageLayout, 816, 468)
ITEM(Upp::RichTextCtrl, recent, LeftPosZ(4, 804).TopPosZ(4, 24))
ITEM(Upp::ParentCtrl, parent, HSizePosZ(4, 8).VSizePosZ(28, 32))
ITEM(Upp::RichTextCtrl, recent, LeftPosZ(4, 804).TopPosZ(4, 19))
ITEM(Upp::ParentCtrl, parent, HSizePosZ(4, 8).VSizePosZ(24, 32))
ITEM(Upp::DropList, kind, Tip(t_("Select which packages should be displayed")).LeftPosZ(4, 124).BottomPosZ(7, 19))
ITEM(Upp::DropList, nest, Tip(t_("Select which packages should be displayed")).LeftPosZ(132, 112).BottomPosZ(7, 19))
ITEM(Upp::EditString, search, Tip(t_("Search for the concrete package")).HSizePosZ(248, 412).BottomPosZ(6, 20))