From 0769f8d599211fe5e7ed88dec19b721a3ec3d63a Mon Sep 17 00:00:00 2001 From: John Levon Date: Tue, 2 Sep 2003 17:08:54 +0000 Subject: [PATCH] remove cursor.i[xy] git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7640 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 2 +- src/ChangeLog | 8 ++++++++ src/frontends/ChangeLog | 4 ++++ src/frontends/screen.C | 2 +- src/insets/ChangeLog | 5 +++++ src/insets/insetbibtex.C | 1 + src/insets/insetbranch.C | 1 + src/insets/insetcollapsable.C | 1 - src/insets/insettext.C | 38 +++++++++-------------------------- src/insets/insettext.h | 4 ---- src/lyxcursor.C | 25 +---------------------- src/lyxcursor.h | 25 +---------------------- src/lyxfunc.C | 8 ++++---- src/text2.C | 20 +++--------------- src/text3.C | 18 ++++++++--------- 15 files changed, 49 insertions(+), 113 deletions(-) diff --git a/src/BufferView.C b/src/BufferView.C index 9fe4f9726e..b8ee1de146 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -479,7 +479,7 @@ bool BufferView::lockInset(UpdatableInset * inset) bool BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc) { if (theLockingInset() && available()) { - y += text->cursor.iy() + theLockingInset()->insetInInsetY(); + y += text->cursor.y() + theLockingInset()->insetInInsetY(); if (screen().fitManualCursor(this, text, x, y, asc, desc)) { updateScrollbar(); return true; diff --git a/src/ChangeLog b/src/ChangeLog index b26470d473..407e728a35 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2003-09-02 John Levon + + * BufferView.C: + * lyxcursor.h: + * lyxcursor.C: + * lyxfunc.C: + * lyxfunc.h: remove cursor.i[x]y(), it no longer differs + 2003-09-02 John Levon * text2.C: simplification of cursorEnd(), including partial diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 6d4810f1ef..92267ad80b 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,7 @@ +2003-09-02 John Levon + + * screen.C: remove cursor.i[xy]() + 2003-09-02 Lars Gullik Bjønnes * Alert.C (prompt, warning, error, information, askForText): Make diff --git a/src/frontends/screen.C b/src/frontends/screen.C index 66826c0d18..e86b870597 100644 --- a/src/frontends/screen.C +++ b/src/frontends/screen.C @@ -183,7 +183,7 @@ void LyXScreen::showCursor(BufferView & bv) // Ugly as you like. int bx, by; inset->getCursorPos(&bv, bx, by); - by += inset->insetInInsetY() + bv.text->cursor.iy(); + by += inset->insetInInsetY() + bv.text->cursor.y(); if (by < top_y) return; if (by > top_y + workarea().workHeight()) diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 5bb9bda925..b2cc5f8736 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2003-09-02 John Levon + + * insettext.h: + * insettext.C: remove cursor.i[xy]() + 2003-08-28 Angus Leeming * insetgraphics.C (prepareFile): prepend "convertDefault.sh" with diff --git a/src/insets/insetbibtex.C b/src/insets/insetbibtex.C index 80d2cd832c..64188f9e03 100644 --- a/src/insets/insetbibtex.C +++ b/src/insets/insetbibtex.C @@ -54,6 +54,7 @@ std::auto_ptr InsetBibtex::clone() const return std::auto_ptr(new InsetBibtex(*this)); } + void InsetBibtex::metrics(MetricsInfo & mi, Dimension & dim) const { InsetCommand::metrics(mi, dim); diff --git a/src/insets/insetbranch.C b/src/insets/insetbranch.C index 655d3694c0..a7da67000a 100644 --- a/src/insets/insetbranch.C +++ b/src/insets/insetbranch.C @@ -131,6 +131,7 @@ dispatch_result InsetBranch::localDispatch(FuncRequest const & cmd) case LFUN_INSET_EDIT: if (cmd.button() != mouse_button::button3) return InsetCollapsable::localDispatch(cmd); + return UNDISPATCHED; case LFUN_INSET_DIALOG_UPDATE: InsetBranchMailer("branch", *this).updateDialog(bv); diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 2ea0f2f908..a86ebc3f16 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -243,7 +243,6 @@ void InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd) } bv->updateInset(this); bv->buffer()->markDirty(); - lyxerr << "InsetCollapsable::lfunMouseRelease\n"; } else if (!collapsed_ && cmd.y > button_dim.y2) { ret = inset.localDispatch(adjustCommand(cmd)) == DISPATCHED; } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index eb69bb6640..246280bd1f 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -281,8 +281,8 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const top_y = y - dim_.asc; if (the_locking_inset && cpar() == inset_par && cpos() == inset_pos) { - inset_x = cix() - x + drawTextXOffset; - inset_y = ciy() + drawTextYOffset; + inset_x = cx() - x + drawTextXOffset; + inset_y = cy() + drawTextYOffset; } x += TEXT_TO_INSET_OFFSET; @@ -386,8 +386,8 @@ void InsetText::lockInset(BufferView * bv) void InsetText::lockInset(BufferView * /*bv*/, UpdatableInset * inset) { the_locking_inset = inset; - inset_x = cix() - top_x + drawTextXOffset; - inset_y = ciy() + drawTextYOffset; + inset_x = cx() - top_x + drawTextXOffset; + inset_y = cy() + drawTextYOffset; inset_pos = cpos(); inset_par = cpar(); inset_boundary = cboundary(); @@ -438,8 +438,8 @@ bool InsetText::lockInsetInInset(BufferView * bv, UpdatableInset * inset) if (the_locking_inset && the_locking_inset == inset) { if (cpar() == inset_par && cpos() == inset_pos) { lyxerr[Debug::INSETS] << "OK" << endl; - inset_x = cix() - top_x + drawTextXOffset; - inset_y = ciy() + drawTextYOffset; + inset_x = cx() - top_x + drawTextXOffset; + inset_y = cy() + drawTextYOffset; } else { lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl; } @@ -581,8 +581,8 @@ bool InsetText::lfunMouseRelease(FuncRequest const & cmd) if (isHighlyEditableInset(inset)) ret = inset->localDispatch(cmd1); else { - inset_x = cix(bv) - top_x + drawTextXOffset; - inset_y = ciy() + drawTextYOffset; + inset_x = cx(bv) - top_x + drawTextXOffset; + inset_y = cy() + drawTextYOffset; cmd1.x = cmd.x - inset_x; cmd1.y = cmd.x - inset_y; inset->edit(bv, cmd1.x, cmd1.y, cmd.button()); @@ -1433,8 +1433,8 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y, x = dim_.wid; if (y < 0) y = dim_.des; - inset_x = cix() - top_x + drawTextXOffset; - inset_y = ciy() + drawTextYOffset; + inset_x = cx() - top_x + drawTextXOffset; + inset_y = cy() + drawTextYOffset; FuncRequest cmd(bv, LFUN_INSET_EDIT, x - inset_x, y - inset_y, button); inset->localDispatch(cmd); if (!the_locking_inset) @@ -1501,30 +1501,12 @@ int InsetText::cx() const } -int InsetText::cix() const -{ - int x = text_.cursor.ix() + top_x + TEXT_TO_INSET_OFFSET; - if (the_locking_inset) { - LyXFont font = text_.getFont(text_.cursor.par(), text_.cursor.pos()); - if (font.isVisibleRightToLeft()) - x -= the_locking_inset->width(); - } - return x; -} - - int InsetText::cy() const { return text_.cursor.y() - dim_.asc + TEXT_TO_INSET_OFFSET; } -int InsetText::ciy() const -{ - return text_.cursor.iy() - dim_.asc + TEXT_TO_INSET_OFFSET; -} - - pos_type InsetText::cpos() const { return text_.cursor.pos(); diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 6c8b773dca..fa6477ec6d 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -258,12 +258,8 @@ private: /// int cx() const; /// - int cix() const; - /// int cy() const; /// - int ciy() const; - /// lyx::pos_type cpos() const; /// ParagraphList::iterator cpar() const; diff --git a/src/lyxcursor.C b/src/lyxcursor.C index 742ee85f1b..c7f62cc713 100644 --- a/src/lyxcursor.C +++ b/src/lyxcursor.C @@ -18,7 +18,7 @@ LyXCursor::LyXCursor() : par_(), pos_(0), boundary_(false), - x_(0), ix_(0), x_fix_(0), y_(0), iy_(0) + x_(0), x_fix_(0), y_(0) {} @@ -69,17 +69,6 @@ int LyXCursor::x() const } -void LyXCursor::ix(int n) -{ - ix_ = n; -} - -int LyXCursor::ix() const -{ - return ix_; -} - - void LyXCursor::x_fix(int i) { x_fix_ = i; @@ -104,18 +93,6 @@ int LyXCursor::y() const } -void LyXCursor::iy(int i) -{ - iy_ = i; -} - - -int LyXCursor::iy() const -{ - return iy_; -} - - bool operator==(LyXCursor const & a, LyXCursor const & b) { return a.par() == b.par() diff --git a/src/lyxcursor.h b/src/lyxcursor.h index c9bbb9c532..e75ce1591c 100644 --- a/src/lyxcursor.h +++ b/src/lyxcursor.h @@ -46,16 +46,6 @@ public: void x(int i); /// return the x position in pixels int x() const; - /// set the stored next-line position when at the end of a row - void ix(int i); - /** - * Return the x position of the start of the next row, when this - * cursor is at the end of the previous row, for insets that take - * a full row. - * - * FIXME: explain why we need this ? - */ - int ix() const; /// set the cached x position void x_fix(int i); /** @@ -75,16 +65,7 @@ public: void y(int i); /// return the y position in pixels int y() const; - /// set the stored next-line y position when at the end of a row - void iy(int i); - /** - * Return the y position of the start of the next row, when this - * cursor is at the end of the previous row, for insets that take - * a full row. - * - * FIXME: explain why we need this ? especially for y... - */ - int iy() const; + private: /// The paragraph the cursor is in. ParagraphList::iterator par_; @@ -108,14 +89,10 @@ private: bool boundary_; /// the pixel x position int x_; - /// the stored next-row x position - int ix_; /// the cached x position int x_fix_; /// the pixel y position int y_; - /// the stored next-row y position - int iy_; }; /// diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 8ee9a726b5..9c85a46ec6 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -922,8 +922,8 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) if (irow != view()->text->firstRow()) { #if 1 view()->text->setCursorFromCoordinates( - view()->text->cursor.ix() + inset_x, - view()->text->cursor.iy() - + view()->text->cursor.x() + inset_x, + view()->text->cursor.y() - irow->baseline() - 1); view()->text->cursor.x_fix(view()->text->cursor.x()); #else @@ -940,8 +940,8 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) if (irow != view()->text->lastRow()) { #if 1 view()->text->setCursorFromCoordinates( - view()->text->cursor.ix() + inset_x, - view()->text->cursor.iy() - + view()->text->cursor.x() + inset_x, + view()->text->cursor.y() - irow->baseline() + irow->height() + 1); view()->text->cursor.x_fix(view()->text->cursor.x()); diff --git a/src/text2.C b/src/text2.C index 97fc51aa5b..848aa5b5dd 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1352,18 +1352,12 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit, RowList::iterator row = getRow(pit, pos); int y = row->y(); - RowList::iterator old_row = row; - // if we are before the first char of this row and are still in the - // same paragraph and there is a previous row then put the cursor on - // the end of the previous row - cur.iy(y + row->baseline()); - // y is now the beginning of the cursor row y += row->baseline(); // y is now the cursor baseline cur.y(y); - pos_type last = lastPrintablePos(*pit, old_row); + pos_type last = lastPrintablePos(*pit, row); // None of these should happen, but we're scaredy-cats if (pos > pit->size()) { @@ -1385,11 +1379,6 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit, float x = getCursorX(pit, row, pos, last, boundary); cur.x(int(x)); cur.x_fix(cur.x()); - if (old_row != row) { - x = getCursorX(pit, old_row, pos, last, boundary); - cur.ix(int(x)); - } else - cur.ix(cur.x()); } @@ -1626,9 +1615,6 @@ void LyXText::setCursorFromCoordinates(LyXCursor & cur, int x, int y) cur.x(x); cur.y(y + rit->baseline()); - cur.iy(cur.y()); - cur.ix(cur.x()); - cur.boundary(bound); } @@ -1675,7 +1661,7 @@ void LyXText::cursorUp(bool selecting) setCursorFromCoordinates(x, y); if (!selecting) { int topy = bv_owner->top_y(); - int y1 = cursor.iy() - topy; + int y1 = cursor.y() - topy; int y2 = y1; y -= topy; InsetOld * inset_hit = checkInsetHit(x, y1); @@ -1701,7 +1687,7 @@ void LyXText::cursorDown(bool selecting) setCursorFromCoordinates(x, y); if (!selecting && cursorRow() == cursorIRow()) { int topy = bv_owner->top_y(); - int y1 = cursor.iy() - topy; + int y1 = cursor.y() - topy; int y2 = y1; y -= topy; InsetOld * inset_hit = checkInsetHit(x, y1); diff --git a/src/text3.C b/src/text3.C index 98dd18cc0b..7af209bf59 100644 --- a/src/text3.C +++ b/src/text3.C @@ -116,13 +116,13 @@ namespace { int const width = inset->width(); int const inset_x = font.isVisibleRightToLeft() - ? (cur.ix() - width) : cur.ix(); + ? (cur.x() - width) : cur.x(); Box b( inset_x + inset->scroll(), inset_x + width, - cur.iy() - inset->ascent(), - cur.iy() + inset->descent() + cur.y() - inset->ascent(), + cur.y() + inset->descent() ); if (!b.contained(x, y)) { @@ -136,7 +136,7 @@ namespace { x -= b.x1; // The origin of an inset is on the baseline - y -= text.cursor.iy(); + y -= text.cursor.y(); return inset; } @@ -266,7 +266,7 @@ void LyXText::cursorPrevious() // tall rows, but it's not working right now. } else { if (inset_owner) { - new_y = bv()->text->cursor.iy() + new_y = bv()->text->cursor.y() + bv()->theLockingInset()->insetInInsetY() + y + rit->height() - bv()->workHeight() + 1; @@ -302,7 +302,7 @@ void LyXText::cursorNext() int y = topy + bv_owner->workHeight(); if (inset_owner && !topy) { - y -= (bv_owner->text->cursor.iy() + y -= (bv_owner->text->cursor.y() - bv_owner->top_y() + bv_owner->theLockingInset()->insetInInsetY()); } @@ -327,7 +327,7 @@ void LyXText::cursorNext() #endif } else { if (inset_owner) { - new_y = bv()->text->cursor.iy() + new_y = bv()->text->cursor.y() + bv()->theLockingInset()->insetInInsetY() + y - rit->baseline(); } else { @@ -1214,11 +1214,11 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd) LyXFont font = bv->text->getFont(cursor.par(), cursor.pos()); int width = tli->width(); int inset_x = font.isVisibleRightToLeft() - ? cursor.ix() - width : cursor.ix(); + ? cursor.x() - width : cursor.x(); int start_x = inset_x + tli->scroll(); FuncRequest cmd1 = cmd; cmd1.x = cmd.x - start_x; - cmd1.y = cmd.y - cursor.iy() + bv->top_y(); + cmd1.y = cmd.y - cursor.y() + bv->top_y(); tli->localDispatch(cmd1); break; } -- 2.39.5