+
+2003-08-15 André Pönitz <poenitz@gmx.net>
+
+ * lyxrow_funcs.[Ch]:
+ * lyxtext.h:
+ * paragraph.h:
+ * paragraph_funcs.C:
+ * rowpainter.C:
+ * text.C:
+ * text2.C:
+ * text3.C:
+ * text_funcs.C: split LyXText::rowlist_ into individual
+ Paragraph::rows_ chunks
+
2003-08-12 Michael Schmitt <michael.schmitt@teststep.org>
* bufferlist.C: beautify two alerts (shorter text of buttons)
int const topy = text->top_y();
int y_text = topy + y1;
- RowList::iterator rit = text->getRowNearY(y_text);
+ ParagraphList::iterator dummypit;
+ RowList::iterator rit = text->getRowNearY(y_text, dummypit);
int y = y_text - topy;
y = paintRows(*bv, *text, rit, xo, y, y, y2, yo);
+2003-08-15 André Pönitz <poenitz@gmx.net>
+
+ * insettext.[Ch]: adjust after rowlist split
+
2003-08-12 Michael Schmitt <michael.schmitt@teststep.org>
- * insettabular.C: rename M_VALIGN_CENTER to M_VALIGN_MIDDLE;
- rename valign-center to valign-middle;
- rename VALIGN_CENTER to VALIGN_MIDDLE
+ * insettabular.C: rename M_VALIGN_CENTER to M_VALIGN_MIDDLE;
+ rename valign-center to valign-middle;
+ rename VALIGN_CENTER to VALIGN_MIDDLE
2003-08-11 André Pönitz <poenitz@gmx.net>
RowList::iterator rit = text_.firstRow();
RowList::iterator end = text_.endRow();
+ ParagraphList::iterator pit = paragraphs.begin();
int y_offset = baseline - rit->ascent_of_text();
int y2 = pain.paperHeight();
while (rit != end && y + rit->height() <= 0) {
y += rit->height();
first += rit->height();
- rit = text_.nextRow(rit);
+ text_.nextRow(pit, rit);
}
if (y_offset < 0) {
text_.top_y(-y_offset);
return true;
}
///
- ParagraphList paragraphs;
+ mutable ParagraphList paragraphs;
protected:
///
void updateLocal(BufferView *, bool mark_dirty);
using std::min;
-bool isParEnd(LyXText const & lt,
- ParagraphList::iterator pit, RowList::iterator rit)
+bool isParEnd(Paragraph const & par, RowList::iterator rit)
{
- return boost::next(rit) == lt.endRow(pit);
+ return boost::next(rit) == par.rows.end();
}
-pos_type lastPos(LyXText const & lt,
- ParagraphList::iterator pit, RowList::iterator rit)
+pos_type lastPos(Paragraph const & par, RowList::iterator rit)
{
- if (pit->empty())
+ if (par.empty())
return 0;
- if (isParEnd(lt, pit, rit))
- return pit->size() - 1;
+ if (isParEnd(par, rit))
+ return par.size() - 1;
return boost::next(rit)->pos() - 1;
}
namespace {
bool nextRowIsAllInset(
- ParagraphList::iterator pit, RowList::iterator rit, pos_type last)
+ Paragraph const & par, pos_type last)
{
- if (last + 1 >= pit->size())
+ if (last + 1 >= par.size())
return false;
- if (!pit->isInset(last + 1))
+ if (!par.isInset(last + 1))
return false;
- InsetOld const * i = pit->getInset(last + 1);
+ InsetOld const * i = par.getInset(last + 1);
return i->needFullRow() || i->display();
}
} // anon namespace
-pos_type lastPrintablePos(LyXText const & lt,
- ParagraphList::iterator pit, RowList::iterator rit)
+pos_type lastPrintablePos(Paragraph const & par, RowList::iterator rit)
{
- pos_type const last = lastPos(lt, pit, rit);
+ pos_type const last = lastPos(par, rit);
// if this row is an end of par, just act like lastPos()
- if (isParEnd(lt, pit, rit))
+ if (isParEnd(par, rit))
return last;
- if (!nextRowIsAllInset(pit, rit, last) && pit->isSeparator(last))
+ if (!nextRowIsAllInset(par, last) && par.isSeparator(last))
return last - 1;
return last;
}
-int numberOfSeparators(LyXText const & lt,
- ParagraphList::iterator pit, RowList::iterator rit)
+int numberOfSeparators(Paragraph const & par, RowList::iterator rit)
{
- pos_type const last = lastPrintablePos(lt, pit, rit);
+ pos_type const last = lastPrintablePos(par, rit);
int n = 0;
- pos_type p = max(rit->pos(), pit->beginningOfBody());
+ pos_type p = max(rit->pos(), par.beginningOfBody());
for ( ; p < last; ++p)
- if (pit->isSeparator(p))
+ if (par.isSeparator(p))
++n;
return n;
}
// This is called _once_ from LyXText and should at least be moved into
// an anonymous namespace there. (Lgb)
-int numberOfHfills(LyXText const & lt,
- ParagraphList::iterator pit, RowList::iterator rit)
+int numberOfHfills(Paragraph const & par, RowList::iterator rit)
{
- pos_type const last = lastPos(lt, pit, rit);
+ pos_type const last = lastPos(par, rit);
pos_type first = rit->pos();
// hfill *DO* count at the beginning of paragraphs!
if (first) {
- while (first < last && pit->isHfill(first))
+ while (first < last && par.isHfill(first))
++first;
}
- first = max(first, pit->beginningOfBody());
+ first = max(first, par.beginningOfBody());
int n = 0;
// last, because the end is ignored!
- for (pos_type p = first; p < last; ++p) {
- if (pit->isHfill(p))
+ for (pos_type p = first; p < last; ++p)
+ if (par.isHfill(p))
++n;
- }
+
return n;
}
// This is called _once_ from LyXText and should at least be moved into
// an anonymous namespace there. (Lgb)
-int numberOfLabelHfills(LyXText const & lt,
- ParagraphList::iterator pit, RowList::iterator rit)
+int numberOfLabelHfills(Paragraph const & par, RowList::iterator rit)
{
- pos_type last = lastPos(lt, pit, rit);
+ pos_type last = lastPos(par, rit);
pos_type first = rit->pos();
// hfill *DO* count at the beginning of paragraphs!
if (first) {
- while (first < last && pit->isHfill(first))
+ while (first < last && par.isHfill(first))
++first;
}
- last = min(last, pit->beginningOfBody());
+ last = min(last, par.beginningOfBody());
int n = 0;
// last, because the end is ignored!
for (pos_type p = first; p < last; ++p) {
- if (pit->isHfill(p))
+ if (par.isHfill(p))
++n;
}
return n;
}
-bool hfillExpansion(LyXText const & lt,
- ParagraphList::iterator pit, RowList::iterator rit, pos_type pos)
+bool hfillExpansion(Paragraph const & par, RowList::iterator rit, pos_type pos)
{
- if (!pit->isHfill(pos))
+ if (!par.isHfill(pos))
return false;
// at the end of a row it does not count
// unless another hfill exists on the line
- if (pos >= lastPos(lt, pit, rit))
- for (pos_type i = rit->pos(); i < pos && !pit->isHfill(i); ++i)
+ if (pos >= lastPos(par, rit))
+ for (pos_type i = rit->pos(); i < pos && !par.isHfill(i); ++i)
return false;
// at the beginning of a row it does not count, if it is not
return true;
// in some labels it does not count
- if (pit->layout()->margintype != MARGIN_MANUAL
- && pos < pit->beginningOfBody())
+ if (par.layout()->margintype != MARGIN_MANUAL
+ && pos < par.beginningOfBody())
return false;
// if there is anything between the first char of the row and
// the specified position that is not a newline and not a hfill,
// the hfill will count, otherwise not
pos_type i = rit->pos();
- while (i < pos && (pit->isNewline(i) || pit->isHfill(i)))
+ while (i < pos && (par.isNewline(i) || par.isHfill(i)))
++i;
return i != pos;
#define LYXROW_FUNCS_H
#include "RowList.h"
-#include "ParagraphList.h"
-
#include "support/types.h"
-class LyXText;
+class Paragraph;
-bool isParEnd(LyXText const & lt,
- ParagraphList::iterator pit, RowList::iterator rit);
+bool isParEnd(Paragraph const & par, RowList::iterator rit);
-lyx::pos_type lastPos(LyXText const & lt,
- ParagraphList::iterator pit, RowList::iterator rit);
+lyx::pos_type lastPos(Paragraph const & par, RowList::iterator rit);
-lyx::pos_type lastPrintablePos(LyXText const & lt,
- ParagraphList::iterator pit, RowList::iterator rit);
+lyx::pos_type lastPrintablePos(Paragraph const & par, RowList::iterator rit);
-int numberOfSeparators(LyXText const & lt,
- ParagraphList::iterator pit, RowList::iterator rit);
+int numberOfSeparators(Paragraph const & par, RowList::iterator rit);
-int numberOfHfills(LyXText const & lt,
- ParagraphList::iterator pit, RowList::iterator rit);
+int numberOfHfills(Paragraph const & par, RowList::iterator rit);
-int numberOfLabelHfills(LyXText const & lt,
- ParagraphList::iterator pit, RowList::iterator rit);
+int numberOfLabelHfills(Paragraph const & par, RowList::iterator rit);
-bool hfillExpansion(LyXText const & lt,
- ParagraphList::iterator pit, RowList::iterator rit, lyx::pos_type pos);
+bool hfillExpansion(Paragraph const & par, RowList::iterator rit,
+ lyx::pos_type pos);
#endif
(relative to the whole text). y is set to the real beginning
of this row
*/
- RowList::iterator getRowNearY(int & y) const;
+ RowList::iterator getRowNearY(int & y,
+ ParagraphList::iterator & pit) const;
/** returns the column near the specified x-coordinate of the row
x is set to the real beginning of this column
RowList::iterator
getRow(ParagraphList::iterator pit, lyx::pos_type pos, int & y) const;
- RowList & rows() const {
- return rowlist_;
- }
-
-
/// need the selection cursor:
void setSelection();
///
///
bool bidi_InRange(lyx::pos_type pos) const;
private:
- ///
- mutable RowList rowlist_;
-
///
float getCursorX(ParagraphList::iterator pit,
RowList::iterator rit, lyx::pos_type pos,
/// used in setlayout
void makeFontEntriesLayoutSpecific(BufferParams const &, Paragraph & par);
- /** forces the redrawing of a paragraph. Needed when manipulating a
- right address box
- */
- void redoDrawingOfParagraph(LyXCursor const & cursor);
-
- /// removes the row and reset the touched counters
- void removeRow(RowList::iterator rit);
-
- /// remove all following rows of the paragraph of the specified row.
- void removeParagraph(ParagraphList::iterator pit, RowList::iterator rit);
-
- /// insert the specified paragraph behind the specified row
- void insertParagraph(ParagraphList::iterator pit,
- RowList::iterator rowit);
-
/// Calculate and set the height of the row
void setHeightOfRow(ParagraphList::iterator, RowList::iterator rit);
// fix the cursor `cur' after a characters has been deleted at `where'
// position. Called by deleteEmptyParagraphMechanism
- void fixCursorAfterDelete(LyXCursor & cur,
- LyXCursor const & where);
+ void fixCursorAfterDelete(LyXCursor & cur, LyXCursor const & where);
/// delete double space (false) or empty paragraphs (true) around old_cursor
bool deleteEmptyParagraphMechanism(LyXCursor const & old_cursor);
/// return true if this is owned by an inset.
bool isInInset() const;
- /// recreate paragraphlist iterator from rowlist iterator
- ParagraphList::iterator getPar(RowList::iterator rit) const;
- /// return first row of par
- RowList::iterator beginRow(ParagraphList::iterator pit) const;
- /// return row "behind" last of par
- RowList::iterator endRow(ParagraphList::iterator pit) const;
/// return first row of text
RowList::iterator firstRow() const;
/// return last row of text
/// return row "behind" last row of text
RowList::iterator endRow() const;
/// return next row crossing paragraph boundaries
- RowList::iterator nextRow(RowList::iterator rit) const;
+ void nextRow(ParagraphList::iterator & pit,
+ RowList::iterator & rit) const;
/// return previous row crossing paragraph boundaries
- RowList::iterator previousRow(RowList::iterator rit) const;
+ void previousRow(ParagraphList::iterator & pit,
+ RowList::iterator & rit) const;
+
+ ///
+ bool noRows() const;
private:
/** Cursor related data.
#include "support/types.h"
#include "changes.h"
+#include "RowList.h"
#include "LString.h"
///
InsetList insetlist;
+ ///
+ mutable RowList rows;
+
private:
///
LyXLayout_ptr layout_;
if (newpit != beg)
--newpit;
- while (newpit != beg && newpit->getDepth() > depth) {
+ while (newpit != beg && newpit->getDepth() > depth) {
--newpit;
}
}
}
- if ((in == 0) || !in->forceDefaultParagraphs(in)) {
+ if (in == 0 || !in->forceDefaultParagraphs(in)) {
further_blank_line = false;
if (pit->params().lineBottom()) {
os << "\\lyxline{\\" << font.latexSize() << '}';
using namespace lyx::support;
using std::max;
+using std::endl;
using lyx::pos_type;
extern int PAPER_MARGIN;
void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
{
pos_type pos = text_.vis2log(vpos);
- pos_type const last = lastPrintablePos(text_, pit_, row_);
+ pos_type const last = lastPrintablePos(*pit_, row_);
LyXFont orig_font = getFont(pos);
// first character
int(x_), row_->height(), LColor::selection);
pos_type const body_pos = pit_->beginningOfBody();
- pos_type const last = lastPrintablePos(text_, pit_, row_);
+ pos_type const last = lastPrintablePos(*pit_, row_);
double tmpx = x_;
for (pos_type vpos = row_->pos(); vpos <= last; ++vpos) {
tmpx -= singleWidth(body_pos - 1);
}
- if (hfillExpansion(text_, pit_, row_, pos)) {
+ if (hfillExpansion(*pit_, row_, pos)) {
tmpx += singleWidth(pos);
if (pos >= body_pos)
tmpx += hfill_;
void RowPainter::paintChangeBar()
{
pos_type const start = row_->pos();
- pos_type const end = lastPrintablePos(text_, pit_, row_);
+ pos_type const end = lastPrintablePos(*pit_, row_);
if (!pit_->isChanged(start, end))
return;
Paragraph::depth_type prev_depth = 0;
if (row_ != text_.firstRow()) {
ParagraphList::iterator pit2 = pit_;
- if (row_ == text_.beginRow(pit2))
+ if (row_ == pit2->rows.begin())
--pit2;
prev_depth = pit2->getDepth();
}
Paragraph::depth_type next_depth = 0;
if (row_ != text_.lastRow()) {
ParagraphList::iterator pit2 = pit_;
- if (boost::next(row_) == text_.endRow(pit2))
+ if (boost::next(row_) == pit2->rows.end())
++pit2;
next_depth = pit2->getDepth();
}
void RowPainter::paintText()
{
- pos_type const last = lastPrintablePos(text_, pit_, row_);
+ pos_type const last = lastPrintablePos(*pit_, row_);
pos_type body_pos = pit_->beginningOfBody();
if (body_pos > 0 &&
(body_pos - 1 > last || !pit_->isLineSeparator(body_pos - 1))) {
pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
- if (hfillExpansion(text_, pit_, row_, pos)) {
+ if (hfillExpansion(*pit_, row_, pos)) {
int const y2 = (y0 + y1) / 2;
if (pos >= body_pos) {
if (row_->isParStart())
paintFirst();
- if (isParEnd(text_, pit_, row_))
+ if (isParEnd(*pit_, row_))
paintLast();
// paint text
const_cast<LyXText&>(text).metrics(mi, dim);
#endif
}
+ const_cast<LyXText&>(text).updateRowPositions();
- //lyxerr << "text: " << &text << " y: " << y << " yf: " << yf
- // << " y2: " << y2 << " yo: " << yo << "\n";
int yy = yf - y;
- RowList::iterator end = text.endRow();
- while (rit != end && yy + y < y2) {
- //const_cast<LyXText &>(text).setHeightOfRow(rit);
- ParagraphList::iterator pit = text.getPar(rit);
- paintRow(bv, text, pit, rit, y + yo, xo, y + text.top_y());
- y += rit->height();
- rit = text.nextRow(rit);
+
+ ParagraphList::iterator pit = text.ownerParagraphs().begin();
+ ParagraphList::iterator end = text.ownerParagraphs().end();
+ bool active = false;
+
+ for ( ; pit != end; ++pit) {
+ RowList::iterator row = pit->rows.begin();
+ RowList::iterator rend = pit->rows.end();
+
+ for ( ; row != rend; ++row) {
+ if (row == rit)
+ active = true;
+ if (active) {
+ paintRow(bv, text, pit, row, y + yo, xo, y + text.top_y());
+ y += row->height();
+ if (yy + y >= y2)
+ return y;
+ } else {
+ //lyxerr << " paintRows: row: " << &*row << " ignored" << endl;
+ }
+ }
}
+
return y;
}
void LyXText::updateRowPositions()
{
- RowList::iterator rit = firstRow();
- RowList::iterator rend = endRow();
- for (int y = 0; rit != rend ; rit = nextRow(rit)) {
- rit->y(y);
- y += rit->height();
+ ParagraphList::iterator pit = ownerParagraphs().begin();
+ ParagraphList::iterator end = ownerParagraphs().end();
+ for (int y = 0; pit != end; ++pit) {
+ RowList::iterator rit = pit->rows.begin();
+ RowList::iterator rend = pit->rows.end();
+ for ( ; rit != rend ; rit = ++rit) {
+ rit->y(y);
+ y += rit->height();
+ }
}
}
void LyXText::top_y(int newy)
{
- if (rows().empty())
+ if (ownerParagraphs().begin()->rows.empty())
return;
if (isInInset()) {
lyxerr[Debug::GUI] << "setting top y = " << newy << endl;
int y = newy;
- RowList::iterator rit = getRowNearY(y);
-
- if (rit == anchor_row_ && anchor_row_offset_ == newy - y) {
- lyxerr[Debug::GUI] << "top_y to same value, skipping update" << endl;
- return;
- }
-
- anchor_row_ = rit;
+ ParagraphList::iterator dummypit;
+ anchor_row_ = getRowNearY(y, dummypit);
anchor_row_offset_ = newy - y;
lyxerr[Debug::GUI] << "changing reference to row: " << &*anchor_row_
<< " offset: " << anchor_row_offset_ << endl;
}
-void LyXText::computeBidiTables(ParagraphList::iterator row_par,
+void LyXText::computeBidiTables(ParagraphList::iterator pit,
Buffer const * buf, RowList::iterator row) const
{
bidi_same_direction = true;
return;
}
- InsetOld * inset = row_par->inInset();
+ InsetOld * inset = pit->inInset();
if (inset && inset->owner() &&
inset->owner()->lyxCode() == InsetOld::ERT_CODE) {
bidi_start = -1;
}
bidi_start = row->pos();
- bidi_end = lastPrintablePos(*this, row_par, row);
+ bidi_end = lastPrintablePos(*pit, row);
if (bidi_start > bidi_end) {
bidi_start = -1;
pos_type stack[2];
bool const rtl_par =
- row_par->isRightToLeftPar(buf->params);
+ pit->isRightToLeftPar(buf->params);
int level = 0;
bool rtl = false;
bool rtl0 = false;
- pos_type const body_pos = row_par->beginningOfBody();
+ pos_type const body_pos = pit->beginningOfBody();
for (pos_type lpos = bidi_start; lpos <= bidi_end; ++lpos) {
- bool is_space = row_par->isLineSeparator(lpos);
+ bool is_space = pit->isLineSeparator(lpos);
pos_type const pos =
(is_space && lpos + 1 <= bidi_end &&
- !row_par->isLineSeparator(lpos + 1) &&
- !row_par->isNewline(lpos + 1))
+ !pit->isLineSeparator(lpos + 1) &&
+ !pit->isNewline(lpos + 1))
? lpos + 1 : lpos;
- LyXFont font = row_par->getFontSettings(buf->params, pos);
+ LyXFont font = pit->getFontSettings(buf->params, pos);
if (pos != lpos && 0 < lpos && rtl0 && font.isRightToLeft() &&
font.number() == LyXFont::ON &&
- row_par->getFontSettings(buf->params, lpos - 1).number()
+ pit->getFontSettings(buf->params, lpos - 1).number()
== LyXFont::ON) {
- font = row_par->getFontSettings(buf->params, lpos);
+ font = pit->getFontSettings(buf->params, lpos);
is_space = false;
}
int LyXText::leftMargin(ParagraphList::iterator pit, Row const & row) const
-{
+{
InsetOld * ins;
if (row.pos() < pit->size())
// are *NOT* allowed in the LaTeX realisation of this layout.
// find the first row of this paragraph
- RowList::iterator rit = beginRow(pit);
- RowList::iterator end = endRow(pit);
+ RowList::iterator rit = pit->rows.begin();
+ RowList::iterator end = pit->rows.end();
int minfill = rit->fill();
for ( ; rit != end; ++rit)
if (rit->fill() < minfill)
int w;
// get the pure distance
- pos_type const last = lastPrintablePos(*this, pit, row);
+ pos_type const last = lastPrintablePos(*pit, row);
LyXLayout_ptr const & layout = pit->layout();
int maxdesc = int(font_metrics::maxDescent(font) *
layout->spacing.getValue() * spacing_val);
- pos_type const pos_end = lastPos(*this, pit, rit);
+ pos_type const pos_end = lastPos(*pit, rit);
int labeladdon = 0;
int maxwidth = 0;
} else if (rit != firstRow()) {
tmptop = layout->topsep;
- if (boost::prior(pit)->getDepth() >= pit->getDepth())
- tmptop -= getPar(boost::prior(rit))->layout()->bottomsep;
+ //if (boost::prior(pit)->getDepth() >= pit->getDepth())
+ // tmptop -= getPar(previousRow(rit))->layout()->bottomsep;
if (tmptop > 0)
layoutasc = (tmptop * defaultRowHeight());
}
// is it a bottom line?
- if (boost::next(rit) == endRow(pit)) {
+ if (boost::next(rit) == pit->rows.end()) {
// the bottom margin
ParagraphList::iterator nextpit = boost::next(pit);
- if (nextpit == ownerParagraphs().end() &&
- !isInInset())
+ if (nextpit == ownerParagraphs().end() && !isInInset())
maxdesc += PAPER_MARGIN;
// add the vertical spaces, that the user added
width = max(0, workWidth());
RowList::iterator rit = firstRow();
RowList::iterator end = endRow();
- for (; rit != end; rit = nextRow(rit))
+ ParagraphList::iterator it = ownerParagraphs().begin();
+ while (rit != end) {
if (rit->width() > width)
width = rit->width();
+ nextRow(it, rit);
+ }
}
}
::breakParagraph(bv()->buffer()->params, paragraphs, cursor.par(),
cursor.pos(), keep_layout);
+#warning Trouble Point! (Lgb)
+ // When ::breakParagraph is called from within an inset we must
+ // ensure that the correct ParagraphList is used. Today that is not
+ // the case and the Buffer::paragraphs is used. Not good. (Lgb)
+ ParagraphList::iterator next_par = boost::next(cursor.par());
+
// well this is the caption hack since one caption is really enough
if (layout->labeltype == LABEL_SENSITIVE) {
if (!cursor.pos())
cursor.par()->applyLayout(tclass.defaultLayout());
else
// set to standard-layout
- boost::next(cursor.par())->applyLayout(tclass.defaultLayout());
+ next_par->applyLayout(tclass.defaultLayout());
}
// if the cursor is at the beginning of a row without prior newline,
cursorLeft(bv());
}
- removeParagraph(cursor.par(), cursorRow());
-
-#warning Trouble Point! (Lgb)
- // When ::breakParagraph is called from within an inset we must
- // ensure that the correct ParagraphList is used. Today that is not
- // the case and the Buffer::paragraphs is used. Not good. (Lgb)
- ParagraphList::iterator next_par = boost::next(cursor.par());
-
while (!next_par->empty() && next_par->isNewline(0))
next_par->erase(0);
- insertParagraph(next_par, boost::next(cursorRow()));
updateCounters();
+ redoParagraph(cursor.par());
+ redoParagraph(next_par);
// This check is necessary. Otherwise the new empty paragraph will
// be deleted automatically. And it is more friendly for the user!
setCursor(next_par, 0);
else
setCursor(cursor.par(), 0);
-
- redoParagraph(cursor.par());
}
if (layout->margintype == MARGIN_MANUAL
&& layout->labeltype == LABEL_MANUAL) {
/// We might have real hfills in the label part
- int nlh = numberOfLabelHfills(*this, pit, rit);
+ int nlh = numberOfLabelHfills(*pit, rit);
// A manual label par (e.g. List) has an auto-hfill
// between the label text and the body of the
}
// are there any hfills in the row?
- int const nh = numberOfHfills(*this, pit, rit);
+ int const nh = numberOfHfills(*pit, rit);
if (nh) {
if (w > 0)
switch (align) {
case LYX_ALIGN_BLOCK:
{
- int const ns = numberOfSeparators(*this, pit, rit);
+ int const ns = numberOfSeparators(*pit, rit);
RowList::iterator next_row = boost::next(rit);
if (ns
- && next_row != endRow(pit)
+ && next_row != pit->rows.end()
&& !pit->isNewline(next_row->pos() - 1)
&& !(pit->isInset(next_row->pos())
&& pit->getInset(next_row->pos())
computeBidiTables(pit, bv()->buffer(), rit);
if (is_rtl) {
pos_type body_pos = pit->beginningOfBody();
- pos_type last = lastPos(*this, pit, rit);
+ pos_type last = lastPos(*pit, rit);
if (body_pos > 0 &&
(body_pos - 1 > last ||
}
ParagraphList::iterator tmppit = cursor.par();
- RowList::iterator tmprow = cursorRow();
-
// We used to do cursorLeftIntern() here, but it is
// not a good idea since it triggers the auto-delete
// mechanism. So we do a cursorLeftIntern()-lite,
&& (cursor.par()->layout() == tmppit->layout()
|| tmppit->layout() == tclass.defaultLayout())
&& cursor.par()->getAlign() == tmppit->getAlign()) {
- removeParagraph(cursor.par(), tmprow);
- removeRow(tmprow);
mergeParagraph(bv()->buffer()->params,
bv()->buffer()->paragraphs, cursor.par());
RowList::iterator
LyXText::getRow(ParagraphList::iterator pit, pos_type pos) const
{
- RowList::iterator rit = beginRow(pit);
- RowList::iterator end = endRow(pit);
+ RowList::iterator rit = pit->rows.begin();
+ RowList::iterator end = pit->rows.end();
#warning Why is this next thing needed? (Andre)
while (rit != end
{
y = 0;
- if (rows().empty())
+ if (noRows())
return firstRow();
- RowList::iterator beg = beginRow(pit);
- RowList::iterator end = endRow(pit);
- RowList::iterator rit;
-
- // find the first row of the specified paragraph
- for (rit = firstRow(); rit != beg; rit = nextRow(rit))
- y += rit->height();
+ ParagraphList::iterator it = ownerParagraphs().begin();
+ for ( ; it != pit; ++it) {
+ RowList::iterator beg = it->rows.begin();
+ RowList::iterator end = it->rows.end();
+ for (RowList::iterator rit = beg; rit != end; ++rit)
+ y += rit->height();
+ }
- // now find the wanted row
+ RowList::iterator rit = pit->rows.begin();
+ RowList::iterator end = pit->rows.end();
while (rit != end
&& rit->pos() < pos
&& boost::next(rit) != end
}
-RowList::iterator LyXText::getRowNearY(int & y) const
+RowList::iterator LyXText::getRowNearY(int & y,
+ ParagraphList::iterator & pit) const
{
- RowList::iterator rit = anchor_row_;
- RowList::iterator const beg = firstRow();
- RowList::iterator const end = endRow();
-
- if (rows().empty()) {
- y = 0;
- return end;
- }
- if (rit == end)
- rit = beg;
-
- int tmpy = rit->y();
-
- if (tmpy <= y) {
- while (rit != end && tmpy <= y) {
- tmpy += rit->height();
- rit = nextRow(rit);
- }
- if (rit != beg) {
- rit = previousRow(rit);
- tmpy -= rit->height();
- }
- } else {
- while (rit != beg && tmpy > y) {
- rit = previousRow(rit);
- tmpy -= rit->height();
+ ParagraphList::iterator const end = ownerParagraphs().end();
+ //lyxerr << "getRowNearY: y " << y << endl;
+
+ for (pit = ownerParagraphs().begin(); pit != end; ++pit) {
+ RowList::iterator rit = pit->rows.begin();
+ RowList::iterator rend = pit->rows.end();
+
+ for ( ; rit != rend; ++rit) {
+ //rit->dump();
+ if (rit->y() >= y) {
+ if (rit != firstRow())
+ previousRow(pit, rit);
+ y = rit->y();
+ return rit;
+ }
}
}
- if (tmpy < 0 || rit == end) {
- tmpy = 0;
- rit = beg;
- }
- // return the rel y
- y = tmpy;
-
- return rit;
+#if 1
+ pit = ownerParagraphs().begin();
+ y = 0;
+ lyxerr << "row not found near " << y << " pit: " << &*pit << endl;
+ return firstRow();
+#else
+ pit = boost::prior(ownerParagraphs().end());
+ lyxerr << "row not found near " << y << " pit: " << &*pit << endl;
+ return lastRow();
+#endif
}
}
-#warning Expensive. Remove before 1.4!
-// computes a ParagraphList::iterator from RowList::iterator by
-// counting zeros in the sequence of pos values.
-
-ParagraphList::iterator LyXText::getPar(RowList::iterator row) const
-{
- if (row == endRow()) {
- lyxerr << "getPar() pit at end " << endl;
- Assert(false);
- }
-
- if (row == firstRow()) {
- return ownerParagraphs().begin();
- }
-
- ParagraphList::iterator pit = ownerParagraphs().begin();
- RowList::iterator rit = firstRow();
- RowList::iterator rend = endRow();
- for (++rit ; rit != rend; rit = nextRow(rit)) {
- if (rit->pos() == 0) {
- ++pit;
- if (pit == ownerParagraphs().end()) {
- lyxerr << "unexpected in LyXText::getPar()" << endl;
- Assert(false);
- }
- }
- if (rit == row) {
- return pit;
- }
- }
-
- lyxerr << "LyXText::getPar: row not found " << endl;
- Assert(false);
- return ownerParagraphs().end(); // shut up compiler
-}
-
-
-RowList::iterator LyXText::beginRow(ParagraphList::iterator pit) const
-{
- int n = std::distance(ownerParagraphs().begin(), pit);
-
- RowList::iterator rit = rows().begin();
- RowList::iterator end = rows().end();
- for ( ; rit != end; ++rit)
- if (rit->pos() == 0 && n-- == 0)
- return rit;
-
- return rit;
-}
-
-
-RowList::iterator LyXText::endRow(ParagraphList::iterator pit) const
+RowList::iterator LyXText::firstRow() const
{
- return beginRow(boost::next(pit));
+ return ownerParagraphs().front().rows.begin();
}
-RowList::iterator LyXText::firstRow() const
+RowList::iterator LyXText::lastRow() const
{
- return rowlist_.begin();
+ return boost::prior(endRow());
}
-RowList::iterator LyXText::lastRow() const
+RowList::iterator LyXText::endRow() const
{
- return boost::prior(rowlist_.end());
+ return ownerParagraphs().back().rows.end();
}
-RowList::iterator LyXText::endRow() const
+void LyXText::nextRow(ParagraphList::iterator & pit,
+ RowList::iterator & rit) const
{
- return rowlist_.end();
+ if (boost::next(rit) != pit->rows.end()) {
+ rit = boost::next(rit);
+ } else {
+ ++pit;
+ if (pit == ownerParagraphs().end())
+ rit = boost::next(rit);
+ else
+ rit = pit->rows.begin();
+ }
}
-RowList::iterator LyXText::nextRow(RowList::iterator rit) const
+void LyXText::previousRow(ParagraphList::iterator & pit,
+ RowList::iterator & rit) const
{
- return boost::next(rit);
+ if (rit != pit->rows.begin())
+ rit = boost::prior(rit);
+ else {
+ Assert(pit != ownerParagraphs().begin());
+ --pit;
+ rit = boost::prior(pit->rows.end());
+ }
}
-RowList::iterator LyXText::previousRow(RowList::iterator rit) const
+bool LyXText::noRows() const
{
- return boost::prior(rit);
+ return ownerParagraphs().begin()->rows.empty();
}
{
bv_owner = bview;
- rowlist_.clear();
+ ParagraphList::iterator const beg = ownerParagraphs().begin();
+ ParagraphList::iterator const end = ownerParagraphs().end();
+ for (ParagraphList::iterator pit = beg; pit != end; ++pit)
+ pit->rows.clear();
+
width = 0;
height = 0;
anchor_row_ = endRow();
anchor_row_offset_ = 0;
- current_font = getFont(ownerParagraphs().begin(), 0);
+ current_font = getFont(beg, 0);
- redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end());
- setCursorIntern(ownerParagraphs().begin(), 0);
+ redoParagraphs(beg, end);
+ setCursorIntern(beg, 0);
selection.cursor = cursor;
updateCounters();
}
-// removes the row and reset the touched counters
-void LyXText::removeRow(RowList::iterator rit)
-{
- if (anchor_row_ == rit) {
- if (rit == firstRow()) {
- anchor_row_ = boost::next(rit);
- anchor_row_offset_ -= rit->height();
- } else {
- anchor_row_ = boost::prior(rit);
- anchor_row_offset_ += anchor_row_->height();
- }
- }
-
- // the text becomes smaller
- height -= rit->height();
-
- rowlist_.erase(rit);
-}
-
-
-// remove all following rows of the paragraph of the specified row.
-void LyXText::removeParagraph(ParagraphList::iterator pit,
- RowList::iterator rit)
-{
- RowList::iterator end = endRow(pit);
- for (++rit; rit != end; ) {
- RowList::iterator rit2 = boost::next(rit);
- removeRow(rit);
- rit = rit2;
- }
-}
-
-
-void LyXText::insertParagraph(ParagraphList::iterator pit,
- RowList::iterator rit)
-{
- // insert a new row, starting at position 0
- rit = rowlist_.insert(rit, Row(0));
-
- // and now append the whole paragraph before the new row
-
- pos_type const last = pit->size();
- bool done = false;
-
- do {
- pos_type z = rowBreakPoint(pit, *rit);
-
- RowList::iterator tmprow = rit;
-
- if (z < last) {
- ++z;
- rit = rowlist_.insert(boost::next(rit), Row(z));
- } else {
- done = true;
- }
-
- // Set the dimensions of the row
- // fixed fill setting now by calling inset->update() in
- // singleWidth when needed!
- tmprow->fill(fill(pit, tmprow, workWidth()));
- setHeightOfRow(pit, tmprow);
-
- } while (!done);
-}
-
-
InsetOld * LyXText::getInset() const
{
ParagraphList::iterator pit = cursor.par();
void LyXText::redoParagraph(ParagraphList::iterator pit)
{
- RowList::iterator first = beginRow(pit);
- RowList::iterator last = endRow(pit);
-
- // remove paragraph from rowlist
- while (first != last) {
- RowList::iterator rit2 = first;
- ++first;
- removeRow(rit2);
+ RowList::iterator rit = pit->rows.begin();
+ RowList::iterator end = pit->rows.end();
+
+ // remove rows of paragraph
+ for ( ; rit != end; ++rit) {
+ if (rit == anchor_row_)
+ anchor_row_ = endRow();
+ height -= rit->height();
}
+ pit->rows.clear();
+
+ // rebreak the paragraph
+ // insert a new row, starting at position 0
+
+ pos_type z = 0;
+ pit->rows.push_back(Row(z));
+ bool done = false;
+ while (!done) {
+ z = rowBreakPoint(pit, pit->rows.back());
+
+ RowList::iterator tmprow = boost::prior(pit->rows.end());
+
+ if (z >= pit->size())
+ done = true;
+ else {
+ ++z;
+ pit->rows.push_back(Row(z));
+ }
- // reinsert the paragraph
- insertParagraph(pit, last);
+ tmprow->fill(fill(pit, tmprow, workWidth()));
+ setHeightOfRow(pit, tmprow);
+ }
+
+ //lyxerr << "redoParagraph: " << pit->rows.size() << " rows\n";
}
//Assert(mi.base.textwidth);
// rebuild row cache
- rowlist_.clear();
width = 0;
height = 0;
ParagraphList::iterator end = ownerParagraphs().end();
for (; pit != end; ++pit) {
+ pit->rows.clear();
+
InsetList::iterator ii = pit->insetlist.begin();
InsetList::iterator iend = pit->insetlist.end();
for (; ii != iend; ++ii) {
RowList::iterator next_rit = boost::next(rit);
RowList::iterator end = boost::next(rit);
ParagraphList::iterator pit = cursor.par();
- pos_type last_pos = lastPos(*this, pit, rit);
+ pos_type last_pos = lastPos(*pit, rit);
if (next_rit == end) {
++last_pos;
cur.par(pit);
cur.pos(pos);
cur.boundary(boundary);
- if (rows().empty())
+ if (noRows())
return;
// get the cursor y position in text
// same paragraph and there is a previous row then put the cursor on
// the end of the previous row
cur.iy(y + row->baseline());
- if (row != beginRow(pit)
+ if (row != pit->rows.begin()
&& pos
&& pos < pit->size()
&& pit->getChar(pos) == Paragraph::META_INSET) {
// y is now the cursor baseline
cur.y(y);
- pos_type last = lastPrintablePos(*this, pit, old_row);
+ pos_type last = lastPrintablePos(*pit, old_row);
// None of these should happen, but we're scaredy-cats
if (pos > pit->size()) {
x -= singleWidth(pit, body_pos - 1);
}
- if (hfillExpansion(*this, pit, rit, pos)) {
+ if (hfillExpansion(*pit, rit, pos)) {
x += singleWidth(pit, pos);
if (pos >= body_pos)
x += fill_hfill;
prepareToPrint(pit, rit, tmpx, fill_separator, fill_hfill, fill_label_hfill);
pos_type vc = rit->pos();
- pos_type last = lastPrintablePos(*this, pit, rit);
+ pos_type last = lastPrintablePos(*pit, rit);
pos_type c = 0;
LyXLayout_ptr const & layout = pit->layout();
tmpx -= singleWidth(pit, body_pos - 1);
}
- if (hfillExpansion(*this, pit, rit, c)) {
+ if (hfillExpansion(*pit, rit, c)) {
tmpx += singleWidth(pit, c);
if (c >= body_pos)
tmpx += fill_hfill;
// This (rtl_support test) is not needed, but gives
// some speedup if rtl_support == false
bool const lastrow = lyxrc.rtl_support
- && boost::next(rit) == endRow(pit);
+ && boost::next(rit) == pit->rows.end();
// If lastrow is false, we don't need to compute
// the value of rtl.
bool beforeFullRowInset(LyXText & lt, LyXCursor const & cur)
{
RowList::iterator row = lt.getRow(cur);
- if (boost::next(row) == lt.endRow())
- return false;
-
RowList::iterator next = boost::next(row);
- if (next == lt.endRow(cur.par()) || next->pos() != cur.pos())
+ if (next == cur.par()->rows.end() || next->pos() != cur.pos())
return false;
- if (cur.pos() == cur.par()->size()
- || !cur.par()->isInset(cur.pos()))
+ if (cur.pos() == cur.par()->size() || !cur.par()->isInset(cur.pos()))
return false;
InsetOld const * inset = cur.par()->getInset(cur.pos());
void LyXText::setCursorFromCoordinates(LyXCursor & cur, int x, int y)
{
// Get the row first.
-
- RowList::iterator row = getRowNearY(y);
- ParagraphList::iterator pit = getPar(row);
+ ParagraphList::iterator pit;
+ RowList::iterator row = getRowNearY(y, pit);
bool bound = false;
pos_type const column = getColumnNearX(pit, row, x, bound);
cur.par(pit);
cur.x(x);
cur.y(y + row->baseline());
- if (beforeFullRowInset(*this, cur)) {
- pos_type const last = lastPrintablePos(*this, pit, row);
- RowList::iterator next_row = boost::next(row);
- cur.ix(int(getCursorX(pit, next_row, cur.pos(), last, bound)));
- cur.iy(y + row->height() + next_row->baseline());
- } else {
+// if (beforeFullRowInset(*this, cur)) {
+// pos_type const last = lastPrintablePos(*this, pit, row);
+// RowList::iterator next_row = nextRow(row);
+// cur.ix(int(getCursorX(pit, next_row, cur.pos(), last, bound)));
+// cur.iy(y + row->height() + next_row->baseline());
+// } else {
cur.iy(cur.y());
cur.ix(cur.x());
- }
+// }
cur.boundary(bound);
}
}
}
#else
+ lyxerr << "cursorUp: y " << cursor.y() << " bl: " <<
+ cursorRow()->baseline() << endl;
setCursorFromCoordinates(cursor.x_fix(),
- cursor.y() - cursorRow()->baseline() - 1);
+ cursor.y() - cursorRow()->baseline() - 1);
#endif
}
selection.cursor.par() == old_cursor.par()
&& selection.cursor.pos() == old_cursor.pos());
- if (getRow(old_cursor) != firstRow()) {
- RowList::iterator prevrow = boost::prior(getRow(old_cursor));
- tmpcursor = cursor;
- cursor = old_cursor; // that undo can restore the right cursor position
- #warning FIXME. --end() iterator is usable here
- ParagraphList::iterator endpit = boost::next(old_cursor.par());
- while (endpit != ownerParagraphs().end() &&
- endpit->getDepth()) {
- ++endpit;
- }
-
- recordUndo(bv(), Undo::DELETE, old_cursor.par(),
- boost::prior(endpit));
- cursor = tmpcursor;
+ tmpcursor = cursor;
+ cursor = old_cursor; // that undo can restore the right cursor position
- // delete old row
- removeRow(getRow(old_cursor));
- // delete old par
- ownerParagraphs().erase(old_cursor.par());
- } else {
- RowList::iterator nextrow = boost::next(getRow(old_cursor));
-
- tmpcursor = cursor;
- cursor = old_cursor; // that undo can restore the right cursor position
-#warning FIXME. --end() iterator is usable here
- ParagraphList::iterator endpit = boost::next(old_cursor.par());
- while (endpit != ownerParagraphs().end() &&
- endpit->getDepth()) {
- ++endpit;
- }
-
- recordUndo(bv(), Undo::DELETE, old_cursor.par(), boost::prior(endpit));
- cursor = tmpcursor;
+ ParagraphList::iterator endpit = boost::next(old_cursor.par());
+ while (endpit != ownerParagraphs().end() && endpit->getDepth())
+ ++endpit;
+
+ recordUndo(bv(), Undo::DELETE, old_cursor.par(), boost::prior(endpit));
+ cursor = tmpcursor;
- // delete old row
- removeRow(getRow(old_cursor));
- // delete old par
- ownerParagraphs().erase(old_cursor.par());
- }
+ // delete old par
+ ownerParagraphs().erase(old_cursor.par());
+ redoParagraph();
// correct cursor y
setCursorIntern(cursor.par(), cursor.pos());
LyXCursor cur;
ParagraphList::iterator pit = cursor.par();
- if (rit == beginRow(pit))
- --pit;
- rit = previousRow(rit);
+ previousRow(pit, rit);
setCursor(cur, pit, rit->pos(), false);
if (cur.y() > top_y())
cursorUp(true);
+ bv()->theLockingInset()->insetInInsetY());
}
- getRowNearY(y);
+ ParagraphList::iterator dummypit;
+ getRowNearY(y, dummypit);
setCursorFromCoordinates(cursor.x_fix(), y);
// + bv->workHeight());
}
ParagraphList::iterator pit = cursor.par();
- if (boost::next(rit) == endRow(pit))
- ++pit;
- rit = nextRow(rit);
+ nextRow(pit, rit);
LyXCursor cur;
setCursor(cur, pit, rit->pos(), false);
if (cur.y() < top_y() + bv()->workHeight())
while (pos &&
(pit->isSeparator(pos - 1) ||
- pit->isKomma(pos - 1) ||
- pit->isNewline(pos - 1)) &&
+ pit->isKomma(pos - 1) ||
+ pit->isNewline(pos - 1)) &&
!(pit->isHfill(pos - 1) ||
pit->isInset(pos - 1)))
--pos;