int const vwidth = workarea().workWidth();
int const vheight = workarea().workHeight();
text->updateRowPositions();
- int const y = max(int(text->refresh_y - text->top_y()), 0);
+ int const y = 0;
drawFromTo(text, &bv, y, vheight, yo, xo);
expose(0, y, vwidth, vheight - y);
}
resetPos(bv);
}
break;
- case SELECTION:
- need_update = FULL;
- break;
default:
break;
}
if (hasSelection()) {
clearSelection();
- updateLocal(cmd.view(), SELECTION);
+ updateLocal(cmd.view(), FULL);
}
int const ocell = actcell;
setPos(bv, cmd.x, cmd.y);
if (!hasSelection()) {
setSelection(actcell, actcell);
- updateLocal(bv, SELECTION);
+ updateLocal(bv, FULL);
} else if (old_cell != actcell) {
setSelection(sel_cell_start, actcell);
- updateLocal(bv, SELECTION);
+ updateLocal(bv, FULL);
}
}
movePrevCell(bv, old_locking_inset != 0);
clearSelection();
if (hs)
- updateLocal(bv, SELECTION);
+ updateLocal(bv, FULL);
if (!the_locking_inset) {
return DISPATCHED_NOUPDATE;
}
end = actcell;
}
setSelection(start, end);
- updateLocal(bv, SELECTION);
+ updateLocal(bv, FULL);
break;
}
case LFUN_RIGHT:
result = moveRight(bv);
clearSelection();
if (hs)
- updateLocal(bv, SELECTION);
+ updateLocal(bv, FULL);
break;
case LFUN_LEFTSEL: {
int const start = hasSelection() ? sel_cell_start : actcell;
end = actcell;
}
setSelection(start, end);
- updateLocal(bv, SELECTION);
+ updateLocal(bv, FULL);
break;
}
case LFUN_LEFT:
result = moveLeft(bv);
clearSelection();
if (hs)
- updateLocal(bv, SELECTION);
+ updateLocal(bv, FULL);
break;
case LFUN_DOWNSEL: {
int const start = hasSelection() ? sel_cell_start : actcell;
} else {
setSelection(start, start);
}
- updateLocal(bv, SELECTION);
+ updateLocal(bv, FULL);
}
break;
case LFUN_DOWN:
result = moveDown(bv, old_locking_inset != 0);
clearSelection();
if (hs) {
- updateLocal(bv, SELECTION);
+ updateLocal(bv, FULL);
}
break;
case LFUN_UPSEL: {
} else {
setSelection(start, start);
}
- updateLocal(bv, SELECTION);
+ updateLocal(bv, FULL);
}
break;
case LFUN_UP:
result = moveUp(bv, old_locking_inset != 0);
clearSelection();
if (hs)
- updateLocal(bv, SELECTION);
+ updateLocal(bv, FULL);
break;
case LFUN_NEXT: {
UpdateCodes code = CURSOR;
if (hs) {
clearSelection();
- code = SELECTION;
+ code = FULL;
}
int column = actcol;
unlockInsetInInset(bv, the_locking_inset);
UpdateCodes code = CURSOR;
if (hs) {
clearSelection();
- code = SELECTION;
+ code = FULL;
}
int column = actcol;
unlockInsetInInset(bv, the_locking_inset);
clearSelection();
// so the below CELL is not set because this is higher
// priority and we get a full redraw
- need_update = SELECTION;
+ need_update = FULL;
}
nodraw(false);
updateLocal(bv, CELL);
NONE = 0,
CURSOR = 1,
CELL = 2,
- SELECTION = 3,
FULL = 4,
INIT = 5
};
bv->fitCursor();
if (flag) {
- text_.postPaint(0);
+ text_.postPaint();
bv->updateInset(const_cast<InsetText *>(this));
}
/// clear any pending paints
void clearPaint();
- /// Mark position y as the starting point for a repaint
- void postPaint(int start_y);
-
- /// Mark the given row at position y as needing a repaint.
- void postRowPaint(RowList::iterator rit, int start_y);
+ /// submit repaint request
+ void postPaint();
///
Inset::RESULT dispatch(FuncRequest const & cmd);
bool needRefresh() const;
private:
- /**
- * The pixel y position from which to repaint the screen.
- * The position is absolute along the height of outermost
- * lyxtext (I think). If need_refresh_ is true
- * repaints use this as a starting point (if it's within
- * the viewable portion of the lyxtext).
- */
- int refresh_y;
// do we need a refresh?
bool need_refresh_;
anchor_row_offset_ = newy - y;
lyxerr[Debug::GUI] << "changing reference to row: " << &*anchor_row_
<< " offset: " << anchor_row_offset_ << endl;
- postPaint(0);
+ postPaint();
}
cursorLeft(bv());
}
- int y = cursor.y() - cursorRow()->baseline();
-
- // Do not forget the special right address boxes
- if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
- RowList::iterator r = cursorRow();
- RowList::iterator beg = rows().begin();
-
- while (r != beg && boost::prior(r)->par() == r->par()) {
- --r;
- y -= r->height();
- }
- }
-
- postPaint(y);
+ postPaint();
removeParagraph(cursorRow());
// get the cursor row fist
RowList::iterator row = cursorRow();
- int y = cursor.y() - row->baseline();
if (c != Paragraph::META_INSET) {
- // Here case LyXText::InsertInset already insertet the character
+ // Here case LyXText::InsertInset already inserted the character
cursor.par()->insertChar(cursor.pos(), c);
}
setCharFont(bv()->buffer(), cursor.par(), cursor.pos(), rawtmpfont);
setHeightOfRow(boost::prior(row));
- y -= boost::prior(row)->height();
-
- postPaint(y);
+ postPaint();
breakAgainOneRow(row);
}
if (c == Paragraph::META_INSET || row->fill() < 0) {
- postPaint(y);
+ postPaint();
breakAgainOneRow(row);
RowList::iterator next_row = boost::next(row);
int const tmpheight = row->height();
setHeightOfRow(row);
-
- if (tmpheight == row->height()) {
- postRowPaint(row, y);
- } else {
- postPaint(y);
- }
+ postPaint();
current_font = rawtmpfont;
real_current_font = realtmpfont;
if (cursor.pos() && cursor.pos() == cursor.par()->size()
&& rawparfont != rawtmpfont) {
redoHeightOfParagraph();
- } else {
- // now the special right address boxes
- if (cursor.par()->layout()->margintype
- == MARGIN_RIGHT_ADDRESS_BOX) {
- redoDrawingOfParagraph(cursor);
- }
}
charInserted();
}
if (getRow(to) != getRow(from))
- postPaint(from.y() - getRow(from)->baseline());
+ postPaint();
}
// the layout things can change the height of a row !
int const tmpheight = cursorRow()->height();
setHeightOfRow(cursorRow());
- if (cursorRow()->height() != tmpheight) {
- postPaint(cursor.y() - cursorRow()->baseline());
- }
+ if (cursorRow()->height() != tmpheight)
+ postPaint();
return;
}
}
if (cursor.pos())
cursor.pos(cursor.pos() - 1);
- postPaint(cursor.y() - cursorRow()->baseline());
+ postPaint();
// remove the lost paragraph
// This one is not safe, since the paragraph that the tmprow and the
y -= tmprow->height();
tmprow->fill(fill(tmprow, workWidth()));
setHeightOfRow(tmprow);
-
- postPaint(y);
+ postPaint();
setCursor(cursor.par(), cursor.pos(),
false, cursor.boundary());
if (lastPos(*this, row) == row->par()->size() - 1)
removeRow(boost::next(row));
- postPaint(y);
+ postPaint();
breakAgainOneRow(row);
// will the cursor be in another row now?
row->fill(fill(row, workWidth()));
int const tmpheight = row->height();
setHeightOfRow(row);
- if (tmpheight == row->height()) {
- postRowPaint(row, y);
- } else {
- postPaint(y);
- }
+ postPaint();
setCursor(cursor.par(), cursor.pos(), false, cursor.boundary());
}
}
if (rawparfont !=
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(cursor);
- }
}
}
{
anchor_row_ = rows().end();
need_break_row = rows().end();
-
- clearPaint();
+ need_refresh_ = true;
}
{
anchor_row_ = rows().end();
need_break_row = rows().end();
-
- clearPaint();
+ need_refresh_ = true;
}
rowlist_.clear();
need_break_row = rows().end();
width = height = 0;
- clearPaint();
+ need_refresh_ = true;
anchor_row_ = rows().end();
anchor_row_offset_ = 0;
void LyXText::redoHeightOfParagraph()
{
RowList::iterator tmprow = cursorRow();
- int y = cursor.y() - tmprow->baseline();
setHeightOfRow(tmprow);
while (tmprow != rows().begin()
&& boost::prior(tmprow)->par() == tmprow->par()) {
--tmprow;
- y -= tmprow->height();
setHeightOfRow(tmprow);
}
- postPaint(y);
+ postPaint();
setCursor(cursor.par(), cursor.pos(), false, cursor.boundary());
}
-void LyXText::redoDrawingOfParagraph(LyXCursor const & cur)
-{
- RowList::iterator tmprow = getRow(cur);
-
- int y = cur.y() - tmprow->baseline();
- setHeightOfRow(tmprow);
-
- while (tmprow != rows().begin()
- && boost::prior(tmprow)->par() == tmprow->par()) {
- --tmprow;
- y -= tmprow->height();
- }
-
- postPaint(y);
- setCursor(cur.par(), cur.pos());
-}
-
-
// deletes and inserts again all paragraphs between the cursor
// and the specified par
// This function is needed after SetLayout and SetFont etc.
ParagraphList::iterator endpit)
{
RowList::iterator tmprit = getRow(cur);
- int y = cur.y() - tmprit->baseline();
ParagraphList::iterator first_phys_pit;
RowList::iterator prevrit;
&& boost::prior(tmprit)->par() == first_phys_pit)
{
--tmprit;
- y -= tmprit->height();
}
prevrit = boost::prior(tmprit);
}
if (tmppit == endpit)
break;
}
- if (prevrit != rows().end()) {
+ if (prevrit != rows().end())
setHeightOfRow(prevrit);
- postPaint(y - prevrit->height());
- } else {
+ else
setHeightOfRow(rows().begin());
- postPaint(0);
- }
+ postPaint();
if (tmprit != rows().end())
setHeightOfRow(tmprit);
while (tmppit != boost::prior(selection.start.par())) {
setCursor(tmppit, 0);
- postPaint(cursor.y() - cursorRow()->baseline());
ParagraphList::iterator pit = cursor.par();
ParagraphParameters & params = pit->params();
params.noindent(noindent);
tmppit = boost::prior(pit);
}
+ postPaint();
redoParagraphs(selection.start, endpit);
{
LyXCursor tmpcursor;
- int y = 0;
pos_type z;
- RowList::iterator row = getRow(pit, pos, y);
+ RowList::iterator row = getRow(pit, pos);
RowList::iterator beg = rows().begin();
// is there a break one row above
- if (row != beg
- && boost::prior(row)->par() == row->par()) {
+ if (row != beg && boost::prior(row)->par() == row->par()) {
z = rowBreakPoint(*boost::prior(row));
if (z >= row->pos()) {
// set the dimensions of the row above
- y -= boost::prior(row)->height();
- postPaint(y);
+ postPaint();
breakAgain(boost::prior(row));
}
}
- int const tmpheight = row->height();
- pos_type const tmplast = lastPos(*this, row);
-
breakAgain(row);
- if (row->height() == tmpheight && lastPos(*this, row) == tmplast) {
- postRowPaint(row, y);
- } else {
- postPaint(y);
- }
-
- // check the special right address boxes
- if (pit->layout()->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
- tmpcursor.par(pit);
- tmpcursor.y(y);
- tmpcursor.x(0);
- tmpcursor.x_fix(0);
- tmpcursor.pos(pos);
- redoDrawingOfParagraph(tmpcursor);
- }
+ postPaint();
// set the cursor again. Otherwise dangling pointers are possible
// also set the selection
{
#if 1
int x = cursor.x_fix();
- int y = cursor.y() - cursorRow()->baseline() +
- cursorRow()->height() + 1;
+ int y = cursor.y() - cursorRow()->baseline() + cursorRow()->height() + 1;
setCursorFromCoordinates(x, y);
if (!selecting && cursorRow() == cursor.irow()) {
int topy = top_y();
&& selection.cursor.pos() == old_cursor.pos());
if (getRow(old_cursor) != rows().begin()) {
- RowList::iterator
- prevrow = boost::prior(getRow(old_cursor));
- postPaint(old_cursor.y() - getRow(old_cursor)->baseline() - prevrow->height());
+ RowList::iterator prevrow = boost::prior(getRow(old_cursor));
+ postPaint();
tmpcursor = cursor;
cursor = old_cursor; // that undo can restore the right cursor position
#warning FIXME. --end() iterator is usable here
setHeightOfRow(prevrow);
} else {
RowList::iterator nextrow = boost::next(getRow(old_cursor));
- postPaint(old_cursor.y() - getRow(old_cursor)->baseline());
+ postPaint();
tmpcursor = cursor;
cursor = old_cursor; // that undo can restore the right cursor position
void LyXText::clearPaint()
{
need_refresh_ = false;
- refresh_y = 0;
-}
-
-
-void LyXText::postPaint(int start_y)
-{
- bool old = need_refresh_;
-
- need_refresh_ = true;
-
- if (old && refresh_y < start_y)
- return;
-
- refresh_y = start_y;
-
- if (!inset_owner)
- return;
-
- // We are an inset's lyxtext. Tell the top-level lyxtext
- // it needs to update the row we're in.
- LyXText * t = bv()->text;
- t->postRowPaint(t->cursorRow(), t->cursor.y() - t->cursorRow()->baseline());
}
-// FIXME: we should probably remove this y parameter,
-// make refresh_y be 0, and use row->y etc.
-void LyXText::postRowPaint(RowList::iterator rit, int start_y)
+void LyXText::postPaint()
{
- if (need_refresh_ && refresh_y < start_y) {
- need_refresh_ = true;
- return;
- }
-
- refresh_y = start_y;
-
- if (need_refresh_)
- return;
-
need_refresh_ = true;
- if (!inset_owner)
- return;
-
// We are an inset's lyxtext. Tell the top-level lyxtext
// it needs to update the row we're in.
- LyXText * t = bv()->text;
- t->postRowPaint(t->cursorRow(), t->cursor.y() - t->cursorRow()->baseline());
+ if (inset_owner)
+ bv()->text->postPaint();
}
// we can set the refreshing parameters now
updateCounters();
redoHeightOfParagraph();
- postPaint(0);
+ postPaint();
setCursor(cursor.par(), cursor.pos());
update();
break;
if (!selection.mark())
bv->beforeChange(this);
bv->update(this, BufferView::UPDATE);
- cursorUp(bv);
+ cursorUp(false);
finishChange(bv);
break;
if (!selection.mark())
bv->beforeChange(this);
bv->update(this, BufferView::UPDATE);
- cursorDown(bv);
+ cursorDown(false);
finishChange(bv);
break;
freezeUndo();
bv->unlockInset(bv->theLockingInset());
finishUndo();
- bv->text->postPaint(0);
+ bv->text->postPaint();
unFreezeUndo();
}
finishUndo();
- bv->text->postPaint(0);
+ bv->text->postPaint();
lyxerr << "finished textHandleUndo...\n";
return true;