]> git.lyx.org Git - lyx.git/blobdiff - src/paragraph_pimpl.C
Painter and scrollbar API patches
[lyx.git] / src / paragraph_pimpl.C
index bbc9f87be89e2d48db80a85b86b60ee28136e233..4f662fe18258c4c19787388b758f20ca3ceebc5e 100644 (file)
@@ -275,19 +275,30 @@ void Paragraph::Pimpl::simpleTeXBlanks(ostream & os, TexRow & texrow,
 }
 
 
-bool Paragraph::Pimpl::isTextAt(BufferParams const & bp,
-                               string const & str, pos_type pos)
+bool Paragraph::Pimpl::isTextAt(string const & str, pos_type pos)
 {
-       LyXFont const & font = owner_->getFont(bp, pos);
+       pos_type const len = str.length();
+       
+       // is the paragraph large enough?
+       if (pos + len > size())
+               return false;
 
+       // does the wanted text start at point?
        for (string::size_type i = 0; i < str.length(); ++i) {
-               if (pos + static_cast<pos_type>(i) >= size())
-                       return false;
-               if (str[i] != getChar(pos + i))
-                       return false;
-               if (owner_->getFont(bp, pos + i) != font)
+               if (str[i] != text[pos + i])
                        return false;
        }
+
+       // is there a font change in middle of the word?
+       FontList::const_iterator cit = fontlist.begin();
+       FontList::const_iterator end = fontlist.end();
+       for (; cit != end; ++cit) {
+               if (cit->pos() >= pos)
+                       break;
+       }
+       if (cit != end && pos + len - 1 > cit->pos())
+               return false;
+
        return true;
 }
 
@@ -507,7 +518,7 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
                        size_t pnr = 0;
 
                        for (; pnr < phrases_nr; ++pnr) {
-                               if (isTextAt(bparams, special_phrases[pnr][0], i)) {
+                               if (isTextAt(special_phrases[pnr][0], i)) {
                                        os << special_phrases[pnr][1];
                                        i += special_phrases[pnr][0].length() - 1;
                                        column += special_phrases[pnr][1].length() - 1;