extern int bibitemMaxWidth(BufferView *, LyXFont const &);
+BufferView * LyXText::bv()
+{
+ lyx::Assert(bv_owner != 0);
+ return bv_owner;
+}
+
+
+BufferView * LyXText::bv() const
+{
+ lyx::Assert(bv_owner != 0);
+ return bv_owner;
+}
+
+
int LyXText::top_y() const
{
- if (!top_row_)
+ if (!anchor_row_)
return 0;
int y = 0;
- for (Row * row = firstrow; row && row != top_row_; row = row->next()) {
+ for (Row * row = firstRow();
+ row && row != anchor_row_; row = row->next()) {
y += row->height();
}
- return y + top_row_offset_;
+ return y + anchor_row_offset_;
}
void LyXText::top_y(int newy)
{
- if (!firstrow)
+ if (!firstRow())
return;
lyxerr[Debug::GUI] << "setting top y = " << newy << endl;
int y = newy;
- top_row_ = getRowNearY(y);
- top_row_offset_ = newy - y;
- lyxerr[Debug::GUI] << "changing reference to row: " << top_row_
- << " offset: " << top_row_offset_ << endl;
+ Row * row = getRowNearY(y);
+
+ if (row == anchor_row_ && anchor_row_offset_ == newy - y) {
+ lyxerr[Debug::GUI] << "top_y to same value, skipping update" << endl;
+ return;
+ }
+
+ anchor_row_ = row;
+ anchor_row_offset_ = newy - y;
+ lyxerr[Debug::GUI] << "changing reference to row: " << anchor_row_
+ << " offset: " << anchor_row_offset_ << endl;
+ postPaint(0);
+}
+
+
+void LyXText::anchor_row(Row * row)
+{
+ int old_y = top_y();
+ anchor_row_offset_ = 0;
+ anchor_row_ = row;
+ anchor_row_offset_ = old_y - top_y();
+ lyxerr[Debug::GUI] << "anchor_row(): changing reference to row: "
+ << anchor_row_ << " offset: " << anchor_row_offset_
+ << endl;
}
-int LyXText::workWidth(BufferView & bview) const
+int LyXText::workWidth() const
{
if (inset_owner) {
// FIXME: pass (const ?) ref
- return inset_owner->textWidth(&bview);
+ return inset_owner->textWidth(bv());
}
- return bview.workWidth();
+ return bv()->workWidth();
}
-int LyXText::workWidth(BufferView & bview, Inset * inset) const
+int LyXText::workWidth(Inset * inset) const
{
Paragraph * par = inset->parOwner();
lyx::Assert(par);
Row dummyrow;
dummyrow.par(par);
dummyrow.pos(pos);
- return workWidth(bview) - leftMargin(&bview, &dummyrow);
+ return workWidth() - leftMargin(&dummyrow);
} else {
int dummy_y;
Row * row = getRow(par, pos, dummy_y);
return maxw;
}
- return workWidth(bview);
+ return workWidth();
}
-int LyXText::getRealCursorX(BufferView * bview) const
+int LyXText::getRealCursorX() const
{
int x = cursor.x();
- if (the_locking_inset && (the_locking_inset->getLyXText(bview)!=this))
- x = the_locking_inset->getLyXText(bview)->getRealCursorX(bview);
+ if (the_locking_inset && (the_locking_inset->getLyXText(bv())!= this))
+ x = the_locking_inset->getLyXText(bv())->getRealCursorX();
return x;
}
//
// Lgb
-int LyXText::singleWidth(BufferView * bview, Paragraph * par,
+int LyXText::singleWidth(Paragraph * par,
pos_type pos) const
{
if (pos >= par->size())
return 0;
char const c = par->getChar(pos);
- return singleWidth(bview, par, pos, c);
+ return singleWidth(par, pos, c);
}
-int LyXText::singleWidth(BufferView * bview, Paragraph * par,
+int LyXText::singleWidth(Paragraph * par,
pos_type pos, char c) const
{
if (pos >= par->size())
return 0;
- LyXFont const font = getFont(bview->buffer(), par, pos);
+ LyXFont const font = getFont(bv()->buffer(), par, pos);
// The most common case is handled first (Asger)
if (IsPrintable(c)) {
return 3;
}
#if 1
+#warning inset->update FIXME
// this IS needed otherwise on initialitation we don't get the fill
// of the row right (ONLY on initialization if we read a file!)
// should be changed! (Jug 20011204)
- tmpinset->update(bview, font);
+ tmpinset->update(bv());
#endif
- return tmpinset->width(bview, font);
+ return tmpinset->width(bv(), font);
}
return 0;
}
}
+lyx::pos_type LyXText::log2vis(lyx::pos_type pos) const
+{
+ if (bidi_start == -1)
+ return pos;
+ else
+ return log2vis_list[pos-bidi_start];
+}
+
+
+lyx::pos_type LyXText::vis2log(lyx::pos_type pos) const
+{
+ if (bidi_start == -1)
+ return pos;
+ else
+ return vis2log_list[pos-bidi_start];
+}
+
+
+lyx::pos_type LyXText::bidi_level(lyx::pos_type pos) const
+{
+ if (bidi_start == -1)
+ return 0;
+ else
+ return bidi_levels[pos-bidi_start];
+}
+
+
+bool LyXText::bidi_InRange(lyx::pos_type pos) const
+{
+ return bidi_start == -1 ||
+ (bidi_start <= pos && pos <= bidi_end);
+}
+
+
void LyXText::computeBidiTables(Buffer const * buf, Row * row) const
{
bidi_same_direction = true;
}
-int LyXText::leftMargin(BufferView * bview, Row const * row) const
+int LyXText::leftMargin(Row const * row) const
{
Inset * ins;
return LEFT_MARGIN;
LyXTextClass const & tclass =
- bview->buffer()->params.getLyXTextClass();
+ bv()->buffer()->params.getLyXTextClass();
LyXLayout_ptr const & layout = row->par()->layout();
string parindent = layout->parindent;
Row dummyrow;
dummyrow.par(newpar);
dummyrow.pos(newpar->size());
- x = leftMargin(bview, &dummyrow);
+ x = leftMargin(&dummyrow);
} else {
// this is no longer an error, because this function
// is used to clear impossible depths after changing
}
}
- LyXFont const labelfont = getLabelFont(bview->buffer(), row->par());
+ LyXFont const labelfont = getLabelFont(bv()->buffer(), row->par());
switch (layout->margintype) {
case MARGIN_DYNAMIC:
if (!layout->leftmargin.empty()) {
break;
}
- if ((workWidth(*bview) > 0) &&
+ if ((workWidth() > 0) &&
!row->par()->params().leftIndent().zero())
{
LyXLength const len = row->par()->params().leftIndent();
int const tw = inset_owner ?
- inset_owner->latexTextWidth(bview) : workWidth(*bview);
+ inset_owner->latexTextWidth(bv()) : workWidth();
x += len.inPixels(tw);
}
(row->par()->inInset()->owner()->lyxCode() != Inset::TABULAR_CODE &&
row->par()->inInset()->owner()->lyxCode() != Inset::ERT_CODE))
&& (row->par()->layout() != tclass.defaultLayout() ||
- bview->buffer()->params.paragraph_separation ==
+ bv()->buffer()->params.paragraph_separation ==
BufferParams::PARSEP_INDENT)) {
x += font_metrics::signedWidth(parindent,
tclass.defaultfont());
} else if (layout->labeltype == LABEL_BIBLIO) {
// ale970405 Right width for bibitems
- x += bibitemMaxWidth(bview, tclass.defaultfont());
+ x += bibitemMaxWidth(bv(), tclass.defaultfont());
}
}
}
-int LyXText::labelEnd(BufferView & bview, Row const & row) const
+int LyXText::labelEnd(Row const & row) const
{
if (row.par()->layout()->margintype == MARGIN_MANUAL) {
Row tmprow = row;
tmprow.pos(row.par()->size());
// return the beginning of the body
- return leftMargin(&bview, &tmprow);
+ return leftMargin(&tmprow);
}
// LabelEnd is only needed if the layout
pos_type addressBreakPoint(pos_type i, Paragraph * par)
{
for (; i < par->size(); ++i) {
- if (par->isNewline(i)) {
+ if (par->isNewline(i))
return i;
- } else if (par->isInset(i) && par->getInset(i)->display()) {
- // FIXME: what are we doing modifying stuff here !
- par->getInset(i)->display(false);
- }
}
return par->size();
pos_type
-LyXText::rowBreakPoint(BufferView & bv, Row const & row) const
+LyXText::rowBreakPoint(Row const & row) const
{
Paragraph * par = row.par();
// maximum pixel width of a row.
- int width = workWidth(bv) - rightMargin(*bv.buffer(), row);
+ int width = workWidth() - rightMargin(*bv()->buffer(), row);
// inset->textWidth() returns -1 via workWidth(),
// but why ?
// or the end of the par, then choose the possible break
// nearest that.
- int const left = leftMargin(&bv, &row);
+ int const left = leftMargin(&row);
int x = left;
// pixel width since last breakpoint
char const c = par->getChar(i);
- int thiswidth = singleWidth(&bv, par, i, c);
+ int thiswidth = singleWidth(par, i, c);
// 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(), par));
+ getLabelFont(bv()->buffer(), par));
if (par->isLineSeparator(i - 1))
- thiswidth -= singleWidth(&bv, par, i - 1);
- int left_margin = labelEnd(bv, row);
+ thiswidth -= singleWidth(par, i - 1);
+ int left_margin = labelEnd(row);
if (thiswidth < left_margin)
thiswidth = left_margin;
}
chunkwidth += thiswidth;
Inset * in = par->isInset(i) ? par->getInset(i) : 0;
- bool display = (in && (in->display() || in->needFullRow()));
-
- // check whether a Display() inset is valid here.
- // If not, change it to non-display. FIXME:
- // we should not be modifying things at this
- // point !
- if (in && in->display() && (layout->isCommand() ||
- (layout->labeltype == LABEL_MANUAL && i < body_pos)))
- in->display(false);
+ bool fullrow = (in && (in->display() || in->needFullRow()));
// break before a character that will fall off
// the right of the row
if (x >= width) {
// if no break before or we are at an inset
// that will take up a row, break here
- if (point == last || display || chunkwidth >= (width - left)) {
+ if (point == last || fullrow || chunkwidth >= (width - left)) {
if (pos < i)
point = i - 1;
else
continue;
}
- if (!display)
+ if (!fullrow)
continue;
// full row insets start at a new row
// returns the minimum space a row needs on the screen in pixel
-int LyXText::fill(BufferView & bview, Row & row, int paper_width) const
+int LyXText::fill(Row & row, int paper_width) const
{
if (paper_width < 0)
return 0;
if (row.par()->layout()->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
int const tmpfill = row.fill();
row.fill(0); // the minfill in MarginLeft()
- w = leftMargin(&bview, &row);
+ w = leftMargin(&row);
row.fill(tmpfill);
} else
- w = leftMargin(&bview, &row);
+ w = leftMargin(&row);
Paragraph * par = row.par();
LyXLayout_ptr const & layout = par->layout();
while (i <= last) {
if (body_pos > 0 && i == body_pos) {
- w += font_metrics::width(layout->labelsep, getLabelFont(bview.buffer(), par));
+ w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), par));
if (par->isLineSeparator(i - 1))
- w -= singleWidth(&bview, par, i - 1);
- int left_margin = labelEnd(bview, row);
+ w -= singleWidth(par, i - 1);
+ int left_margin = labelEnd(row);
if (w < left_margin)
w = left_margin;
}
- w += singleWidth(&bview, par, i);
+ w += singleWidth(par, i);
++i;
}
if (body_pos > 0 && body_pos > last) {
- w += font_metrics::width(layout->labelsep, getLabelFont(bview.buffer(), par));
+ w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), par));
if (last >= 0 && par->isLineSeparator(last))
- w -= singleWidth(&bview, par, last);
- int const left_margin = labelEnd(bview, row);
+ w -= singleWidth(par, last);
+ int const left_margin = labelEnd(row);
if (w < left_margin)
w = left_margin;
}
- int const fill = paper_width - w - rightMargin(*bview.buffer(), row);
+ int const fill = paper_width - w - rightMargin(*bv()->buffer(), row);
return fill;
}
// returns the minimum space a manual label needs on the screen in pixel
-int LyXText::labelFill(BufferView & bview, Row const & row) const
+int LyXText::labelFill(Row const & row) const
{
pos_type last = row.par()->beginningOfBody();
int w = 0;
pos_type i = row.pos();
while (i <= last) {
- w += singleWidth(&bview, row.par(), i);
+ w += singleWidth(row.par(), i);
++i;
}
int fill = 0;
string const & labwidstr = row.par()->params().labelWidthString();
if (!labwidstr.empty()) {
- LyXFont const labfont = getLabelFont(bview.buffer(), row.par());
+ LyXFont const labfont = getLabelFont(bv()->buffer(), row.par());
int const labwidth = font_metrics::width(labwidstr, labfont);
fill = max(labwidth - w, 0);
}
return LColor::background;
}
-void LyXText::setHeightOfRow(BufferView * bview, Row * row) const
+void LyXText::setHeightOfRow(Row * row)
{
// get the maximum ascent and the maximum descent
int asc = 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(bview->buffer(), par, row->pos());
+ LyXFont font = getFont(bv()->buffer(), par, row->pos());
LyXFont::FONT_SIZE const tmpsize = font.size();
- font = getLayoutFont(bview->buffer(), par);
+ font = getLayoutFont(bv()->buffer(), par);
LyXFont::FONT_SIZE const size = font.size();
font.setSize(tmpsize);
- LyXFont labelfont = getLabelFont(bview->buffer(), par);
+ LyXFont labelfont = getLabelFont(bv()->buffer(), par);
float spacing_val = 1.0;
if (!row->par()->params().spacing().isDefault()) {
spacing_val = row->par()->params().spacing().getValue();
} else {
- spacing_val = bview->buffer()->params.spacing.getValue();
+ spacing_val = bv()->buffer()->params.spacing.getValue();
}
//lyxerr << "spacing_val = " << spacing_val << endl;
// Check if any insets are larger
for (pos_type pos = row->pos(); pos <= pos_end; ++pos) {
if (row->par()->isInset(pos)) {
- tmpfont = getFont(bview->buffer(), row->par(), pos);
+ tmpfont = getFont(bv()->buffer(), row->par(), pos);
tmpinset = row->par()->getInset(pos);
if (tmpinset) {
#if 1 // this is needed for deep update on initialitation
- tmpinset->update(bview, tmpfont);
+#warning inset->update FIXME
+ tmpinset->update(bv());
#endif
- asc = tmpinset->ascent(bview, tmpfont);
- desc = tmpinset->descent(bview, tmpfont);
- maxwidth += tmpinset->width(bview, tmpfont);
+ asc = tmpinset->ascent(bv(), tmpfont);
+ desc = tmpinset->descent(bv(), tmpfont);
+ maxwidth += tmpinset->width(bv(), tmpfont);
maxasc = max(maxasc, asc);
maxdesc = max(maxdesc, desc);
}
} else {
- maxwidth += singleWidth(bview, row->par(), pos);
+ maxwidth += singleWidth(row->par(), pos);
}
}
}
if (!row->pos() && (row->par() == firstpar)) {
// some parksips VERY EASY IMPLEMENTATION
- if (bview->buffer()->params.paragraph_separation ==
+ if (bv()->buffer()->params.paragraph_separation ==
BufferParams::PARSEP_SKIP)
{
if (layout->isParagraph()
&& firstpar->getDepth() == 0
&& firstpar->previous())
{
- maxasc += bview->buffer()->params.getDefSkip().inPixels(*bview);
+ maxasc += bv()->buffer()->params.getDefSkip().inPixels(*bv());
} else if (firstpar->previous() &&
firstpar->previous()->layout()->isParagraph() &&
firstpar->previous()->getDepth() == 0)
{
// is it right to use defskip here too? (AS)
- maxasc += bview->buffer()->params.getDefSkip().inPixels(*bview);
+ maxasc += bv()->buffer()->params.getDefSkip().inPixels(*bv());
}
}
// the top margin
- if (!row->par()->previous() && isTopLevel())
+ if (!row->par()->previous() && !isInInset())
maxasc += PAPER_MARGIN;
// add the vertical spaces, that the user added
- maxasc += getLengthMarkerHeight(*bview, firstpar->params().spaceTop());
+ maxasc += getLengthMarkerHeight(*bv(), firstpar->params().spaceTop());
// do not forget the DTP-lines!
// there height depends on the font of the nearest character
if (firstpar->params().lineTop())
- maxasc += 2 * font_metrics::ascent('x', getFont(bview->buffer(),
+ maxasc += 2 * font_metrics::ascent('x', getFont(bv()->buffer(),
firstpar, 0));
// and now the pagebreaks
if (firstpar->params().pagebreakTop())
// This is special code for the chapter, since the label of this
// layout is printed in an extra row
if (layout->labeltype == LABEL_COUNTER_CHAPTER
- && bview->buffer()->params.secnumdepth >= 0)
+ && bv()->buffer()->params.secnumdepth >= 0)
{
float spacing_val = 1.0;
if (!row->par()->params().spacing().isDefault()) {
spacing_val = row->par()->params().spacing().getValue();
} else {
- spacing_val = bview->buffer()->params.spacing.getValue();
+ spacing_val = bv()->buffer()->params.spacing.getValue();
}
labeladdon = int(font_metrics::maxDescent(labelfont) *
if (!row->par()->params().spacing().isDefault()) {
spacing_val = row->par()->params().spacing().getValue();
} else {
- spacing_val = bview->buffer()->params.spacing.getValue();
+ spacing_val = bv()->buffer()->params.spacing.getValue();
}
labeladdon = int(
if (row->par() == par
&& (!row->next() || row->next()->par() != row->par())) {
// the bottom margin
- if (!par->next() && isTopLevel())
+ if (!par->next() && !isInInset())
maxdesc += PAPER_MARGIN;
// add the vertical spaces, that the user added
- maxdesc += getLengthMarkerHeight(*bview, firstpar->params().spaceBottom());
+ maxdesc += getLengthMarkerHeight(*bv(), firstpar->params().spaceBottom());
// do not forget the DTP-lines!
// there height depends on the font of the nearest character
if (firstpar->params().lineBottom())
maxdesc += 2 * font_metrics::ascent('x',
- getFont(bview->buffer(),
+ getFont(bv()->buffer(),
par,
max(pos_type(0), par->size() - 1)));
float dummy;
// this IS needed
row->width(maxwidth);
- prepareToPrint(bview, row, x, dummy, dummy, dummy, false);
+ prepareToPrint(row, x, dummy, dummy, dummy, false);
}
row->width(int(maxwidth + x));
if (inset_owner) {
- Row * r = firstrow;
- width = max(0, workWidth(*bview));
+ Row * r = firstRow();
+ width = max(0, workWidth());
while (r) {
if (r->width() > width)
width = r->width();
// Appends the implicit specified paragraph before the specified row,
// start at the implicit given position
-void LyXText::appendParagraph(BufferView * bview, Row * row) const
+void LyXText::appendParagraph(Row * row)
{
pos_type const last = row->par()->size();
bool done = false;
do {
- pos_type z = rowBreakPoint(*bview, *row);
+ pos_type z = rowBreakPoint(*row);
Row * tmprow = row;
++z;
insertRow(row, row->par(), z);
row = row->next();
- row->height(0);
} else {
done = true;
}
// Set the dimensions of the row
// fixed fill setting now by calling inset->update() in
// SingleWidth when needed!
- tmprow->fill(fill(*bview, *tmprow, workWidth(*bview)));
- setHeightOfRow(bview, tmprow);
+ tmprow->fill(fill(*tmprow, workWidth()));
+ setHeightOfRow(tmprow);
} while (!done);
}
-// Do we even need this at all ? Code that uses RowPainter *already*
-// sets need_break_row when it sees a CHANGED_IN_DRAW, though not
-// quite like this
-void LyXText::markChangeInDraw(BufferView * bv, Row * row, Row * prev)
-{
- if (prev && prev->par() == row->par()) {
- breakAgainOneRow(bv, prev);
- if (prev->next() != row) {
- // breakAgainOneRow() has removed row_
- need_break_row = prev;
- } else {
- need_break_row = row;
- }
- } else if (!prev) {
- need_break_row = firstrow;
- } else {
- need_break_row = prev->next();
- }
- setCursor(bv, cursor.par(), cursor.pos());
- /* FIXME */
-}
-
-
-void LyXText::breakAgain(BufferView * bview, Row * row) const
+void LyXText::breakAgain(Row * row)
{
bool not_ready = true;
do {
- pos_type z = rowBreakPoint(*bview, *row);
+ pos_type z = rowBreakPoint(*row);
Row * tmprow = row;
if (z < row->par()->size()) {
++z;
insertRow(row, row->par(), z);
row = row->next();
- row->height(0);
} else {
row = row->next();
++z;
if (row->pos() == z)
- not_ready = false; // the rest will not change
+ not_ready = false; // the rest will not change
else {
row->pos(z);
}
}
// set the dimensions of the row
- tmprow->fill(fill(*bview, *tmprow, workWidth(*bview)));
- setHeightOfRow(bview, tmprow);
+ tmprow->fill(fill(*tmprow, workWidth()));
+ setHeightOfRow(tmprow);
} while (not_ready);
}
// this is just a little changed version of break again
-void LyXText::breakAgainOneRow(BufferView * bview, Row * row)
+void LyXText::breakAgainOneRow(Row * row)
{
- pos_type z = rowBreakPoint(*bview, *row);
+ pos_type z = rowBreakPoint(*row);
Row * tmprow = row;
if (z < row->par()->size()) {
++z;
insertRow(row, row->par(), z);
row = row->next();
- row->height(0);
} else {
row = row->next();
++z;
}
// set the dimensions of the row
- tmprow->fill(fill(*bview, *tmprow, workWidth(*bview)));
- setHeightOfRow(bview, tmprow);
+ tmprow->fill(fill(*tmprow, workWidth()));
+ setHeightOfRow(tmprow);
}
-void LyXText::breakParagraph(BufferView * bview,
- ParagraphList & paragraphs, char keep_layout)
+void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
{
// allow only if at start or end, or all previous is new text
if (cursor.pos() && cursor.pos() != cursor.par()->size()
return;
LyXTextClass const & tclass =
- bview->buffer()->params.getLyXTextClass();
+ bv()->buffer()->params.getLyXTextClass();
LyXLayout_ptr const & layout = cursor.par()->layout();
// this is only allowed, if the current paragraph is not empty or caption
&& !layout->keepempty)
return;
- setUndo(bview, Undo::FINISH, cursor.par(), cursor.par()->next());
+ setUndo(bv(), Undo::FINISH, cursor.par(), cursor.par()->next());
// Always break behind a space
//
// paragraph before or behind and we should react on that one
// but we can fix this in 1.3.0 (Jug 20020509)
bool const isempty = (layout->keepempty && cursor.par()->empty());
- ::breakParagraph(bview->buffer()->params, paragraphs, cursor.par(), cursor.pos(),
+ ::breakParagraph(bv()->buffer()->params, paragraphs, cursor.par(), cursor.pos(),
keep_layout);
// well this is the caption hack since one caption is really enough
if (cursor.pos() && !cursor.row()->par()->isNewline(cursor.row()->pos() - 1)
&& cursor.row()->pos() == cursor.pos())
{
- cursorLeft(bview);
+ cursorLeft(bv());
}
- status(bview, LyXText::NEED_MORE_REFRESH);
- refresh_row = cursor.row();
- refresh_y = cursor.y() - cursor.row()->baseline();
+ int y = cursor.y() - cursor.row()->baseline();
// Do not forget the special right address boxes
if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
- while (refresh_row->previous() &&
- refresh_row->previous()->par() == refresh_row->par())
- {
- refresh_row = refresh_row->previous();
- refresh_y -= refresh_row->height();
+ Row * r = cursor.row();
+ while (r->previous() && r->previous()->par() == r->par()) {
+ r = r->previous();
+ y -= r->height();
}
}
+
+ postPaint(y);
+
removeParagraph(cursor.row());
// set the dimensions of the cursor row
- cursor.row()->fill(fill(*bview, *cursor.row(), workWidth(*bview)));
+ cursor.row()->fill(fill(*cursor.row(), workWidth()));
- setHeightOfRow(bview, cursor.row());
+ setHeightOfRow(cursor.row());
#warning Trouble Point! (Lgb)
// When ::breakParagraph is called from within an inset we must
&& cursor.par()->next()->isNewline(0))
cursor.par()->next()->erase(0);
- insertParagraph(bview, cursor.par()->next(), cursor.row());
-
- updateCounters(bview);
+ insertParagraph(cursor.par()->next(), cursor.row());
+ updateCounters();
// This check is necessary. Otherwise the new empty paragraph will
// be deleted automatically. And it is more friendly for the user!
if (cursor.pos() || isempty)
- setCursor(bview, cursor.par()->next(), 0);
+ setCursor(cursor.par()->next(), 0);
else
- setCursor(bview, cursor.par(), 0);
+ setCursor(cursor.par(), 0);
if (cursor.row()->next())
- breakAgain(bview, cursor.row()->next());
+ breakAgain(cursor.row()->next());
need_break_row = 0;
}
// Just a macro to make some thing easier.
-void LyXText::redoParagraph(BufferView * bview) const
+void LyXText::redoParagraph()
{
clearSelection();
- redoParagraphs(bview, cursor, cursor.par()->next());
- setCursorIntern(bview, cursor.par(), cursor.pos());
+ redoParagraphs(cursor, cursor.par()->next());
+ setCursorIntern(cursor.par(), cursor.pos());
}
// insert a character, moves all the following breaks in the
// same Paragraph one to the right and make a rebreak
-void LyXText::insertChar(BufferView * bview, char c)
+void LyXText::insertChar(char c)
{
- setUndo(bview, Undo::INSERT, cursor.par(), cursor.par()->next());
+ setUndo(bv(), Undo::INSERT, cursor.par(), cursor.par()->next());
// When the free-spacing option is set for the current layout,
// disable the double-space checking
!(contains(number_seperators, c) &&
cursor.pos() >= 1 &&
cursor.pos() < cursor.par()->size() &&
- getFont(bview->buffer(),
+ getFont(bv()->buffer(),
cursor.par(),
cursor.pos()).number() == LyXFont::ON &&
- getFont(bview->buffer(),
+ getFont(bv()->buffer(),
cursor.par(),
cursor.pos() - 1).number() == LyXFont::ON)
)
- number(bview); // Set current_font.number to OFF
+ number(bv()); // Set current_font.number to OFF
} else if (IsDigit(c) &&
real_current_font.isVisibleRightToLeft()) {
- number(bview); // Set current_font.number to ON
+ number(bv()); // Set current_font.number to ON
if (cursor.pos() > 0) {
char const c = cursor.par()->getChar(cursor.pos() - 1);
cursor.par()->isSeparator(cursor.pos() - 2) ||
cursor.par()->isNewline(cursor.pos() - 2))
) {
- setCharFont(bview->buffer(),
+ setCharFont(bv()->buffer(),
cursor.par(),
cursor.pos() - 1,
current_font);
} else if (contains(number_seperators, c) &&
cursor.pos() >= 2 &&
- getFont(bview->buffer(),
+ getFont(bv()->buffer(),
cursor.par(),
cursor.pos() - 2).number() == LyXFont::ON) {
- setCharFont(bview->buffer(),
+ setCharFont(bv()->buffer(),
cursor.par(),
cursor.pos() - 1,
current_font);
// Get the font that is used to calculate the baselineskip
pos_type const lastpos = cursor.par()->size();
LyXFont rawparfont =
- cursor.par()->getFontSettings(bview->buffer()->params,
+ cursor.par()->getFontSettings(bv()->buffer()->params,
lastpos - 1);
bool jumped_over_space = false;
static bool sent_space_message = false;
if (!sent_space_message) {
if (cursor.pos() == 0)
- bview->owner()->message(_("You cannot insert a space at the beginning of a paragraph. Please read the Tutorial."));
+ bv()->owner()->message(_("You cannot insert a space at the beginning of a paragraph. Please read the Tutorial."));
else
- bview->owner()->message(_("You cannot type two spaces this way. Please read the Tutorial."));
+ bv()->owner()->message(_("You cannot type two spaces this way. Please read the Tutorial."));
sent_space_message = true;
}
charInserted();
// Here case LyXText::InsertInset already insertet the character
cursor.par()->insertChar(cursor.pos(), c);
}
- setCharFont(bview->buffer(), cursor.par(), cursor.pos(), rawtmpfont);
+ setCharFont(bv()->buffer(), cursor.par(), cursor.pos(), rawtmpfont);
if (!jumped_over_space) {
// refresh the positions
if (row->previous() && row->previous()->par() == row->par()
&& (cursor.par()->isLineSeparator(cursor.pos())
|| cursor.par()->isNewline(cursor.pos())
- || ((cursor.pos() < cursor.par()->size()) &&
- cursor.par()->isInset(cursor.pos()+1))
+ || ((cursor.pos() + 1 < cursor.par()->size()) &&
+ cursor.par()->isInset(cursor.pos() + 1))
|| cursor.row()->fill() == -1))
{
- pos_type z = rowBreakPoint(*bview, *row->previous());
+ pos_type z = rowBreakPoint(*row->previous());
if (z >= row->pos()) {
row->pos(z + 1);
// set the dimensions of the row above
- row->previous()->fill(fill(*bview,
+ row->previous()->fill(fill(
*row->previous(),
- workWidth(*bview)));
+ workWidth()));
- setHeightOfRow(bview, row->previous());
+ setHeightOfRow(row->previous());
y -= row->previous()->height();
- refresh_y = y;
- refresh_row = row->previous();
- status(bview, LyXText::NEED_MORE_REFRESH);
- breakAgainOneRow(bview, row);
+ postPaint(y);
+
+ breakAgainOneRow(row);
current_font = rawtmpfont;
real_current_font = realtmpfont;
- setCursor(bview, cursor.par(), cursor.pos() + 1,
+ setCursor(cursor.par(), cursor.pos() + 1,
false, cursor.boundary());
// cursor MUST be in row now.
// check, wether the last characters font has changed.
if (cursor.pos() && cursor.pos() == cursor.par()->size()
&& rawparfont != rawtmpfont)
- redoHeightOfParagraph(bview);
+ redoHeightOfParagraph();
charInserted();
return;
if (row->fill() >= 0) {
// needed because a newline will set fill to -1. Otherwise
// we would not get a rebreak!
- row->fill(fill(*bview, *row, workWidth(*bview)));
+ row->fill(fill(*row, workWidth()));
}
if (c == Paragraph::META_INSET || row->fill() < 0) {
- refresh_y = y;
- refresh_row = row;
- status(bview, LyXText::NEED_MORE_REFRESH);
- breakAgainOneRow(bview, row);
+ postPaint(y);
+ breakAgainOneRow(row);
// will the cursor be in another row now?
if (row->lastPos() <= cursor.pos() + 1 && row->next()) {
if (row->next() && row->next()->par() == row->par())
// this should always be true
row = row->next();
- breakAgainOneRow(bview, row);
+ breakAgainOneRow(row);
}
current_font = rawtmpfont;
real_current_font = realtmpfont;
- setCursor(bview, cursor.par(), cursor.pos() + 1, false,
+ setCursor(cursor.par(), cursor.pos() + 1, false,
cursor.boundary());
- if (isBoundary(bview->buffer(), cursor.par(), cursor.pos())
+ if (isBoundary(bv()->buffer(), cursor.par(), cursor.pos())
!= cursor.boundary())
- setCursor(bview, cursor.par(), cursor.pos(), false,
+ setCursor(cursor.par(), cursor.pos(), false,
!cursor.boundary());
if (row->next() && row->next()->par() == row->par())
need_break_row = row->next();
else
need_break_row = 0;
} else {
- refresh_y = y;
- refresh_row = row;
-
+ // FIXME: similar code is duplicated all over - make resetHeightOfRow
int const tmpheight = row->height();
- setHeightOfRow(bview, row);
- if (tmpheight == row->height())
- status(bview, LyXText::NEED_VERY_LITTLE_REFRESH);
- else
- status(bview, LyXText::NEED_MORE_REFRESH);
+
+ setHeightOfRow(row);
+
+ if (tmpheight == row->height()) {
+ postRowPaint(row, y);
+ } else {
+ postPaint(y);
+ }
current_font = rawtmpfont;
real_current_font = realtmpfont;
- setCursor(bview, cursor.par(), cursor.pos() + 1, false,
+ setCursor(cursor.par(), cursor.pos() + 1, false,
cursor.boundary());
}
// check, wether the last characters font has changed.
if (cursor.pos() && cursor.pos() == cursor.par()->size()
&& rawparfont != rawtmpfont) {
- redoHeightOfParagraph(bview);
+ redoHeightOfParagraph();
} else {
// now the special right address boxes
if (cursor.par()->layout()->margintype
== MARGIN_RIGHT_ADDRESS_BOX) {
- redoDrawingOfParagraph(bview, cursor);
+ redoDrawingOfParagraph(cursor);
}
}
}
-void LyXText::prepareToPrint(BufferView * bview,
- Row * row, float & x,
+void LyXText::prepareToPrint(Row * row, float & x,
float & fill_separator,
float & fill_hfill,
float & fill_label_hfill,
fill_label_hfill = 0;
bool const is_rtl =
- row->par()->isRightToLeftPar(bview->buffer()->params);
+ row->par()->isRightToLeftPar(bv()->buffer()->params);
if (is_rtl) {
- x = (workWidth(*bview) > 0)
- ? rightMargin(*bview->buffer(), *row) : 0;
+ x = (workWidth() > 0)
+ ? rightMargin(*bv()->buffer(), *row) : 0;
} else
- x = (workWidth(*bview) > 0)
- ? leftMargin(bview, row) : 0;
+ x = (workWidth() > 0)
+ ? leftMargin(row) : 0;
// is there a manual margin with a manual label
LyXLayout_ptr const & layout = row->par()->layout();
++nlh;
if (nlh && !row->par()->getLabelWidthString().empty()) {
- fill_label_hfill = labelFill(*bview, *row) / nlh;
+ fill_label_hfill = labelFill(*row) / nlh;
}
}
// we don't have to look at the alignment if it is ALIGN_LEFT and
// if the row is already larger then the permitted width as then
// we force the LEFT_ALIGN'edness!
- } else if (static_cast<int>(row->width()) < workWidth(*bview)) {
+ } else if (static_cast<int>(row->width()) < workWidth()) {
// is it block, flushleft or flushright?
// set x how you need it
int align;
if (!bidi)
return;
- computeBidiTables(bview->buffer(), row);
+ computeBidiTables(bv()->buffer(), row);
if (is_rtl) {
pos_type body_pos = row->par()->beginningOfBody();
pos_type last = row->lastPos();
(body_pos - 1 > last ||
!row->par()->isLineSeparator(body_pos - 1))) {
x += font_metrics::width(layout->labelsep,
- getLabelFont(bview->buffer(), row->par()));
+ getLabelFont(bv()->buffer(), row->par()));
if (body_pos - 1 <= last)
x += fill_label_hfill;
}
// realize, that you left an empty paragraph, they will delete it.
// They also delete the corresponding row
-void LyXText::cursorRightOneWord(BufferView * bview) const
+void LyXText::cursorRightOneWord()
{
// treat floats, HFills and Insets as words
LyXCursor tmpcursor = cursor;
++steps;
}
}
- setCursor(bview, tmpcursor.par(), tmpcursor.pos());
+ setCursor(tmpcursor.par(), tmpcursor.pos());
}
-void LyXText::cursorTab(BufferView * bview) const
+void LyXText::cursorTab()
{
LyXCursor tmpcursor = cursor;
while (tmpcursor.pos() < tmpcursor.par()->size()
}
} else
tmpcursor.pos(tmpcursor.pos() + 1);
- setCursor(bview, tmpcursor.par(), tmpcursor.pos());
+ setCursor(tmpcursor.par(), tmpcursor.pos());
}
// Skip initial whitespace at end of word and move cursor to *start*
// of prior word, not to end of next prior word.
-void LyXText::cursorLeftOneWord(BufferView * bview) const
+void LyXText::cursorLeftOneWord()
{
LyXCursor tmpcursor = cursor;
cursorLeftOneWord(tmpcursor);
- setCursor(bview, tmpcursor.par(), tmpcursor.pos());
+ setCursor(tmpcursor.par(), tmpcursor.pos());
}
-void LyXText::cursorLeftOneWord(LyXCursor & cur) const
+void LyXText::cursorLeftOneWord(LyXCursor & cur)
{
// treat HFills, floats and Insets as words
cur = cursor;
// Select current word. This depends on behaviour of
// CursorLeftOneWord(), so it is patched as well.
void LyXText::getWord(LyXCursor & from, LyXCursor & to,
- word_location const loc) const
+ word_location const loc)
{
// first put the cursor where we wana start to select the word
from = cursor;
}
-void LyXText::selectWord(BufferView * bview, word_location const loc)
+void LyXText::selectWord(word_location loc)
{
LyXCursor from;
LyXCursor to;
getWord(from, to, loc);
if (cursor != from)
- setCursor(bview, from.par(), from.pos());
+ setCursor(from.par(), from.pos());
if (to == from)
return;
selection.cursor = cursor;
- setCursor(bview, to.par(), to.pos());
- setSelection(bview);
+ setCursor(to.par(), to.pos());
+ setSelection();
}
// Select the word currently under the cursor when no
// selection is currently set
-bool LyXText::selectWordWhenUnderCursor(BufferView * bview,
- word_location const loc)
+bool LyXText::selectWordWhenUnderCursor(word_location loc)
{
if (!selection.set()) {
- selectWord(bview, loc);
+ selectWord(loc);
return selection.set();
}
return false;
}
-void LyXText::acceptChange(BufferView * bv)
+void LyXText::acceptChange()
{
if (!selection.set() && cursor.par()->size())
return;
- bv->hideCursor();
+ bv()->hideCursor();
if (selection.start.par() == selection.end.par()) {
LyXCursor & startc = selection.start;
LyXCursor & endc = selection.end;
- setUndo(bv, Undo::INSERT, startc.par(), startc.par()->next());
+ setUndo(bv(), Undo::INSERT, startc.par(), startc.par()->next());
startc.par()->acceptChange(startc.pos(), endc.pos());
finishUndo();
clearSelection();
- redoParagraphs(bv, startc, startc.par()->next());
- setCursorIntern(bv, startc.par(), 0);
+ redoParagraphs(startc, startc.par()->next());
+ setCursorIntern(startc.par(), 0);
}
#warning handle multi par selection
}
-void LyXText::rejectChange(BufferView * bv)
+void LyXText::rejectChange()
{
if (!selection.set() && cursor.par()->size())
return;
- bv->hideCursor();
+ bv()->hideCursor();
if (selection.start.par() == selection.end.par()) {
LyXCursor & startc = selection.start;
LyXCursor & endc = selection.end;
- setUndo(bv, Undo::INSERT, startc.par(), startc.par()->next());
+ setUndo(bv(), Undo::INSERT, startc.par(), startc.par()->next());
startc.par()->rejectChange(startc.pos(), endc.pos());
finishUndo();
clearSelection();
- redoParagraphs(bv, startc, startc.par()->next());
- setCursorIntern(bv, startc.par(), 0);
+ redoParagraphs(startc, startc.par()->next());
+ setCursorIntern(startc.par(), 0);
}
#warning handle multi par selection
}
// This function is only used by the spellchecker for NextWord().
// It doesn't handle LYX_ACCENTs and probably never will.
WordLangTuple const
-LyXText::selectNextWordToSpellcheck(BufferView * bview, float & value) const
+LyXText::selectNextWordToSpellcheck(float & value)
{
if (the_locking_inset) {
- WordLangTuple word = the_locking_inset->selectNextWordToSpellcheck(bview, value);
+ WordLangTuple word = the_locking_inset->selectNextWordToSpellcheck(bv(), value);
if (!word.word().empty()) {
value += float(cursor.y());
value /= float(height);
if (cursor.pos() < cursor.par()->size() &&
cursor.par()->isInset(cursor.pos())) {
// lock the inset!
- cursor.par()->getInset(cursor.pos())->edit(bview);
+ cursor.par()->getInset(cursor.pos())->edit(bv());
// now call us again to do the above trick
// but obviously we have to start from down below ;)
- return bview->text->selectNextWordToSpellcheck(bview, value);
+ return bv()->text->selectNextWordToSpellcheck(value);
}
// Update the value if we changed paragraphs
if (cursor.par() != tmppar) {
- setCursor(bview, cursor.par(), cursor.pos());
+ setCursor(cursor.par(), cursor.pos());
value = float(cursor.y())/float(height);
}
selection.cursor = cursor;
string lang_code(
- getFont(bview->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)
// This one is also only for the spellchecker
-void LyXText::selectSelectedWord(BufferView * bview)
+void LyXText::selectSelectedWord()
{
if (the_locking_inset) {
- the_locking_inset->selectSelectedWord(bview);
+ the_locking_inset->selectSelectedWord(bv());
return;
}
// move cursor to the beginning
- setCursor(bview, selection.cursor.par(), selection.cursor.pos());
+ setCursor(selection.cursor.par(), selection.cursor.pos());
// set the sel cursor
selection.cursor = cursor;
&& (cursor.par()->isLetter(cursor.pos())))
cursor.pos(cursor.pos() + 1);
- setCursor(bview, cursor.par(), cursor.pos());
+ setCursor(cursor.par(), cursor.pos());
// finally set the selection
- setSelection(bview);
+ setSelection();
}
// Delete from cursor up to the end of the current or next word.
-void LyXText::deleteWordForward(BufferView * bview)
+void LyXText::deleteWordForward()
{
if (cursor.par()->empty())
- cursorRight(bview);
+ cursorRight(bv());
else {
LyXCursor tmpcursor = cursor;
tmpcursor.row(0); //Â ??
selection.set(true); // to avoid deletion
- cursorRightOneWord(bview);
- setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
+ cursorRightOneWord();
+ setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos());
selection.cursor = cursor;
cursor = tmpcursor;
- setSelection(bview);
+ setSelection();
// Great, CutSelection() gets rid of multiple spaces.
- cutSelection(bview, true, false);
+ cutSelection(true, false);
}
}
// Delete from cursor to start of current or prior word.
-void LyXText::deleteWordBackward(BufferView * bview)
+void LyXText::deleteWordBackward()
{
if (cursor.par()->empty())
- cursorLeft(bview);
+ cursorLeft(bv());
else {
LyXCursor tmpcursor = cursor;
tmpcursor.row(0); // ??
selection.set(true); // to avoid deletion
- cursorLeftOneWord(bview);
- setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
+ cursorLeftOneWord();
+ setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos());
selection.cursor = cursor;
cursor = tmpcursor;
- setSelection(bview);
- cutSelection(bview, true, false);
+ setSelection();
+ cutSelection(true, false);
}
}
// Kill to end of line.
-void LyXText::deleteLineForward(BufferView * bview)
+void LyXText::deleteLineForward()
{
if (cursor.par()->empty())
// Paragraph is empty, so we just go to the right
- cursorRight(bview);
+ cursorRight(bv());
else {
LyXCursor tmpcursor = cursor;
// We can't store the row over a regular setCursor
// so we set it to 0 and reset it afterwards.
tmpcursor.row(0); //Â ??
selection.set(true); // to avoid deletion
- cursorEnd(bview);
- setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
+ cursorEnd();
+ setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos());
selection.cursor = cursor;
cursor = tmpcursor;
- setSelection(bview);
+ setSelection();
// What is this test for ??? (JMarc)
if (!selection.set()) {
- deleteWordForward(bview);
+ deleteWordForward();
} else {
- cutSelection(bview, true, false);
+ cutSelection(true, false);
}
}
}
-void LyXText::changeCase(BufferView & bview, LyXText::TextCase action)
+void LyXText::changeCase(LyXText::TextCase action)
{
LyXCursor from;
LyXCursor to;
to = selection.end;
} else {
getWord(from, to, PARTIAL_WORD);
- setCursor(&bview, to.par(), to.pos() + 1);
+ setCursor(to.par(), to.pos() + 1);
}
lyx::Assert(from <= to);
- setUndo(&bview, Undo::FINISH, from.par(), to.par()->next());
+ setUndo(bv(), Undo::FINISH, from.par(), to.par()->next());
pos_type pos = from.pos();
Paragraph * par = from.par();
}
#warning changes
par->setChar(pos, c);
- checkParagraph(&bview, par, pos);
+ checkParagraph(par, pos);
++pos;
}
- if (to.row() != from.row()) {
- refresh_y = from.y() - from.row()->baseline();
- refresh_row = from.row();
- status(&bview, LyXText::NEED_MORE_REFRESH);
- }
+
+ if (to.row() != from.row())
+ postPaint(from.y() - from.row()->baseline());
}
-void LyXText::transposeChars(BufferView & bview)
+void LyXText::transposeChars()
{
Paragraph * tmppar = cursor.par();
- setUndo(&bview, Undo::FINISH, tmppar, tmppar->next());
+ setUndo(bv(), Undo::FINISH, tmppar, tmppar->next());
pos_type tmppos = cursor.pos();
tmppar->insertChar(ipos, c1);
tmppar->insertChar(ipos + 1, c2);
- checkParagraph(&bview, tmppar, tmppos);
+ checkParagraph(tmppar, tmppos);
}
-void LyXText::Delete(BufferView * bview)
+void LyXText::Delete()
{
// this is a very easy implementation
old_cursor.par()->previous()->id() : -1;
// just move to the right
- cursorRight(bview);
+ cursorRight(bv());
// CHECK Look at the comment here.
// This check is not very good...
LyXCursor tmpcursor = cursor;
// to make sure undo gets the right cursor position
cursor = old_cursor;
- setUndo(bview, Undo::DELETE,
+ setUndo(bv(), Undo::DELETE,
cursor.par(), cursor.par()->next());
cursor = tmpcursor;
- backspace(bview);
+ backspace();
}
}
-void LyXText::backspace(BufferView * bview)
+void LyXText::backspace()
{
// Get the font that is used to calculate the baselineskip
pos_type lastpos = cursor.par()->size();
LyXFont rawparfont =
- cursor.par()->getFontSettings(bview->buffer()->params,
+ cursor.par()->getFontSettings(bv()->buffer()->params,
lastpos - 1);
if (cursor.pos() == 0) {
tmppar->params().pagebreakBottom(cursor.par()->params().pagebreakBottom());
}
- cursorLeft(bview);
+ cursorLeft(bv());
// the layout things can change the height of a row !
int const tmpheight = cursor.row()->height();
- setHeightOfRow(bview, cursor.row());
+ setHeightOfRow(cursor.row());
if (cursor.row()->height() != tmpheight) {
- refresh_y = cursor.y() - cursor.row()->baseline();
- refresh_row = cursor.row();
- status(bview, LyXText::NEED_MORE_REFRESH);
+ postPaint(cursor.y() - cursor.row()->baseline());
}
return;
}
}
if (cursor.par()->previous()) {
- setUndo(bview, Undo::DELETE,
+ setUndo(bv(), Undo::DELETE,
cursor.par()->previous(), cursor.par()->next());
}
// without the dreaded mechanism. (JMarc)
if (cursor.par()->previous()) {
// steps into the above paragraph.
- setCursorIntern(bview, cursor.par()->previous(),
+ setCursorIntern(cursor.par()->previous(),
cursor.par()->previous()->size(),
false);
}
// Correction: Pasting is always allowed with standard-layout
LyXTextClass const & tclass =
- bview->buffer()->params.getLyXTextClass();
+ bv()->buffer()->params.getLyXTextClass();
if (cursor.par() != tmppar
&& (cursor.par()->layout() == tmppar->layout()
&& cursor.par()->getAlign() == tmppar->getAlign()) {
removeParagraph(tmprow);
removeRow(tmprow);
- mergeParagraph(bview->buffer()->params, bview->buffer()->paragraphs, cursor.par());
+ mergeParagraph(bv()->buffer()->params, bv()->buffer()->paragraphs, cursor.par());
if (!cursor.pos() || !cursor.par()->isSeparator(cursor.pos() - 1))
; //cursor.par()->insertChar(cursor.pos(), ' ');
if (cursor.pos())
cursor.pos(cursor.pos() - 1);
- status(bview, LyXText::NEED_MORE_REFRESH);
- refresh_row = cursor.row();
- refresh_y = cursor.y() - cursor.row()->baseline();
+ postPaint(cursor.y() - cursor.row()->baseline());
// remove the lost paragraph
// This one is not safe, since the paragraph that the tmprow and the
//RemoveRow(tmprow);
// This rebuilds the rows.
- appendParagraph(bview, cursor.row());
- updateCounters(bview);
+ appendParagraph(cursor.row());
+ updateCounters();
// the row may have changed, block, hfills etc.
- setCursor(bview, cursor.par(), cursor.pos(), false);
+ setCursor(cursor.par(), cursor.pos(), false);
}
} else {
// this is the code for a normal backspace, not pasting
// any paragraphs
- setUndo(bview, Undo::DELETE,
+ setUndo(bv(), Undo::DELETE,
cursor.par(), cursor.par()->next());
// 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,
// without the dreaded mechanism. (JMarc)
- setCursorIntern(bview, cursor.par(), cursor.pos()- 1,
+ setCursorIntern(cursor.par(), cursor.pos()- 1,
false, cursor.boundary());
if (cursor.par()->isInset(cursor.pos())) {
if (cursor.par()->getInset(cursor.pos())->display() ||
cursor.par()->getInset(cursor.pos())->needFullRow()) {
cursor.par()->erase(cursor.pos());
- redoParagraph(bview);
+ redoParagraph();
return;
}
}
// when calculating the fill
if (cursor.pos() < row->lastPos() ||
!cursor.par()->isLineSeparator(cursor.pos())) {
- row->fill(row->fill() + singleWidth(bview,
+ row->fill(row->fill() + singleWidth(
cursor.par(),
cursor.pos()));
}
if (cursor.pos() < cursor.par()->size()
&& !cursor.par()->isSeparator(cursor.pos())) {
cursor.par()->insertChar(cursor.pos(), ' ');
- setCharFont(bview->buffer(), cursor.par(),
+ setCharFont(bv()->buffer(), cursor.par(),
cursor.pos(), current_font);
// refresh the positions
tmprow = row;
// delete newlines at the beginning of paragraphs
while (!cursor.par()->empty() &&
+ cursor.pos() < cursor.par()->size() &&
cursor.par()->isNewline(cursor.pos()) &&
cursor.pos() == cursor.par()->beginningOfBody()) {
cursor.par()->erase(cursor.pos());
// is there a break one row above
if (row->previous() && row->previous()->par() == row->par()) {
- z = rowBreakPoint(*bview, *row->previous());
+ z = rowBreakPoint(*row->previous());
if (z >= row->pos()) {
row->pos(z + 1);
removeRow(row);
need_break_row = 0;
} else {
- breakAgainOneRow(bview, row);
+ breakAgainOneRow(row);
if (row->next() && row->next()->par() == row->par())
need_break_row = row->next();
else
// set the dimensions of the row above
y -= tmprow->height();
- tmprow->fill(fill(*bview, *tmprow, workWidth(*bview)));
- setHeightOfRow(bview, tmprow);
+ tmprow->fill(fill(*tmprow, workWidth()));
+ setHeightOfRow(tmprow);
- refresh_y = y;
- refresh_row = tmprow;
- status(bview, LyXText::NEED_MORE_REFRESH);
- setCursor(bview, cursor.par(), cursor.pos(),
+ postPaint(y);
+
+ setCursor(cursor.par(), cursor.pos(),
false, cursor.boundary());
//current_font = rawtmpfont;
//real_current_font = realtmpfont;
// check, whether the last character's font has changed.
if (rawparfont !=
- cursor.par()->getFontSettings(bview->buffer()->params,
+ cursor.par()->getFontSettings(bv()->buffer()->params,
cursor.par()->size() - 1))
- redoHeightOfParagraph(bview);
+ redoHeightOfParagraph();
return;
}
}
// break the cursor row again
if (row->next() && row->next()->par() == row->par() &&
(row->lastPos() == row->par()->size() - 1 ||
- rowBreakPoint(*bview, *row) != row->lastPos())) {
+ rowBreakPoint(*row) != row->lastPos())) {
// it can happen that a paragraph loses one row
// without a real breakup. This is when a word
if (row->lastPos() == row->par()->size() - 1)
removeRow(row->next());
- refresh_y = y;
- refresh_row = row;
- status(bview, LyXText::NEED_MORE_REFRESH);
+ postPaint(y);
- breakAgainOneRow(bview, row);
+ breakAgainOneRow(row);
// will the cursor be in another row now?
if (row->next() && row->next()->par() == row->par() &&
row->lastPos() <= cursor.pos()) {
row = row->next();
- breakAgainOneRow(bview, row);
+ breakAgainOneRow(row);
}
- setCursor(bview, cursor.par(), cursor.pos(), false, cursor.boundary());
+ setCursor(cursor.par(), cursor.pos(), false, cursor.boundary());
if (row->next() && row->next()->par() == row->par())
need_break_row = row->next();
need_break_row = 0;
} else {
// set the dimensions of the row
- row->fill(fill(*bview, *row, workWidth(*bview)));
+ row->fill(fill(*row, workWidth()));
int const tmpheight = row->height();
- setHeightOfRow(bview, row);
- if (tmpheight == row->height())
- status(bview, LyXText::NEED_VERY_LITTLE_REFRESH);
- else
- status(bview, LyXText::NEED_MORE_REFRESH);
- refresh_y = y;
- refresh_row = row;
- setCursor(bview, cursor.par(), cursor.pos(), false, cursor.boundary());
+ setHeightOfRow(row);
+ if (tmpheight == row->height()) {
+ postRowPaint(row, y);
+ } else {
+ postPaint(y);
+ }
+ setCursor(cursor.par(), cursor.pos(), false, cursor.boundary());
}
}
// current_font = rawtmpfont;
// real_current_font = realtmpfont;
- if (isBoundary(bview->buffer(), cursor.par(), cursor.pos())
+ if (isBoundary(bv()->buffer(), cursor.par(), cursor.pos())
!= cursor.boundary())
- setCursor(bview, cursor.par(), cursor.pos(), false,
+ setCursor(cursor.par(), cursor.pos(), false,
!cursor.boundary());
lastpos = cursor.par()->size();
if (cursor.pos() == lastpos)
- setCurrentFont(bview);
+ setCurrentFont();
// check, whether the last characters font has changed.
if (rawparfont !=
- cursor.par()->getFontSettings(bview->buffer()->params, lastpos - 1)) {
- redoHeightOfParagraph(bview);
+ cursor.par()->getFontSettings(bv()->buffer()->params, lastpos - 1)) {
+ redoHeightOfParagraph();
} else {
// now the special right address boxes
if (cursor.par()->layout()->margintype
== MARGIN_RIGHT_ADDRESS_BOX) {
- redoDrawingOfParagraph(bview, cursor);
+ redoDrawingOfParagraph(cursor);
}
}
}
// returns pointer to a specified row
Row * LyXText::getRow(Paragraph * par, pos_type pos, int & y) const
{
- if (!firstrow)
+ if (!firstRow())
return 0;
- Row * tmprow = firstrow;
+ Row * tmprow = firstRow();
y = 0;
// find the first row of the specified paragraph
{
#if 1
// If possible we should optimize this method. (Lgb)
- Row * tmprow = firstrow;
+ Row * tmprow = firstRow();
int tmpy = 0;
while (tmprow->next() && tmpy + tmprow->height() <= y) {