+2003-04-10 Lars Gullik Bjønnes <larsbj@gullik.net>
+
+ * text2.C: adjust several funcs.
+ (realizeFont): take a ParagraphList::iterator as arg.
+ (getLayoutFont): ditto
+ (getLabelFont): ditto
+ (setCharFont): ditto
+
+ * text.C: adjust several funcs.
+
2003-04-09 Alfredo Braunstein <abraunst@libero.it>
* text.C (selectNextWordToSpellcheck): don't accidentally
2003-04-09 Alfredo Braunstein <abraunst@libero.it>
- * text2.C (cursorRight): a getChar assert fixed
+ * text2.C (cursorRight): a getChar assert fixed
2003-04-09 Lars Gullik Bjønnes <larsbj@gullik.net>
LyXFont const getFont(Buffer const *, ParagraphList::iterator pit,
lyx::pos_type pos) const;
///
- LyXFont const getLayoutFont(Buffer const *, Paragraph * par) const;
+ LyXFont const getLayoutFont(Buffer const *,
+ ParagraphList::iterator pit) const;
///
- LyXFont const getLabelFont(Buffer const *, Paragraph * par) const;
+ LyXFont const getLabelFont(Buffer const *,
+ ParagraphList::iterator pit) const;
///
- void setCharFont(Buffer const *, Paragraph * par,
+ void setCharFont(Buffer const *, ParagraphList::iterator pit,
lyx::pos_type pos, LyXFont const & font);
- void setCharFont(Paragraph * par,
- lyx::pos_type pos, LyXFont const & font, bool toggleall);
+ void setCharFont(ParagraphList::iterator pit,
+ lyx::pos_type pos,
+ LyXFont const & font, bool toggleall);
///
void breakAgainOneRow(RowList::iterator rit);
}
}
- LyXFont const labelfont = getLabelFont(bv()->buffer(), &*row.par());
+ LyXFont const labelfont = getLabelFont(bv()->buffer(), row.par());
switch (layout->margintype) {
case MARGIN_DYNAMIC:
if (!layout->leftmargin.empty()) {
// add the auto-hfill from label end to the body
if (body_pos && i == body_pos) {
thiswidth += font_metrics::width(layout->labelsep,
- getLabelFont(bv()->buffer(), &*pit));
+ getLabelFont(bv()->buffer(), pit));
if (pit->isLineSeparator(i - 1))
thiswidth -= singleWidth(pit, i - 1);
}
while (i <= last) {
if (body_pos > 0 && i == body_pos) {
- w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), &*pit));
+ w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), pit));
if (pit->isLineSeparator(i - 1))
w -= singleWidth(pit, i - 1);
int left_margin = labelEnd(*row);
++i;
}
if (body_pos > 0 && body_pos > last) {
- w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), &*pit));
+ w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), pit));
if (last >= 0 && pit->isLineSeparator(last))
w -= singleWidth(pit, last);
int const left_margin = labelEnd(*row);
int fill = 0;
string const & labwidstr = row.par()->params().labelWidthString();
if (!labwidstr.empty()) {
- LyXFont const labfont = getLabelFont(bv()->buffer(), &*row.par());
+ LyXFont const labfont = getLabelFont(bv()->buffer(), row.par());
int const labwidth = font_metrics::width(labwidstr, labfont);
fill = max(labwidth - w, 0);
}
// as max get the first character of this row then it can increase but not
// decrease the height. Just some point to start with so we don't have to
// do the assignment below too often.
- LyXFont font = getFont(bv()->buffer(), &*pit, rit->pos());
+ LyXFont font = getFont(bv()->buffer(), pit, rit->pos());
LyXFont::FONT_SIZE const tmpsize = font.size();
- font = getLayoutFont(bv()->buffer(), &*pit);
+ font = getLayoutFont(bv()->buffer(), pit);
LyXFont::FONT_SIZE const size = font.size();
font.setSize(tmpsize);
- LyXFont labelfont = getLabelFont(bv()->buffer(), &*pit);
+ LyXFont labelfont = getLabelFont(bv()->buffer(), pit);
float spacing_val = 1.0;
if (!rit->par()->params().spacing().isDefault()) {
// Check if any insets are larger
for (pos_type pos = rit->pos(); pos <= pos_end; ++pos) {
if (rit->par()->isInset(pos)) {
- tmpfont = getFont(bv()->buffer(), &*rit->par(), pos);
+ tmpfont = getFont(bv()->buffer(), rit->par(), pos);
tmpinset = rit->par()->getInset(pos);
if (tmpinset) {
#if 1 // this is needed for deep update on initialitation
if (firstpit->params().lineTop())
maxasc += 2 * font_metrics::ascent('x', getFont(bv()->buffer(),
- &*firstpit, 0));
+ firstpit, 0));
// and now the pagebreaks
if (firstpit->params().pagebreakTop())
maxasc += 3 * defaultRowHeight();
if (firstpit->params().lineBottom())
maxdesc += 2 * font_metrics::ascent('x',
getFont(bv()->buffer(),
- &*pit,
+ pit,
max(pos_type(0), pit->size() - 1)));
// and now the pagebreaks
cursor.pos() >= 1 &&
cursor.pos() < cursor.par()->size() &&
getFont(bv()->buffer(),
- &*cursor.par(),
+ cursor.par(),
cursor.pos()).number() == LyXFont::ON &&
getFont(bv()->buffer(),
- &*cursor.par(),
+ cursor.par(),
cursor.pos() - 1).number() == LyXFont::ON)
)
number(bv()); // Set current_font.number to OFF
} else if (contains(number_seperators, c) &&
cursor.pos() >= 2 &&
getFont(bv()->buffer(),
- &*cursor.par(),
+ cursor.par(),
cursor.pos() - 2).number() == LyXFont::ON) {
setCharFont(bv()->buffer(),
- &*cursor.par(),
+ cursor.par(),
cursor.pos() - 1,
current_font);
}
!rit->par()->isLineSeparator(body_pos - 1))) {
x += font_metrics::width(layout->labelsep,
getLabelFont(bv()->buffer(),
- &*rit->par()));
+ rit->par()));
if (body_pos - 1 <= last)
x += fill_label_hfill;
}
bool const is_good_inset = cpit->isInset(cpos)
&& cpit->getInset(cpos)->allowSpellcheck();
-
- if (!isDeletedText(*cpit, cpos)
+
+ if (!isDeletedText(*cpit, cpos)
&& (is_good_inset || cpit->isLetter(cpos)))
- break;
-
+ break;
+
cursor.pos(cpos + 1);
}
selection.cursor = cursor;
string lang_code(
- getFont(bv()->buffer(), &*cursor.par(), cursor.pos())
+ getFont(bv()->buffer(), cursor.par(), cursor.pos())
.language()->code());
// and find the end of the word (insets like optional hyphens
// and ligature break are part of a word)
} else if (!rowlist_.empty())
return;
- ParagraphList::iterator par = ownerParagraphs().begin();
+ ParagraphList::iterator pit = ownerParagraphs().begin();
ParagraphList::iterator end = ownerParagraphs().end();
- current_font = getFont(bview->buffer(), &*par, 0);
+ current_font = getFont(bview->buffer(), pit, 0);
- for (; par != end; ++par) {
- insertParagraph(&*par, rowlist_.end());
+ for (; pit != end; ++pit) {
+ insertParagraph(&*pit, rowlist_.end());
}
- setCursorIntern(&*rowlist_.begin()->par(), 0);
+ setCursorIntern(rowlist_.begin()->par(), 0);
selection.cursor = cursor;
updateCounters();
LyXFont const realizeFont(LyXFont const & font,
Buffer const * buf,
- Paragraph * par)
+ ParagraphList & /*plist*/,
+ ParagraphList::iterator pit)
{
LyXTextClass const & tclass = buf->params.getLyXTextClass();
LyXFont tmpfont(font);
- Paragraph::depth_type par_depth = par->getDepth();
+ Paragraph::depth_type par_depth = pit->getDepth();
+
+ Paragraph * par = &*pit;
// Resolve against environment font information
while (par && par_depth && !tmpfont.resolved()) {
if (pit->inInset())
pit->inInset()->getDrawFont(tmpfont);
- return realizeFont(tmpfont, buf, &*pit);
+ return realizeFont(tmpfont, buf, ownerParagraphs(), pit);
}
-LyXFont const LyXText::getLayoutFont(Buffer const * buf, Paragraph * par) const
+LyXFont const LyXText::getLayoutFont(Buffer const * buf,
+ ParagraphList::iterator pit) const
{
- LyXLayout_ptr const & layout = par->layout();
+ LyXLayout_ptr const & layout = pit->layout();
- if (!par->getDepth()) {
+ if (!pit->getDepth()) {
return layout->resfont;
}
- return realizeFont(layout->font, buf, par);
+ return realizeFont(layout->font, buf, ownerParagraphs(), pit);
}
-LyXFont const LyXText::getLabelFont(Buffer const * buf, Paragraph * par) const
+LyXFont const LyXText::getLabelFont(Buffer const * buf,
+ ParagraphList::iterator pit) const
{
- LyXLayout_ptr const & layout = par->layout();
+ LyXLayout_ptr const & layout = pit->layout();
- if (!par->getDepth()) {
+ if (!pit->getDepth()) {
return layout->reslabelfont;
}
- return realizeFont(layout->labelfont, buf, par);
+ return realizeFont(layout->labelfont, buf, ownerParagraphs(), pit);
}
-void LyXText::setCharFont(Paragraph * par,
+void LyXText::setCharFont(ParagraphList::iterator pit,
pos_type pos, LyXFont const & fnt,
bool toggleall)
{
Buffer const * buf = bv()->buffer();
- LyXFont font = getFont(buf, par, pos);
+ LyXFont font = getFont(buf, pit, pos);
font.update(fnt, buf->params.language, toggleall);
// Let the insets convert their font
- if (par->isInset(pos)) {
- Inset * inset = par->getInset(pos);
+ if (pit->isInset(pos)) {
+ Inset * inset = pit->getInset(pos);
if (isEditableInset(inset)) {
UpdatableInset * uinset =
static_cast<UpdatableInset *>(inset);
}
// Plug thru to version below:
- setCharFont(buf, par, pos, font);
+ setCharFont(buf, pit, pos, font);
}
-void LyXText::setCharFont(Buffer const * buf, Paragraph * par,
+void LyXText::setCharFont(Buffer const * buf, ParagraphList::iterator pit,
pos_type pos, LyXFont const & fnt)
{
LyXFont font(fnt);
LyXTextClass const & tclass = buf->params.getLyXTextClass();
- LyXLayout_ptr const & layout = par->layout();
+ LyXLayout_ptr const & layout = pit->layout();
// Get concrete layout font to reduce against
LyXFont layoutfont;
- if (pos < par->beginningOfBody())
+ if (pos < pit->beginningOfBody())
layoutfont = layout->labelfont;
else
layoutfont = layout->font;
// Realize against environment font information
- if (par->getDepth()) {
- Paragraph * tp = par;
+ if (pit->getDepth()) {
+#warning FIXME I think I hate this outerHood stuff.
+ Paragraph * tp = &*pit;
while (!layoutfont.resolved() && tp && tp->getDepth()) {
tp = tp->outerHook();
if (tp)
// Now, reduce font against full layout font
font.reduce(layoutfont);
- par->setFont(pos, font);
+ pit->setFont(pos, font);
}
LyXFont layoutfont;
if (cursor.pos() < cursor.par()->beginningOfBody()) {
layoutfont = getLabelFont(bv()->buffer(),
- &*cursor.par());
+ cursor.par());
} else {
layoutfont = getLayoutFont(bv()->buffer(),
- &*cursor.par());
+ cursor.par());
}
// Update current font
real_current_font.update(font,
font_metrics::width(
rit->par()->layout()->labelsep,
getLabelFont(bv()->buffer(),
- &*rit->par()));
+ rit->par()));
if (rit->par()->isLineSeparator(body_pos - 1))
x -= singleWidth(rit->par(), body_pos - 1);
}
current_font =
cursor.par()->getFontSettings(bv()->buffer()->params, pos);
- real_current_font = getFont(bv()->buffer(), &*cursor.par(), pos);
+ real_current_font = getFont(bv()->buffer(), cursor.par(), pos);
if (cursor.pos() == cursor.par()->size() &&
isBoundary(bv()->buffer(), &*cursor.par(), cursor.pos()) &&