From eb0fcfeca30df67153ca0fabbd495ae66c71f8dd Mon Sep 17 00:00:00 2001 From: Mirek Fidler Date: Wed, 7 May 2025 16:32:55 +0200 Subject: [PATCH] ide: More lines in package selection Recents, single-line mode in RichText removed --- uppsrc/CtrlLib/RichText.h | 2 -- uppsrc/CtrlLib/RichTextView.cpp | 18 +----------------- uppsrc/RichText/ParaPaint.cpp | 2 -- uppsrc/RichText/RichText.h | 1 - uppsrc/ide/SelectPkg.cpp | 26 +++++++++++++++++++++----- uppsrc/ide/ide.lay | 24 ++++++++++++------------ 6 files changed, 34 insertions(+), 39 deletions(-) diff --git a/uppsrc/CtrlLib/RichText.h b/uppsrc/CtrlLib/RichText.h index f67c15ed3..0ccee115d 100644 --- a/uppsrc/CtrlLib/RichText.h +++ b/uppsrc/CtrlLib/RichText.h @@ -34,7 +34,6 @@ private: bool shrink_oversized_objects; bool icursor = true; bool copy_with_tabs = false; - bool single_line = false; void EndSizeTracking(); void SetSb(); @@ -121,7 +120,6 @@ 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); } diff --git a/uppsrc/CtrlLib/RichTextView.cpp b/uppsrc/CtrlLib/RichTextView.cpp index 65c1e8571..f9ead002e 100644 --- a/uppsrc/CtrlLib/RichTextView.cpp +++ b/uppsrc/CtrlLib/RichTextView.cpp @@ -66,7 +66,6 @@ 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); @@ -82,8 +81,6 @@ void RichTextView::SetSb() bool RichTextView::Key(dword key, int count) { - if(single_line) - return false; if(key == K_CTRL_C || key == K_SHIFT_INSERT) { Copy(); return true; @@ -93,8 +90,6 @@ bool RichTextView::Key(dword key, int count) void RichTextView::MouseWheel(Point p, int zdelta, dword keyflags) { - if(single_line) - return; if(!WhenMouseWheel(zdelta, keyflags)) sb.Wheel(zdelta); } @@ -138,8 +133,6 @@ String RichTextView::GetSelectionData(const String& fmt) const void RichTextView::RightDown(Point p, dword keyflags) { - if(single_line) - return; MenuBar b; b.Add(cursor != anchor, t_("Copy"), CtrlImg::copy(), THISBACK(Copy)).Key(K_CTRL_C); b.Execute(); @@ -159,10 +152,7 @@ int RichTextView::GetPointPos(Point p) const sz.cx -= margin.left + margin.right; sz.cy -= margin.top + margin.bottom; p = GetTextPoint(p); - Rect pg = GetPage(); - if(single_line) - pg.right = INT_MAX / 2; - return text.GetPos(p.x, PageY(0, p.y), pg); + return text.GetPos(p.x, PageY(0, p.y), GetPage()); } String RichTextView::GetLink(int pos, Point p) const @@ -251,8 +241,6 @@ void RichTextView::LeftDown(Point p, dword keyflags) void RichTextView::LeftDouble(Point p, dword keyflags) { - if(single_line) - return; int pos = GetPointPos(p); if(IsLeNum(text[pos])) { anchor = pos; @@ -270,8 +258,6 @@ void RichTextView::LeftDouble(Point p, dword keyflags) void RichTextView::LeftTriple(Point p, dword keyflags) { - if(single_line) - return; int pos = GetPointPos(p); RichPos rp = text.GetRichPos(pos); anchor = pos - rp.posinpara; @@ -285,8 +271,6 @@ void RichTextView::MouseMove(Point p, dword keyflags) int pos = GetPointPos(p); WhenMouseMove(pos); if(HasCapture()) { - if(single_line) - return; if(pos < 0) return; cursor = pos; diff --git a/uppsrc/RichText/ParaPaint.cpp b/uppsrc/RichText/ParaPaint.cpp index 4bec607fa..16497f3a1 100644 --- a/uppsrc/RichText/ParaPaint.cpp +++ b/uppsrc/RichText/ParaPaint.cpp @@ -414,8 +414,6 @@ 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)) diff --git a/uppsrc/RichText/RichText.h b/uppsrc/RichText/RichText.h index 6ff548755..59af324b0 100644 --- a/uppsrc/RichText/RichText.h +++ b/uppsrc/RichText/RichText.h @@ -290,7 +290,6 @@ 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; diff --git a/uppsrc/ide/SelectPkg.cpp b/uppsrc/ide/SelectPkg.cpp index 3a7177814..4dbc8dfae 100644 --- a/uppsrc/ide/SelectPkg.cpp +++ b/uppsrc/ide/SelectPkg.cpp @@ -207,16 +207,29 @@ SelectPackageDlg::SelectPackageDlg(const char *title, bool selectvars_, bool mai parent.Add(list.SizePos()); parent.AddFrame(splitter.Left(base, Zx(170))); - recent.NoSb().NoHyperlinkDecoration().SingleLine(); + recent.NoSb().NoHyperlinkDecoration(); LoadLRU(); if(main && selectvars && lru.GetCount()) { String text; for(int i = 0; i < lru.GetCount(); i++) { const auto& m = lru[i]; - MergeWith(text, ", ", "[$W^A" + AsString(i) + "^ \1" + m.a + "\1]" + + MergeWith(text, ", ", "[@b^A" + AsString(i) + "^ \1" + m.a + "\1]" + ":_[*^ "+ AsString(i) + "^ \1" + m.b + "\1]"); } - recent <<= "[g [@K/ Recent:] " + text; + if(text.GetCount()) + recent <<= "[gpw [@K/ Recent:] " + text; + Rect r = recent.GetRect(); + Rect pg = recent.GetPage(); + RichText txt = ParseQTF(recent.GetQTF()); + int cy = 0; + for(int i = 0; i < txt.GetLength(); i++) { // Find the height of text that completely fits + Rect cr = txt.GetCaret(i, pg); + if(cr.bottom > r.GetHeight()) // does not fit + break; + cy = cr.bottom; + } + r.bottom = r.top + cy; + recent.SetRect(r); recent.WhenLink = [=](const String& s) { if(*s == 'A') { int i = Atoi(~s + 1); @@ -233,6 +246,9 @@ SelectPackageDlg::SelectPackageDlg(const char *title, bool selectvars_, bool mai } } }; + LogPos p = parent.GetPos(); + p.y.SetA(r.bottom + DPI(3)); + parent.SetPos(p); } else { LogPos p = parent.GetPos(); @@ -297,8 +313,8 @@ void SelectPackageDlg::StoreLRU(const String& p) if(i >= 0) lru.Remove(i); lru.Insert(0, q); - if(lru.GetCount() > 10) - lru.Trim(10); + if(lru.GetCount() > 100) + lru.Trim(100); StoreToFile(lru, LRUFilePath()); } diff --git a/uppsrc/ide/ide.lay b/uppsrc/ide/ide.lay index c03e52498..f3d8ce65c 100644 --- a/uppsrc/ide/ide.lay +++ b/uppsrc/ide/ide.lay @@ -1,15 +1,15 @@ -LAYOUT(SelectPackageLayout, 816, 468) - 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)) - ITEM(Upp::Option, brief, SetLabel(t_("Brief list")).RightPosZ(332, 72).BottomPosZ(6, 20)) - ITEM(Upp::Button, help, SetLabel(t_("?")).RightPosZ(308, 20).BottomPosZ(4, 24)) - ITEM(Upp::Button, upphub, SetLabel(t_("UppHub")).RightPosZ(236, 68).BottomPosZ(4, 24)) - ITEM(Upp::Button, newu, SetLabel(t_("&New package")).RightPosZ(144, 88).BottomPosZ(4, 24)) - ITEM(Upp::Button, ok, SetLabel(t_("OK")).RightPosZ(76, 64).BottomPosZ(4, 24)) - ITEM(Upp::Button, cancel, SetLabel(t_("Cancel")).RightPosZ(8, 64).BottomPosZ(4, 24)) +LAYOUT(SelectPackageLayout, 816, 588) + ITEM(Upp::RichTextCtrl, recent, LeftPosZ(4, 804).TopPosZ(4, 56)) + ITEM(Upp::ParentCtrl, parent, HSizePosZ(4, 8).VSizePosZ(64, 36)) + ITEM(Upp::DropList, kind, Tip(t_("Select which packages should be displayed")).LeftPosZ(4, 124).BottomPosZ(9, 19)) + ITEM(Upp::DropList, nest, Tip(t_("Select which packages should be displayed")).LeftPosZ(132, 112).BottomPosZ(9, 19)) + ITEM(Upp::EditString, search, Tip(t_("Search for the concrete package")).HSizePosZ(248, 412).BottomPosZ(8, 20)) + ITEM(Upp::Option, brief, SetLabel(t_("Brief list")).RightPosZ(332, 72).BottomPosZ(8, 20)) + ITEM(Upp::Button, help, SetLabel(t_("?")).RightPosZ(308, 20).BottomPosZ(6, 24)) + ITEM(Upp::Button, upphub, SetLabel(t_("UppHub")).RightPosZ(236, 68).BottomPosZ(6, 24)) + ITEM(Upp::Button, newu, SetLabel(t_("&New package")).RightPosZ(144, 88).BottomPosZ(6, 24)) + ITEM(Upp::Button, ok, SetLabel(t_("OK")).RightPosZ(76, 64).BottomPosZ(6, 24)) + ITEM(Upp::Button, cancel, SetLabel(t_("Cancel")).RightPosZ(8, 64).BottomPosZ(6, 24)) END_LAYOUT LAYOUT(ConfigLayout, 724, 216)