mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
fix the general collapsable context-menu:
* src/InsetCollapsable.cpp (getStatus): - fix the logic * src/BufferView.cpp: - fix next-inset-toggle - don't require argument for inset-settings * lib/stdmenus.inc (context-collapsable): - use next-inset-toggle instead of inset-toggle - add (optional) inset-settings git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23928 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
56a974ac55
commit
241a8442d7
@ -572,8 +572,10 @@ Menuset
|
||||
# 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
|
||||
|
||||
#
|
||||
|
@ -862,10 +862,32 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
|
||||
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());
|
||||
@ -953,28 +975,15 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
|
||||
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;
|
||||
@ -1326,10 +1335,9 @@ bool BufferView::dispatch(FuncRequest const & cmd)
|
||||
}
|
||||
}
|
||||
// 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();
|
||||
|
@ -748,9 +748,9 @@ bool InsetCollapsable::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
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);
|
||||
@ -887,9 +887,7 @@ docstring InsetCollapsable::contextMenu(BufferView const & bv, int x,
|
||||
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user