#include <vector>
+using lyx::CoordCache;
using lyx::docstring;
using lyx::pos_type;
+using lyx::Point;
using lyx::support::addPath;
using lyx::support::bformat;
namespace Alert = lyx::frontend::Alert;
-
namespace {
unsigned int const saved_positions_num = 20;
theFontMetrics(cursor_.getFont());
int const asc = fm.maxAscent();
int const des = fm.maxDescent();
- Point const p = bv_funcs::getPos(cursor_, cursor_.boundary());
+ Point const p = bv_funcs::getPos(*this, cursor_, cursor_.boundary());
if (p.y_ - asc >= 0 && p.y_ + des < height_)
return false;
}
cur.clearSelection();
break;
case bv_funcs::CUR_INSIDE:
- int const y = bv_funcs::getPos(cur, cur.boundary()).y_;
+ int const y = bv_funcs::getPos(*this, cur, cur.boundary()).y_;
int const newy = min(last, max(y, first));
if (y != newy) {
cur.reset(buffer_->inset());
}
-Change const BufferView::getCurrentChange()
+Change const BufferView::getCurrentChange() const
{
if (!cursor_.selection())
return Change(Change::UNCHANGED);
bot.text()->redoParagraph(pit);
Paragraph const & par = bot.text()->paragraphs()[pit];
anchor_ref_ = pit;
- offset_ref_ = bv_funcs::coordOffset(cursor_, cursor_.boundary()).y_
+ offset_ref_ = bv_funcs::coordOffset(*this, cursor_, cursor_.boundary()).y_
+ par.ascent() - height_ / 2;
}
break;
case LFUN_LABEL_GOTO: {
- string label = lyx::to_utf8(cmd.argument());
+ docstring label = cmd.argument();
if (label.empty()) {
InsetRef * inset =
getInsetByCode<InsetRef>(cursor_,
InsetBase::REF_CODE);
if (inset) {
- label = inset->getContents();
+ label = lyx::from_utf8(inset->getContents());
savePosition(0);
}
}
}
-void BufferView::gotoLabel(string const & label)
+void BufferView::gotoLabel(docstring const & label)
{
for (InsetIterator it = inset_iterator_begin(buffer_->inset()); it; ++it) {
- vector<string> labels;
+ vector<docstring> labels;
it->getLabelList(*buffer_, labels);
if (find(labels.begin(),labels.end(),label) != labels.end()) {
setCursor(it);
void BufferView::updateMetrics(bool singlepar)
{
+ // FIXME (Abdel 19/10/2006):
+ // There's something fishy in tabular. The coord_cache_ is not
+ // correctly reconstructed when a character is trying to be inserted.
+ // Not clearing out the coord_cache_ fixes the crash but I don't know
+ // what side effect this could have on other insets.
+ //
// Remove old position cache
- theCoords.clear();
+ // coord_cache_.clear();
+
LyXText & buftext = buffer_->text();
lyx::pit_type size = int(buftext.paragraphs().size());
// The coordinates of all these paragraphs are correct, cache them
int y = y1;
- CoordCache::InnerParPosCache & parPos = theCoords.parPos()[&buftext];
+ CoordCache::InnerParPosCache & parPos = coord_cache_.parPos()[&buftext];
for (lyx::pit_type pit = pit1; pit <= pit2; ++pit) {
Paragraph const & par = buftext.getPar(pit);
y += par.ascent();