Asger's commentary, const-correct and bug-squashing little beauty.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9558 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2005-01-31 16:29:48 +00:00
parent 8855810d55
commit e22c5f4d97
32 changed files with 257 additions and 131 deletions

View File

@ -290,8 +290,7 @@ void BufferView::hideCursor()
screen().hideCursor();
}
LyXText * BufferView::getLyXText() const
LyXText * BufferView::getLyXText()
{
LyXText * text = cursor().innerText();
BOOST_ASSERT(text);
@ -299,6 +298,14 @@ LyXText * BufferView::getLyXText() const
}
LyXText const * BufferView::getLyXText() const
{
LyXText const * text = cursor().innerText();
BOOST_ASSERT(text);
return text;
}
void BufferView::haveSelection(bool sel)
{
pimpl_->workarea().haveSelection(sel);

View File

@ -102,7 +102,10 @@ public:
Change const getCurrentChange();
/// return the lyxtext we are using
LyXText * getLyXText() const;
LyXText * getLyXText();
/// return the lyxtext we are using
LyXText const * getLyXText() const;
/// simple replacing. Use the font of the first selected character
void replaceSelectionWithString(std::string const & str);

View File

@ -445,7 +445,6 @@ void BufferView::Pimpl::scrollDocView(int value)
t.redoParagraph(anchor_ref_);
int const h = t.getPar(anchor_ref_).height();
offset_ref_ = int((bar * t.paragraphs().size() - anchor_ref_) * h);
lyxerr << "scrolling: " << value << std::endl;
update();
if (!lyxrc.cursor_follows_scrollbar)
@ -612,6 +611,7 @@ void BufferView::Pimpl::update(bool fitcursor, bool forceupdate)
CoordCache backup;
std::swap(theCoords, backup);
theCoords.startUpdating();
//
ViewMetricsInfo vi = metrics();
@ -622,8 +622,11 @@ void BufferView::Pimpl::update(bool fitcursor, bool forceupdate)
if (forceupdate) {
// second drawing step
screen().redraw(*bv_, vi);
} else
theCoords.doneUpdating();
} else {
// Abort updating of the coord cache - just restore the old one
std::swap(theCoords, backup);
}
} else
screen().greyOut();
@ -743,7 +746,7 @@ void BufferView::Pimpl::switchKeyMap()
void BufferView::Pimpl::center()
{
CursorSlice const & bot = bv_->cursor().bottom();
CursorSlice & bot = bv_->cursor().bottom();
lyx::pit_type const pit = bot.pit();
bot.text()->redoParagraph(pit);
Paragraph const & par = bot.text()->paragraphs()[pit];
@ -1247,7 +1250,7 @@ ViewMetricsInfo BufferView::Pimpl::metrics()
int y = y1;
for (lyx::pit_type pit = pit1; pit <= pit2; ++pit) {
y += text->getPar(pit).ascent();
theCoords.pars_[text][pit] = Point(0, y);
theCoords.parPos()[text][pit] = Point(0, y);
y += text->getPar(pit).descent();
}

View File

@ -2,6 +2,38 @@
* lyxlex_pimpl.h: #include <fstream>.
* BufferView.[Ch] (getLyXText): add a const version.
* BufferView_pimpl.C: add debug aids.
* RowList_fwd.h:
* buffer.h:
* lyxrow.h:
* paragraph_funcs.h: add commentary explaining what the class does.
* coordcache.[Ch]: add lots of commentary.
(startUpdating, doneUpdating): debug aids.
(arrays, insets, parPos, getParPos): accessors to private data.
* cursor_slice.[Ch] (text): add a const version.
* dociterator.[Ch] (text, innerText): add const versions.
* lyxtext.h (breakParagraph): change the keep_layout arg to a
bool.
* paragraph.C (getRow, pos2ros): add asserts.
* paragraph.h: add commentary. Lots of.
* paragraph.[Ch] (metrucs, draw): removed.
* cursor.C:
* rowpainter.[Ch]: const-correct changes.
* text.C: various obvious clean-ups. Removal of ancient cruft.
Bug fixes, even.
2005-01-31 Lars Gullik Bjonnes <larsbj@gullik.net>
* vc-backend.C (find_file): rewrite to use boost.filesystem

View File

@ -16,6 +16,11 @@
#include <vector>
/**
* Each paragraph is broken up into a number of rows on the screen.
* This is a list of such on-screen rows, ordered from the top row
* downwards.
*/
typedef std::vector<Row> RowList;
#endif

View File

@ -49,10 +49,15 @@ class Undo;
/** The buffer object.
This is the buffer object. It contains all the informations about
a document loaded into LyX. I am not sure if the class is complete or
minimal, probably not.
\author Lars Gullik Bjønnes
* This is the buffer object. It contains all the informations about
* a document loaded into LyX.
* The buffer object owns the LyXText (wrapped in an InsetText), which
* contains the individual paragraphs of the document.
*
*
* I am not sure if the class is complete or
* minimal, probably not.
* \author Lars Gullik Bjønnes
*/
class Buffer {
public:

View File

@ -180,8 +180,8 @@ Point coordOffset(DocIterator const & dit)
Point getPos(DocIterator const & dit)
{
CursorSlice const & bot = dit.bottom();
CoordCache::InnerParPosCache & cache = theCoords.pars_[bot.text()];
CoordCache::InnerParPosCache::iterator it = cache.find(bot.pit());
CoordCache::InnerParPosCache const & cache = theCoords.getParPos().find(bot.text())->second;
CoordCache::InnerParPosCache::const_iterator it = cache.find(bot.pit());
if (it == cache.end()) {
//lyxerr << "cursor out of view" << std::endl;
return Point(-1,-1);
@ -195,7 +195,7 @@ Point getPos(DocIterator const & dit)
// this could be used elsewhere as well?
CurStatus status(BufferView const * bv, DocIterator const & dit)
{
CoordCache::InnerParPosCache & cache = theCoords.pars_[dit.bottom().text()];
CoordCache::InnerParPosCache const & cache = theCoords.getParPos().find(dit.bottom().text())->second;
if (cache.find(dit.bottom().pit()) != cache.end())
return CUR_INSIDE;

View File

@ -21,20 +21,24 @@ void lyxbreaker(void const * data, const char * hint, int size)
}
void lyxaborter(int x, int y)
{
lyxerr << "abort on x: " << x << " y: " << y << std::endl;
BOOST_ASSERT(false);
}
void CoordCache::clear()
{
BOOST_ASSERT(updating);
arrays_.clear();
insets_.clear();
pars_.clear();
}
void CoordCache::startUpdating() {
BOOST_ASSERT(!updating);
updating = true;
}
void CoordCache::doneUpdating() {
BOOST_ASSERT(updating);
updating = false;
}
Point CoordCache::get(LyXText const * text, lyx::pit_type pit)
{

View File

@ -12,13 +12,7 @@ class Paragraph;
#include <map>
// All positions cached in this cache are only valid between subsequent
// updated. (x,y) == (0,0) is the upper left screen corner, x increases
// to the right, y increases downwords.
void lyxbreaker(void const * data, const char * hint, int size);
void lyxaborter(int x, int y);
class Point {
public:
@ -92,21 +86,55 @@ private:
cache_type data_;
};
/**
* A global cache that allows us to come from a paragraph in a document
* to a position point on the screen.
* All points cached in this cache are only valid between subsequent
* updated. (x,y) == (0,0) is the upper left screen corner, x increases
* to the right, y increases downwords.
* The cache is built in BufferView::Pimpl::metrics which is called
* from BufferView::Pimpl::update. The individual points are added
* while we paint them. See for instance paintPar in RowPainter.C.
*/
class CoordCache {
public:
CoordCache() : updating(false) { }
/// In order to find bugs, we record when we start updating the cache
void startUpdating();
/// When we are done, we record that to help find bugs
void doneUpdating();
void clear();
Point get(LyXText const *, lyx::pit_type);
/// A map from paragraph index number to screen point
typedef std::map<lyx::pit_type, Point> InnerParPosCache;
/// A map from a LyXText to the map of paragraphs to screen points
typedef std::map<LyXText const *, InnerParPosCache> ParPosCache;
/// A map from MathArray to position on the screen
CoordCacheBase<MathArray> & arrays() { BOOST_ASSERT(updating); return arrays_; }
CoordCacheBase<MathArray> const & getArrays() const { return arrays_; }
/// A map from insets to positions on the screen
CoordCacheBase<InsetBase> & insets() { BOOST_ASSERT(updating); return insets_; }
CoordCacheBase<InsetBase> const & getInsets() const { return insets_; }
/// A map from (LyXText, paragraph) pair to screen positions
ParPosCache & parPos() { BOOST_ASSERT(updating); return pars_; }
ParPosCache const & getParPos() const { return pars_; }
private:
CoordCacheBase<MathArray> arrays_;
// all insets
CoordCacheBase<InsetBase> insets_;
// paragraph grouped by owning text
typedef std::map<lyx::pit_type, Point> InnerParPosCache;
typedef std::map<LyXText const *, InnerParPosCache> ParPosCache;
ParPosCache pars_;
/**
* Debugging flag only: Set to true while the cache is being built.
* No changes to the structure are allowed unless we are updating.
*/
bool updating;
};
extern CoordCache theCoords;

View File

@ -1086,7 +1086,7 @@ Encoding const * LCursor::getEncoding() const
if (operator[](s).text())
break;
CursorSlice const & sl = operator[](s);
LyXText & text = *sl.text();
LyXText const & text = *sl.text();
LyXFont font = text.getPar(sl.pit()).getFont(
bv().buffer()->params(), sl.pos(), outerFont(sl.pit(), text.paragraphs()));
return font.language()->encoding();
@ -1127,7 +1127,7 @@ LyXFont LCursor::getFont() const
if (operator[](s).text())
break;
CursorSlice const & sl = operator[](s);
LyXText & text = *sl.text();
LyXText const & text = *sl.text();
LyXFont font = text.getPar(sl.pit()).getFont(
bv().buffer()->params(),
sl.pos(),

View File

@ -104,7 +104,13 @@ MathArray & CursorSlice::cell() const
}
LyXText * CursorSlice::text() const
LyXText * CursorSlice::text()
{
BOOST_ASSERT(inset_);
return inset_->getText(idx_);
}
LyXText const * CursorSlice::text() const
{
BOOST_ASSERT(inset_);
return inset_->getText(idx_);

View File

@ -97,7 +97,9 @@ public:
/// see comment for the member
bool & boundary() { return boundary_; }
///
LyXText * text() const;
LyXText * text();
///
LyXText const * text() const;
///
UpdatableInset * asUpdatableInset() const;
///

View File

@ -123,7 +123,13 @@ MathAtom & DocIterator::nextAtom()
}
LyXText * DocIterator::text() const
LyXText * DocIterator::text()
{
BOOST_ASSERT(!empty());
return top().text();
}
LyXText const * DocIterator::text() const
{
BOOST_ASSERT(!empty());
return top().text();
@ -146,12 +152,14 @@ Paragraph const & DocIterator::paragraph() const
Row & DocIterator::textRow()
{
BOOST_ASSERT(!paragraph().rows().empty());
return paragraph().getRow(pos());
}
Row const & DocIterator::textRow() const
{
BOOST_ASSERT(!paragraph().rows().empty());
return paragraph().getRow(pos());
}
@ -233,7 +241,18 @@ bool DocIterator::inTexted() const
}
LyXText * DocIterator::innerText() const
LyXText * DocIterator::innerText()
{
BOOST_ASSERT(!empty());
// go up until first non-0 text is hit
// (innermost text is 0 in mathed)
for (int i = size() - 1; i >= 0; --i)
if (operator[](i).text())
return operator[](i).text();
return 0;
}
LyXText const * DocIterator::innerText() const
{
BOOST_ASSERT(!empty());
// go up until first non-0 text is hit

View File

@ -151,11 +151,15 @@ public:
/// the row in the paragraph we're in
Row const & textRow() const;
///
LyXText * text() const;
LyXText * text();
///
LyXText const * text() const;
///
InsetBase * innerInsetOfType(int code) const;
///
LyXText * innerText() const;
LyXText * innerText();
///
LyXText const * innerText() const;
//
// elementary moving

View File

@ -1,3 +1,10 @@
2005-01-31 Asger Ottar Alstrup <aalstrup@laerdal.dk>
* inset.C:
* insetbase.C:
* insettabular.C:
* updatableinset.C: Use new cursor accessors.
2005-01-31 Lars Gullik Bjonnes <larsbj@gullik.net>
* insetinclude.C (loadIfNeeded): rewrite to use boost.filesystem

View File

@ -79,5 +79,5 @@ int InsetOld::scroll(bool) const
void InsetOld::setPosCache(PainterInfo const &, int x, int y) const
{
//lyxerr << "InsetOld:: position cache to " << x << " " << y << std::endl;
theCoords.insets_.add(this, x, y);
theCoords.insets().add(this, x, y);
}

View File

@ -293,13 +293,13 @@ bool InsetBase::editing(BufferView * bv) const
int InsetBase::xo() const
{
return theCoords.insets_.x(this);
return theCoords.getInsets().x(this);
}
int InsetBase::yo() const
{
return theCoords.insets_.y(this);
return theCoords.getInsets().y(this);
}
@ -310,7 +310,7 @@ bool InsetBase::covers(int x, int y) const
// << " x1: " << xo() << " x2: " << xo() + width()
// << " y1: " << yo() - ascent() << " y2: " << yo() + descent()
// << std::endl;
return theCoords.insets_.has(this)
return theCoords.getInsets().has(this)
&& x >= xo()
&& x <= xo() + width()
&& y >= yo() - ascent()

View File

@ -1024,7 +1024,7 @@ int dist(InsetOld const & inset, int x, int y)
{
int xx = 0;
int yy = 0;
Point o = theCoords.insets_.xy(&inset);
Point o = theCoords.getInsets().xy(&inset);
int const xo = o.x_;
int const yo = o.y_;
@ -1055,7 +1055,7 @@ InsetBase * InsetTabular::setPos(LCursor & cur, int x, int y) const
idx_type idx_min = 0;
int dist_min = std::numeric_limits<int>::max();
for (idx_type i = 0; i < nargs(); ++i) {
if (theCoords.insets_.has(tabular.getCellInset(i).get())) {
if (theCoords.getInsets().has(tabular.getCellInset(i).get())) {
int d = dist(*tabular.getCellInset(i), x, y);
if (d < dist_min) {
dist_min = d;

View File

@ -43,7 +43,7 @@ void UpdatableInset::scroll(BufferView & bv, double s) const
}
int const workW = bv.workWidth();
int xo_ = theCoords.insets_.x(this);
int xo_ = theCoords.getInsets().x(this);
int const tmp_xo_ = xo_ - scx;
if (tmp_xo_ > 0 && tmp_xo_ + width() < workW)
@ -63,7 +63,7 @@ void UpdatableInset::scroll(BufferView & bv, double s) const
void UpdatableInset::scroll(BufferView & bv, int offset) const
{
int const xo_ = theCoords.insets_.x(this);
int const xo_ = theCoords.getInsets().x(this);
if (offset > 0) {
if (!scx && xo_ >= 20)
return;

View File

@ -17,7 +17,11 @@
#include "support/types.h"
///
/**
* An on-screen row of text. A paragraph is broken into a
* RowList for display. Each Row contains position pointers
* into the first and last character positions of that row.
*/
class Row {
public:
///

View File

@ -70,7 +70,7 @@ public:
bool toggleall);
/// what you expect when pressing <enter> at cursor position
void breakParagraph(LCursor & cur, char keep_layout = 0);
void breakParagraph(LCursor & cur, bool keep_layout = false);
/// set layout over selection
pit_type setLayout(pit_type start, pit_type end,
@ -124,7 +124,7 @@ public:
FuncStatus & status) const;
/// access to out BufferView. This should go...
BufferView * bv();
// BufferView * bv();
/// access to out BufferView. This should go...
BufferView * bv() const;

View File

@ -1,3 +1,9 @@
2005-01-31 Asger Ottar Alstrup <aalstrup@laerdal.dk>
* math_data.C:
* math_diminset.C:
* math_nestinset.C: Use new cursor accessors.
2005-01-27 Lars Gullik Bjonnes <larsbj@gullik.net>
* math_parser.C,math_sizeinset.C: use convert<> instead of

View File

@ -411,17 +411,17 @@ int MathArray::dist(int x, int y) const
void MathArray::setXY(int x, int y) const
{
//lyxerr << "setting position cache for MathArray " << this << std::endl;
theCoords.arrays_.add(this, x, y);
theCoords.arrays().add(this, x, y);
}
int MathArray::xo() const
{
return theCoords.arrays_.x(this);
return theCoords.getArrays().x(this);
}
int MathArray::yo() const
{
return theCoords.arrays_.y(this);
return theCoords.getArrays().y(this);
}

View File

@ -40,5 +40,5 @@ int MathDimInset::width() const
void MathDimInset::setPosCache(PainterInfo const &, int x, int y) const
{
//lyxerr << "MathDimInset: cache to " << x << " " << y << std::endl;
theCoords.insets_.add(this, x, y);
theCoords.insets().add(this, x, y);
}

View File

@ -110,23 +110,23 @@ void MathNestInset::getCursorPos(CursorSlice const & sl,
// absolute again when actually drawing the cursor. What a mess.
BOOST_ASSERT(ptr_cmp(&sl.inset(), this));
MathArray const & ar = sl.cell();
if (!theCoords.arrays_.has(&ar)) {
// this can (semi-)legally happen if we jsut created this cell
if (!theCoords.getArrays().has(&ar)) {
// this can (semi-)legally happen if we just created this cell
// and it never has been drawn before. So don't ASSERT.
//lyxerr << "no cached data for array " << &ar << endl;
x = 0;
y = 0;
return;
}
Point const pt = theCoords.arrays_.xy(&ar);
if (!theCoords.insets_.has(this)) {
Point const pt = theCoords.getArrays().xy(&ar);
if (!theCoords.getInsets().has(this)) {
// same as above
//lyxerr << "no cached data for inset " << this << endl;
x = 0;
y = 0;
return;
}
Point const pt2 = theCoords.insets_.xy(this);
Point const pt2 = theCoords.getInsets().xy(this);
//lyxerr << "retrieving position cache for MathArray "
// << pt.x_ << ' ' << pt.y_ << std::endl;
x = pt.x_ - pt2.x_ + ar.pos2x(sl.pos());

View File

@ -1795,6 +1795,8 @@ bool Paragraph::allowEmpty() const
Row & Paragraph::getRow(pos_type pos)
{
BOOST_ASSERT(!rows().empty());
RowList::iterator rit = rows_.end();
RowList::iterator const begin = rows_.begin();
@ -1807,6 +1809,8 @@ Row & Paragraph::getRow(pos_type pos)
Row const & Paragraph::getRow(pos_type pos) const
{
BOOST_ASSERT(!rows().empty());
RowList::const_iterator rit = rows_.end();
RowList::const_iterator const begin = rows_.begin();
@ -1819,6 +1823,8 @@ Row const & Paragraph::getRow(pos_type pos) const
size_t Paragraph::pos2row(pos_type pos) const
{
BOOST_ASSERT(!rows().empty());
RowList::const_iterator rit = rows_.end();
RowList::const_iterator const begin = rows_.begin();
@ -1873,11 +1879,3 @@ void Paragraph::dump() const
}
}
//void Paragraph::metrics(MetricsInfo & mi, Dimension & dim, LyXText & text)
//{
//}
//
//
//void draw(PainterInfo & pi, int x, int y, LyXText & text) const
//{
//}

View File

@ -134,7 +134,7 @@ public:
lyx::depth_type depth) const;
/// Can we drop the standard paragraph wrapper?
bool Paragraph::emptyTag() const;
bool emptyTag() const;
/// Get the id of the paragraph, usefull for docbook and linuxdoc
std::string getID(Buffer const & buf,
@ -293,7 +293,7 @@ public:
BOOST_ASSERT(pos < int(text_.size()));
return text_[pos];
}
///
/// Get the char, but mirror all bracket characters if it is right-to-left
value_type getUChar(BufferParams const &, lyx::pos_type pos) const;
/// The position must already exist.
void setChar(lyx::pos_type pos, value_type c);
@ -326,6 +326,9 @@ public:
InsetBase * getInset(lyx::pos_type pos);
///
InsetBase const * getInset(lyx::pos_type pos) const;
///
InsetList insetlist;
///
bool isHfill(lyx::pos_type pos) const;
@ -344,7 +347,7 @@ public:
/// returns -1 if inset not found
int getPositionOfInset(InsetBase const * inset) const;
///
/// Returns the number of line breaks and white-space stripped at the start
int stripLeadingSpaces();
/// return true if we allow multiple spaces
@ -352,7 +355,7 @@ public:
/// return true if we allow this par to stay empty
bool allowEmpty() const;
////
///
unsigned char transformChar(unsigned char c, lyx::pos_type pos) const;
///
ParagraphParameters & params();
@ -366,37 +369,34 @@ public:
///
size_t pos2row(lyx::pos_type pos) const;
///
InsetList insetlist;
/// total height of paragraph
unsigned int height() const { return dim_.height(); }
/// total width of paragraph, may differ from workwidth
unsigned int width() const { return dim_.width(); }
unsigned int ascent() const { return dim_.ascent(); }
unsigned int descent() const { return dim_.descent(); }
///
/// LyXText updates the rows using this access point
RowList & rows() { return rows_; }
///
/// The painter and others use this
RowList const & rows() const { return rows_; }
// compute paragraph metrics
void metrics(MetricsInfo & mi, Dimension & dim, LyXText & text);
// draw paragraph
void draw(PainterInfo & pi, int x, int y, LyXText & text) const;
/// dump some information
void dump() const;
/// LyXText::redoParagraph updates this
Dimension & dim() { return dim_; }
/// dump some information to lyxerr
void dump() const;
private:
/// cached dimensions of paragraph
Dimension dim_;
private:
///
mutable RowList rows_;
///
LyXLayout_ptr layout_;
/// keeping this here instead of in the pimpl makes LyX >10% faster
// for average tasks as buffer loading/switching etc.
/**
* Keeping this here instead of in the pimpl makes LyX >10% faster
* for average tasks as buffer loading/switching etc.
*/
TextContainer text_;
/// end of label
lyx::pos_type begin_of_body_;
@ -406,7 +406,6 @@ private:
friend class Paragraph::Pimpl;
///
Pimpl * pimpl_;
};

View File

@ -21,8 +21,15 @@ class LyXFont;
class Paragraph;
class ParagraphList;
///
/**
* This breaks a paragraph at the specified position.
* The new paragraph will:
* get the default layout, when flag == 0
* will inherit the existing one, except for depth, when flag == 1
* will inherit the existing one, including depth, when flag == 2
* Be aware that the old or new paragraph does not contain any rows
* after this.
*/
void breakParagraph(BufferParams const & bparams,
ParagraphList & paragraphs,
lyx::pit_type par,

View File

@ -58,7 +58,7 @@ class RowPainter {
public:
/// initialise and run painter
RowPainter(PainterInfo & pi, LyXText const & text,
pit_type pit, Row & row, int x, int y);
pit_type pit, Row const & row, int x, int y);
// paint various parts
void paintAppendix();
@ -101,7 +101,7 @@ private:
ParagraphList & pars_;
/// The row to paint
Row & row_;
Row const & row_;
/// Row's paragraph
pit_type const pit_;
@ -119,7 +119,7 @@ private:
RowPainter::RowPainter(PainterInfo & pi,
LyXText const & text, pit_type pit, Row & row, int x, int y)
LyXText const & text, pit_type pit, Row const & row, int x, int y)
: bv_(*pi.base.bv), pain_(pi.pain), text_(text), pars_(text.paragraphs()),
row_(row), pit_(pit), par_(text.paragraphs()[pit]),
xo_(x), yo_(y), width_(text_.width())
@ -178,7 +178,7 @@ void RowPainter::paintInset(pos_type const pos)
PainterInfo pi(const_cast<BufferView *>(&bv_), pain_);
pi.base.font = getFont(pos);
pi.ltr_pos = (text_.bidi.level(pos) % 2 == 0);
theCoords.insets_.add(inset, int(x_), yo_);
theCoords.insets().add(inset, int(x_), yo_);
inset->drawSelection(pi, int(x_), yo_);
inset->draw(pi, int(x_), yo_);
x_ += inset->width();
@ -738,12 +738,12 @@ void paintPar
Paragraph & par = text.paragraphs()[pit];
RowList::iterator const rb = par.rows().begin();
RowList::iterator const re = par.rows().end();
theCoords.pars_[&text][pit] = Point(x, y);
RowList::const_iterator const rb = par.rows().begin();
RowList::const_iterator const re = par.rows().end();
theCoords.parPos()[&text][pit] = Point(x, y);
y -= rb->ascent();
for (RowList::iterator rit = rb; rit != re; ++rit) {
for (RowList::const_iterator rit = rb; rit != re; ++rit) {
y += rit->ascent();
bool const inside = (y + rit->descent() >= 0
&& y - rit->ascent() < ww);
@ -801,12 +801,12 @@ void paintText(BufferView const & bv, ViewMetricsInfo const & vi)
}
// and grey out above (should not happen later)
lyxerr << "par ascent: " << text->getPar(vi.p1).ascent() << endl;
// lyxerr << "par ascent: " << text->getPar(vi.p1).ascent() << endl;
if (vi.y1 > 0)
pain.fillRectangle(0, 0, bv.workWidth(), vi.y1, LColor::bottomarea);
// and possibly grey out below
lyxerr << "par descent: " << text->getPar(vi.p1).ascent() << endl;
// lyxerr << "par descent: " << text->getPar(vi.p1).ascent() << endl;
if (vi.y2 < bv.workHeight())
pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() - vi.y2, LColor::bottomarea);
}

View File

@ -376,12 +376,6 @@ void readParagraph(Buffer const & buf, Paragraph & par, LyXLex & lex)
} // namespace anon
BufferView * LyXText::bv()
{
BOOST_ASSERT(bv_owner != 0);
return bv_owner;
}
BufferView * LyXText::bv() const
{
@ -1017,7 +1011,7 @@ namespace {
}
void LyXText::breakParagraph(LCursor & cur, char keep_layout)
void LyXText::breakParagraph(LCursor & cur, bool keep_layout)
{
BOOST_ASSERT(this == cur.text());
// allow only if at start or end, or all previous is new text
@ -1045,25 +1039,30 @@ void LyXText::breakParagraph(LCursor & cur, char keep_layout)
if (cur.pos() != cur.lastpos() && cpar.isLineSeparator(cur.pos()))
cpar.erase(cur.pos());
// break the paragraph
// How should the layout for the new paragraph be?
int preserve_layout = 0;
if (keep_layout)
keep_layout = 2;
preserve_layout = 2;
else
keep_layout = layout->isEnvironment();
preserve_layout = layout->isEnvironment();
// we need to set this before we insert the paragraph. IMO the
// breakParagraph call should return a bool if it inserts the
// paragraph before or behind and we should react on that one
// but we can fix this in 1.3.0 (Jug 20020509)
// We need to remember this before we break the paragraph, because
// that invalidates the layout variable
bool sensitive = layout->labeltype == LABEL_SENSITIVE;
// we need to set this before we insert the paragraph.
bool const isempty = cpar.allowEmpty() && cpar.empty();
::breakParagraph(cur.buffer().params(), paragraphs(), cpit,
cur.pos(), keep_layout);
cur.pos(), preserve_layout);
// After this, neither paragraph contains any rows!
cpit = cur.pit();
pit_type next_par = cpit + 1;
// well this is the caption hack since one caption is really enough
if (layout->labeltype == LABEL_SENSITIVE) {
if (sensitive) {
if (cur.pos() == 0)
// set to standard-layout
pars_[cpit].applyLayout(tclass.defaultLayout());
@ -1072,16 +1071,6 @@ void LyXText::breakParagraph(LCursor & cur, char keep_layout)
pars_[next_par].applyLayout(tclass.defaultLayout());
}
// if the cursor is at the beginning of a row without prior newline,
// move one row up!
// This touches only the screen-update. Otherwise we would may have
// an empty row on the screen
if (cur.pos() != 0 && cur.textRow().pos() == cur.pos()
&& !pars_[cpit].isNewline(cur.pos() - 1))
{
cursorLeft(cur);
}
while (!pars_[next_par].empty() && pars_[next_par].isNewline(0))
pars_[next_par].erase(0);
@ -1172,8 +1161,8 @@ void LyXText::insertChar(LCursor & cur, char c)
cur.message(_("You cannot insert a space at the "
"beginning of a paragraph. Please read the Tutorial."));
sent_space_message = true;
return;
}
return;
}
BOOST_ASSERT(cur.pos() > 0);
if (par.isLineSeparator(cur.pos() - 1)
@ -1686,7 +1675,7 @@ void LyXText::redoParagraph(pit_type const pit)
dim.asc += par.rows()[0].ascent();
dim.des -= par.rows()[0].ascent();
par.dim_ = dim;
par.dim() = dim;
//lyxerr << "redoParagraph: " << par.rows().size() << " rows\n";
}

View File

@ -119,7 +119,7 @@ InsetBase * LyXText::checkInsetHit(int x, int y) const
InsetBase * inset = iit->inset;
#if 1
lyxerr << "examining inset " << inset << endl;
if (theCoords.insets_.has(inset))
if (theCoords.getInsets().has(inset))
lyxerr
<< " xo: " << inset->xo() << "..."
<< inset->xo() + inset->width()
@ -1122,8 +1122,8 @@ pos_type LyXText::getColumnNearX(pit_type const pit,
pit_type LyXText::getPitNearY(int y) const
{
BOOST_ASSERT(!paragraphs().empty());
BOOST_ASSERT(theCoords.pars_.find(this) != theCoords.pars_.end());
CoordCache::InnerParPosCache const & cc = theCoords.pars_[this];
BOOST_ASSERT(theCoords.getParPos().find(this) != theCoords.getParPos().end());
CoordCache::InnerParPosCache const & cc = theCoords.getParPos().find(this)->second;
lyxerr << "LyXText::getPitNearY: y: " << y << " cache size: "
<< cc.size() << endl;
@ -1282,8 +1282,6 @@ void LyXText::cursorUp(LCursor & cur)
void LyXText::cursorDown(LCursor & cur)
{
Paragraph const & par = cur.paragraph();
int const row = par.pos2row(cur.pos());
int const x = cur.targetX();

View File

@ -353,7 +353,7 @@ bool LyXText::isRTL(Paragraph const & par) const
void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
{
lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
//lyxerr << "*** LyXText::dispatch: cmd: " << cmd << endl;
lyxerr << "*** LyXText::dispatch: cmd: " << cmd << endl;
BOOST_ASSERT(cur.text() == this);
BufferView * bv = &cur.bv();