From 4385c156e2aa7a6ea313cd6a0e3b3ab9b4992509 Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Sun, 14 Oct 2007 00:47:52 +0000 Subject: [PATCH] Allow the input of an InsetInfo using command buffer (e.g. "info-insert menu paste"). Document this change in InsetInfo.h git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20961 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Text3.cpp | 14 ++++++++------ src/insets/InsetInfo.h | 28 ++++++++++++++++------------ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/Text3.cpp b/src/Text3.cpp index f32007acb7..c95b90787c 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -1097,16 +1097,18 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) } case LFUN_INFO_INSERT: { - if (!cur.selection()) - break; Inset * inset = createInset(&cur.bv(), cmd); if (!inset) break; - // use selected text as info to avoid a separate UI - docstring ds = cur.selectionAsString(false); - cutSelection(cur, true, false); + // if an empty inset is created (cmd.argument() is empty) + // use current selection as parameter. + if (cmd.argument().empty() && cur.selection()) { + // use selected text as info to avoid a separate UI + docstring ds = cur.selectionAsString(false); + cutSelection(cur, true, false); + static_cast(inset)->setInfo(to_utf8(ds)); + } insertInset(cur, inset); - static_cast(inset)->setInfo(to_utf8(ds)); cur.posRight(); break; } diff --git a/src/insets/InsetInfo.h b/src/insets/InsetInfo.h index a8c6dbdf67..280303c05c 100644 --- a/src/insets/InsetInfo.h +++ b/src/insets/InsetInfo.h @@ -33,32 +33,36 @@ InsetInfo can have type "shortcut", "lyxrc", "package", "textclass", or "menu". Arguments and outputs vary by type. shortcut: name of the LFUN such as "math-insert \alpha". The syntax - is the same as what is used in the bind and ui files. - The output of this inset is all shortcuts separated by comma. + is the same as what is used in the bind and ui files. + The output of this inset is all shortcuts separated by comma. lyxrc: name of the rc entry such as "bind_file". Look in src/LyXRC.h - for available entries. The output is the content of this RC - entry. + for available entries. The output is the content of this RC + entry. package: name of a latex package such as "listings". The output is - "yes" or "no". + "yes" or "no". textclass: name of a textclass such as "article". The output is "yes" - or "no". + or "no". menu: name of the LFUN such as "paste". The syntax is the same as - what is used in the bind and ui files. The output is the - menu item that trigger this LFUN. For example, "File > Paste". - '>' is actually \lyxarrow (an InsetSpecialChar). + what is used in the bind and ui files. The output is the + menu item that trigger this LFUN. For example, "File > Paste". + '>' is actually \lyxarrow (an InsetSpecialChar). Because this inset is intended to be used only by document maintainers, -there is no GUI, no menu entry for this inset. A user would have to -define a shortcut for "info-insert" (e.g. C-S-I), and +there is no GUI, no menu entry for this inset. A user can define a +shortcut for "info-insert" (e.g. C-S-I), and -1. input the type and argument of this inset. E.g. "menu paste". +1. input the type and argument of this inset, e.g. "menu paste", in + the work area. 2. select the text and run "info-insert" (e.g. press C-S-I). +An alternative method is to enter command "info-insert type args" in +the command buffer (view->Toolbar->Command Buffer). + */ namespace lyx { -- 2.39.2