mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-18 21:45:24 +00:00
* BufferView.cpp (setCursorFromInset): new method, useful to find an inset that is known to be in the document. * LyXFunc.cpp (dispatch): do a proper recordUndo before appplying changes to an inset. The insets are responsible for recording additional undo steps that could be needed. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@26436 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
57cf25edf5
commit
bd6dbedd9c
@ -1270,6 +1270,27 @@ void BufferView::setCursorFromRow(int row)
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::setCursorFromInset(Inset const * inset)
|
||||
{
|
||||
// are we already there?
|
||||
if (cursor().nextInset() == inset)
|
||||
return true;
|
||||
|
||||
// Inset is not at cursor position. Find it in the document.
|
||||
Cursor cur(*this);
|
||||
cur.reset(buffer()->inset());
|
||||
do
|
||||
cur.forwardInset();
|
||||
while (cur && cur.nextInset() != inset);
|
||||
|
||||
if (cur) {
|
||||
setCursor(cur);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void BufferView::gotoLabel(docstring const & label)
|
||||
{
|
||||
for (InsetIterator it = inset_iterator_begin(buffer_->inset()); it; ++it) {
|
||||
|
@ -130,10 +130,14 @@ public:
|
||||
/// set the cursor based on the given TeX source row.
|
||||
void setCursorFromRow(int row);
|
||||
|
||||
/// set cursor to the given inset. Return true if found.
|
||||
bool setCursorFromInset(Inset const *);
|
||||
|
||||
/// center the document view around the cursor.
|
||||
void center();
|
||||
/// scroll document by the given number of lines of default height.
|
||||
void scroll(int lines);
|
||||
|
||||
/// Scroll the view by a number of pixels.
|
||||
void scrollDocView(int pixels);
|
||||
/// Set the cursor position based on the scrollbar one.
|
||||
|
@ -1645,9 +1645,14 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
string const name = cmd.getArg(0);
|
||||
Inset * inset = lyx_view_->getDialogs().getOpenInset(name);
|
||||
if (inset) {
|
||||
FuncRequest fr(LFUN_INSET_MODIFY, argument);
|
||||
// put cursor in front of inset.
|
||||
if (!view()->setCursorFromInset(inset))
|
||||
BOOST_ASSERT(false);
|
||||
recordUndo(view()->cursor());
|
||||
FuncRequest fr(LFUN_INSET_MODIFY, argument);
|
||||
inset->dispatch(view()->cursor(), fr);
|
||||
} else {
|
||||
recordUndo(view()->cursor());
|
||||
FuncRequest fr(LFUN_INSET_INSERT, argument);
|
||||
dispatch(fr);
|
||||
}
|
||||
|
@ -96,6 +96,8 @@ What's new
|
||||
- Empty lines are correctly removed when the cursor moves due to the
|
||||
"cursor follows scrollbar" feature (bug 5065).
|
||||
|
||||
- Fix undo when modifying the parameters of an inset (bug 2040).
|
||||
|
||||
- Fix undo for "text in math mode" (bug 3407).
|
||||
|
||||
- Fix undo for insertion of some math elements (e.g. delimiters)
|
||||
|
Loading…
x
Reference in New Issue
Block a user