diff --git a/uppsrc/Core/Speller.cpp b/uppsrc/Core/Speller.cpp index a7cdfc989..c126523bf 100644 --- a/uppsrc/Core/Speller.cpp +++ b/uppsrc/Core/Speller.cpp @@ -156,7 +156,6 @@ Speller *sGetSpeller(int lang) #ifdef PLATFORM_POSIX pp << "/usr/local/share/upp/speller;/usr/local/share/upp;/usr/share/upp/speller;/usr/share/upp"; #endif - RDUMP(pp); String path = GetFileOnPath(ToLower(LNGAsText(lang)) + ".udc", pp); if(IsNull(path)) return NULL; diff --git a/uppsrc/CtrlLib/RichText.h b/uppsrc/CtrlLib/RichText.h index 618445fa8..8b619d725 100644 --- a/uppsrc/CtrlLib/RichText.h +++ b/uppsrc/CtrlLib/RichText.h @@ -43,6 +43,7 @@ private: void RefreshSel(); void RefreshRange(int a, int b); WString GetSelText() const; + int TopY() const; protected: enum { @@ -63,7 +64,7 @@ public: int GetWidth() const { return text.GetWidth(); } int GetHeight(int cx) const { return text.GetHeight(Zoom(1, 1), cx); } - int GetHeight() const { return text.GetHeight(GetZoom(), GetSize().cx); } + int GetHeight() const; int GetSb() const { return sb; } void SetSb(int i) { sb = i; } diff --git a/uppsrc/CtrlLib/RichTextView.cpp b/uppsrc/CtrlLib/RichTextView.cpp index fd06473a3..0de31cf2a 100644 --- a/uppsrc/CtrlLib/RichTextView.cpp +++ b/uppsrc/CtrlLib/RichTextView.cpp @@ -4,11 +4,40 @@ namespace Upp { #define LLOG(x) // LOG(x) + +Zoom RichTextView::GetZoom() const +{ + int szcx = GetSize().cx; + if(!sb.IsShown() && sb.IsAutoHide()) + szcx -= ScrollBarSize(); + return IsNull(zoom) ? Zoom(szcx - margin.left - margin.right, cx) : zoom; +} + +int RichTextView::GetPageCx(bool reduced) const +{ + int szcx = GetSize().cx; + if(reduced && !sb.IsShown() && sb.IsAutoHide()) + szcx -= ScrollBarSize(); + return IsNull(zoom) ? cx : (szcx - margin.left - margin.right) / zoom; +} + Rect RichTextView::GetPage() const { return Rect(0, 0, GetPageCx(), INT_MAX); } +int RichTextView::GetHeight() const +{ + return text.GetHeight(GetPage()).y; +} + +int RichTextView::TopY() const +{ + if(vcenter && sb.GetTotal() < sb.GetPage()) + return (sb.GetPage() - sb.GetTotal()) / 2; + return 0; +} + void RichTextView::Paint(Draw& w) { Size sz = GetSize(); @@ -38,34 +67,15 @@ void RichTextView::Paint(Draw& w) pi.shrink_oversized_objects = shrink_oversized_objects; pi.darktheme = Grayscale(SColorPaper()) < 100; Rect pg = GetPage(); - if(vcenter && sb.GetTotal() < sb.GetPage()) - pg.top = (sb.GetPage() - sb.GetTotal()) / 2; + pg.top = TopY(); text.Paint(pw, pg, pi); w.End(); w.End(); } -Zoom RichTextView::GetZoom() const -{ - int szcx = GetSize().cx; - if(!sb.IsShown() && sb.IsAutoHide()) - szcx -= ScrollBarSize(); - return IsNull(zoom) ? Zoom(szcx - margin.left - margin.right, cx) : zoom; -} - -int RichTextView::GetPageCx(bool reduced) const -{ - int szcx = GetSize().cx; - if(reduced && !sb.IsShown() && sb.IsAutoHide()) - szcx -= ScrollBarSize(); - return IsNull(zoom) ? cx : (szcx - margin.left - margin.right) / zoom; -} - void RichTextView::SetSb() { - Rect page(0, 0, GetPageCx(true), INT_MAX); - PageY py = text.GetHeight(page); - sb.SetTotal(py.y); + sb.SetTotal(GetHeight()); sb.SetPage((GetSize().cy - margin.top - margin.bottom) / GetZoom()); } @@ -132,7 +142,7 @@ Point RichTextView::GetTextPoint(Point p) const p -= margin.TopLeft(); Zoom zoom = GetZoom(); p.y += sb * zoom; - return Point(p.x / zoom, p.y / zoom); + return Point(p.x / zoom, p.y / zoom - TopY()); } int RichTextView::GetPointPos(Point p) const @@ -172,7 +182,7 @@ void RichTextView::RefreshRange(int a, int b) Rect r1 = text.GetCaret(l, GetPage()) + margin.TopLeft(); Rect r2 = text.GetCaret(h, GetPage()) + margin.TopLeft(); Zoom zoom = GetZoom(); - Refresh(Rect(0, zoom * (r1.top - sb), GetSize().cx, zoom * (r2.bottom - sb + zoom.d - 1))); + Refresh(Rect(0, zoom * (r1.top - sb + TopY()), GetSize().cx, zoom * (r2.bottom - sb + zoom.d - 1) + TopY())); } void RichTextView::RefreshSel() diff --git a/uppsrc/ide/Browser/File.cpp b/uppsrc/ide/Browser/File.cpp index 9e580cd7f..5159e9add 100644 --- a/uppsrc/ide/Browser/File.cpp +++ b/uppsrc/ide/Browser/File.cpp @@ -8,7 +8,7 @@ int CharFilterID(int c) bool ParseTopicFileName(const String& fn, String& topic, int& lang) { String q = GetFileTitle(fn); - int w = q.Find('_'); + int w = q.ReverseFind('_'); if(w < 0) return false; topic = q.Mid(0, w); diff --git a/uppsrc/ide/Browser/Move.cpp b/uppsrc/ide/Browser/Move.cpp index a4e4f7865..e734e173d 100644 --- a/uppsrc/ide/Browser/Move.cpp +++ b/uppsrc/ide/Browser/Move.cpp @@ -64,7 +64,7 @@ void TopicEditor::MoveTopic() if(dlg.Run() != IDOK) return; String np = AppendFileName(SourcePath(~dlg.package, (String)~dlg.group + ".tpp"), - (String)~dlg.topic + "@" + ToLower(LNGAsText(~dlg.lang)) + ".tpp"); + (String)~dlg.topic + "_" + ToLower(LNGAsText(~dlg.lang)) + ".tpp"); if(FindFile(np)) { if(!PromptYesNo("Target file aready exists!&Do you want to overwrite it?")) return; diff --git a/uppsrc/ide/Browser/Topic.cpp b/uppsrc/ide/Browser/Topic.cpp index 384482265..ada6db810 100644 --- a/uppsrc/ide/Browser/Topic.cpp +++ b/uppsrc/ide/Browser/Topic.cpp @@ -1,7 +1,7 @@ #include "Browser.h" ArrayMap TopicEditor::editstate; -VectorMap TopicEditor::grouptopic; +VectorMap TopicEditor::grouptopic; // the last topic edited in group String TopicEditor::lasttemplate; int TopicEditor::lastlang; @@ -19,11 +19,15 @@ bool LoadTopics(Vector& topics, const String& grouppath) bool renamed = false; for(int pass = 0; pass < 2; pass++) { + topics.Clear(); + FindFile ff(AppendFileName(grouppath, "*.*")); for(; ff; ff.Next()) { if(ff.IsFile() && GetFileExt(ff.GetName()) == ".tppi") { String n = ff.GetName(); int q = n.ReverseFind('$'); + if(q < 0) + q = n.ReverseFind('@'); if(q >= 0 && q > n.GetLength() - 12) { String nn = n; n.Set(q, '_'); @@ -57,16 +61,17 @@ void FillTopicsList(FileList& list, const Vector& topics) { list.Clear(); - for (const auto& topic : topics) { + for (const auto& topic : topics) list.Add(topic, TopicImg::Topic()); - } list.Sort(ListOrder()); list.Enable(); + } void TopicEditor::Open(const String& group_path) { + topics_search.Clear(); grouppath = group_path; @@ -74,7 +79,6 @@ void TopicEditor::Open(const String& group_path) DeleteFile(grouppath); DirectoryCreate(grouppath); - topics.Clear(); if(LoadTopics(topics, grouppath)) SaveInc(); FillTopicsList(topics_list, topics); diff --git a/uppsrc/ide/Browser/TopicWin.cpp b/uppsrc/ide/Browser/TopicWin.cpp index 47b50725f..bcb068561 100644 --- a/uppsrc/ide/Browser/TopicWin.cpp +++ b/uppsrc/ide/Browser/TopicWin.cpp @@ -384,7 +384,7 @@ void TopicEditor::SaveAsTemplate() d.nest.GoBegin(); if(d.Execute() != IDOK || IsNull(~d.nest)) return; - SaveFile(AppendFileName(AppendFileName(~d.nest, "$.tpp"), d.GetName()), + SaveFile(AppendFileName(AppendFileName(~d.nest, "_.tpp"), d.GetName()), WriteTopic((String)~title, editor.Get())); } diff --git a/uppsrc/ide/SlideShow.cpp b/uppsrc/ide/SlideShow.cpp index 2c0d02d0e..1a8569feb 100644 --- a/uppsrc/ide/SlideShow.cpp +++ b/uppsrc/ide/SlideShow.cpp @@ -55,8 +55,8 @@ SlideShowSettingsDlg::SlideShowSettingsDlg() zoom_minus.WhenRepeat = zoom_minus ^= [=] { slideshow->Key(K_CTRL|K_SUBTRACT, 1); }; margin_plus.WhenRepeat = margin_plus ^= [=] { slideshow->Key(K_ALT|K_ADD, 1); }; margin_minus.WhenRepeat = margin_minus ^= [=] { slideshow->Key(K_ALT|K_SUBTRACT, 1); }; - title_plus.WhenRepeat = title_plus ^= [=] { slideshow->Key(K_SHIFT|K_ALT|K_ADD, 1); }; - title_minus.WhenRepeat = title_minus ^= [=] { slideshow->Key(K_SHIFT|K_ALT|K_SUBTRACT, 1); }; + title_plus.WhenRepeat = title_plus ^= [=] { slideshow->Key(K_CTRL|K_ALT|K_ADD, 1); }; + title_minus.WhenRepeat = title_minus ^= [=] { slideshow->Key(K_CTRL|K_ALT|K_SUBTRACT, 1); }; } void SlideShow::Serialize(Stream& s) @@ -88,6 +88,7 @@ SlideShow::SlideShow() title.NoSb(); Add(title); title.SetFrame(NullFrame()); + title.SizePos(); LoadFromGlobal(*this, "SlideShow"); } @@ -131,6 +132,9 @@ bool SlideShow::Key(dword key, int count) case K_ESCAPE: Break(); return true; + case K_HOME: + page = 0; + break; case K_LEFT: case K_PAGEUP: case K_SPACE: @@ -180,11 +184,11 @@ void SlideShow::SetPage() if(page >= 0) t = ReadTopic(LoadFile(path[page])); if(settings.title) { - title <<= "{{1@C~ [*R+" + AsString(titleh) + " " + t.title + "}}"; + title <<= "{{1@C~ [*R+" + AsString(titleh) + " \1" + t.title + "\1}}"; title.HMargins(DPI(8) * margins); title.VMargins(0); - int cy = min(title.GetHeight() + DPI(20), GetSize().cx / 2); - title.HSizePos().TopPos(0, cy); + int cy = min(title.GetHeight() + DPI(20), GetSize().cy / 2); + title.TopPos(0, cy); text.VSizePos(cy, 0); title.Show(); }