if (!par.getDepth()) {
LyXFont f = par.getFontSettings(params, pos);
if (!isMainText())
- f.realize(font_);
+ applyOuterFont(f);
if (layout->labeltype == LABEL_MANUAL && pos < body_pos)
return f.realize(layout->reslabelfont);
else
font.realize(layoutfont);
if (!isMainText())
- font.realize(font_);
+ applyOuterFont(font);
// Realize with the fonts of lesser depth.
font.realize(defaultfont_);
return font;
}
+// There are currently two font mechanisms in LyX:
+// 1. The font attributes in a lyxtext, and
+// 2. The inset-specific font properties, defined in an inset's
+// metrics() and draw() methods and handed down the inset chain through
+// the pi/mi parameters, and stored locally in a lyxtext in font_.
+// This is where the two are integrated in the final fully realized
+// font.
+void LyXText::applyOuterFont(LyXFont & font) const {
+ LyXFont lf(font_);
+ lf.reduce(defaultfont_);
+ lf.realize(font);
+ lf.setLanguage(font.language());
+ font = lf;
+}
+
LyXFont LyXText::getLayoutFont(pit_type const pit) const
{
// Don't use forwardChar here as ditend might have
// pos() == lastpos() and forwardChar would miss it.
// Can't use forwardPos either as this descends into
- // nested insets.
+ // nested insets.
for (; dit != ditend; dit.forwardPosNoDescend()) {
if (dit.pos() != dit.lastpos()) {
LyXFont f = getFont(dit.paragraph(), dit.pos());
}
-string LyXText::getStringToIndex(LCursor & cur)
+string LyXText::getStringToIndex(LCursor const & cur)
{
BOOST_ASSERT(this == cur.text());
- // Try implicit word selection
- // If there is a change in the language the implicit word selection
- // is disabled.
- CursorSlice const reset_cursor = cur.top();
- bool const implicitSelection =
- selectWordWhenUnderCursor(cur, lyx::PREVIOUS_WORD);
string idxstring;
- if (!cur.selection())
- cur.message(_("Nothing to index!"));
- else if (cur.selBegin().pit() != cur.selEnd().pit())
- cur.message(_("Cannot index more than one paragraph!"));
- else
+ if (cur.selection()) {
idxstring = cur.selectionAsString(false);
-
- // Reset cursors to their original position.
- cur.top() = reset_cursor;
- cur.resetAnchor();
-
- // Clear the implicit selection.
- if (implicitSelection)
- cur.clearSelection();
+ } else {
+ // Try implicit word selection. If there is a change
+ // in the language the implicit word selection is
+ // disabled.
+ LCursor tmpcur = cur;
+ selectWord(tmpcur, lyx::PREVIOUS_WORD);
+
+ if (!tmpcur.selection())
+ cur.message(_("Nothing to index!"));
+ else if (tmpcur.selBegin().pit() != tmpcur.selEnd().pit())
+ cur.message(_("Cannot index more than one paragraph!"));
+ else
+ idxstring = tmpcur.selectionAsString(false);
+ }
return idxstring;
}
}
}
+ // The following code is necessary because the cursor position past
+ // the last char in a row is logically equivalent to that before
+ // the first char in the next row. That's why insets causing row
+ // divisions -- Newline and display-style insets -- must be treated
+ // specially, so cursor up/down doesn't get stuck in an air gap -- MV
+ // Newline inset, air gap below:
if (row.pos() < end && c >= end && par.isNewline(end - 1)) {
if (bidi.level(end -1) % 2 == 0)
tmpx -= singleWidth(par, end - 1);
tmpx += singleWidth(par, end - 1);
c = end - 1;
}
+ // Air gap above display inset:
+ if (row.pos() < end && c >= end && end < par.size()
+ && par.isInset(end) && par.getInset(end)->display()) {
+ c = end - 1;
+ }
+ // Air gap below display inset:
+ if (row.pos() < end && c >= end && par.isInset(end - 1)
+ && par.getInset(end - 1)->display()) {
+ c = end - 1;
+ }
x = int(tmpx) + xo;
return c - row.pos();
x2pos(cur.pit(), row - 1, x));
} else if (cur.pit() > 0) {
--cur.pit();
- updateNeeded |= setCursor(cur, cur.pit(),
- x2pos(cur.pit(), par.rows().size() - 1, x));
+ //cannot use 'par' now
+ updateNeeded |= setCursor(cur, cur.pit(), x2pos(cur.pit(), cur.paragraph().rows().size() - 1, x));
}
cur.x_target() = x;