Kill next-inset-toggle and expand inset-toggle to provide the same functionality

* src/LyXAction.h: introduce new function attribute AtPoint: this is 
	for lfuns that should first look at cursor postion whether there
	is an inset, before dispatching to container inset.
	* src/LyXAction.cpp: remove LFUN_NEXT_INSET_TOGGLE; 
	mark LFUN_INSET_TOGGLE as AtPoint.
	* src/BufferView.cpp (dispatch, getStatus): remove handling of
	LFUN_NEXT_INSET_TOGGLE.
	* src/LyXFunc.cpp (dispatch, getStatus): handle functions marked 
	AtPoint.	
	* lib/*/*: replace next-inset-toggle with inset-toggle.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28980 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2009-03-30 13:49:52 +00:00
parent 827c72e1f5
commit 30afece93d
12 changed files with 77 additions and 98 deletions

View File

@ -16,11 +16,15 @@ The following variables are obsoleted in 2.0
The following new LyX functions have been introduced:
- LFUN_WORD_FINDAD, "word-findadv".
- LFUN_WORD_FINDAD ("word-findadv").
- LFUN_REGEXP_MODE, "regexp-mode".
- LFUN_REGEXP_MODE ("regexp-mode").
- LFUN_COPY_LABEL_AS_REF, "copy-label-as-reference"
- LFUN_COPY_LABEL_AS_REF ("copy-label-as-reference").
The following LyX functions have been removed:
- LFUN_NEXT_INSET_TOGGLE (next-inset-toggle): use "inset-toggle" instead.
Known issues in version 2.0.0
-----------------------------

View File

@ -80,7 +80,7 @@
\bind "M-~S-e s" "spellchecker"
\bind "M-~S-e h" "buffer-chktex"
\bind "M-~S-e e" "error-remove-all"
\bind "M-~S-e l" "next-inset-toggle"
\bind "M-~S-e l" "inset-toggle"
\bind "M-~S-e p" "dialog-preferences"
\bind "M-~S-e r" "reconfigure"

View File

@ -70,7 +70,7 @@
\bind "C-f" "dialog-show findreplace"
\bind "C-S-f" "dialog-show findreplaceadv"
\bind "C-i" "next-inset-toggle" # 'i' for Inset
\bind "C-i" "inset-toggle" # 'i' for Inset
\bind "C-c" "copy"
\bind "C-x" "cut"

View File

@ -43,7 +43,7 @@
\bind "C-l" "screen-recenter"
\bind "C-m" "mark-toggle"
\bind "C-n" "down"
\bind "C-o" "next-inset-toggle"
\bind "C-o" "inset-toggle"
\bind "C-p" "up"
# this is "quoted-insert" a total different meaning from "quote-insert"

View File

@ -52,7 +52,7 @@
\bind "C-S-M" "math-display"
\bind "C-f" "dialog-show findreplace"
\bind "C-i" "next-inset-toggle" # 'i' for Inset
\bind "C-i" "inset-toggle" # 'i' for Inset
\bind "C-c" "copy"
\bind "C-x" "cut"

View File

@ -45,7 +45,7 @@
\bind "C-l" "screen-recenter"
\bind "C-m" "mark-toggle"
\bind "C-n" "down"
\bind "C-o" "next-inset-toggle"
\bind "C-o" "inset-toggle"
\bind "C-p" "up"
# this is "quoted-insert" a total different meaning from "quote-insert"

View File

@ -80,7 +80,7 @@ Menuset
Item "<reference> on page <page>|f" "next-inset-modify changetype vref"
Item "Formatted reference|t" "next-inset-modify changetype prettyref"
Separator
Item "Settings...|S" "next-inset-toggle"
Item "Settings...|S" "inset-toggle"
End
#
@ -92,7 +92,7 @@ Menuset
Separator
Item "Copy as Reference|C" "copy-label-as-reference"
Separator
Item "Settings...|S" "next-inset-toggle"
Item "Settings...|S" "inset-toggle"
End
@ -102,7 +102,7 @@ Menuset
Menu "context-citation"
CiteStyles
Separator
Item "Settings...|S" "next-inset-toggle"
Item "Settings...|S" "inset-toggle"
End
@ -110,7 +110,7 @@ Menuset
# InsetBibtex context menu
#
Menu "context-bibtex"
Item "Settings...|S" "next-inset-toggle"
Item "Settings...|S" "inset-toggle"
Separator
Item "Edit Database(s) externally...|x" "inset-edit"
End
@ -120,15 +120,15 @@ Menuset
# InsetCollapsable context menu
#
Menu "context-collapsable"
OptItem "Open Inset|O" "next-inset-toggle open"
OptItem "Close Inset|C" "next-inset-toggle close"
OptItem "Open Inset|O" "inset-toggle open"
OptItem "Close Inset|C" "inset-toggle close"
Separator
Item "Dissolve Inset|D" "inset-dissolve"
OptItem "Settings...|S" "inset-settings"
End
Menu "context-conglomerate"
Item "Toggle Label|L" "next-inset-toggle"
Item "Toggle Label|L" "inset-toggle"
Item "Dissolve Inset|D" "inset-dissolve charstyle"
Separator
OptItem "Settings...|S" "inset-settings"
@ -148,8 +148,8 @@ Menuset
Item "Shaded background|b" "next-inset-modify changetype Shaded"
Item "Double frame|u" "next-inset-modify changetype Doublebox"
Separator
OptItem "Open Inset|O" "next-inset-toggle open"
OptItem "Close Inset|C" "next-inset-toggle close"
OptItem "Open Inset|O" "inset-toggle open"
OptItem "Close Inset|C" "inset-toggle close"
Separator
Item "Dissolve Inset|D" "inset-dissolve"
Item "Settings...|S" "inset-settings box"
@ -164,8 +164,8 @@ Menuset
Item "Comment|m" "next-inset-modify note Note Comment"
Item "Greyed Out|G" "next-inset-modify note Note Greyedout"
Separator
OptItem "Open Inset|O" "next-inset-toggle open"
OptItem "Close Inset|C" "next-inset-toggle close"
OptItem "Open Inset|O" "inset-toggle open"
OptItem "Close Inset|C" "inset-toggle close"
Separator
Item "Dissolve Inset|D" "inset-dissolve"
End
@ -202,9 +202,9 @@ Menuset
Item "Horizontal Fill (Right Arrow)|g" "next-inset-modify space \rightarrowfill{}"
Item "Horizontal Fill (Up Brace)|p" "next-inset-modify space \upbracefill{}"
Item "Horizontal Fill (Down Brace)|B" "next-inset-modify space \downbracefill{}"
Item "Custom Length|C" "command-sequence next-inset-modify space \hspace{} \length 1in; next-inset-toggle"
Item "Custom Length|C" "command-sequence next-inset-modify space \hspace{} \length 1in; inset-toggle"
Separator
Item "Settings...|S" "next-inset-toggle"
Item "Settings...|S" "inset-toggle"
End
#
@ -220,9 +220,9 @@ Menuset
Item "Half Quad Space (Enskip)|k" "next-inset-modify mathspace \enskip{}"
Item "Quad Space|Q" "next-inset-modify mathspace \quad{}"
Item "Double Quad Space|u" "next-inset-modify mathspace \qquad{}"
Item "Custom Length|C" "command-sequence next-inset-modify mathspace \hspace{} \length 1in; next-inset-toggle"
Item "Custom Length|C" "command-sequence next-inset-modify mathspace \hspace{} \length 1in; inset-toggle"
Separator
Item "Settings...|S" "next-inset-toggle"
Item "Settings...|S" "inset-toggle"
End
#
@ -234,9 +234,9 @@ Menuset
Item "MedSkip|M" "next-inset-modify vspace medskip"
Item "BigSkip|B" "next-inset-modify vspace bigskip"
Item "VFill|F" "next-inset-modify vspace vfill"
Item "Custom|C" "command-sequence next-inset-modify vspace 1in; next-inset-toggle"
Item "Custom|C" "command-sequence next-inset-modify vspace 1in; inset-toggle"
Separator
Item "Settings...|e" "next-inset-toggle"
Item "Settings...|e" "inset-toggle"
End
#
@ -249,7 +249,7 @@ Menuset
Item "Verbatim (marked blanks)|b" "next-inset-modify changetype verbatiminput*"
Item "Listing|L" "next-inset-modify changetype lstinputlisting"
Separator
Item "Settings...|S" "next-inset-toggle"
Item "Settings...|S" "inset-toggle"
Separator
Item "Edit included file...|E" "inset-edit"
End
@ -327,8 +327,8 @@ Menuset
Item "Paste" "paste"
Submenu "Paste Recent|e" "edit_pasterecent"
Separator
OptItem "Open Inset|O" "next-inset-toggle open"
OptItem "Close Inset|C" "next-inset-toggle close"
OptItem "Open Inset|O" "inset-toggle open"
OptItem "Close Inset|C" "inset-toggle close"
Separator
Item "Dissolve Inset|D" "inset-dissolve"
Item "Settings...|S" "inset-settings listings"
@ -339,7 +339,7 @@ Menuset
#
Menu "context-graphics"
Item "Settings...|S" "next-inset-toggle"
Item "Settings...|S" "inset-toggle"
Separator
Item "Edit externally...|x" "inset-edit"
Separator
@ -351,7 +351,7 @@ Menuset
#
Menu "context-external"
Item "Settings...|S" "next-inset-toggle"
Item "Settings...|S" "inset-toggle"
Separator
Item "Edit externally...|x" "inset-edit"
End

View File

@ -953,12 +953,10 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
break;
}
case LFUN_NEXT_INSET_TOGGLE:
case LFUN_NEXT_INSET_MODIFY: {
// this is the real function we want to invoke
FuncRequest tmpcmd = cmd;
tmpcmd.action = (cmd.action == LFUN_NEXT_INSET_TOGGLE)
? LFUN_INSET_TOGGLE : LFUN_INSET_MODIFY;
tmpcmd.action = LFUN_INSET_MODIFY;
// if there is an inset at cursor, see whether it
// handles the lfun, other start from scratch
Inset * inset = cur.nextInset();
@ -1411,35 +1409,6 @@ bool BufferView::dispatch(FuncRequest const & cmd)
processUpdateFlags(Update::SinglePar | Update::FitCursor);
break;
}
case LFUN_NEXT_INSET_TOGGLE: {
// create the the real function we want to invoke
FuncRequest tmpcmd = cmd;
tmpcmd.action = LFUN_INSET_TOGGLE;
// if there is an inset at cursor, see whether it
// wants to toggle.
Inset * inset = cur.nextInset();
if (inset) {
if (inset->isActive()) {
Cursor tmpcur = cur;
tmpcur.pushBackward(*inset);
inset->dispatch(tmpcur, tmpcmd);
if (tmpcur.result().dispatched())
cur.dispatched();
} else
inset->dispatch(cur, tmpcmd);
}
// if it did not work, try the underlying inset.
if (!inset || !cur.result().dispatched())
cur.dispatch(tmpcmd);
if (!cur.result().dispatched())
// It did not work too; no action needed.
break;
cur.clearSelection();
processUpdateFlags(Update::SinglePar | Update::FitCursor);
break;
}
case LFUN_NEXT_INSET_MODIFY: {
// create the the real function we want to invoke
FuncRequest tmpcmd = cmd;

View File

@ -322,105 +322,104 @@ enum FuncCode
LFUN_WORD_REPLACE,
LFUN_BUFFER_EXPORT_CUSTOM,
LFUN_BUFFER_PRINT,
LFUN_NEXT_INSET_TOGGLE,
// 245
LFUN_ALL_INSETS_TOGGLE,
// 245
LFUN_BUFFER_LANGUAGE,
LFUN_TEXTCLASS_APPLY,
LFUN_TEXTCLASS_LOAD,
LFUN_BUFFER_SAVE_AS_DEFAULT,
// 250
LFUN_BUFFER_PARAMS_APPLY,
// 250
LFUN_LYXRC_APPLY,
LFUN_BUFFER_NEXT,
LFUN_BUFFER_PREVIOUS,
LFUN_STATISTICS,
// 255
LFUN_CHANGES_OUTPUT, // jspitzm 20050121
// 255
LFUN_BIBTEX_DATABASE_ADD,
LFUN_BIBTEX_DATABASE_DEL,
LFUN_CITATION_INSERT,
LFUN_OUTLINE_UP,
// 260
LFUN_OUTLINE_DOWN,
// 260
LFUN_OUTLINE_IN,
LFUN_OUTLINE_OUT,
LFUN_PARAGRAPH_MOVE_DOWN,
LFUN_PARAGRAPH_MOVE_UP,
// 265
LFUN_BUFFER_TOGGLE_COMPRESSION, // bpeng 20060427
// 265
LFUN_MATH_BIGDELIM,
LFUN_CLIPBOARD_PASTE,
LFUN_INSET_DISSOLVE, // jspitzm 20060807
LFUN_CHANGE_NEXT,
// 270
LFUN_WINDOW_NEW, // Abdel 20061021
// 270
LFUN_WINDOW_CLOSE, // Abdel 20061023
LFUN_UNICODE_INSERT, // Lgb 20061022
LFUN_BOOKMARK_CLEAR, // bpeng 20061031
LFUN_NOMENCL_INSERT, // Ugras
// 275
LFUN_NOMENCL_PRINT, // Ugras
// 275
LFUN_LISTING_INSERT, // Herbert 20011110, bpeng 20070502
LFUN_TOOLBAR_TOGGLE, // Edwin 20070521
LFUN_BUFFER_WRITE_ALL, // rgh, gpothier 200707XX
LFUN_PARAGRAPH_PARAMS,
// 280
LFUN_LAYOUT_MODULES_CLEAR,
// 280
LFUN_LAYOUT_MODULE_ADD,
LFUN_LAYOUT_RELOAD,
LFUN_MASTER_BUFFER_VIEW, // Tommaso, 20070920
LFUN_MASTER_BUFFER_UPDATE, // Tommaso, 20070920
// 285
LFUN_INFO_INSERT, // bpeng, 20071007
// 285
LFUN_CALL, // broider, 20071002
LFUN_CHAR_LEFT, // dov, 20071022
LFUN_CHAR_LEFT_SELECT, // dov, 20071022
LFUN_CHAR_RIGHT, // dov, 20071022
// 290
LFUN_CHAR_RIGHT_SELECT, // dov, 20071022
// 290
LFUN_FINISHED_BACKWARD, // dov, 20071022
LFUN_FINISHED_FORWARD, // dov, 20071022
LFUN_WORD_LEFT, // dov, 20071028
LFUN_WORD_LEFT_SELECT, // dov, 20071028
// 295
LFUN_WORD_RIGHT, // dov, 20071028
// 295
LFUN_WORD_RIGHT_SELECT, // dov, 20071028
LFUN_MATH_MACRO_FOLD,
LFUN_MATH_MACRO_UNFOLD,
LFUN_MATH_MACRO_ADD_PARAM,
// 300
LFUN_MATH_MACRO_REMOVE_PARAM,
// 300
LFUN_MATH_MACRO_APPEND_GREEDY_PARAM,
LFUN_MATH_MACRO_REMOVE_GREEDY_PARAM,
LFUN_MATH_MACRO_MAKE_OPTIONAL,
LFUN_MATH_MACRO_MAKE_NONOPTIONAL,
// 305
LFUN_MATH_MACRO_ADD_OPTIONAL_PARAM,
// 305
LFUN_MATH_MACRO_REMOVE_OPTIONAL_PARAM,
LFUN_MATH_MACRO_ADD_GREEDY_OPTIONAL_PARAM,
LFUN_IN_MATHMACROTEMPLATE,
LFUN_COMPLETION_POPUP,
// 310
LFUN_COMPLETION_INLINE,
// 310
LFUN_COMPLETION_COMPLETE,
LFUN_SET_GRAPHICS_GROUP,
LFUN_COMPLETION_CANCEL,
LFUN_COMPLETION_ACCEPT,
// 315
LFUN_COMMAND_ALTERNATIVES,
// 315
LFUN_TAB_INSERT,
LFUN_TAB_DELETE,
LFUN_WORD_FINDADV, // Tommaso, 20081003
LFUN_REGEXP_MODE, // Tommaso, 20081003
// 320
LFUN_COPY_LABEL_AS_REF, // sts, 20081116
// 320
LFUN_VC_COMMAND,
LFUN_MATH_FONT_STYLE,
LFUN_PHANTOM_INSERT, // uwestoehr, 20090130
LFUN_INSET_BEGIN, // JMarc, 20090316
// 325
LFUN_INSET_END, // JMarc, 20090316
// 325
LFUN_INSET_BEGIN_SELECT, // JMarc, 20090316
LFUN_INSET_END_SELECT, // JMarc, 20090316
LFUN_SCREEN_SHOW_CURSOR, // vfr, 20090325

View File

@ -2238,33 +2238,18 @@ void LyXAction::init()
* \endvar
*/
{ LFUN_INSET_SETTINGS, "inset-settings", ReadOnly, Edit },
/*!
* \var lyx::FuncCode lyx::LFUN_NEXT_INSET_TOGGLE
* \li Action: Toggles the inset at cursor position. For collapsables, this means it will
be (un-)collapsed, in case of other insets, the editing widget (dialog) will
be entered. Also cf. #LFUN_INSET_SETTINGS.
* \li Notion: Used for bibitem, bibtex, box, branch, command, ert, external,
floats, graphics, include, label, listings, note,
phantom, ref, space, tabular, vspace, wrap insets.
* \li Syntax: next-inset-toggle <ARG>
* \li Params: <ARG>: these are passed as arguments to #LFUN_INSET_TOGGLE .
* \li Origin: leeming, 30 Mar 2004
* \endvar
*/
{ LFUN_NEXT_INSET_TOGGLE, "next-inset-toggle", ReadOnly, Edit },
/*!
* \var lyx::FuncCode lyx::LFUN_INSET_TOGGLE
* \li Action: Toggles the collapsable inset we are currently in.
* \li Syntax: inset-toggle [<ARG>]
* \li Params: <ARG>: <open|close|toggle|assign>. \n
open/close/toggle are for collapsable insets. close can be currently used
by #LFUN_NEXT_INSET_TOGGLE. toggle is used when no argument is given.\n
open/close/toggle are for collapsable insets. toggle is used when no argument is given.\n
assign synchronize the branch-inset with activation status of the branch.
Used for global toggling when changed activation.
* \li Origin: lasgouttes, 19 Jul 2001
* \endvar
*/
{ LFUN_INSET_TOGGLE, "inset-toggle", ReadOnly, Hidden },
{ LFUN_INSET_TOGGLE, "inset-toggle", ReadOnly | AtPoint, Hidden },
/*!
* \var lyx::FuncCode lyx::LFUN_ALL_INSETS_TOGGLE
* \li Action: Toggles (open/closes) all collapsable insets (of a given type) in the document.

View File

@ -68,7 +68,8 @@ public:
NoBuffer = 2, //< Can be used when there is no document open
Argument = 4, //< Requires argument
NoUpdate = 8, //< Does not (usually) require update
SingleParUpdate = 16 //< Usually only requires this par updated
SingleParUpdate = 16, //< Usually only requires this par updated
AtPoint = 32, //< dispatch first to inset at cursor if there is one
};
LyXAction();

View File

@ -659,6 +659,13 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
enable = false;
break;
}
// Is this a function that acts on inset at point?
Inset * inset = view()->cursor().nextInset();
if (lyxaction.funcHasFlag(cmd.action, LyXAction::AtPoint)
&& inset && inset->getStatus(view()->cursor(), cmd, flag))
break;
if (!getLocalStatus(view()->cursor(), cmd, flag))
flag = view()->getStatus(cmd);
}
@ -1705,6 +1712,20 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
break;
}
// Is this a function that acts on inset at point?
Inset * inset = view()->cursor().nextInset();
if (lyxaction.funcHasFlag(action, LyXAction::AtPoint)
&& inset) {
view()->cursor().result().dispatched(true);
view()->cursor().result().update(Update::FitCursor | Update::Force);
FuncRequest tmpcmd = cmd;
inset->dispatch(view()->cursor(), tmpcmd);
if (view()->cursor().result().dispatched()) {
updateFlags = view()->cursor().result().update();
break;
}
}
// Let the current Cursor dispatch its own actions.
Cursor old = view()->cursor();
view()->cursor().getPos(cursorPosBeforeDispatchX_,