mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 10:18:50 +00:00
Fix bug #5948: Copy as reference for equation labels.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29678 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
831b74c236
commit
3c976db90b
@ -1357,9 +1357,12 @@ bool BufferView::dispatch(FuncRequest const & cmd)
|
||||
// turn compression on/off
|
||||
buffer_.params().compressed = !buffer_.params().compressed;
|
||||
break;
|
||||
|
||||
case LFUN_COPY_LABEL_AS_REF: {
|
||||
// if there is an inset at cursor, try to copy it
|
||||
Inset * inset = cur.nextInset();
|
||||
Inset * inset = &cur.inset();
|
||||
if (!inset || !inset->asInsetMath())
|
||||
inset = cur.nextInset();
|
||||
if (inset) {
|
||||
FuncRequest tmpcmd = cmd;
|
||||
inset->dispatch(cur, tmpcmd);
|
||||
@ -1371,6 +1374,7 @@ bool BufferView::dispatch(FuncRequest const & cmd)
|
||||
processUpdateFlags(Update::SinglePar | Update::FitCursor);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_NEXT_INSET_MODIFY: {
|
||||
// create the the real function we want to invoke
|
||||
FuncRequest tmpcmd = cmd;
|
||||
|
@ -46,6 +46,7 @@
|
||||
|
||||
#include "insets/RenderPreview.h"
|
||||
#include "insets/InsetLabel.h"
|
||||
#include "insets/InsetRef.h"
|
||||
|
||||
#include "graphics/PreviewImage.h"
|
||||
#include "graphics/PreviewLoader.h"
|
||||
@ -1227,6 +1228,15 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_COPY_LABEL_AS_REF: {
|
||||
row_type row = (type_ == hullMultline) ? nrows() - 1 : cur.row();
|
||||
InsetCommandParams p(REF_CODE, "ref");
|
||||
p["reference"] = label(row);
|
||||
cap::clearSelection();
|
||||
cap::copyInset(cur, new InsetRef(*cur.buffer(), p), label(row));
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_WORD_DELETE_FORWARD:
|
||||
case LFUN_CHAR_DELETE_FORWARD:
|
||||
if (col(cur.idx()) + 1 == ncols()
|
||||
@ -1335,12 +1345,14 @@ bool InsetMathHull::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
// we handle these
|
||||
status.setEnabled(true);
|
||||
return true;
|
||||
|
||||
case LFUN_MATH_NUMBER_TOGGLE:
|
||||
// FIXME: what is the right test, this or the one of
|
||||
// LABEL_INSERT?
|
||||
status.setEnabled(display());
|
||||
status.setOnOff(numberedType());
|
||||
return true;
|
||||
|
||||
case LFUN_MATH_NUMBER_LINE_TOGGLE: {
|
||||
// FIXME: what is the right test, this or the one of
|
||||
// LABEL_INSERT?
|
||||
@ -1352,15 +1364,24 @@ bool InsetMathHull::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
status.setOnOff(numbered(r));
|
||||
return true;
|
||||
}
|
||||
|
||||
case LFUN_LABEL_INSERT:
|
||||
status.setEnabled(type_ != hullSimple);
|
||||
return true;
|
||||
|
||||
case LFUN_COPY_LABEL_AS_REF: {
|
||||
row_type const row = (type_ == hullMultline) ? nrows() - 1 : cur.row();
|
||||
status.setEnabled(numberedType() && label_[row] && !nonum_[row]);
|
||||
return true;
|
||||
}
|
||||
|
||||
case LFUN_INSET_INSERT:
|
||||
if (cmd.getArg(0) == "label") {
|
||||
status.setEnabled(type_ != hullSimple);
|
||||
return true;
|
||||
}
|
||||
return InsetMathGrid::getStatus(cur, cmd, status);
|
||||
|
||||
case LFUN_TABULAR_FEATURE: {
|
||||
istringstream is(to_utf8(cmd.argument()));
|
||||
string s;
|
||||
@ -1410,6 +1431,7 @@ bool InsetMathHull::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
}
|
||||
return InsetMathGrid::getStatus(cur, cmd, status);
|
||||
}
|
||||
|
||||
default:
|
||||
return InsetMathGrid::getStatus(cur, cmd, status);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user