From 5795dddd40fefda11f965d95e0deaaaa023b1e9f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 27 Jun 2003 08:38:41 +0000 Subject: [PATCH] remove LyXCursor::row_ member git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7214 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 4 +- src/ChangeLog | 13 ++++++ src/bufferview_funcs.C | 2 +- src/frontends/ChangeLog | 5 +++ src/frontends/screen.C | 27 ++++++------ src/frontends/screen.h | 5 +-- src/insets/ChangeLog | 5 +++ src/insets/insettext.C | 6 +-- src/lyxcursor.C | 14 +----- src/lyxcursor.h | 6 --- src/lyxfunc.C | 2 +- src/lyxtext.h | 8 ++++ src/rowpainter.C | 4 +- src/text.C | 95 +++++++++++++++++++++++++++-------------- src/text2.C | 52 +++++++++++----------- src/text3.C | 38 ++++++++--------- 16 files changed, 164 insertions(+), 122 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index be1cea275f..b5e6a52038 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -258,7 +258,7 @@ void BufferView::Pimpl::buffer(Buffer * b) } // FIXME: needed when ? - bv_->text->top_y(screen().topCursorVisible(bv_->text->cursor, bv_->text->top_y())); + bv_->text->top_y(screen().topCursorVisible(bv_->text)); // Buffer-dependent dialogs should be updated or // hidden. This should go here because some dialogs (eg ToC) @@ -409,7 +409,7 @@ int BufferView::Pimpl::resizeCurrentBuffer() bv_->theLockingInset(the_locking_inset); } - bv_->text->top_y(screen().topCursorVisible(bv_->text->cursor, bv_->text->top_y())); + bv_->text->top_y(screen().topCursorVisible(bv_->text)); switchKeyMap(); owner_->busy(false); diff --git a/src/ChangeLog b/src/ChangeLog index 6697d026c6..11a0a61570 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,17 @@ +2003-06-27 André Pönitz + + * BufferView_pimpl.C: + * bufferview_funcs.C: + * lyxcursor.C: + * lyxcursor.h: + * lyxfunc.C: + * lyxtext.h: + * rowpainter.C: + * text.C: + * text2.C: + * text3.C: remove LyXCursor::row_ member + 2003-06-26 Alfredo Brauntein * lyx_main.C (LyX): get full path of document loaded on the diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index 4914580145..c1747beb64 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -391,7 +391,7 @@ void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall) if (font.language() != ignore_language || font.number() != LyXFont::IGNORE) { LyXCursor & cursor = text->cursor; - text->computeBidiTables(bv->buffer(), cursor.row()); + text->computeBidiTables(bv->buffer(), text->cursorRow()); if (cursor.boundary() != text->isBoundary(bv->buffer(), *cursor.par(), cursor.pos(), text->real_current_font)) diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 745330c6a0..9d37cd8092 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,8 @@ + +2003-06-27 André Pönitz + + * screen.[Ch]: take care of removed LyXCursor::row_ member + 2003-06-19 Angus Leeming * Dialogs.h: (showTexinfo): diff --git a/src/frontends/screen.C b/src/frontends/screen.C index 14baa80f9c..8fb9f8e644 100644 --- a/src/frontends/screen.C +++ b/src/frontends/screen.C @@ -243,12 +243,14 @@ bool LyXScreen::fitManualCursor(BufferView * bv, LyXText * text, } -unsigned int LyXScreen::topCursorVisible(LyXCursor const & cursor, int top_y) +unsigned int LyXScreen::topCursorVisible(LyXText * text) { - int const vheight = workarea().workHeight(); + LyXCursor const & cursor = text->cursor; + int top_y = text->top_y(); int newtop = top_y; + int const vheight = workarea().workHeight(); - RowList::iterator row = cursor.row(); + RowList::iterator row = text->cursorRow(); #warning SUPER HACK DISABLED (Lgb) #if 0 @@ -263,9 +265,8 @@ unsigned int LyXScreen::topCursorVisible(LyXCursor const & cursor, int top_y) + row->height() - row->baseline() - vheight; } else { - // scroll down - newtop = cursor.y() - - vheight / 2; /* the scroll region must be so big!! */ + // scroll down, the scroll region must be so big!! + newtop = cursor.y() - vheight / 2; } } else if (static_cast((cursor.y()) - row->baseline()) < @@ -289,7 +290,7 @@ unsigned int LyXScreen::topCursorVisible(LyXCursor const & cursor, int top_y) bool LyXScreen::fitCursor(LyXText * text, BufferView * bv) { // Is a change necessary? - int const newtop = topCursorVisible(text->cursor, text->top_y()); + int const newtop = topCursorVisible(text); bool const result = (newtop != text->top_y()); if (result) { draw(text, bv, newtop); @@ -348,13 +349,13 @@ void LyXScreen::toggleSelection(LyXText * text, BufferView * bv, int const bottom = min( max(static_cast(text->selection.end.y() - - text->selection.end.row()->baseline() - + text->selection.end.row()->height()), + - text->getRow(text->selection.end)->baseline() + + text->getRow(text->selection.end)->height()), text->top_y()), static_cast(text->top_y() + workarea().workHeight())); int const top = min( max(static_cast(text->selection.start.y() - - text->selection.start.row()->baseline()), + text->getRow(text->selection.start)->baseline()), text->top_y()), static_cast(text->top_y() + workarea().workHeight())); @@ -381,10 +382,10 @@ void LyXScreen::toggleToggle(LyXText * text, BufferView * bv, return; int const top_tmp = text->toggle_cursor.y() - - text->toggle_cursor.row()->baseline(); + - text->getRow(text->toggle_cursor)->baseline(); int const bottom_tmp = text->toggle_end_cursor.y() - - text->toggle_end_cursor.row()->baseline() - + text->toggle_end_cursor.row()->height(); + - text->getRow(text->toggle_end_cursor)->baseline() + + text->getRow(text->toggle_end_cursor)->height(); int const offset = yo < 0 ? yo : 0; int const bottom = min(max(bottom_tmp, text->top_y()), diff --git a/src/frontends/screen.h b/src/frontends/screen.h index 282dfc4746..fd1b229e3a 100644 --- a/src/frontends/screen.h +++ b/src/frontends/screen.h @@ -65,14 +65,13 @@ public: /** * topCursorVisible - get a new "top" to make the cursor visible - * @param c the cursor - * @param top_y the current y location of the containing region + * in a LyXText * * This helper function calculates a new y co-ordinate for * the top of the containing region such that the cursor contained * within the LyXText is "nicely" visible. */ - virtual unsigned int topCursorVisible(LyXCursor const & c, int top_y); + virtual unsigned int topCursorVisible(LyXText *); /** * fitCursor - fit the cursor onto the work area diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 8a16ff1635..bdf6750571 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ + +2003-06-27 André Pönitz + + * insettext.C: take care of removed LyXCursor::row_ member + 2003-06-21 Alfredo Braunstein * inseterror.[Ch]: removed diff --git a/src/insets/insettext.C b/src/insets/insettext.C index a5ff6909ad..634855a0dc 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -2077,7 +2077,7 @@ bool InsetText::cboundary(BufferView * bv) const RowList::iterator InsetText::crow(BufferView * bv) const { - return getLyXText(bv)->cursor.row(); + return getLyXText(bv)->cursorRow(); } @@ -2213,7 +2213,7 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const inset_y = ciy(bv) + drawTextYOffset; } - t->top_y(bv->screen().topCursorVisible(t->cursor, t->top_y())); + t->top_y(bv->screen().topCursorVisible(t)); if (!owner()) { const_cast(this)->updateLocal(bv, FULL, false); // this will scroll the screen such that the cursor becomes visible @@ -2252,7 +2252,7 @@ void InsetText::reinitLyXText() const inset_x = cix(bv) - top_x + drawTextXOffset; inset_y = ciy(bv) + drawTextYOffset; } - t->top_y(bv->screen().topCursorVisible(t->cursor, t->top_y())); + t->top_y(bv->screen().topCursorVisible(t)); if (!owner()) { const_cast(this)->updateLocal(bv, FULL, false); // this will scroll the screen such that the cursor becomes visible diff --git a/src/lyxcursor.C b/src/lyxcursor.C index 2ec6731cc9..1e16cba9bd 100644 --- a/src/lyxcursor.C +++ b/src/lyxcursor.C @@ -13,7 +13,7 @@ LyXCursor::LyXCursor() : par_(), pos_(0), boundary_(false), - x_(0), ix_(0), x_fix_(0), y_(0), iy_(0), row_(0) + x_(0), ix_(0), x_fix_(0), y_(0), iy_(0) {} @@ -111,18 +111,6 @@ int LyXCursor::iy() const } -void LyXCursor::row(RowList::iterator r) -{ - row_ = r; -} - - -RowList::iterator LyXCursor::row() const -{ - return row_; -} - - void LyXCursor::irow(RowList::iterator r) { irow_ = r; diff --git a/src/lyxcursor.h b/src/lyxcursor.h index 32a2540579..c098d6e472 100644 --- a/src/lyxcursor.h +++ b/src/lyxcursor.h @@ -79,10 +79,6 @@ public: * FIXME: explain why we need this ? especially for y... */ int iy() const; - /// set the row of the paragraph the cursor is in - void row(RowList::iterator r); - /// return the row of the paragraph this cursor is in - RowList::iterator row() const; /// set the stored next row void irow(RowList::iterator r); /** @@ -124,8 +120,6 @@ private: int y_; /// the stored next-row y position int iy_; - /// the containing row - RowList::iterator row_; /// the containing row for the next line RowList::iterator irow_; }; diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 6799685caf..7a2d17d98d 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -948,7 +948,7 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) } goto exit_with_message; case LFUN_DOWN: - if (boost::next(TEXT()->cursor.row()) != TEXT()->rows().end()) + if (boost::next(TEXT()->cursorRow()) != TEXT()->rows().end()) TEXT()->cursorDown(view()); else TEXT()->cursorRight(view()); diff --git a/src/lyxtext.h b/src/lyxtext.h index 6aa0bdc3b1..0f53ba0b90 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -235,7 +235,15 @@ private: /// only the top-level LyXText has this non-zero BufferView * bv_owner; + /// returns a pointer to a specified row. + RowList::iterator + getRow(ParagraphList::iterator pit, lyx::pos_type pos) const; public: + /// returns a pointer cursor row + RowList::iterator getRow(LyXCursor const & cursor) const; + /// convenience + RowList::iterator cursorRow() const; + /** returns a pointer to the row near the specified y-coordinate (relative to the whole text). y is set to the real beginning of this row diff --git a/src/rowpainter.C b/src/rowpainter.C index 718a1f7ac9..500c2293fc 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -314,8 +314,8 @@ void RowPainter::paintSelection() int const endx = text_.selection.end.x(); int const starty = text_.selection.start.y(); int const endy = text_.selection.end.y(); - RowList::iterator startrow = text_.selection.start.row(); - RowList::iterator endrow = text_.selection.end.row(); + RowList::iterator startrow = text_.getRow(text_.selection.start); + RowList::iterator endrow = text_.getRow(text_.selection.end); if (text_.bidi_same_direction) { int x; diff --git a/src/text.C b/src/text.C index ead3e5231d..4396e19894 100644 --- a/src/text.C +++ b/src/text.C @@ -1503,17 +1503,17 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout) // move one row up! // This touches only the screen-update. Otherwise we would may have // an empty row on the screen - if (cursor.pos() && cursor.row()->pos() == cursor.pos() - && !cursor.row()->par()->isNewline(cursor.pos() - 1)) + if (cursor.pos() && cursorRow()->pos() == cursor.pos() + && !cursorRow()->par()->isNewline(cursor.pos() - 1)) { cursorLeft(bv()); } - int y = cursor.y() - cursor.row()->baseline(); + int y = cursor.y() - cursorRow()->baseline(); // Do not forget the special right address boxes if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) { - RowList::iterator r = cursor.row(); + RowList::iterator r = cursorRow(); RowList::iterator beg = rows().begin(); while (r != beg && boost::prior(r)->par() == r->par()) { @@ -1524,12 +1524,12 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout) postPaint(y); - removeParagraph(cursor.row()); + removeParagraph(cursorRow()); // set the dimensions of the cursor row - cursor.row()->fill(fill(cursor.row(), workWidth())); + cursorRow()->fill(fill(cursorRow(), workWidth())); - setHeightOfRow(cursor.row()); + setHeightOfRow(cursorRow()); #warning Trouble Point! (Lgb) // When ::breakParagraph is called from within an inset we must @@ -1540,7 +1540,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout) while (!next_par->empty() && next_par->isNewline(0)) next_par->erase(0); - insertParagraph(next_par, boost::next(cursor.row())); + insertParagraph(next_par, boost::next(cursorRow())); updateCounters(); // This check is necessary. Otherwise the new empty paragraph will @@ -1550,8 +1550,8 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout) else setCursor(cursor.par(), 0); - if (boost::next(cursor.row()) != rows().end()) - breakAgain(boost::next(cursor.row())); + if (boost::next(cursorRow()) != rows().end()) + breakAgain(boost::next(cursorRow())); need_break_row = rows().end(); } @@ -1575,8 +1575,8 @@ void LyXText::insertChar(char c) // When the free-spacing option is set for the current layout, // disable the double-space checking - bool const freeSpacing = cursor.row()->par()->layout()->free_spacing || - cursor.row()->par()->isFreeSpacing(); + bool const freeSpacing = cursorRow()->par()->layout()->free_spacing || + cursorRow()->par()->isFreeSpacing(); if (lyxrc.auto_number) { static string const number_operators = "+-/*"; @@ -1670,17 +1670,17 @@ void LyXText::insertChar(char c) } // the display inset stuff - if (cursor.row()->pos() < cursor.row()->par()->size() - && cursor.row()->par()->isInset(cursor.row()->pos())) { - Inset * inset = cursor.row()->par()->getInset(cursor.row()->pos()); + if (cursorRow()->pos() < cursorRow()->par()->size() + && cursorRow()->par()->isInset(cursorRow()->pos())) { + Inset * inset = cursorRow()->par()->getInset(cursorRow()->pos()); if (inset && (inset->display() || inset->needFullRow())) { // force a new break - cursor.row()->fill(-1); // to force a new break + cursorRow()->fill(-1); // to force a new break } } // get the cursor row fist - RowList::iterator row = cursor.row(); + RowList::iterator row = cursorRow(); int y = cursor.y() - row->baseline(); if (c != Paragraph::META_INSET) { // Here case LyXText::InsertInset already insertet the character @@ -1705,7 +1705,7 @@ void LyXText::insertChar(char c) || cursor.par()->isNewline(cursor.pos()) || ((cursor.pos() + 1 < cursor.par()->size()) && cursor.par()->isInset(cursor.pos() + 1)) - || cursor.row()->fill() == -1)) + || cursorRow()->fill() == -1)) { pos_type z = rowBreakPoint(*boost::prior(row)); @@ -2290,7 +2290,6 @@ void LyXText::deleteWordForward() cursorRight(bv()); else { LyXCursor tmpcursor = cursor; - tmpcursor.row(0); // ?? selection.set(true); // to avoid deletion cursorRightOneWord(); setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos()); @@ -2311,7 +2310,6 @@ void LyXText::deleteWordBackward() cursorLeft(bv()); else { LyXCursor tmpcursor = cursor; - tmpcursor.row(0); // ?? selection.set(true); // to avoid deletion cursorLeftOneWord(); setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos()); @@ -2333,7 +2331,6 @@ void LyXText::deleteLineForward() 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(); setCursor(tmpcursor, tmpcursor.par(), tmpcursor.pos()); @@ -2397,8 +2394,8 @@ void LyXText::changeCase(LyXText::TextCase action) ++pos; } - if (to.row() != from.row()) - postPaint(from.y() - from.row()->baseline()); + if (getRow(to) != getRow(from)) + postPaint(from.y() - getRow(from)->baseline()); } @@ -2480,10 +2477,10 @@ void LyXText::backspace() cursorLeft(bv()); // the layout things can change the height of a row ! - int const tmpheight = cursor.row()->height(); - setHeightOfRow(cursor.row()); - if (cursor.row()->height() != tmpheight) { - postPaint(cursor.y() - cursor.row()->baseline()); + int const tmpheight = cursorRow()->height(); + setHeightOfRow(cursorRow()); + if (cursorRow()->height() != tmpheight) { + postPaint(cursor.y() - cursorRow()->baseline()); } return; } @@ -2496,7 +2493,7 @@ void LyXText::backspace() } ParagraphList::iterator tmppit = cursor.par(); - RowList::iterator tmprow = cursor.row(); + RowList::iterator tmprow = cursorRow(); // We used to do cursorLeftIntern() here, but it is // not a good idea since it triggers the auto-delete @@ -2538,7 +2535,7 @@ void LyXText::backspace() if (cursor.pos()) cursor.pos(cursor.pos() - 1); - postPaint(cursor.y() - cursor.row()->baseline()); + postPaint(cursor.y() - cursorRow()->baseline()); // remove the lost paragraph // This one is not safe, since the paragraph that the tmprow and the @@ -2549,7 +2546,7 @@ void LyXText::backspace() //RemoveRow(tmprow); // This rebuilds the rows. - appendParagraph(cursor.row()); + appendParagraph(cursorRow()); updateCounters(); // the row may have changed, block, hfills etc. @@ -2577,7 +2574,7 @@ void LyXText::backspace() } } - RowList::iterator row = cursor.row(); + RowList::iterator row = cursorRow(); int y = cursor.y() - row->baseline(); pos_type z; // remember that a space at the end of a row doesnt count @@ -2756,6 +2753,42 @@ void LyXText::backspace() } +RowList::iterator LyXText::cursorRow() const +{ + return getRow(cursor.par(), cursor.pos()); +} + + +RowList::iterator LyXText::getRow(LyXCursor const & cur) const +{ + return getRow(cur.par(), cur.pos()); +} + + +RowList::iterator +LyXText::getRow(ParagraphList::iterator pit, pos_type pos) const +{ + if (rows().empty()) + return rowlist_.end(); + + // find the first row of the specified paragraph + RowList::iterator rit = rowlist_.begin(); + RowList::iterator end = rowlist_.end(); + while (boost::next(rit) != end && rit->par() != pit) { + ++rit; + } + + // now find the wanted row + while (rit->pos() < pos + && boost::next(rit) != end + && boost::next(rit)->par() == pit + && boost::next(rit)->pos() <= pos) { + ++rit; + } + + return rit; +} + // returns pointer to a specified row RowList::iterator LyXText::getRow(ParagraphList::iterator pit, pos_type pos, int & y) const diff --git a/src/text2.C b/src/text2.C index 94ce377a9f..4fef3bdb4e 100644 --- a/src/text2.C +++ b/src/text2.C @@ -623,7 +623,7 @@ void LyXText::setFont(LyXFont const & font, bool toggleall) void LyXText::redoHeightOfParagraph() { - RowList::iterator tmprow = cursor.row(); + RowList::iterator tmprow = cursorRow(); int y = cursor.y() - tmprow->baseline(); setHeightOfRow(tmprow); @@ -643,7 +643,7 @@ void LyXText::redoHeightOfParagraph() void LyXText::redoDrawingOfParagraph(LyXCursor const & cur) { - RowList::iterator tmprow = cur.row(); + RowList::iterator tmprow = getRow(cur); int y = cur.y() - tmprow->baseline(); setHeightOfRow(tmprow); @@ -665,7 +665,7 @@ void LyXText::redoDrawingOfParagraph(LyXCursor const & cur) void LyXText::redoParagraphs(LyXCursor const & cur, ParagraphList::iterator endpit) { - RowList::iterator tmprit = cur.row(); + RowList::iterator tmprit = getRow(cur); int y = cur.y() - tmprit->baseline(); ParagraphList::iterator first_phys_pit; @@ -849,7 +849,7 @@ void LyXText::clearSelection() void LyXText::cursorHome() { - setCursor(cursor.par(), cursor.row()->pos()); + setCursor(cursor.par(), cursorRow()->pos()); } @@ -858,7 +858,7 @@ void LyXText::cursorEnd() if (cursor.par()->empty()) return; - RowList::iterator rit = cursor.row(); + RowList::iterator rit = cursorRow(); RowList::iterator next_rit = boost::next(rit); ParagraphList::iterator pit = rit->par(); pos_type last_pos = lastPos(*this, rit); @@ -996,7 +996,7 @@ void LyXText::setParagraph(bool line_top, bool line_bottom, while (tmppit != boost::prior(selection.start.par())) { setCursor(tmppit, 0); - postPaint(cursor.y() - cursor.row()->baseline()); + postPaint(cursor.y() - cursorRow()->baseline()); ParagraphList::iterator pit = cursor.par(); ParagraphParameters & params = pit->params(); @@ -1567,7 +1567,6 @@ void LyXText::checkParagraph(ParagraphList::iterator pit, pos_type pos) // check the special right address boxes if (pit->layout()->margintype == MARGIN_RIGHT_ADDRESS_BOX) { tmpcursor.par(pit); - tmpcursor.row(row); tmpcursor.y(y); tmpcursor.x(0); tmpcursor.x_fix(0); @@ -1670,7 +1669,6 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit, } } - cur.row(row); // y is now the beginning of the cursor row y += row->baseline(); // y is now the cursor baseline @@ -1827,7 +1825,7 @@ void LyXText::setCurrentFont() --pos; else // potentional bug... BUG (Lgb) if (pit->isSeparator(pos)) { - if (pos > cursor.row()->pos() && + if (pos > cursorRow()->pos() && bidi_level(pos) % 2 == bidi_level(pos - 1) % 2) --pos; @@ -1989,7 +1987,7 @@ namespace { */ bool beforeFullRowInset(LyXText & lt, LyXCursor const & cur) { - RowList::iterator row = cur.row(); + RowList::iterator row = lt.getRow(cur); if (boost::next(row) == lt.rows().end()) return false; @@ -2022,7 +2020,6 @@ void LyXText::setCursorFromCoordinates(LyXCursor & cur, int x, int y) cur.pos(row->pos() + column); cur.x(x); cur.y(y + row->baseline()); - cur.row(row); if (beforeFullRowInset(*this, cur)) { pos_type const last = lastPrintablePos(*this, row); @@ -2078,7 +2075,7 @@ void LyXText::cursorUp(bool selecting) { #if 1 int x = cursor.x_fix(); - int y = cursor.y() - cursor.row()->baseline() - 1; + int y = cursor.y() - cursorRow()->baseline() - 1; setCursorFromCoordinates(x, y); if (!selecting) { int topy = top_y(); @@ -2093,7 +2090,7 @@ void LyXText::cursorUp(bool selecting) } #else setCursorFromCoordinates(bv(), cursor.x_fix(), - cursor.y() - cursor.row()->baseline() - 1); + cursor.y() - cursorRow()->baseline() - 1); #endif } @@ -2102,10 +2099,10 @@ void LyXText::cursorDown(bool selecting) { #if 1 int x = cursor.x_fix(); - int y = cursor.y() - cursor.row()->baseline() + - cursor.row()->height() + 1; + int y = cursor.y() - cursorRow()->baseline() + + cursorRow()->height() + 1; setCursorFromCoordinates(x, y); - if (!selecting && cursor.row() == cursor.irow()) { + if (!selecting && cursorRow() == cursor.irow()) { int topy = top_y(); int y1 = cursor.iy() - topy; int y2 = y1; @@ -2118,8 +2115,8 @@ void LyXText::cursorDown(bool selecting) } #else setCursorFromCoordinates(bv(), cursor.x_fix(), - cursor.y() - cursor.row()->baseline() - + cursor.row()->height() + 1); + cursor.y() - cursorRow()->baseline() + + cursorRow()->height() + 1); #endif } @@ -2269,10 +2266,10 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor) selection.cursor.par() == old_cursor.par() && selection.cursor.pos() == old_cursor.pos()); - if (old_cursor.row() != rows().begin()) { + if (getRow(old_cursor) != rows().begin()) { RowList::iterator - prevrow = boost::prior(old_cursor.row()); - const_cast(this)->postPaint(old_cursor.y() - old_cursor.row()->baseline() - prevrow->height()); + prevrow = boost::prior(getRow(old_cursor)); + postPaint(old_cursor.y() - getRow(old_cursor)->baseline() - prevrow->height()); tmpcursor = cursor; cursor = old_cursor; // that undo can restore the right cursor position #warning FIXME. --end() iterator is usable here @@ -2287,7 +2284,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor) cursor = tmpcursor; // delete old row - removeRow(old_cursor.row()); + removeRow(getRow(old_cursor)); // delete old par ownerParagraphs().erase(old_cursor.par()); @@ -2302,9 +2299,8 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor) } setHeightOfRow(prevrow); } else { - RowList::iterator nextrow = boost::next(old_cursor.row()); - const_cast(this)->postPaint( - old_cursor.y() - old_cursor.row()->baseline()); + RowList::iterator nextrow = boost::next(getRow(old_cursor)); + postPaint(old_cursor.y() - getRow(old_cursor)->baseline()); tmpcursor = cursor; cursor = old_cursor; // that undo can restore the right cursor position @@ -2319,7 +2315,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor) cursor = tmpcursor; // delete old row - removeRow(old_cursor.row()); + removeRow(getRow(old_cursor)); // delete old par ownerParagraphs().erase(old_cursor.par()); @@ -2394,7 +2390,7 @@ void LyXText::postPaint(int start_y) // 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->cursor.row(), t->cursor.y() - t->cursor.row()->baseline()); + t->postRowPaint(t->cursorRow(), t->cursor.y() - t->cursorRow()->baseline()); } @@ -2421,7 +2417,7 @@ void LyXText::postRowPaint(RowList::iterator rit, int start_y) // 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->cursor.row(), t->cursor.y() - t->cursor.row()->baseline()); + t->postRowPaint(t->cursorRow(), t->cursor.y() - t->cursorRow()->baseline()); } diff --git a/src/text3.C b/src/text3.C index 8ded18b4d1..c1117c6f95 100644 --- a/src/text3.C +++ b/src/text3.C @@ -243,7 +243,7 @@ void LyXText::cursorPrevious() { int y = top_y(); - if (cursor.row() == rows().begin()) { + if (cursorRow() == rows().begin()) { if (y > 0) { int new_y = bv()->text->top_y() - bv()->workHeight(); bv()->screen().draw(bv()->text, bv(), new_y < 0 ? 0 : new_y); @@ -252,13 +252,13 @@ void LyXText::cursorPrevious() return; } - RowList::iterator cursorrow = cursor.row(); + RowList::iterator cursorrow = cursorRow(); setCursorFromCoordinates(cursor.x_fix(), y); finishUndo(); int new_y; - if (cursorrow == bv()->text->cursor.row()) { + if (cursorrow == bv()->text->cursorRow()) { // we have a row which is taller than the workarea. The // simplest solution is to move to the previous row instead. cursorUp(true); @@ -272,20 +272,20 @@ void LyXText::cursorPrevious() if (inset_owner) { new_y = bv()->text->cursor.iy() + bv()->theLockingInset()->insetInInsetY() + y - + cursor.row()->height() + + cursorRow()->height() - bv()->workHeight() + 1; } else { new_y = cursor.y() - - cursor.row()->baseline() - + cursor.row()->height() + - cursorRow()->baseline() + + cursorRow()->height() - bv()->workHeight() + 1; } } bv()->screen().draw(bv()->text, bv(), new_y < 0 ? 0 : new_y); - if (cursor.row() != rows().begin()) { + if (cursorRow() != rows().begin()) { LyXCursor cur; - setCursor(cur, boost::prior(cursor.row())->par(), - boost::prior(cursor.row())->pos(), false); + setCursor(cur, boost::prior(cursorRow())->par(), + boost::prior(cursorRow())->pos(), false); if (cur.y() > top_y()) { cursorUp(true); } @@ -298,9 +298,9 @@ void LyXText::cursorNext() { int topy = top_y(); - if (boost::next(cursor.row()) == rows().end()) { - int y = cursor.y() - cursor.row()->baseline() + - cursor.row()->height(); + if (boost::next(cursorRow()) == rows().end()) { + int y = cursor.y() - cursorRow()->baseline() + + cursorRow()->height(); if (y > topy + bv()->workHeight()) { bv()->screen().draw(bv()->text, bv(), bv()->text->top_y() + bv()->workHeight()); bv()->updateScrollbar(); @@ -317,13 +317,13 @@ void LyXText::cursorNext() getRowNearY(y); - RowList::iterator cursorrow = cursor.row(); + RowList::iterator cursorrow = cursorRow(); setCursorFromCoordinates(cursor.x_fix(), y); // + bv->workHeight()); finishUndo(); int new_y; - if (cursorrow == bv()->text->cursor.row()) { + if (cursorrow == bv()->text->cursorRow()) { // we have a row which is taller than the workarea. The // simplest solution is to move to the next row instead. cursorDown(true); @@ -337,14 +337,14 @@ void LyXText::cursorNext() if (inset_owner) { new_y = bv()->text->cursor.iy() + bv()->theLockingInset()->insetInInsetY() - + y - cursor.row()->baseline(); + + y - cursorRow()->baseline(); } else { - new_y = cursor.y() - cursor.row()->baseline(); + new_y = cursor.y() - cursorRow()->baseline(); } } bv()->screen().draw(bv()->text, bv(), new_y); - RowList::iterator next_row = boost::next(cursor.row()); + RowList::iterator next_row = boost::next(cursorRow()); if (next_row != rows().end()) { LyXCursor cur; setCursor(cur, next_row->par(), next_row->pos(), false); @@ -1311,7 +1311,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) break; } - RowList::iterator cursorrow = bv->text->cursor.row(); + RowList::iterator cursorrow = bv->text->cursorRow(); bv->text->setCursorFromCoordinates(cmd.x, cmd.y + bv->text->top_y()); #if 0 // sorry for this but I have a strange error that the y value jumps at @@ -1323,7 +1323,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) << bv->text->cursor.y() << endl; #endif // This is to allow jumping over large insets - if (cursorrow == bv->text->cursor.row()) { + if (cursorrow == bv->text->cursorRow()) { if (cmd.y >= bv->workHeight()) bv->text->cursorDown(false); else if (cmd.y < 0) -- 2.39.2