break;
}
- case LFUN_COPY_LABEL_AS_REF: {
- row_type row = (type_ == hullMultline) ? nrows() - 1 : cur.row();
+ case LFUN_LABEL_COPY_AS_REF: {
+ row_type row;
+ if (cmd.argument().empty() && &cur.inset() == this)
+ // if there is no argument and we're inside math, we retrieve
+ // the row number from the cursor position.
+ row = (type_ == hullMultline) ? nrows() - 1 : cur.row();
+ else {
+ // if there is an argument, find the corresponding label, else
+ // check whether there is at least one label.
+ for (row = 0; row != nrows(); ++row)
+ if (!nonum_[row] && label_[row]
+ && (cmd.argument().empty() || label(row) == cmd.argument()))
+ break;
+ }
+
+ if (row == nrows())
+ break;
+
InsetCommandParams p(REF_CODE, "ref");
p["reference"] = label(row);
cap::clearSelection();
case LFUN_DOWN:
case LFUN_NEWLINE_INSERT:
case LFUN_MATH_EXTERN:
- case LFUN_MATH_MUTATE:
case LFUN_MATH_DISPLAY:
// we handle these
status.setEnabled(true);
return true;
+ case LFUN_MATH_MUTATE: {
+ HullType ht = hullType(cmd.argument());
+ status.setOnOff(type_ == ht);
+ status.setEnabled(true);
+ return true;
+ }
+
case LFUN_MATH_NUMBER_TOGGLE:
// FIXME: what is the right test, this or the one of
// LABEL_INSERT?
// LABEL_INSERT?
bool const enable = (type_ == hullMultline)
? (nrows() - 1 == cur.row())
- : display() != Inline;
+ : display() != Inline && nrows() > 1;
row_type const r = (type_ == hullMultline) ? nrows() - 1 : cur.row();
status.setEnabled(enable);
- status.setOnOff(numbered(r));
+ status.setOnOff(enable && numbered(r));
return true;
}
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]);
+ case LFUN_LABEL_COPY_AS_REF: {
+ bool enabled = false;
+ row_type row;
+ if (cmd.argument().empty() && &cur.inset() == this) {
+ // if there is no argument and we're inside math, we retrieve
+ // the row number from the cursor position.
+ row = (type_ == hullMultline) ? nrows() - 1 : cur.row();
+ enabled = numberedType() && label_[row] && !nonum_[row];
+ } else {
+ // if there is an argument, find the corresponding label, else
+ // check whether there is at least one label.
+ for (row_type row = 0; row != nrows(); ++row) {
+ if (!nonum_[row] && label_[row] &&
+ (cmd.argument().empty() || label(row) == cmd.argument())) {
+ enabled = true;
+ break;
+ }
+ }
+ }
+ status.setEnabled(enabled);
return true;
}