In a document full of previews, the size of the document changes when mathed insets get replaced by preview snippets. This makes very unconfortable to input (or even follow) text when the changes are being made. The problem is not exclusive to previews, but also to other things that could change size without user interaction. (for instance insertion of latex error boxes).
The attached quick & dirty hack makes lyx respect the position in the document by selecting a fixed text reference. The behaviour is the following: the row where the cursor is remains fixed with respect to the start of the screen. So you don't see on screen "from y pixel coord 1000 from the start of the doc and below", but "from row y and below". In fact pixel coord 1000 and below doesn't have much sense anyway. This is achieved by simply: * rename LyXText::first_y to first_y_ and make it private. * add a first_y() const method that returns first_y with some adjustment * add a set_first_y(int newy) method Putting set_first_y(int newy) to assign first_y_ = newy and first_y() to return first_y_ would reproduce the old behaviour. (In fact, up to here I think it would be a sane change no matter what) What we do in the patch instead is to select a reference row (in set_first_y) and return first_y_ plus the variations of this reference row. The reference row is selected as the cursor row, but I think it would be better to select the first visible row or somethig. Maybe select other types of reference instead of a row (a paragraph?). I would like to know if: * Is there someone interested in this type of behaviour * Is this the right approach for the implementation * Any other though Thanks, Alfredo
? save Index: BufferView_pimpl.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.336 diff -u -p -u -r1.336 BufferView_pimpl.C --- BufferView_pimpl.C 2003/03/04 14:31:02 1.336 +++ BufferView_pimpl.C 2003/03/05 15:06:24 @@ -184,8 +184,7 @@ void BufferView::Pimpl::buffer(Buffer * } // FIXME: needed when ? - bv_->text->first_y = - screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y); + bv_->text->set_first_y(screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y())); // Similarly, buffer-dependent dialogs should be updated or // hidden. This should go here because some dialogs (eg ToC) @@ -322,7 +321,7 @@ int BufferView::Pimpl::resizeCurrentBuff bv_->theLockingInset(the_locking_inset); } - bv_->text->first_y = screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y); + bv_->text->set_first_y(screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y())); switchKeyMap(); owner_->busy(false); @@ -350,10 +349,10 @@ void BufferView::Pimpl::updateScrollbar( LyXText const & t = *bv_->text; - lyxerr[Debug::GUI] << "Updating scrollbar: h " << t.height << ", first_y " - << t.first_y << ", default height " << defaultRowHeight() << endl; + lyxerr[Debug::GUI] << "Updating scrollbar: h " << t.height << ", first_y() " + << t.first_y() << ", default height " << defaultRowHeight() << endl; - workarea().setScrollbarParams(t.height, t.first_y, defaultRowHeight()); + workarea().setScrollbarParams(t.height, t.first_y(), defaultRowHeight()); } @@ -372,8 +371,8 @@ void BufferView::Pimpl::scrollDocView(in LyXText * vbt = bv_->text; int const height = defaultRowHeight(); - int const first = static_cast<int>((bv_->text->first_y + height)); - int const last = static_cast<int>((bv_->text->first_y + workarea().workHeight() - height)); + int const first = static_cast<int>((bv_->text->first_y() + height)); + int const last = static_cast<int>((bv_->text->first_y() + workarea().workHeight() - height)); if (vbt->cursor.y() < first) vbt->setCursorFromCoordinates(bv_, 0, first); @@ -392,7 +391,7 @@ void BufferView::Pimpl::scroll(int lines int const line_height = defaultRowHeight(); // The new absolute coordinate - int new_first_y = t->first_y + lines * line_height; + int new_first_y = t->first_y() + lines * line_height; // Restrict to a valid value new_first_y = std::min(t->height - 4 * line_height, new_first_y); @@ -401,7 +400,7 @@ void BufferView::Pimpl::scroll(int lines scrollDocView(new_first_y); // Update the scrollbar. - workarea().setScrollbarParams(t->height, t->first_y, defaultRowHeight()); + workarea().setScrollbarParams(t->height, t->first_y(), defaultRowHeight()); } @@ -777,14 +776,14 @@ void BufferView::Pimpl::center() } // FIXME: can we do this w/o calling screen directly ? - // This updates first_y but means the fitCursor() call + // This updates first_y() but means the fitCursor() call // from the update(FITCUR) doesn't realise that we might // have moved (e.g. from GOTOPARAGRAPH), so doesn't cause // the scrollbar to be updated as it should, so we have // to do it manually. Any operation that does a center() - // and also might have moved first_y must make sure to call + // and also might have moved first_y() must make sure to call // updateScrollbar() currently. Never mind that this is a - // pretty obfuscated way of updating t->first_y + // pretty obfuscated way of updating t->first_y() screen().draw(t, bv_, new_y); update(t, BufferView::SELECT | BufferView::FITCUR); Index: converter.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/converter.C,v retrieving revision 1.66 diff -u -p -u -r1.66 converter.C --- converter.C 2003/03/03 23:18:58 1.66 +++ converter.C 2003/03/05 15:06:26 @@ -102,11 +102,12 @@ bool operator<(Converter const & a, Conv // and thus turkish locale breaks parsing of tags. int const i = compare_ascii_no_case(a.From->prettyname(), b.From->prettyname()); - if (i == 0) - return compare_ascii_no_case(a.To->prettyname(), b.To->prettyname()) - < 0; - else + if (i == 0) { + return compare_ascii_no_case(a.To->prettyname(), + b.To->prettyname()) < 0; + } else { return i < 0; + } } @@ -270,8 +271,9 @@ bool Converters::convert(Buffer const * Converter const & conv = converterlist_[*cit]; bool dummy = conv.To->dummy() && conv.to != "program"; if (!dummy) - lyxerr[Debug::FILES] << "Converting from " - << conv.from << " to " << conv.to << endl; + lyxerr[Debug::FILES] << "Converting from " + << conv.from << " to " + << conv.to << endl; infile = outfile; outfile = conv.result_dir.empty() ? ChangeExtension(from_file, conv.To->extension()) Index: lyxtext.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxtext.h,v retrieving revision 1.135 diff -u -p -u -r1.135 lyxtext.h --- lyxtext.h 2003/03/04 09:27:27 1.135 +++ lyxtext.h 2003/03/05 15:06:27 @@ -80,7 +80,16 @@ public: mutable LyXFont real_current_font; /// first visible pixel-row is set from LyXScreen!!! // unsigned is wrong here for text-insets! - int first_y; + +private: + int first_y_; + int reference_y_; + Row * reference_row_; +public: + + int first_y() const; + /// + void set_first_y(int newy); /// InsetText * inset_owner; /// Index: text.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/text.C,v retrieving revision 1.294 diff -u -p -u -r1.294 text.C --- text.C 2003/03/03 23:18:58 1.294 +++ text.C 2003/03/05 15:06:31 @@ -58,6 +58,43 @@ extern int const LEFT_MARGIN = PAPER_MAR extern int bibitemMaxWidth(BufferView *, LyXFont const &); +int LyXText::first_y() const +{ + if (reference_row_) { + Row * tmprow = firstrow; + int tmp_y_ = 0; + while (tmprow->next() && tmprow != reference_row_) { + tmp_y_ += tmprow->height(); + tmprow = tmprow->next(); + } + cout << "adjusted first_y_ = " << + first_y_ << " by " << + tmp_y_ - reference_y_ << endl; + return first_y_ + tmp_y_ - reference_y_; + } else { + cout << "non adjusted first_y_ = " << + first_y_ << endl; + return first_y_; + } +} + +void LyXText::set_first_y(int newy) +{ + first_y_ = newy; + cout << "setting first_y = " << newy << endl; + if (reference_row_ != cursor.row()) { + Row * tmprow = firstrow; + reference_y_ = 0; + reference_row_ = cursor.row(); + while (tmprow->next() && tmprow != reference_row_) { + reference_y_ += tmprow->height(); + tmprow = tmprow->next(); + } + cout << "changing reference row with baseline" + << reference_y_ << endl; + } +} + int LyXText::workWidth(BufferView & bview) const { if (inset_owner) { Index: text2.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/text2.C,v retrieving revision 1.279 diff -u -p -u -r1.279 text2.C --- text2.C 2003/03/03 23:18:59 1.279 +++ text2.C 2003/03/05 15:06:34 @@ -52,7 +52,7 @@ using lyx::pos_type; LyXText::LyXText(BufferView * bv) - : height(0), width(0), first_y(0), + : height(0), width(0), first_y_(0), reference_y_(0), reference_row_(0), inset_owner(0), the_locking_inset(0), need_break_row(0), refresh_y(0), refresh_row(0), bv_owner(bv), status_(LyXText::UNCHANGED), firstrow(0), lastrow(0) @@ -60,7 +60,7 @@ LyXText::LyXText(BufferView * bv) LyXText::LyXText(InsetText * inset) - : height(0), width(0), first_y(0), + : height(0), width(0), first_y_(0), reference_y_(0), reference_row_(0), inset_owner(inset), the_locking_inset(0), need_break_row(0), refresh_y(0), refresh_row(0), bv_owner(0), status_(LyXText::UNCHANGED), firstrow(0), lastrow(0) @@ -83,7 +83,7 @@ void LyXText::init(BufferView * bview, b need_break_row = 0; width = height = 0; copylayouttype.erase(); - first_y = refresh_y = 0; + set_first_y(refresh_y = 0); status_ = LyXText::UNCHANGED; } else if (firstrow) return; @@ -2034,9 +2034,9 @@ void LyXText::cursorUp(BufferView * bvie int y = cursor.y() - cursor.row()->baseline() - 1; setCursorFromCoordinates(bview, x, y); if (!selecting) { - int y1 = cursor.iy() - first_y; + int y1 = cursor.iy() - first_y(); int y2 = y1; - y -= first_y; + y -= first_y(); Inset * inset_hit = checkInsetHit(bview, x, y1); if (inset_hit && isHighlyEditableInset(inset_hit)) { inset_hit->edit(bview, x, y - (y2 - y1), mouse_button::none); @@ -2057,9 +2057,9 @@ void LyXText::cursorDown(BufferView * bv cursor.row()->height() + 1; setCursorFromCoordinates(bview, x, y); if (!selecting && cursor.row() == cursor.irow()) { - int y1 = cursor.iy() - first_y; + int y1 = cursor.iy() - first_y(); int y2 = y1; - y -= first_y; + y -= first_y(); Inset * inset_hit = checkInsetHit(bview, x, y1); if (inset_hit && isHighlyEditableInset(inset_hit)) { inset_hit->edit(bview, x, y - (y2 - y1), mouse_button::none); Index: text3.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/text3.C,v retrieving revision 1.37 diff -u -p -u -r1.37 text3.C --- text3.C 2003/03/03 23:19:01 1.37 +++ text3.C 2003/03/05 15:06:36 @@ -143,7 +143,7 @@ namespace { Inset * LyXText::checkInsetHit(BufferView * bv, int & x, int & y) const { - int y_tmp = y + first_y; + int y_tmp = y + first_y(); LyXCursor cur; setCursorFromCoordinates(bv, cur, x, y_tmp); @@ -241,15 +241,15 @@ void LyXText::gotoInset(BufferView * bv, void LyXText::cursorPrevious(BufferView * bv) { if (!cursor.row()->previous()) { - if (first_y > 0) { - int new_y = bv->text->first_y - bv->workHeight(); + if (first_y() > 0) { + int new_y = bv->text->first_y() - bv->workHeight(); bv->screen().draw(bv->text, bv, new_y < 0 ? 0 : new_y); bv->updateScrollbar(); } return; } - int y = first_y; + int y = first_y(); Row * cursorrow = cursor.row(); setCursorFromCoordinates(bv, cursor.x_fix(), y); @@ -264,7 +264,7 @@ void LyXText::cursorPrevious(BufferView // This is what we used to do, so we wouldn't skip right past // tall rows, but it's not working right now. #if 0 - new_y = bv->text->first_y - bv->workHeight(); + new_y = bv->text->first_y() - bv->workHeight(); #endif } else { if (inset_owner) { @@ -284,7 +284,7 @@ void LyXText::cursorPrevious(BufferView LyXCursor cur; setCursor(bv, cur, cursor.row()->previous()->par(), cursor.row()->previous()->pos(), false); - if (cur.y() > first_y) { + if (cur.y() > first_y()) { cursorUp(bv, true); } } @@ -297,18 +297,18 @@ void LyXText::cursorNext(BufferView * bv if (!cursor.row()->next()) { int y = cursor.y() - cursor.row()->baseline() + cursor.row()->height(); - if (y > int(first_y + bv->workHeight())) { + if (y > int(first_y() + bv->workHeight())) { bv->screen().draw(bv->text, bv, - bv->text->first_y + bv->workHeight()); + bv->text->first_y() + bv->workHeight()); bv->updateScrollbar(); } return; } - int y = first_y + bv->workHeight(); - if (inset_owner && !first_y) { + int y = first_y() + bv->workHeight(); + if (inset_owner && !first_y()) { y -= (bv->text->cursor.iy() - - bv->text->first_y + - bv->text->first_y() + bv->theLockingInset()->insetInInsetY()); } @@ -328,7 +328,7 @@ void LyXText::cursorNext(BufferView * bv // This is what we used to do, so we wouldn't skip right past // tall rows, but it's not working right now. #if 0 - new_y = bv->text->first_y + bv->workHeight(); + new_y = bv->text->first_y() + bv->workHeight(); #endif } else { if (inset_owner) { @@ -344,7 +344,7 @@ void LyXText::cursorNext(BufferView * bv LyXCursor cur; setCursor(bv, cur, cursor.row()->next()->par(), cursor.row()->next()->pos(), false); - if (cur.y() < int(first_y + bv->workHeight())) { + if (cur.y() < int(first_y() + bv->workHeight())) { cursorDown(bv, true); } } @@ -1298,7 +1298,7 @@ Inset::RESULT LyXText::dispatch(FuncRequ int start_x = inset_x + tli->scroll(); FuncRequest cmd1 = cmd; cmd1.x = cmd.x - start_x; - cmd1.y = cmd.y - cursor.iy() + bv->text->first_y; + cmd1.y = cmd.y - cursor.iy() + bv->text->first_y(); tli->localDispatch(cmd1); break; } @@ -1315,7 +1315,7 @@ Inset::RESULT LyXText::dispatch(FuncRequ bv->screen().hideCursor(); Row * cursorrow = bv->text->cursor.row(); - bv->text->setCursorFromCoordinates(bv, cmd.x, cmd.y + bv->text->first_y); + bv->text->setCursorFromCoordinates(bv, cmd.x, cmd.y + bv->text->first_y()); #if 0 // sorry for this but I have a strange error that the y value jumps at // a certain point. This seems like an error in my xforms library or @@ -1376,7 +1376,7 @@ Inset::RESULT LyXText::dispatch(FuncRequ paste_internally = true; } - int const screen_first = bv->text->first_y; + int const screen_first = bv->text->first_y(); if (bv->theLockingInset()) { // We are in inset locking mode Index: frontends/screen.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/screen.C,v retrieving revision 1.30 diff -u -p -u -r1.30 screen.C --- frontends/screen.C 2003/02/27 09:39:24 1.30 +++ frontends/screen.C 2003/03/05 15:06:37 @@ -160,20 +160,20 @@ bool LyXScreen::fitManualCursor(BufferVi int /*x*/, int y, int asc, int desc) { int const vheight = workarea().workHeight(); - int newtop = text->first_y; + int newtop = text->first_y(); - if (y + desc - text->first_y >= vheight) + if (y + desc - text->first_y() >= vheight) newtop = y - 3 * vheight / 4; // the scroll region must be so big!! - else if (y - asc < text->first_y - && text->first_y > 0) { + else if (y - asc < text->first_y() + && text->first_y() > 0) { newtop = y - vheight / 4; } newtop = max(newtop, 0); // can newtop ever be < 0? (Lgb) - if (newtop != text->first_y) { + if (newtop != text->first_y()) { draw(text, bv, newtop); - text->first_y = newtop; + text->set_first_y(newtop); return true; } @@ -234,8 +234,8 @@ unsigned int LyXScreen::topCursorVisible bool LyXScreen::fitCursor(LyXText * text, BufferView * bv) { // Is a change necessary? - int const newtop = topCursorVisible(text->cursor, text->first_y); - bool const result = (newtop != text->first_y); + int const newtop = topCursorVisible(text->cursor, text->first_y()); + bool const result = (newtop != text->first_y()); if (result) { draw(text, bv, newtop); } @@ -255,7 +255,7 @@ void LyXScreen::update(LyXText * text, B switch (text->status()) { case LyXText::NEED_MORE_REFRESH: { - int const y = max(int(text->refresh_y - text->first_y), 0); + int const y = max(int(text->refresh_y - text->first_y()), 0); drawFromTo(text, bv, y, vheight, yo, xo); text->refresh_y = 0; // otherwise this is called ONLY from BufferView_pimpl(update) @@ -277,7 +277,7 @@ void LyXScreen::update(LyXText * text, B // or we should see to set this flag accordingly if (text != bv->text) text->status(bv, LyXText::UNCHANGED); - expose(0, text->refresh_y - text->first_y + yo, + expose(0, text->refresh_y - text->first_y() + yo, vwidth, text->refresh_row->height()); } } @@ -303,24 +303,24 @@ void LyXScreen::toggleSelection(LyXText max(static_cast<int>(text->selection.end.y() - text->selection.end.row()->baseline() + text->selection.end.row()->height()), - text->first_y), - static_cast<int>(text->first_y + workarea().workHeight())); + text->first_y()), + static_cast<int>(text->first_y() + workarea().workHeight())); int const top = min( max(static_cast<int>(text->selection.start.y() - text->selection.start.row()->baseline()), - text->first_y), - static_cast<int>(text->first_y + workarea().workHeight())); + text->first_y()), + static_cast<int>(text->first_y() + workarea().workHeight())); if (kill_selection) text->selection.set(false); workarea().getPainter().start(); - drawFromTo(text, bv, top - text->first_y, bottom - text->first_y, + drawFromTo(text, bv, top - text->first_y(), bottom - text->first_y(), yo, xo); - expose(0, top - text->first_y, + expose(0, top - text->first_y(), workarea().workWidth(), - bottom - text->first_y - (top - text->first_y)); + bottom - text->first_y() - (top - text->first_y())); workarea().getPainter().end(); } @@ -340,18 +340,18 @@ void LyXScreen::toggleToggle(LyXText * t + text->toggle_end_cursor.row()->height(); int const offset = yo < 0 ? yo : 0; - int const bottom = min(max(bottom_tmp, text->first_y), - static_cast<int>(text->first_y + workarea().workHeight())) - offset; - int const top = min(max(top_tmp, text->first_y), - static_cast<int>(text->first_y + workarea().workHeight())) - offset; + int const bottom = min(max(bottom_tmp, text->first_y()), + static_cast<int>(text->first_y() + workarea().workHeight())) - offset; + int const top = min(max(top_tmp, text->first_y()), + static_cast<int>(text->first_y() + workarea().workHeight())) - offset; workarea().getPainter().start(); - drawFromTo(text, bv, top - text->first_y, - bottom - text->first_y, yo, + drawFromTo(text, bv, top - text->first_y(), + bottom - text->first_y(), yo, xo); - expose(0, top - text->first_y, workarea().workWidth(), - bottom - text->first_y - (top - text->first_y)); + expose(0, top - text->first_y(), workarea().workWidth(), + bottom - text->first_y() - (top - text->first_y())); workarea().getPainter().end(); } @@ -366,6 +366,8 @@ void LyXScreen::redraw(LyXText * text, B return; } + + workarea().getPainter().start(); drawFromTo(text, bv, 0, workarea().workHeight(), 0, 0, text == bv->text); @@ -423,22 +425,24 @@ void LyXScreen::drawFromTo(LyXText * tex { lyxerr[Debug::GUI] << "screen: drawFromTo " << y1 << '-' << y2 << endl; - int y_text = text->first_y + y1; + int y_text = text->first_y() + y1; // get the first needed row Row * row = text->getRowNearY(y_text); // y_text is now the real beginning of the row - int y = y_text - text->first_y; + int y = y_text - text->first_y(); // y1 is now the real beginning of row on the screen + while (row != 0 && y < y2) { LyXText::text_status st = text->status(); // we need this here as the row pointer may be illegal // at a later time (Jug20020502) Row * prev = row->previous(); RowPainter rp(*bv, *text, *row); - if (rp.paint(y + yo, xo, y + text->first_y)) + + if (rp.paint(y + yo, xo, y + text->first_y())) text->markChangeInDraw(bv, row, prev); internal = internal && (st != LyXText::CHANGED_IN_DRAW); @@ -449,7 +453,7 @@ void LyXScreen::drawFromTo(LyXText * tex text->status(bv, st); Row * prev = row->previous(); RowPainter rp(*bv, *text, *row); - if (rp.paint(y + yo, xo, y + text->first_y)) + if (rp.paint(y + yo, xo, y + text->first_y())) text->markChangeInDraw(bv, row, prev); } y += row->height(); @@ -469,13 +473,13 @@ void LyXScreen::drawFromTo(LyXText * tex void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row, int y_text, int yo, int xo) { - int const y = y_text - text->first_y + yo; + int const y = y_text - text->first_y() + yo; if (((y + row->height()) > 0) && ((y - row->height()) <= static_cast<int>(workarea().workHeight()))) { Row * prev = row->previous(); RowPainter rp(*bv, *text, *row); - if (rp.paint(y, xo, y + text->first_y)) + if (rp.paint(y, xo, y + text->first_y())) text->markChangeInDraw(bv, row, prev); } force_clear_ = false; Index: frontends/qt2/qscreen.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/qscreen.C,v retrieving revision 1.13 diff -u -p -u -r1.13 qscreen.C --- frontends/qt2/qscreen.C 2003/02/13 16:52:54 1.13 +++ frontends/qt2/qscreen.C 2003/03/05 15:06:38 @@ -58,8 +58,8 @@ void QScreen::showManualCursor(LyXText c if (!qApp->focusWidget()) return; - int const y1 = max(y - text->first_y - asc, 0); - int const y_tmp = min(y - text->first_y + desc, owner_.height()); + int const y1 = max(y - text->first_y() - asc, 0); + int const y_tmp = min(y - text->first_y() + desc, owner_.height()); // secure against very strange situations // which would be when .... ? @@ -160,9 +160,9 @@ void QScreen::draw(LyXText * text, Buffe if (cursor_visible_) hideCursor(); - int const old_first = text->first_y; + int const old_first = text->first_y(); bool const internal = (text == bv->text); - text->first_y = y; + text->set_first_y(y); // If you want to fix the warning below, fix it so it // actually scrolls properly. Hint: a cast won't do. @@ -170,13 +170,13 @@ void QScreen::draw(LyXText * text, Buffe // is any optimization possible? if (y - old_first < owner_.workHeight() && old_first - y < owner_.workHeight()) { - if (text->first_y < old_first) { - int const dest_y = old_first - text->first_y; + if (text->first_y() < old_first) { + int const dest_y = old_first - text->first_y(); drawFromTo(text, bv, 0, dest_y, 0, 0, internal); copyInPixmap(p, dest_y, 0, owner_.workWidth(), owner_.height() - dest_y); expose(0, 0, owner_.workWidth(), dest_y); } else { - int const src_y = text->first_y - old_first; + int const src_y = text->first_y() - old_first; drawFromTo(text, bv, owner_.height() - src_y, owner_.height(), 0, 0, internal); copyInPixmap(p, 0, 0, owner_.workWidth(), owner_.height() - src_y); expose(0, owner_.height() - src_y, owner_.workWidth(), src_y); Index: insets/insettabular.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/insettabular.C,v retrieving revision 1.241 diff -u -p -u -r1.241 insettabular.C --- insets/insettabular.C 2003/03/03 23:19:01 1.241 +++ insets/insettabular.C 2003/03/05 15:06:43 @@ -1080,10 +1080,10 @@ Inset::RESULT InsetTabular::localDispatc } int column = actcol; unlockInsetInInset(bv, the_locking_inset); - if (bv->text->first_y + bv->painter().paperHeight() < + if (bv->text->first_y() + bv->painter().paperHeight() < (top_baseline + tabular->GetHeightOfTabular())) { - bv->scrollDocView(bv->text->first_y + bv->painter().paperHeight()); + bv->scrollDocView(bv->text->first_y() + bv->painter().paperHeight()); code = FULL; actcell = tabular->GetCellBelow(first_visible_cell) + column; } else { @@ -1102,7 +1102,7 @@ Inset::RESULT InsetTabular::localDispatc int column = actcol; unlockInsetInInset(bv, the_locking_inset); if (top_baseline < 0) { - bv->scrollDocView(bv->text->first_y - bv->painter().paperHeight()); + bv->scrollDocView(bv->text->first_y() - bv->painter().paperHeight()); code = FULL; if (top_baseline > 0) actcell = column; @@ -1495,9 +1495,9 @@ void InsetTabular::hideInsetCursor(Buffe void InsetTabular::fitInsetCursor(BufferView * bv) const { if (the_locking_inset) { - int old_first_y = bv->text->first_y; + int old_first_y = bv->text->first_y(); the_locking_inset->fitInsetCursor(bv); - if (old_first_y != bv->text->first_y) + if (old_first_y != bv->text->first_y()) need_update = FULL; return; } Index: insets/insettext.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/insettext.C,v retrieving revision 1.347 diff -u -p -u -r1.347 insettext.C --- insets/insettext.C 2003/03/03 23:19:01 1.347 +++ insets/insettext.C 2003/03/05 15:06:47 @@ -458,11 +458,11 @@ void InsetText::draw(BufferView * bv, Ly row = row->next(); } if (y_offset < 0) { - lt->first_y = -y_offset; + lt->set_first_y(-y_offset); first = y; y_offset = 0; } else { - lt->first_y = first; + lt->set_first_y(first); first = 0; } if (cleared || (need_update&(INIT|FULL))) { @@ -471,7 +471,7 @@ void InsetText::draw(BufferView * bv, Ly while ((row != 0) && (yf < ph)) { Row * prev = row->previous(); RowPainter rp(*bv, *lt, *row); - if (rp.paint(y + y_offset + first, int(x), y + lt->first_y, cleared)) + if (rp.paint(y + y_offset + first, int(x), y + lt->first_y(), cleared)) lt->markChangeInDraw(bv, row, prev); if (bv->text->status() == LyXText::CHANGED_IN_DRAW) { lt->need_break_row = row; @@ -1020,7 +1020,7 @@ void InsetText::lfunMousePress(FuncReque lockInset(bv); int tmp_x = cmd.x - drawTextXOffset; - int tmp_y = cmd.y + insetAscent - getLyXText(bv)->first_y; + int tmp_y = cmd.y + insetAscent - getLyXText(bv)->first_y(); Inset * inset = getLyXText(bv)->checkInsetHit(bv, tmp_x, tmp_y); hideInsetCursor(bv); @@ -1075,7 +1075,7 @@ void InsetText::lfunMousePress(FuncReque lt = getLyXText(bv); clear = true; } - int old_first_y = lt->first_y; + int old_first_y = lt->first_y(); lt->setCursorFromCoordinates(bv, cmd.x - drawTextXOffset, cmd.y + insetAscent); @@ -1098,7 +1098,7 @@ void InsetText::lfunMousePress(FuncReque bv->owner()->setLayout(cpar(bv)->layout()->name()); // we moved the view we cannot do mouse selection in this case! - if (getLyXText(bv)->first_y != old_first_y) + if (getLyXText(bv)->first_y() != old_first_y) no_selection = true; old_par = cpar(bv); // Insert primary selection with middle mouse @@ -1129,7 +1129,7 @@ bool InsetText::lfunMouseRelease(FuncReq return the_locking_inset->localDispatch(cmd1); int tmp_x = cmd.x - drawTextXOffset; - int tmp_y = cmd.y + insetAscent - getLyXText(bv)->first_y; + int tmp_y = cmd.y + insetAscent - getLyXText(bv)->first_y(); Inset * inset = getLyXText(bv)->checkInsetHit(bv, tmp_x, tmp_y); bool ret = false; if (inset) { @@ -2386,7 +2386,7 @@ void InsetText::resizeLyXText(BufferView inset_y = ciy(bv) + drawTextYOffset; } - t->first_y = bv->screen().topCursorVisible(t->cursor, t->first_y); + t->set_first_y(bv->screen().topCursorVisible(t->cursor, t->first_y())); if (!owner()) { updateLocal(bv, FULL, false); // this will scroll the screen such that the cursor becomes visible @@ -2425,7 +2425,7 @@ void InsetText::reinitLyXText() const inset_x = cix(bv) - top_x + drawTextXOffset; inset_y = ciy(bv) + drawTextYOffset; } - t->first_y = bv->screen().topCursorVisible(t->cursor, t->first_y); + t->set_first_y(bv->screen().topCursorVisible(t->cursor, t->first_y())); if (!owner()) { updateLocal(bv, FULL, false); // this will scroll the screen such that the cursor becomes visible