mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-31 11:36:40 +00:00
Bug 1047 Fix
Dialog links can no longer be highlighted if they appear in the middle of the word. This is achieved by confirming that the character before a match is not alphabetic, so that words following hyphens can still potentially match.
This commit is contained in:
parent
65161c3e24
commit
9095a45ba7
2 changed files with 12 additions and 2 deletions
|
@ -162,7 +162,8 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
std::string::const_iterator i = text.begin ();
|
std::string::const_iterator i = text.begin ();
|
||||||
KeywordSearchT::Match match;
|
KeywordSearchT::Match match;
|
||||||
while (i != text.end () && keywordSearch->search (i, text.end (), match))
|
|
||||||
|
while (i != text.end () && keywordSearch->search (i, text.end (), match, false))
|
||||||
{
|
{
|
||||||
if (i != match.mBeg)
|
if (i != match.mBeg)
|
||||||
addTopicLink (typesetter, 0, i - text.begin (), match.mBeg - text.begin ());
|
addTopicLink (typesetter, 0, i - text.begin (), match.mBeg - text.begin ());
|
||||||
|
|
|
@ -66,10 +66,19 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool search (Point beg, Point end, Match & match)
|
bool search (Point beg, Point end, Match & match, bool matchSubword = true)
|
||||||
{
|
{
|
||||||
|
char prev = ' ';
|
||||||
for (Point i = beg; i != end; ++i)
|
for (Point i = beg; i != end; ++i)
|
||||||
{
|
{
|
||||||
|
// check if previous character marked start of new word
|
||||||
|
if (!matchSubword && isalpha(prev))
|
||||||
|
{
|
||||||
|
prev = *i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
prev = *i;
|
||||||
|
|
||||||
// check first character
|
// check first character
|
||||||
typename Entry::childen_t::iterator candidate = mRoot.mChildren.find (std::tolower (*i, mLocale));
|
typename Entry::childen_t::iterator candidate = mRoot.mChildren.find (std::tolower (*i, mLocale));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue