Allow to separate menu string from label string for arguments

This commit is contained in:
Juergen Spitzmueller 2012-12-09 19:15:41 +01:00
parent 86559aa318
commit 25ef8e7eef
7 changed files with 176 additions and 37 deletions

View File

@ -1,5 +1,5 @@
#LyX 2.1 created this file. For more info see http://www.lyx.org/ #LyX 2.1 created this file. For more info see http://www.lyx.org/
\lyxformat 449 \lyxformat 452
\begin_document \begin_document
\begin_header \begin_header
\textclass scrbook \textclass scrbook
@ -10338,7 +10338,7 @@ Argument
\begin_layout Itemize \begin_layout Itemize
\change_inserted -712698321 1353691469 \change_inserted -712698321 1355076779
\begin_inset Flex Code \begin_inset Flex Code
status collapsed status collapsed
@ -10365,7 +10365,19 @@ status collapsed
\end_inset \end_inset
The string that will appear both in the menu (to insert this argument) The string that will appear both in the menu (to insert this argument)
and on the argument inset button. and on the argument inset button (unless you also specify a separate
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1355076779
MenuString
\end_layout
\end_inset
).
For the menu, you can define an accelerator by appending the respective For the menu, you can define an accelerator by appending the respective
character to the string, divided by character to the string, divided by
\begin_inset Quotes eld \begin_inset Quotes eld
@ -10406,6 +10418,85 @@ Short Title|S
\begin_layout Itemize \begin_layout Itemize
\change_inserted -712698321 1355076754
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1355076658
MenuString
\end_layout
\end_inset
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1355076654
[string]
\end_layout
\end_inset
A separate string for the menu.
You can define an accelerator by appending the respective character to
the string, divided by
\begin_inset Quotes eld
\end_inset
|
\begin_inset Quotes erd
\end_inset
(e.
\begin_inset space \thinspace{}
\end_inset
g.
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1355076654
\begin_inset Quotes eld
\end_inset
Short Title|S
\begin_inset Quotes erd
\end_inset
\end_layout
\end_inset
).
This specification is optional.
If it is not given the
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1355076736
LabelString
\change_unchanged
\end_layout
\end_inset
will be used instead for the menu.
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1353680665 \change_inserted -712698321 1353680665
\begin_inset Flex Code \begin_inset Flex Code
status collapsed status collapsed

View File

@ -93,7 +93,8 @@ Style Itemize
Tooltip "A customized item string" Tooltip "A customized item string"
EndArgument EndArgument
Argument item:2 Argument item:2
LabelString "Item Overlay Specifications" MenuString "Item Overlay Specifications"
LabelString "On Slide"
Tooltip "Overlay specifications for this item" Tooltip "Overlay specifications for this item"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -129,7 +130,8 @@ Style Enumerate
Tooltip "A customized item string" Tooltip "A customized item string"
EndArgument EndArgument
Argument item:2 Argument item:2
LabelString "Item Overlay Specifications" MenuString "Item Overlay Specifications"
LabelString "On Slide"
Tooltip "Overlay specifications for this item" Tooltip "Overlay specifications for this item"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -163,7 +165,8 @@ Style Description
Tooltip "The longest label in this list (to determine the indendation width)" Tooltip "The longest label in this list (to determine the indendation width)"
EndArgument EndArgument
Argument item:1 Argument item:1
LabelString "Item Overlay Specifications" MenuString "Item Overlay Specifications"
LabelString "On Slide"
Tooltip "Overlay specifications for this item" Tooltip "Overlay specifications for this item"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -194,7 +197,8 @@ Style Part
LatexType Command LatexType Command
LatexName part LatexName part
Argument 1 Argument 1
LabelString "Mode Specification|S" LabelString "Mode"
MenuString "Mode Specification|S"
Tooltip "Specify in which mode (article, presentation etc.) this header appears" Tooltip "Specify in which mode (article, presentation etc.) this header appears"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -243,7 +247,8 @@ Style Section
LabelString "Section \arabic{section}" LabelString "Section \arabic{section}"
RefPrefix sec RefPrefix sec
Argument 1 Argument 1
LabelString "Mode Specification|S" LabelString "Mode"
MenuString "Mode Specification|S"
Tooltip "Specify in which mode (article, presentation etc.) this header appears" Tooltip "Specify in which mode (article, presentation etc.) this header appears"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -272,7 +277,8 @@ Style Section*
LabelType No_Label LabelType No_Label
ResetArgs 1 ResetArgs 1
Argument 1 Argument 1
LabelString "Mode Specification|S" LabelString "Mode"
MenuString "Mode Specification|S"
Tooltip "Specify in which mode (article, presentation etc.) this header appears" Tooltip "Specify in which mode (article, presentation etc.) this header appears"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -298,7 +304,8 @@ Style Subsection
LabelString "Subsection \arabic{section}.\arabic{subsection}" LabelString "Subsection \arabic{section}.\arabic{subsection}"
RefPrefix sub RefPrefix sub
Argument 1 Argument 1
LabelString "Mode Specification|S" LabelString "Mode"
MenuString "Mode Specification|S"
Tooltip "Specify in which mode (article, presentation etc.) this header appears" Tooltip "Specify in which mode (article, presentation etc.) this header appears"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -327,7 +334,8 @@ Style Subsection*
LabelType No_Label LabelType No_Label
ResetArgs 1 ResetArgs 1
Argument 1 Argument 1
LabelString "Mode Specification|S" LabelString "Mode"
MenuString "Mode Specification|S"
Tooltip "Specify in which mode (article, presentation etc.) this header appears" Tooltip "Specify in which mode (article, presentation etc.) this header appears"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -353,7 +361,8 @@ Style Subsubsection
LabelString "Subsubsection \arabic{section}.\arabic{subsection}.\arabic{subsubsection}" LabelString "Subsubsection \arabic{section}.\arabic{subsection}.\arabic{subsubsection}"
RefPrefix sub RefPrefix sub
Argument 1 Argument 1
LabelString "Mode Specification|S" LabelString "Mode"
MenuString "Mode Specification|S"
Tooltip "Specify in which mode (article, presentation etc.) this header appears" Tooltip "Specify in which mode (article, presentation etc.) this header appears"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -382,7 +391,8 @@ Style Subsubsection*
LabelType No_Label LabelType No_Label
ResetArgs 1 ResetArgs 1
Argument 1 Argument 1
LabelString "Mode Specification|S" LabelString "Mode"
MenuString "Mode Specification|S"
Tooltip "Specify in which mode (article, presentation etc.) this header appears" Tooltip "Specify in which mode (article, presentation etc.) this header appears"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -478,7 +488,8 @@ Style AgainFrame
LatexType Command LatexType Command
LatexName lyxframeend{}\againframe LatexName lyxframeend{}\againframe
Argument 1 Argument 1
LabelString "Overlay Specifications|S" LabelString "On Slide"
MenuString "Overlay Specifications|S"
Tooltip "Overlay specifications for this frame" Tooltip "Overlay specifications for this frame"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -490,7 +501,8 @@ Style AgainFrame
RightDelim >] RightDelim >]
EndArgument EndArgument
Argument 3 Argument 3
LabelString "Frame Options" MenuString "Frame Options"
LabelString "Options"
Tooltip "Frame options (see beamer manual)" Tooltip "Frame options (see beamer manual)"
EndArgument EndArgument
Margin First_Dynamic Margin First_Dynamic
@ -559,7 +571,8 @@ Style FrameSubtitle
Color Blue Color Blue
EndFont EndFont
Argument 1 Argument 1
LabelString "Overlay Specification|S" LabelString "On Slide"
MenuString "Overlay Specifications|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -586,7 +599,8 @@ Style Column
LabelSep xx LabelSep xx
LabelString "Start column (increase depth!), width:" LabelString "Start column (increase depth!), width:"
Argument 1 Argument 1
LabelString "Column Options" MenuString "Column Options"
LabelString "Options"
Tooltip "Column options (see beamer manual)" Tooltip "Column options (see beamer manual)"
EndArgument EndArgument
LeftMargin "Start column (increase depth!), width:xx" LeftMargin "Start column (increase depth!), width:xx"
@ -693,7 +707,8 @@ Style Overprint
Color latex Color latex
EndFont EndFont
Argument 1 Argument 1
LabelString "Overprint Area Width" MenuString "Overprint Area Width"
LabelString "Width"
Tooltip "The width of the overprint area (default: text width)" Tooltip "The width of the overprint area (default: text width)"
EndArgument EndArgument
End End
@ -723,7 +738,8 @@ Style OverlayArea
Mandatory 1 Mandatory 1
EndArgument EndArgument
Argument 2 Argument 2
LabelString "Overlay Area Height" MenuString "Overlay Area Height"
LabelString "Height"
Tooltip "The height of the overlay area" Tooltip "The height of the overlay area"
Mandatory 1 Mandatory 1
EndArgument EndArgument
@ -749,7 +765,8 @@ Style Uncover
Color Latex Color Latex
EndFont EndFont
Argument 1 Argument 1
LabelString "Overlay Specification|S" LabelString "On Slide"
MenuString "Overlay Specifications|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -776,7 +793,8 @@ Style Only
Color Latex Color Latex
EndFont EndFont
Argument 1 Argument 1
LabelString "Overlay Specification|S" LabelString "On Slide"
MenuString "Overlay Specifications|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -807,7 +825,8 @@ Style Block
Color latex Color latex
EndFont EndFont
Argument 1 Argument 1
LabelString "Action Specification|S" LabelString "Action"
MenuString "Action Specification|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -1059,7 +1078,8 @@ Style Quotation
Align Block Align Block
AlignPossible Block, Left, Right, Center AlignPossible Block, Left, Right, Center
Argument 1 Argument 1
LabelString "Overlay Specification|S" LabelString "On Slide"
MenuString "Overlay Specifications|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -1081,7 +1101,8 @@ Style Quote
AlignPossible Block, Left, Right, Center AlignPossible Block, Left, Right, Center
LabelType No_Label LabelType No_Label
Argument 1 Argument 1
LabelString "Overlay Specification|S" LabelString "On Slide"
MenuString "Overlay Specifications|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -1106,7 +1127,8 @@ Style Verse
AlignPossible Block, Left AlignPossible Block, Left
LabelType No_Label LabelType No_Label
Argument 1 Argument 1
LabelString "Overlay Specification|S" LabelString "On Slide"
MenuString "Overlay Specifications|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -1140,7 +1162,8 @@ Style Corollary
Size Large Size Large
EndFont EndFont
Argument 1 Argument 1
LabelString "Action Specification|S" LabelString "Action"
MenuString "Action Specifications|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -1279,7 +1302,8 @@ Style NoteItem
Color latex Color latex
EndFont EndFont
Argument 1 Argument 1
LabelString "Overlay Specification|S" LabelString "On Slide"
MenuString "Overlay Specifications|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -1300,7 +1324,8 @@ InsetLayout Flex:Emphasize
Shape italic Shape italic
EndFont EndFont
Argument 1 Argument 1
LabelString "Action Specification|S" LabelString "Action"
MenuString "Action Specifications|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -1316,7 +1341,8 @@ InsetLayout Flex:Alert
Color red Color red
EndFont EndFont
Argument 1 Argument 1
LabelString "Action Specification|S" LabelString "Action"
MenuString "Action Specifications|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -1332,7 +1358,8 @@ InsetLayout Flex:Structure
Color blue Color blue
EndFont EndFont
Argument 1 Argument 1
LabelString "Action Specification|S" LabelString "Action"
MenuString "Action Specifications|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -1348,7 +1375,8 @@ InsetLayout Flex:Only
Color red Color red
EndFont EndFont
Argument 1 Argument 1
LabelString "Overlay Specification|S" LabelString "Action"
MenuString "Action Specifications|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -1364,7 +1392,8 @@ InsetLayout Flex:Uncover
Color red Color red
EndFont EndFont
Argument 1 Argument 1
LabelString "Overlay Specification|S" LabelString "Action"
MenuString "Action Specifications|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -1380,7 +1409,8 @@ InsetLayout Flex:Visible
Color red Color red
EndFont EndFont
Argument 1 Argument 1
LabelString "Overlay Specification|S" LabelString "Action"
MenuString "Action Specifications|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -1396,7 +1426,8 @@ InsetLayout Flex:Invisible
Color red Color red
EndFont EndFont
Argument 1 Argument 1
LabelString "Overlay Specification|S" LabelString "Action"
MenuString "Action Specifications|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -1412,7 +1443,8 @@ InsetLayout Flex:Alternative
Color red Color red
EndFont EndFont
Argument 1 Argument 1
LabelString "Overlay Specification|S" LabelString "Action"
MenuString "Action Specifications|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >
@ -1434,7 +1466,8 @@ InsetLayout Flex:Beamer_Note
Color blue Color blue
EndFont EndFont
Argument 1 Argument 1
LabelString "Overlay Specification|S" LabelString "Action"
MenuString "Action Specifications|S"
Tooltip "Specify the overlay settings (see beamer manual)" Tooltip "Specify the overlay settings (see beamer manual)"
LeftDelim < LeftDelim <
RightDelim > RightDelim >

View File

@ -83,6 +83,7 @@ def layouts_l10n(input_files, output, base, layouttranslations):
Style = re.compile(r'^\s*Style\s+(.*)\s*$', re.IGNORECASE) Style = re.compile(r'^\s*Style\s+(.*)\s*$', re.IGNORECASE)
# match LabelString, EndLabelString, LabelStringAppendix and maybe others but no comments # match LabelString, EndLabelString, LabelStringAppendix and maybe others but no comments
LabelString = re.compile(r'^[^#]*LabelString\S*\s+(.*)\s*$', re.IGNORECASE) LabelString = re.compile(r'^[^#]*LabelString\S*\s+(.*)\s*$', re.IGNORECASE)
MenuString = re.compile(r'^[^#]*MenuString\S*\s+(.*)\s*$', re.IGNORECASE)
Tooltip = re.compile(r'^[^#]*Tooltip\S*\s+(.*)\s*$', re.IGNORECASE) Tooltip = re.compile(r'^[^#]*Tooltip\S*\s+(.*)\s*$', re.IGNORECASE)
GuiName = re.compile(r'^\s*GuiName\s+(.*)\s*$', re.IGNORECASE) GuiName = re.compile(r'^\s*GuiName\s+(.*)\s*$', re.IGNORECASE)
ListName = re.compile(r'^\s*ListName\s+(.*)\s*$', re.IGNORECASE) ListName = re.compile(r'^\s*ListName\s+(.*)\s*$', re.IGNORECASE)
@ -237,6 +238,12 @@ def layouts_l10n(input_files, output, base, layouttranslations):
writeString(out, src, base, lineno, string) writeString(out, src, base, lineno, string)
continue continue
res = LabelString.search(line) res = LabelString.search(line)
if res != None:
string = res.group(1)
if not layouttranslations:
writeString(out, src, base, lineno, string)
continue
res = MenuString.search(line)
if res != None: if res != None:
string = res.group(1) string = res.group(1)
if not layouttranslations: if not layouttranslations:

View File

@ -900,6 +900,9 @@ void Layout::readArgument(Lexer & lex)
} else if (tok == "labelstring") { } else if (tok == "labelstring") {
lex.next(); lex.next();
arg.labelstring = lex.getDocString(); arg.labelstring = lex.getDocString();
} else if (tok == "menustring") {
lex.next();
arg.menustring = lex.getDocString();
} else if (tok == "mandatory") { } else if (tok == "mandatory") {
lex.next(); lex.next();
arg.mandatory = lex.getBool(); arg.mandatory = lex.getBool();

View File

@ -90,6 +90,7 @@ public:
/// The arguments of this layout /// The arguments of this layout
struct latexarg { struct latexarg {
docstring labelstring; docstring labelstring;
docstring menustring;
bool mandatory; bool mandatory;
docstring ldelim; docstring ldelim;
docstring rdelim; docstring rdelim;

View File

@ -1570,7 +1570,8 @@ void MenuDefinition::expandArguments(BufferView const * bv, bool switcharg)
Layout::LaTeXArgMap::const_iterator const laend = args.end(); Layout::LaTeXArgMap::const_iterator const laend = args.end();
for (; lait != laend; ++lait) { for (; lait != laend; ++lait) {
Layout::latexarg arg = (*lait).second; Layout::latexarg arg = (*lait).second;
QString item = toqstr(translateIfPossible(arg.labelstring)); docstring str = arg.menustring.empty()? arg.labelstring : arg.menustring;
QString item = toqstr(translateIfPossible(str));
if (switcharg) if (switcharg)
add(MenuItem(MenuItem::Command, item, add(MenuItem(MenuItem::Command, item,
FuncRequest(LFUN_INSET_MODIFY, FuncRequest(LFUN_INSET_MODIFY,

View File

@ -528,6 +528,9 @@ void InsetLayout::readArgument(Lexer & lex)
} else if (tok == "labelstring") { } else if (tok == "labelstring") {
lex.next(); lex.next();
arg.labelstring = lex.getDocString(); arg.labelstring = lex.getDocString();
} else if (tok == "menustring") {
lex.next();
arg.menustring = lex.getDocString();
} else if (tok == "mandatory") { } else if (tok == "mandatory") {
lex.next(); lex.next();
arg.mandatory = lex.getBool(); arg.mandatory = lex.getBool();