Paragraph::value_type Paragraph::Pimpl::getChar(pos_type pos) const
{
// This is in the critical path for loading!
- pos_type siz = size();
+ pos_type const siz = size();
lyx::Assert(pos <= siz);
// This is stronger, and I belive that this is the assertion
// that we should really use. (Lgb)
}
-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;
}
break;
case '±': case '²': case '³':
- case '×': case '÷': case '¹':
+ case '×': case '÷': case '¹':
case '¬': case 'µ':
if ((bparams.inputenc == "latin1" ||
bparams.inputenc == "latin9") ||
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;
Paragraph * par = owner_;
while (par && par->params().depth() == owner_->params().depth()) {
- if (textclasslist[bparams.textclass][par->layout()].isEnvironment()) {
+ if (par->layout()->isEnvironment()) {
par = par->TeXEnvironment(buf, bparams,
os, texrow);
} else {
while (par && par->getDepth() && !tmpfont.resolved()) {
par = par->outerHook();
if (par) {
- tmpfont.realize(tclass[par->layout()].font
+ tmpfont.realize(par->layout()->font
#ifdef INHERIT_LANGUAGE
, bparams.language
#endif