From 7a502d6450d6f63729d20c1c1b81ab669c410650 Mon Sep 17 00:00:00 2001 From: cxl Date: Wed, 20 Jan 2010 21:29:21 +0000 Subject: [PATCH] theide: Fixed highlighting of searched words in help git-svn-id: svn://ultimatepp.org/upp/trunk@1913 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/src.tpp/XmlNode$en-us.tpp | 25 +++++++++++++------------ uppsrc/Core/src.tpp/XmlOutput$en-us.tpp | 2 +- uppsrc/Core/src.tpp/XmlParser$en-us.tpp | 2 +- uppsrc/CtrlLib/RichText.h | 1 + uppsrc/ide/Help.cpp | 25 ++++++++++++++++++------- 5 files changed, 34 insertions(+), 21 deletions(-) diff --git a/uppsrc/Core/src.tpp/XmlNode$en-us.tpp b/uppsrc/Core/src.tpp/XmlNode$en-us.tpp index 1dbf752f8..d074a5d6a 100644 --- a/uppsrc/Core/src.tpp/XmlNode$en-us.tpp +++ b/uppsrc/Core/src.tpp/XmlNode$en-us.tpp @@ -1,4 +1,4 @@ -topic ""; +topic "XmlNode"; [2 $$0,0#00000000000000000000000000000000:Default] [i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class] [l288;2 $$2,2#27521748481378242620020725143825:desc] @@ -235,12 +235,12 @@ ser][@(0.0.255) `&]_[*@3 p], [_^dword^ dword]_[*@3 style]_`=_XML`_IGNORE`_DECLS[ [s2;%% Creates XmlNode parsing XML document supplied either as string or XmlParser. [%-*@3 style] can be a combination of&] [s2;%% &] -[ {{3581:6419<288; [s2;l32;%% XML`_IGNORE`_DECLS] -:: [s2;l64;%% Declaration elements are ignored.] -:: [s2;l32;%% XML`_IGNORE`_PIS] -:: [s2;l64;%% Processing info elements are ignored.] -:: [s2;l32;%% XML`_IGNORE`_COMMENTS] -:: [s2;l64;%% Comments are ignored.]}}&] +[ {{3581:6419<288;^ [s2;l32;%% XML`_IGNORE`_DECLS] +::= [s2;l64;%% Declaration elements are ignored.] +::^ [s2;l32;%% XML`_IGNORE`_PIS] +::= [s2;l64;%% Processing info elements are ignored.] +::^ [s2;l32;%% XML`_IGNORE`_COMMENTS] +::= [s2;l64;%% Comments are ignored.]}}&] [s3;%% &] [s4; &] [s5;:AsXML`(const XmlNode`&`,dword`): [_^String^ String]_[* AsXML]([@(0.0.255) const]_[_^XmlNode^ X @@ -249,11 +249,12 @@ ML`_DOCTYPE)&] [s2;%% Creates a XML document from XmlNode [%-*@3 n]. [%-*@3 style] can be a combination &] [s2;%% &] -[ {{3581:6419<288; [s2;l32; XML`_HEADER] -:: [s2;l64;%% Adds standard XML header at the beginning of the document.] -:: [s2;l32; XML`_DOCTYPE] -:: [s2;l64;%% Adds DOCTYPE declaration at the beginning of the document -with type taken as id of first XML`_TAG sub`-node.]}}&] +[ {{3581:6419<288;^ [s2;l32; XML`_HEADER] +::= [s2;l64;%% Adds standard XML header at the beginning of the document.] +::^ [s2;l32; XML`_DOCTYPE] +::= [s2;l64;%% Adds DOCTYPE declaration at the beginning of the document +with type taken as id of first XML`_TAG sub`-node (which represents +the root element).]}}&] [s2;%% &] [s3;%% &] [s0; ] \ No newline at end of file diff --git a/uppsrc/Core/src.tpp/XmlOutput$en-us.tpp b/uppsrc/Core/src.tpp/XmlOutput$en-us.tpp index d8ab9c84b..47149687d 100644 --- a/uppsrc/Core/src.tpp/XmlOutput$en-us.tpp +++ b/uppsrc/Core/src.tpp/XmlOutput$en-us.tpp @@ -1,4 +1,4 @@ -topic ""; +topic "XML output"; [2 $$0,0#00000000000000000000000000000000:Default] [i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class] [l288;2 $$2,2#27521748481378242620020725143825:desc] diff --git a/uppsrc/Core/src.tpp/XmlParser$en-us.tpp b/uppsrc/Core/src.tpp/XmlParser$en-us.tpp index d26e5414e..bdbffd58d 100644 --- a/uppsrc/Core/src.tpp/XmlParser$en-us.tpp +++ b/uppsrc/Core/src.tpp/XmlParser$en-us.tpp @@ -1,4 +1,4 @@ -topic ""; +topic "XmlParser"; [2 $$0,0#00000000000000000000000000000000:Default] [i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class] [l288;2 $$2,2#27521748481378242620020725143825:desc] diff --git a/uppsrc/CtrlLib/RichText.h b/uppsrc/CtrlLib/RichText.h index 0768b060d..6fe719c90 100644 --- a/uppsrc/CtrlLib/RichText.h +++ b/uppsrc/CtrlLib/RichText.h @@ -197,6 +197,7 @@ public: void FinishTree(); void OpenDeep(int id = 0); void CurrentOrHome(); + void ClearCurrentLink() { current_link.Clear(); } String GetCurrent() const { return topic; } String GetCurrentLabel() const { return label; } diff --git a/uppsrc/ide/Help.cpp b/uppsrc/ide/Help.cpp index d10f1c886..5a5bdf518 100644 --- a/uppsrc/ide/Help.cpp +++ b/uppsrc/ide/Help.cpp @@ -293,27 +293,37 @@ Topic TopicCtrl::AcquireTopic(const String& t) return Topic(); } + + struct HighlightWords : RichText::Iterator { - Index words; + Vector words; struct Pos : Moveable { int pos, len; }; Vector pos; + int FindPattern(const String& x) { + for(int i = 0; i < words.GetCount(); i++) + if(x.StartsWith(words[i])) + return words[i].GetCount(); + return -1; + } + virtual bool operator()(int tpos, const RichPara& para) { WString text = para.GetText(); const wchar *s = text; for(;;) { - while(!IsLetter(*s) && *s) + while(!IsAlpha(*s) && !IsDigit(*s) && *s) s++; if(*s == '\0') break; - WStringBuffer wb; + String wb; const wchar *b = s; - while(IsLetter(*s)) - wb.Cat(ToLower(*s++)); - if(words.Find(FromUnicode(wb)) >= 0) { + while(IsAlpha(*s) || IsDigit(*s)) + wb.Cat(ToUpper(*s++)); + int q = FindPattern(wb); + if(q >= 0) { Pos& p = pos.Add(); p.pos = int(b - ~text) + tpos; - p.len = int(s - b); + p.len = q; } } return false; @@ -431,6 +441,7 @@ void TopicCtrl::SShow() void TopicCtrl::Search() { int l, h; + ClearCurrentLink(); search.GetSelection(l, h); SyncDocTree(); SetBar();