From 1a9992c7967460eda189e5eab811e5a0e47f838f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 15 Jul 2005 00:39:44 +0000 Subject: [PATCH] partial fix for bug 622, cosmetic rest remains open git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10195 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 11 +++++------ src/ChangeLog | 6 +++--- src/insets/insetbase.C | 4 ++-- src/insets/insetbase.h | 2 +- src/insets/insetcollapsable.C | 9 ++++----- src/insets/insetcollapsable.h | 2 +- src/insets/insettabular.C | 4 ++-- src/insets/insettabular.h | 2 +- src/insets/insettext.C | 2 +- src/insets/insettext.h | 2 +- src/lyxtext.h | 2 +- src/mathed/ChangeLog | 12 ++++++++---- src/mathed/math_hullinset.C | 10 ++++++++++ src/mathed/math_hullinset.h | 2 ++ src/mathed/math_nestinset.C | 12 ++++++------ src/mathed/math_nestinset.h | 2 +- src/text2.C | 6 +++--- src/text3.C | 3 +-- src/undo.C | 4 ++-- 19 files changed, 55 insertions(+), 42 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 0d2d466a85..d497313e49 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -875,8 +875,7 @@ void BufferView::Pimpl::trackChanges() bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0) { - lyxerr << BOOST_CURRENT_FUNCTION - << "[ cmd0 " << cmd0 << "]" << endl; + //lyxerr << BOOST_CURRENT_FUNCTION << "[ cmd0 " << cmd0 << "]" << endl; // This is only called for mouse related events including // LFUN_FILE_OPEN generated by drag-and-drop. @@ -910,10 +909,10 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0) // Build temporary cursor. cmd.y = min(max(cmd.y,-1), workarea().workHeight()); InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y); - lyxerr << BOOST_CURRENT_FUNCTION - << " * hit inset at tip: " << inset << endl; - lyxerr << BOOST_CURRENT_FUNCTION - << " * created temp cursor:" << cur << endl; + //lyxerr << BOOST_CURRENT_FUNCTION + // << " * hit inset at tip: " << inset << endl; + //lyxerr << BOOST_CURRENT_FUNCTION + // << " * created temp cursor:" << cur << endl; // Put anchor at the same position. cur.resetAnchor(); diff --git a/src/ChangeLog b/src/ChangeLog index eee34cf82e..0a105e0205 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,15 +1,15 @@ -2005-05-07 André Pönitz +2005-07-14 André Pönitz * undo.C (recordUndoFullBuffer): implement undo for textclass switches -2005-05-07 André Pönitz +2005-07-14 André Pönitz * cursor.C (setSelection): open insets when selection is set there to avoid crashs with cold coord cache -2005-05-07 André Pönitz +2005-07-14 André Pönitz * trans_mgr.C (insert): move cursor to the right after inserting a char. diff --git a/src/insets/insetbase.C b/src/insets/insetbase.C index dcbc08fac9..c97ec15af5 100644 --- a/src/insets/insetbase.C +++ b/src/insets/insetbase.C @@ -176,10 +176,10 @@ void InsetBase::edit(LCursor &, bool) } -InsetBase * InsetBase::editXY(LCursor &, int x, int y) const +InsetBase * InsetBase::editXY(LCursor &, int x, int y) { lyxerr << "InsetBase: editXY x:" << x << " y: " << y << std::endl; - return const_cast(this); + return this; } diff --git a/src/insets/insetbase.h b/src/insets/insetbase.h index 52ead30127..8ea7690410 100644 --- a/src/insets/insetbase.h +++ b/src/insets/insetbase.h @@ -106,7 +106,7 @@ public: /// cursor enters virtual void edit(LCursor & cur, bool left); /// cursor enters - virtual InsetBase * editXY(LCursor & cur, int x, int y) const; + virtual InsetBase * editXY(LCursor & cur, int x, int y); /// compute the size of the object returned in dim virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0; diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 7e371e6235..410cd90a58 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -260,13 +260,12 @@ void InsetCollapsable::edit(LCursor & cur, bool left) } -InsetBase * InsetCollapsable::editXY(LCursor & cur, int x, int y) const +InsetBase * InsetCollapsable::editXY(LCursor & cur, int x, int y) { //lyxerr << "InsetCollapsable: edit xy" << endl; - if (status_ == Collapsed) { - return const_cast(this); - } - cur.push(const_cast(*this)); + if (status_ == Collapsed) + return this; + cur.push(*this); return InsetText::editXY(cur, x, y); } diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index a552119eb4..264904902e 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -96,7 +96,7 @@ protected: /// void edit(LCursor & cur, bool left); /// - InsetBase * editXY(LCursor & cur, int x, int y) const; + InsetBase * editXY(LCursor & cur, int x, int y); /// void setInlined() { status_ = Inlined; } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 4ccb70b768..3a9f61bed9 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -1158,11 +1158,11 @@ int InsetTabular::dist(idx_type const cell, int x, int y) const } -InsetBase * InsetTabular::editXY(LCursor & cur, int x, int y) const +InsetBase * InsetTabular::editXY(LCursor & cur, int x, int y) { //lyxerr << "InsetTabular::editXY: " << this << endl; cur.selection() = false; - cur.push(const_cast(*this)); + cur.push(*this); cur.idx() = getNearestCell(x, y); resetPos(cur); return cell(cur.idx())->text_.editXY(cur, x, y); diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 4d73b7859d..206f573f5d 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -130,7 +130,7 @@ public: /// lock cell with given index void edit(LCursor & cur, bool left); /// - InsetBase * editXY(LCursor & cur, int x, int y) const; + InsetBase * editXY(LCursor & cur, int x, int y); /// can we go further down on mouse click? bool descendable() const { return true; } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 0b9f8cad59..0c17b80920 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -288,7 +288,7 @@ void InsetText::edit(LCursor & cur, bool left) } -InsetBase * InsetText::editXY(LCursor & cur, int x, int y) const +InsetBase * InsetText::editXY(LCursor & cur, int x, int y) { old_pit = -1; return text_.editXY(cur, x, y); diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 4d82a7b2c5..ed387ff0f2 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -124,7 +124,7 @@ public: /// void edit(LCursor & cur, bool left); /// - InsetBase * editXY(LCursor & cur, int x, int y) const; + InsetBase * editXY(LCursor & cur, int x, int y); /// number of cells in this inset size_t nargs() const { return 1; } diff --git a/src/lyxtext.h b/src/lyxtext.h index a73826cb8a..882f340571 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -180,7 +180,7 @@ public: /// void setCursorFromCoordinates(LCursor & cur, int x, int y); /// - InsetBase * editXY(LCursor & cur, int x, int y) const; + InsetBase * editXY(LCursor & cur, int x, int y); /// Move cursor one line up. /** * Returns true if an update is needed after the move. diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index d1763faa80..e10d7fa3d6 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,18 +1,22 @@ -2005-07-16 André Pönitz +2005-07-15 Andreas Vox + + * math_hullinset.C (editXY): partial fix for #622 + +2005-07-14 André Pönitz * math_hullinset.C (BREAKLINE): choose between eqnarray and align according to user preference -2005-07-16 André Pönitz +2005-07-14 André Pönitz * math_charinset.C (mathmlize): escape <, >, and & on export -2005-07-16 André Pönitz +2005-07-14 André Pönitz * math_gridinset.C (doDispatch): cur.undispatched on LFUN_ESCAPE -2005-07-16 André Pönitz +2005-07-14 André Pönitz * math_gridinset.C (doDispatch): cur.undispatched on LFUN_NEXT/PRIOR diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index cacf5cdd52..b920084405 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -183,6 +183,16 @@ MathHullInset & MathHullInset::operator=(MathHullInset const & other) } +InsetBase * MathHullInset::editXY(LCursor & cur, int x, int y) +{ + if (RenderPreview::status() == LyXRC::PREVIEW_ON) { + edit(cur, true); + return this; + } + return MathNestInset::editXY(cur, x, y); +} + + MathInset::mode_type MathHullInset::currentMode() const { if (type_ == "none") diff --git a/src/mathed/math_hullinset.h b/src/mathed/math_hullinset.h index d82b845c5b..64bd708820 100644 --- a/src/mathed/math_hullinset.h +++ b/src/mathed/math_hullinset.h @@ -196,6 +196,8 @@ public: /// void edit(LCursor & cur, bool left); /// + InsetBase * editXY(LCursor & cur, int x, int y); + /// bool display() const; /// Code lyxCode() const; diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index 2950fbb59f..90addf0155 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -987,19 +987,19 @@ void MathNestInset::edit(LCursor & cur, bool left) } -InsetBase * MathNestInset::editXY(LCursor & cur, int x, int y) const +InsetBase * MathNestInset::editXY(LCursor & cur, int x, int y) { int idx_min = 0; int dist_min = 1000000; - for (idx_type i = 0; i < nargs(); ++i) { - int d = cell(i).dist(x, y); + for (idx_type i = 0, n = nargs(); i != n; ++i) { + int const d = cell(i).dist(x, y); if (d < dist_min) { dist_min = d; idx_min = i; } } - MathArray const & ar = cell(idx_min); - cur.push(const_cast(*this)); + MathArray & ar = cell(idx_min); + cur.push(*this); cur.idx() = idx_min; cur.pos() = ar.x2pos(x - ar.xo()); lyxerr << "found cell : " << idx_min << " pos: " << cur.pos() << endl; @@ -1009,7 +1009,7 @@ InsetBase * MathNestInset::editXY(LCursor & cur, int x, int y) const if (ar[i]->covers(x, y)) return ar[i].nucleus()->editXY(cur, x, y); } - return const_cast(this); + return this; } diff --git a/src/mathed/math_nestinset.h b/src/mathed/math_nestinset.h index 4e3af6185e..46b6abe332 100644 --- a/src/mathed/math_nestinset.h +++ b/src/mathed/math_nestinset.h @@ -41,7 +41,7 @@ public: /// void edit(LCursor & cur, bool left); /// - InsetBase * editXY(LCursor & cur, int x, int y) const; + InsetBase * editXY(LCursor & cur, int x, int y); /// order of movement through the cells when pressing the left key bool idxLeft(LCursor &) const; diff --git a/src/text2.C b/src/text2.C index f7fbeeaace..8b0460572d 100644 --- a/src/text2.C +++ b/src/text2.C @@ -912,7 +912,7 @@ Row const & LyXText::getRowNearY(int y, pit_type pit) const // x,y are absolute screen coordinates // sets cursor recursively descending into nested editable insets -InsetBase * LyXText::editXY(LCursor & cur, int x, int y) const +InsetBase * LyXText::editXY(LCursor & cur, int x, int y) { pit_type pit = getPitNearY(y); BOOST_ASSERT(pit != -1); @@ -932,7 +932,7 @@ InsetBase * LyXText::editXY(LCursor & cur, int x, int y) const if (!inset) { // Either we deconst editXY or better we move current_font // and real_current_font to LCursor - const_cast(this)->setCurrentFont(cur); + setCurrentFont(cur); return 0; } @@ -946,7 +946,7 @@ InsetBase * LyXText::editXY(LCursor & cur, int x, int y) const --cur.pos(); inset = inset->editXY(cur, x, y); if (cur.top().text() == this) - const_cast(this)->setCurrentFont(cur); + setCurrentFont(cur); return inset; } diff --git a/src/text3.C b/src/text3.C index b8dfda9675..16a2fe645f 100644 --- a/src/text3.C +++ b/src/text3.C @@ -288,7 +288,6 @@ bool LyXText::isRTL(Paragraph const & par) const void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) { lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl; - lyxerr << "*** LyXText::dispatch: cmd: " << cmd << endl; BOOST_ASSERT(cur.text() == this); BufferView * bv = &cur.bv(); @@ -1062,7 +1061,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) // don't set anchor_ bvcur.setCursor(cur); bvcur.selection() = true; - lyxerr << "MOTION: " << bv->cursor() << endl; + //lyxerr << "MOTION: " << bv->cursor() << endl; } } else diff --git a/src/undo.C b/src/undo.C index 4afddcbaf4..cecca1c39e 100644 --- a/src/undo.C +++ b/src/undo.C @@ -65,8 +65,8 @@ void doRecordUndo(Undo::undo_kind kind, undo.cursor = cur; undo.bparams = bparams ; undo.isFullBuffer = isFullBuffer; - lyxerr << "recordUndo: cur: " << cur << endl; - lyxerr << "recordUndo: pos: " << cur.pos() << endl; + //lyxerr << "recordUndo: cur: " << cur << endl; + //lyxerr << "recordUndo: pos: " << cur.pos() << endl; //lyxerr << "recordUndo: cell: " << cell << endl; undo.from = first_pit; undo.end = cell.lastpit() - last_pit; -- 2.39.2