#include "BranchList.h"
#include "Buffer.h"
-#include "buffer_funcs.h"
#include "BufferList.h"
#include "BufferParams.h"
#include "CoordCache.h"
#include "CutAndPaste.h"
#include "DispatchResult.h"
#include "ErrorList.h"
-#include "factory.h"
-#include "FloatList.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "Intl.h"
-#include "InsetIterator.h"
#include "Language.h"
-#include "LaTeXFeatures.h"
#include "LayoutFile.h"
-#include "Length.h"
#include "Lexer.h"
#include "LyX.h"
#include "LyXAction.h"
#include "lyxfind.h"
-#include "Layout.h"
#include "LyXRC.h"
#include "MetricsInfo.h"
#include "Paragraph.h"
-#include "ParagraphParameters.h"
-#include "ParIterator.h"
-#include "RowPainter.h"
#include "Session.h"
#include "Text.h"
-#include "TextClass.h"
#include "TextMetrics.h"
#include "TexRow.h"
#include "TocBackend.h"
-#include "WordLangTuple.h"
#include "insets/InsetBibtex.h"
#include "insets/InsetCitation.h"
#include "insets/InsetCommand.h" // ChangeRefs
-#include "insets/InsetExternal.h"
#include "insets/InsetGraphics.h"
-#include "insets/InsetNote.h"
#include "insets/InsetRef.h"
#include "insets/InsetText.h"
#include "mathed/MathData.h"
-#include "mathed/InsetMathNest.h"
#include "frontends/alert.h"
-#include "frontends/Application.h"
#include "frontends/Delegates.h"
#include "frontends/FontMetrics.h"
#include "frontends/NullPainter.h"
#include "support/convert.h"
#include "support/debug.h"
-#include "support/ExceptionMessage.h"
+#include "support/docstring.h"
#include "support/filetools.h"
#include "support/gettext.h"
#include "support/lassert.h"
+#include "support/Length.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
-#include "support/Package.h"
#include "support/types.h"
+#include <algorithm>
#include <cerrno>
+#include <cstring>
#include <fstream>
#include <functional>
#include <iterator>
TextMetrics & tm = d->text_metrics_[bot.text()];
pos_type const max_pit = pos_type(bot.text()->paragraphs().size() - 1);
- int bot_pit = bot.pit();
+ pos_type bot_pit = bot.pit();
if (bot_pit > max_pit) {
// FIXME: Why does this happen?
LYXERR0("bottom pit is greater that max pit: "
Text & buftext = buffer_.text();
pit_type const bottom_pit = d->cursor_.bottom().pit();
TextMetrics & tm = textMetrics(&buftext);
- int old_height = tm.parMetrics(bottom_pit).height();
+ Dimension const old_dim = tm.parMetrics(bottom_pit).dim();
// make sure inline completion pointer is ok
if (d->inlineCompletionPos_.fixIfBroken())
// (if this paragraph contains insets etc., rebreaking will
// recursively descend)
tm.redoParagraph(bottom_pit);
- ParagraphMetrics const & pm = tm.parMetrics(bottom_pit);
- if (pm.height() != old_height)
+ ParagraphMetrics & pm = tm.parMetrics(bottom_pit);
+ if (pm.height() != old_dim.height()) {
// Paragraph height has changed so we cannot proceed to
// the singlePar optimisation.
return false;
+ }
+ // Since position() points to the baseline of the first row, we
+ // may have to update it. See ticket #11601 for an example where
+ // the height does not change but the ascent does.
+ pm.setPosition(pm.position() - old_dim.ascent() + pm.ascent());
tm.updatePosCache(bottom_pit);
// Rebreak anchor paragraph.
tm.redoParagraph(d->anchor_pit_);
- ParagraphMetrics & anchor_pm = tm.par_metrics_[d->anchor_pit_];
+ ParagraphMetrics & anchor_pm = tm.parMetrics(d->anchor_pit_);
// position anchor
if (d->anchor_pit_ == 0) {
pit_type pit1 = d->anchor_pit_ - 1;
for (; pit1 >= 0 && y1 >= 0; --pit1) {
tm.redoParagraph(pit1);
- ParagraphMetrics & pm = tm.par_metrics_[pit1];
+ ParagraphMetrics & pm = tm.parMetrics(pit1);
y1 -= pm.descent();
// Save the paragraph position in the cache.
pm.setPosition(y1);
pit_type pit2 = d->anchor_pit_ + 1;
for (; pit2 < npit && y2 <= height_; ++pit2) {
tm.redoParagraph(pit2);
- ParagraphMetrics & pm = tm.par_metrics_[pit2];
+ ParagraphMetrics & pm = tm.parMetrics(pit2);
y2 += pm.ascent();
// Save the paragraph position in the cache.
pm.setPosition(y2);
}
-void BufferView::caretPosAndHeight(Point & p, int & h) const
+void BufferView::caretPosAndDim(Point & p, Dimension & dim) const
{
- int asc, des;
Cursor const & cur = cursor();
if (cur.inMathed()) {
MathRow const & mrow = mathRow(&cur.cell());
- asc = mrow.caret_ascent;
- des = mrow.caret_descent;
+ dim = mrow.caret_dim;
} else {
Font const font = cur.real_current_font;
frontend::FontMetrics const & fm = theFontMetrics(font);
- asc = fm.maxAscent();
- des = fm.maxDescent();
+ dim.wid = fm.lineWidth();
+ dim.asc = fm.maxAscent();
+ dim.des = fm.maxDescent();
}
- h = asc + des;
+ if (lyxrc.cursor_width > 0)
+ dim.wid = lyxrc.cursor_width;
+
p = getPos(cur);
- p.y_ -= asc;
+ p.y_ -= dim.asc;
}
if (!paragraphVisible(cursor()))
return false;
Point p;
- int h;
- caretPosAndHeight(p, h);
+ Dimension dim;
+ caretPosAndDim(p, dim);
// does the cursor touch the screen ?
- if (p.y_ + h < 0 || p.y_ >= workHeight())
+ if (p.y_ + dim.height() < 0 || p.y_ >= workHeight())
return false;
return true;
}
: "\t\t *** END DRAWING ***"));
// The scrollbar needs an update.
+ // FIXME: does it always? see ticket #11947.
updateScrollbar();
// Normalize anchor for next time
}
-size_t const & BufferView::inlineCompletionUniqueChars() const
+size_t BufferView::inlineCompletionUniqueChars() const
{
return d->inlineCompletionUniqueChars_;
}