From: Alfredo Braunstein Date: Mon, 2 Feb 2004 11:07:51 +0000 (+0000) Subject: remove lockPath X-Git-Tag: 1.6.10~15548 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=da1f3b8ac93b75cea98091e24d994d21e3811dbc;p=lyx.git remove lockPath git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8380 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView.C b/src/BufferView.C index 3de1d1b603..a04f019931 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -444,6 +444,19 @@ LyXText * BufferView::text() const } +void BufferView::setCursor(ParIterator const & par, + lyx::pos_type pos) +{ + LCursor & cur = cursor(); + cur.reset(); + ParIterator::PosHolder const & positions = par.positions(); + int const last = par.size() - 1; + for (int i = 0; i < last; ++i) + (*positions[i].it)->inset->edit(cur, true); + cur.resetAnchor(); + LyXText * lt = par.text(*buffer()); + lt->setCursor(par.pit(), pos); +} /* @@ -468,7 +481,8 @@ void BufferView::putSelectionAt(PosIterator const & cur, cursor().clearSelection(); LyXText * text = par.text(*buffer()); - par.lockPath(this); + setCursor(par, cur.pos()); + // hack for the chicken and egg problem if (par.inset()) top_y(par.outerPar()->y); diff --git a/src/BufferView.h b/src/BufferView.h index d6beddec1a..fa89ca527c 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -15,6 +15,8 @@ #ifndef BUFFER_VIEW_H #define BUFFER_VIEW_H +#include "support/types.h" + #include #include @@ -32,6 +34,7 @@ class LyXText; class LyXScreen; class LyXView; class Painter; +class ParIterator; class PosIterator; class TeXErrors; class UpdatableInset; @@ -190,6 +193,8 @@ public: /// LyXText * text() const; /// + void setCursor(ParIterator const & par, lyx::pos_type pos); + /// void putSelectionAt(PosIterator const & cur, int length, bool backwards); private: diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 27adc9dcfb..a71644d47b 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -933,8 +933,8 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0) screen().hideCursor(); - // either the inset under the cursor or the surrounding LyXText will - // handle this event. + // either the inset under the cursor or the + // surrounding LyXText will handle this event. // built temporary path to inset LyXText * text = bv_->text(); diff --git a/src/ChangeLog b/src/ChangeLog index 7b5e490f13..83653aae7b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ + +2004-02-02 Alfredo Braunstein + + * iterators.[Ch] (lockPath): remove in favour of... + * BufferView.[Ch] (setCursor): this addition + * BufferView.C (putSelectionAt): adjust + * undo.C (performUndoOrRedo): adjust + * lyxfunc.C (dispatch): adjust + 2004-02-02 Alfredo Braunstein * iterators.C (lockPath): add a missing slice diff --git a/src/iterators.C b/src/iterators.C index 3fcd6cf392..befe0a971c 100644 --- a/src/iterators.C +++ b/src/iterators.C @@ -221,17 +221,6 @@ ParIterator::ParIterator(PosIterator const & pos) } -void ParIterator::lockPath(BufferView * bv) const -{ - LCursor & cur = bv->cursor(); - cur.reset(); - int const last = size() - 1; - for (int i = 0; i < last; ++i) - (*positions_[i].it)->inset->edit(cur, true); - cur.resetAnchor(); -} - - bool operator==(ParIterator const & iter1, ParIterator const & iter2) { return iter1.positions() == iter2.positions(); diff --git a/src/iterators.h b/src/iterators.h index 07c885b8c6..a68f7ff12d 100644 --- a/src/iterators.h +++ b/src/iterators.h @@ -25,7 +25,6 @@ class LyXText; class InsetBase; class Cursor; class Buffer; -class BufferView; class PosIterator; @@ -78,8 +77,6 @@ public: int index() const; /// size_t size() const; - /// - void lockPath(BufferView *) const; typedef std::vector PosHolder; PosHolder const & positions() const diff --git a/src/lyxfunc.C b/src/lyxfunc.C index d079a8970b..a4fe32bcf8 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1164,11 +1164,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose) << " found." << endl; } - par.lockPath(view()); - LyXText * lt = par.text(*view()->buffer()); - // Set the cursor - lt->setCursor(par.pit(), 0); + view()->setCursor(par, 0); + view()->switchKeyMap(); owner->view_state_changed(); diff --git a/src/undo.C b/src/undo.C index 272caf6fa3..939aee4530 100644 --- a/src/undo.C +++ b/src/undo.C @@ -183,8 +183,9 @@ bool performUndoOrRedo(BufferView * bv, Undo const & undo) // rebreak the entire lyxtext buf.text().fullRebreak(); - pit.lockPath(bv); - text->setCursor(undo.cursor_par, undo.cursor_pos); + ParIterator pit2 = num2pit(buf, undo.text); + advance(pit2, undo.cursor_par); + bv->setCursor(pit2, undo.cursor_pos); finishUndo(); return true;