summaryrefslogtreecommitdiff
path: root/docview
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@gmail.com>2013-04-25 16:40:37 +0100
committerGraeme Geldenhuys <graemeg@gmail.com>2013-04-25 16:40:37 +0100
commit4331749d924fe50be3b33e9fc5a2ccd98ef3cacf (patch)
tree66d56ebdc0c32cb2c550a33758a9743d66625c12 /docview
parent26933c6be705219d5e9fabd33cb4d501f3651abd (diff)
downloadfpGUI-4331749d924fe50be3b33e9fc5a2ccd98ef3cacf.tar.xz
docview: When searching, do a text encoding conversion of dictionary words.
We forgot to do this before, so sometimes text could not be found. Also added a note on how we could improve the speed.
Diffstat (limited to 'docview')
-rw-r--r--docview/src/SearchUnit.pas17
1 files changed, 14 insertions, 3 deletions
diff --git a/docview/src/SearchUnit.pas b/docview/src/SearchUnit.pas
index ec333406..5f40f641 100644
--- a/docview/src/SearchUnit.pas
+++ b/docview/src/SearchUnit.pas
@@ -2,9 +2,11 @@ Unit SearchUnit;
{$mode objfpc}{$H+}
-// NewView - a new OS/2 Help Viewer
-// Copyright 2003 Aaron Lawrence (aaronl at consultant dot com)
-// This software is released under the Gnu Public License - see readme.txt
+{ TODO: Possible speed improvement here is to populate the DictionaryWords
+ array with already UTF8 text encoded words. That way we don't need
+ to do conversions each time for each word we search for. This should
+ be a nice speed impromevent.
+}
Interface
@@ -52,6 +54,7 @@ uses
,CompareWordUnit
,nvUtilities
,ACLStringUtility
+ ,fpg_stringutils
;
type
@@ -129,6 +132,8 @@ begin
for DictIndex := 0 to HelpFile.DictionaryCount - 1 do
begin
DictWord := HelpFile.DictionaryWords[ DictIndex ];
+ // apply encoding conversion
+ DictWord := ConvertTextToUTF8(HelpFile.Encoding, DictWord);
Results^[ DictIndex ] := CompareWord( SearchWord, DictWord );
end;
end;
@@ -147,6 +152,8 @@ begin
for DictIndex := 0 to HelpFile.DictionaryCount - 1 do
begin
DictWord := HelpFile.DictionaryWords[ DictIndex ];
+ // apply encoding conversion
+ DictWord := ConvertTextToUTF8(HelpFile.Encoding, DictWord);
if SameText( SearchWord, DictWord ) then
Results^[ DictIndex ] := mwExactWord;
end;
@@ -166,6 +173,8 @@ begin
for DictIndex := 0 to HelpFile.DictionaryCount - 1 do
begin
DictWord := HelpFile.DictionaryWords[ DictIndex ];
+ // apply encoding conversion
+ DictWord := ConvertTextToUTF8(HelpFile.Encoding, DictWord);
if StrStartsWithIgnoringCase(DictWord, SearchWord) then
Results^[ DictIndex ] := MatchedWordRelevance( SearchWord, DictWord );
end;
@@ -185,6 +194,8 @@ begin
for DictIndex := 0 to HelpFile.DictionaryCount - 1 do
begin
DictWord := HelpFile.DictionaryWords[ DictIndex ];
+ // apply encoding conversion
+ DictWord := ConvertTextToUTF8(HelpFile.Encoding, DictWord);
if StrEndsWithIgnoringCase( SearchWord, DictWord ) then
Results^[ DictIndex ] := MatchedWordRelevance( SearchWord, DictWord );
end;