'full redraw' related stuff that's innocent for the upward-selection-in-tables bug.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7285 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-07-15 16:25:02 +00:00
parent b3ed50a4d3
commit cd12251e27
9 changed files with 56 additions and 195 deletions

View File

@ -314,7 +314,7 @@ void LyXScreen::update(BufferView & bv, int yo, int xo)
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);
}

View File

@ -443,9 +443,6 @@ void InsetTabular::update(BufferView * bv, bool reinit)
resetPos(bv);
}
break;
case SELECTION:
need_update = FULL;
break;
default:
break;
}
@ -630,7 +627,7 @@ void InsetTabular::lfunMousePress(FuncRequest const & cmd)
if (hasSelection()) {
clearSelection();
updateLocal(cmd.view(), SELECTION);
updateLocal(cmd.view(), FULL);
}
int const ocell = actcell;
@ -729,10 +726,10 @@ void InsetTabular::lfunMouseMotion(FuncRequest const & cmd)
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);
}
}
@ -821,7 +818,7 @@ Inset::RESULT InsetTabular::localDispatch(FuncRequest const & cmd)
movePrevCell(bv, old_locking_inset != 0);
clearSelection();
if (hs)
updateLocal(bv, SELECTION);
updateLocal(bv, FULL);
if (!the_locking_inset) {
return DISPATCHED_NOUPDATE;
}
@ -880,14 +877,14 @@ Inset::RESULT InsetTabular::localDispatch(FuncRequest const & cmd)
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;
@ -904,14 +901,14 @@ Inset::RESULT InsetTabular::localDispatch(FuncRequest const & cmd)
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;
@ -928,14 +925,14 @@ Inset::RESULT InsetTabular::localDispatch(FuncRequest const & cmd)
} 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: {
@ -953,20 +950,20 @@ Inset::RESULT InsetTabular::localDispatch(FuncRequest const & cmd)
} 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);
@ -987,7 +984,7 @@ Inset::RESULT InsetTabular::localDispatch(FuncRequest const & cmd)
UpdateCodes code = CURSOR;
if (hs) {
clearSelection();
code = SELECTION;
code = FULL;
}
int column = actcol;
unlockInsetInInset(bv, the_locking_inset);
@ -1193,7 +1190,7 @@ Inset::RESULT InsetTabular::localDispatch(FuncRequest const & cmd)
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);

View File

@ -66,7 +66,6 @@ public:
NONE = 0,
CURSOR = 1,
CELL = 2,
SELECTION = 3,
FULL = 4,
INIT = 5
};

View File

@ -490,7 +490,7 @@ void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty)
bv->fitCursor();
if (flag) {
text_.postPaint(0);
text_.postPaint();
bv->updateInset(const_cast<InsetText *>(this));
}

View File

@ -170,11 +170,8 @@ public:
/// 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);
@ -192,14 +189,6 @@ public:
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_;

View File

@ -125,7 +125,7 @@ void LyXText::top_y(int newy)
anchor_row_offset_ = newy - y;
lyxerr[Debug::GUI] << "changing reference to row: " << &*anchor_row_
<< " offset: " << anchor_row_offset_ << endl;
postPaint(0);
postPaint();
}
@ -1518,20 +1518,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
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());
@ -1690,9 +1677,8 @@ void LyXText::insertChar(char c)
// 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);
@ -1728,9 +1714,7 @@ void LyXText::insertChar(char c)
setHeightOfRow(boost::prior(row));
y -= boost::prior(row)->height();
postPaint(y);
postPaint();
breakAgainOneRow(row);
@ -1765,7 +1749,7 @@ void LyXText::insertChar(char c)
}
if (c == Paragraph::META_INSET || row->fill() < 0) {
postPaint(y);
postPaint();
breakAgainOneRow(row);
RowList::iterator next_row = boost::next(row);
@ -1803,12 +1787,7 @@ void LyXText::insertChar(char c)
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;
@ -1820,12 +1799,6 @@ void LyXText::insertChar(char c)
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();
@ -2300,7 +2273,7 @@ void LyXText::changeCase(LyXText::TextCase action)
}
if (getRow(to) != getRow(from))
postPaint(from.y() - getRow(from)->baseline());
postPaint();
}
@ -2384,9 +2357,8 @@ void LyXText::backspace()
// 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;
}
}
@ -2440,7 +2412,7 @@ void LyXText::backspace()
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
@ -2571,8 +2543,7 @@ void LyXText::backspace()
y -= tmprow->height();
tmprow->fill(fill(tmprow, workWidth()));
setHeightOfRow(tmprow);
postPaint(y);
postPaint();
setCursor(cursor.par(), cursor.pos(),
false, cursor.boundary());
@ -2600,7 +2571,7 @@ void LyXText::backspace()
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?
@ -2623,11 +2594,7 @@ void LyXText::backspace()
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());
}
}
@ -2648,12 +2615,6 @@ void LyXText::backspace()
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);
}
}
}

View File

@ -63,8 +63,7 @@ LyXText::LyXText(BufferView * bv)
{
anchor_row_ = rows().end();
need_break_row = rows().end();
clearPaint();
need_refresh_ = true;
}
@ -74,8 +73,7 @@ LyXText::LyXText(BufferView * bv, InsetText * inset)
{
anchor_row_ = rows().end();
need_break_row = rows().end();
clearPaint();
need_refresh_ = true;
}
@ -86,7 +84,7 @@ void LyXText::init(BufferView * bview)
rowlist_.clear();
need_break_row = rows().end();
width = height = 0;
clearPaint();
need_refresh_ = true;
anchor_row_ = rows().end();
anchor_row_offset_ = 0;
@ -613,41 +611,21 @@ void LyXText::setFont(LyXFont const & font, bool toggleall)
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.
@ -655,7 +633,6 @@ void LyXText::redoParagraphs(LyXCursor const & cur,
ParagraphList::iterator endpit)
{
RowList::iterator tmprit = getRow(cur);
int y = cur.y() - tmprit->baseline();
ParagraphList::iterator first_phys_pit;
RowList::iterator prevrit;
@ -673,7 +650,6 @@ void LyXText::redoParagraphs(LyXCursor const & cur,
&& boost::prior(tmprit)->par() == first_phys_pit)
{
--tmprit;
y -= tmprit->height();
}
prevrit = boost::prior(tmprit);
}
@ -697,13 +673,11 @@ void LyXText::redoParagraphs(LyXCursor const & cur,
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);
@ -913,7 +887,6 @@ void LyXText::setParagraph(bool line_top, bool line_bottom,
while (tmppit != boost::prior(selection.start.par())) {
setCursor(tmppit, 0);
postPaint(cursor.y() - cursorRow()->baseline());
ParagraphList::iterator pit = cursor.par();
ParagraphParameters & params = pit->params();
@ -940,6 +913,7 @@ void LyXText::setParagraph(bool line_top, bool line_bottom,
params.noindent(noindent);
tmppit = boost::prior(pit);
}
postPaint();
redoParagraphs(selection.start, endpit);
@ -1446,19 +1420,16 @@ void LyXText::checkParagraph(ParagraphList::iterator pit, pos_type pos)
{
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));
@ -1471,25 +1442,8 @@ void LyXText::checkParagraph(ParagraphList::iterator pit, pos_type pos)
}
}
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
@ -2016,8 +1970,7 @@ void LyXText::cursorDown(bool selecting)
{
#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();
@ -2184,9 +2137,8 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
&& 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
@ -2217,7 +2169,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
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
@ -2284,54 +2236,17 @@ bool LyXText::needRefresh() const
void LyXText::clearPaint()
{
need_refresh_ = false;
refresh_y = 0;
}
void LyXText::postPaint(int start_y)
void LyXText::postPaint()
{
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)
{
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();
}

View File

@ -439,7 +439,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
// we can set the refreshing parameters now
updateCounters();
redoHeightOfParagraph();
postPaint(0);
postPaint();
setCursor(cursor.par(), cursor.pos());
update();
break;
@ -655,7 +655,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
if (!selection.mark())
bv->beforeChange(this);
bv->update(this, BufferView::UPDATE);
cursorUp(bv);
cursorUp(false);
finishChange(bv);
break;
@ -663,7 +663,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
if (!selection.mark())
bv->beforeChange(this);
bv->update(this, BufferView::UPDATE);
cursorDown(bv);
cursorDown(false);
finishChange(bv);
break;

View File

@ -38,7 +38,7 @@ void finishNoUndo(BufferView * bv)
freezeUndo();
bv->unlockInset(bv->theLockingInset());
finishUndo();
bv->text->postPaint(0);
bv->text->postPaint();
unFreezeUndo();
}
@ -153,7 +153,7 @@ bool textHandleUndo(BufferView * bv, Undo & undo)
finishUndo();
bv->text->postPaint(0);
bv->text->postPaint();
lyxerr << "finished textHandleUndo...\n";
return true;