# InsetCollapsable context menu
#
Menu "context-collapsable"
- Item "Open Inset|O" "inset-toggle open"
- Item "Close Inset|C" "inset-toggle close"
+ Item "Open Inset|O" "next-inset-toggle open"
+ Item "Close Inset|C" "next-inset-toggle close"
+ Separator
+ OptItem "Settings...|S" "inset-settings"
End
#
case LFUN_BIBTEX_DATABASE_ADD:
case LFUN_BIBTEX_DATABASE_DEL:
case LFUN_STATISTICS:
- case LFUN_NEXT_INSET_TOGGLE:
flag.enabled(true);
break;
+ case LFUN_NEXT_INSET_TOGGLE: {
+ // this is the real function we want to invoke
+ FuncRequest tmpcmd = FuncRequest(LFUN_INSET_TOGGLE, cmd.argument());
+ // if there is an inset at cursor, see whether it
+ // can be modified.
+ Inset * inset = cur.nextInset();
+ if (inset) {
+ inset->getStatus(cur, tmpcmd, flag);
+ return flag;
+ break;
+ }
+ // if it did not work, try the underlying inset.
+ inset = &cur.inset();
+ if (inset) {
+ inset->getStatus(cur, tmpcmd, flag);
+ return flag;
+ break;
+ }
+ // else disable
+ flag.enabled(false);
+ break;
+ }
+
case LFUN_NEXT_INSET_MODIFY: {
// this is the real function we want to invoke
FuncRequest tmpcmd = FuncRequest(LFUN_INSET_MODIFY, cmd.argument());
bool enable = false;
switch (code) {
case TABULAR_CODE:
- enable = cmd.argument() == "tabular";
- break;
case ERT_CODE:
- enable = cmd.argument() == "ert";
- break;
case FLOAT_CODE:
- enable = cmd.argument() == "float";
- break;
case WRAP_CODE:
- enable = cmd.argument() == "wrap";
- break;
case NOTE_CODE:
- enable = cmd.argument() == "note";
- break;
case BRANCH_CODE:
- enable = cmd.argument() == "branch";
- break;
case BOX_CODE:
- enable = cmd.argument() == "box";
- break;
case LISTINGS_CODE:
- enable = cmd.argument() == "listings";
+ enable = (cmd.argument().empty() ||
+ cmd.getArg(0) == insetName(code));
break;
default:
break;
}
}
// if it did not work, try the underlying inset.
- if (!cur.result().dispatched())
- cur.dispatch(tmpcmd);
-
- if (!cur.result().dispatched())
+ else if (&cur.inset())
+ cur.inset().dispatch(cur, tmpcmd);
+ else
// It did not work too; no action needed.
break;
cur.clearSelection();
return InsetText::getStatus(cur, cmd, flag);
case LFUN_INSET_TOGGLE:
- if ((cmd.argument() == "open" && status_ == Open)
- || (cmd.argument() == "close" && status_ != Open)
- || cmd.argument() == "toggle")
+ if ((cmd.argument() == "open" && status_ != Open)
+ || (cmd.argument() == "close" && status_ == Open)
+ || cmd.argument() == "toggle" || cmd.argument().empty())
flag.enabled(true);
else
flag.enabled(false);
Dimension dim = dimensionCollapsed();
if (x < xo(bv) + dim.wid && y < yo(bv) + dim.des)
- //FIXME: We should offer the "context-collapsable" menu here too but
- // this is not possible right now because the cursor must be set first.
- return docstring();
+ return from_ascii("context-collapsable");
return InsetText::contextMenu(bv, x, y);
}