diff --git a/lib/layouts/IEEEtran.layout b/lib/layouts/IEEEtran.layout index 714e9be0e8..d17aa0bcd1 100644 --- a/lib/layouts/IEEEtran.layout +++ b/lib/layouts/IEEEtran.layout @@ -68,7 +68,7 @@ Style Title LatexName title Category FrontMatter InTitle 1 - OptionalArgs 0 + ResetArgs 1 ParSkip 0.4 ItemSep 0 TopSep 0 @@ -117,7 +117,11 @@ Style Author LatexType Command Category FrontMatter InTitle 1 - OptionalArgs 1 + Argument 1 + LabelString "Short Author" + Shortcut S + Tooltip "A Short version of the author name" + EndArgument LatexName author LabelSep xxx ParSkip 0.4 @@ -236,7 +240,10 @@ Style Appendix CopyStyle Appendices LatexName appendix LabelString "Appendix" - OptionalArgs 1 + Argument 1 + LabelString "Appendix Title" + Tooltip "Optional title of the appendix" + EndArgument End @@ -268,7 +275,10 @@ Style Biography LaTeXType Environment LaTeXName IEEEbiography Category BackMatter - OptionalArgs 1 + Argument 1 + LabelString "Biography Photo" + Tooltip "Insert a photo to your biography" + EndArgument Align Block TextFont Size Small @@ -279,7 +289,7 @@ End Style Biography_without_photo CopyStyle Biography LaTeXName IEEEbiographynophoto - OptionalArgs 0 + ResetArgs 1 End Style BiographyNoPhoto @@ -293,7 +303,10 @@ Style Proof LatexType Environment LatexName IEEEproof NextNoIndent 1 - OptionalArgs 1 + Argument 1 + LabelString "Alternative Proof String" + Tooltip "An alternative proof string" + EndArgument LabelSep xx ParIndent MMM ParSkip 0.4 diff --git a/lib/layouts/aastex.layout b/lib/layouts/aastex.layout index ac5e921c11..347877016e 100644 --- a/lib/layouts/aastex.layout +++ b/lib/layouts/aastex.layout @@ -619,7 +619,11 @@ Style FigCaption AlignPossible Block, Left LabelType Static LabelString "Fig. ---" - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Caption as it appears in the List of Figures" + EndArgument End # Facility style definition @@ -662,7 +666,10 @@ Style Objectname LabelType Static LabelSep M LabelString "Obj:" - OptionalArgs 1 + Argument 1 + LabelString "Recognized Name" + Tooltip "Separate the recognized name of an object from text" + EndArgument Font Family Roman Shape Up @@ -689,7 +696,10 @@ Style Dataset LabelType Static LabelSep M LabelString "Dataset:" - OptionalArgs 1 + Argument 1 + LabelString "Recognized Name" + Tooltip "Separate the dataset ID from text" + EndArgument Font Family Roman Shape Up diff --git a/lib/layouts/achemso.layout b/lib/layouts/achemso.layout index 4c3247f5c6..25b2f1a9e7 100644 --- a/lib/layouts/achemso.layout +++ b/lib/layouts/achemso.layout @@ -72,7 +72,11 @@ Style Title EndFont HTMLTag h1 HTMLTitle true - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "Short Title which appears in the running headers" + EndArgument End Style Author @@ -95,7 +99,11 @@ End Style Affiliation CopyStyle Author LatexName affiliation - OptionalArgs 1 + Argument 1 + LabelString "Short Affiliation" + Shortcut S + Tooltip "Short version of the affiliation" + EndArgument End Style Alt_Affiliation diff --git a/lib/layouts/aguplus.inc b/lib/layouts/aguplus.inc index 09640606b3..e709c02135 100644 --- a/lib/layouts/aguplus.inc +++ b/lib/layouts/aguplus.inc @@ -73,7 +73,7 @@ Style Paragraph* Margin Static LatexName subsubsubsection* LabelType No_Label - OptionalArgs 0 + ResetArgs 1 End diff --git a/lib/layouts/amsart.layout b/lib/layouts/amsart.layout index fc97f733af..fedc52cfb2 100644 --- a/lib/layouts/amsart.layout +++ b/lib/layouts/amsart.layout @@ -98,7 +98,7 @@ Style SpecialSection* Margin Static LabelType No_Label LabelCounter "" - OptionalArgs 0 + ResetArgs 1 End diff --git a/lib/layouts/amsdefs.inc b/lib/layouts/amsdefs.inc index c0b299461f..b3c1a880b8 100644 --- a/lib/layouts/amsdefs.inc +++ b/lib/layouts/amsdefs.inc @@ -34,7 +34,11 @@ Style Title ParSep 1 Align Center LabelType No_Label - OptionalArgs 1 + Argument shorttitle + LabelString "Short Title" + Shortcut S + Tooltip "Short Title which appears in the running headers" + EndArgument Font Shape Smallcaps Series Bold diff --git a/lib/layouts/apa.layout b/lib/layouts/apa.layout index 3e84ac0f66..76c24f5378 100644 --- a/lib/layouts/apa.layout +++ b/lib/layouts/apa.layout @@ -244,7 +244,11 @@ Style CenteredCaption Align Center LabelType Sensitive LabelString "Senseless!" - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Caption as it appears in the List of Figures/Tables" + EndArgument LabelFont Series Bold EndFont diff --git a/lib/layouts/beamer.layout b/lib/layouts/beamer.layout index 3ac4aae311..e95fc2c29b 100644 --- a/lib/layouts/beamer.layout +++ b/lib/layouts/beamer.layout @@ -51,7 +51,11 @@ Style Itemize Margin Static LatexType Item_Environment LatexName itemize - OptionalArgs 1 + Argument 1 + LabelString "Overlay Specifications" + Shortcut S + Tooltip "Overlay Specifications for this List" + EndArgument NextNoIndent 1 LeftMargin MMN LabelSep xx @@ -69,7 +73,15 @@ Style Enumerate Margin Static LatexType Item_Environment LatexName enumerate - OptionalArgs 2 + Argument 1 + LabelString "Overlay Specifications" + Shortcut S + Tooltip "Overlay Specifications for this List" + EndArgument + Argument 2 + LabelString "Mini template" + Tooltip "Mini template for this List" + EndArgument NextNoIndent 1 LeftMargin MMN LabelSep xx @@ -89,7 +101,15 @@ Style Description Margin First_Dynamic LatexType Item_environment LatexName description - OptionalArgs 2 + Argument 1 + LabelString "Overlay Specifications" + Shortcut S + Tooltip "Overlay Specifications for this List" + EndArgument + Argument 2 + LabelString "Longest label" + Tooltip "The longest label in this List" + EndArgument NextNoIndent 1 LeftMargin MM LabelSep xx @@ -112,7 +132,11 @@ Style Part Margin Dynamic LatexType Command LatexName part - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "Short title for TOC and running headers" + EndArgument NeedProtect 1 NextNoIndent 1 Labelsep xx @@ -155,8 +179,12 @@ Style Section LabelType Counter LabelCounter section LabelString "Section \arabic{section}" - RefPrefix sec - OptionalArgs 1 + RefPrefix sec + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "Short title for TOC and running headers" + EndArgument Font Family Roman @@ -178,7 +206,7 @@ Style Section* Margin Static LatexName lyxframeend{}\section* LabelType No_Label - OptionalArgs 0 + ResetArgs 1 End # Subsection style definition @@ -199,7 +227,11 @@ Style Subsection LabelCounter subsection LabelString "Subsection \arabic{section}.\arabic{subsection}" RefPrefix sub - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "Short title for TOC and running headers" + EndArgument # standard font definition Font @@ -222,7 +254,7 @@ Style Subsection* Margin Static LatexName lyxframeend{}\subsection* LabelType No_Label - OptionalArgs 0 + ResetArgs 1 End # Subsubsection style definition @@ -243,7 +275,11 @@ Style Subsubsection LabelCounter subsubsection LabelString "Subsubsection \arabic{section}.\arabic{subsection}.\arabic{subsubsection}" RefPrefix sub - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "Short title for TOC and running headers" + EndArgument # standard font definition Font @@ -266,7 +302,7 @@ Style Subsubsection* Margin Static LatexName lyxframeend{}\subsubsection* LabelType No_Label - OptionalArgs 0 + ResetArgs 1 End # Frame control definition @@ -276,7 +312,10 @@ Style BeginFrame KeepEmpty 1 LatexType Command LatexName lyxframeend{}\lyxframe - OptionalArgs 1 + Argument 1 + LabelString "Frame Options" + Tooltip "Frame options (see beamer manual)" + EndArgument Margin First_Dynamic NextNoIndent 1 ParSkip 0 @@ -355,7 +394,15 @@ Style AgainFrame KeepEmpty 0 LatexType Command LatexName lyxframeend{}\lyxagainframe - OptionalArgs 2 + Argument 1 + LabelString "Overlay Specifications" + Shortcut S + Tooltip "Overlay Specifications for this List" + EndArgument + Argument 2 + LabelString "Frame Options" + Tooltip "Frame options (see beamer manual)" + EndArgument Margin First_Dynamic NextNoIndent 1 ParSkip 0 @@ -430,7 +477,6 @@ Style FrameSubtitle ParSep 1 Align Center LabelType No_Label - OptionalArgs 1 # standard font definition Font @@ -455,7 +501,10 @@ Style Column LabelType Static LabelSep xx LabelString "Start column (increase depth!), width:" - OptionalArgs 1 + Argument 1 + LabelString "Column Options" + Tooltip "Column options (see beamer manual)" + EndArgument LeftMargin "Start column (increase depth!), width:xx" # standard font definition @@ -564,7 +613,10 @@ Style Pause LatexType Command LatexName pause Margin First_Dynamic - OptionalArgs 1 + Argument 1 + LabelString "Pause number" + Tooltip "Number of slide where the pause takes effect" + EndArgument NextNoIndent 1 ParSkip 0 TopSep 0 @@ -791,7 +843,11 @@ Style Title ParSep 1 Align Center LabelType No_Label - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "Short Title which appears in the sidebar" + EndArgument # standard font definition Font @@ -823,7 +879,11 @@ Style Subtitle ParSep 1 Align Center LabelType No_Label - OptionalArgs 1 + Argument 1 + LabelString "Short Subtitle" + Shortcut S + Tooltip "Short Subtitle which appears in the sidebar" + EndArgument # standard font definition Font @@ -847,7 +907,11 @@ Style Author ParSep 0.7 Align Center LabelType No_Label - OptionalArgs 1 + Argument 1 + LabelString "Short Author" + Shortcut S + Tooltip "Short Author which appears in the sidebar" + EndArgument # standard font definition Font @@ -869,7 +933,11 @@ Style Institute ParSep 1 Align Center LabelType No_Label - OptionalArgs 1 + Argument 1 + LabelString "Short Institute" + Shortcut S + Tooltip "Short Institute which appears in the sidebar" + EndArgument # standard font definition Font @@ -912,7 +980,11 @@ Style Date ParSep 1 Align Center LabelType No_Label - OptionalArgs 1 + Argument 1 + LabelString "Short Date" + Shortcut S + Tooltip "Short Date which appears in the sidebar" + EndArgument # standard font definition Font @@ -1180,7 +1252,6 @@ Style NoteItem LabelType Static LabelSep xx LabelString "Note:" - OptionalArgs 1 LeftMargin "Note:xx" # standard font definition diff --git a/lib/layouts/bicaption.module b/lib/layouts/bicaption.module index 3796ab9d3b..c21d5a5086 100644 --- a/lib/layouts/bicaption.module +++ b/lib/layouts/bicaption.module @@ -11,7 +11,11 @@ Style "Caption setup" LatexType command LatexName captionsetup Category FrontMatter - OptionalArgs 1 + Argument options + LabelString "Caption Setup Options" + Shortcut S + Tooltip "Options for the caption setup command (see bicaption manual)" + EndArgument Margin Dynamic LabelSep xx ParSkip 0.0 @@ -35,7 +39,12 @@ Style Bicaption CopyStyle "Caption setup" LatexName bicaption Category MainText - RequiredArgs 1 + Argument options + Mandatory 1 + LabelString "Second language caption text" + Shortcut S + Tooltip "The caption text in the second language" + EndArgument TopSep 0 Align Center AlignPossible Center diff --git a/lib/layouts/customHeadersFooters.module b/lib/layouts/customHeadersFooters.module index 17c3344925..e85d06f845 100644 --- a/lib/layouts/customHeadersFooters.module +++ b/lib/layouts/customHeadersFooters.module @@ -16,7 +16,10 @@ Style "Left Header" LabelSep xx LatexName lhead LabelString "Left Header:" - OptionalArgs 1 + Argument even + LabelString "Even Header" + Tooltip "Alternative text for the even header" + EndArgument KeepEmpty 1 ParSkip 0 TopSep 0 diff --git a/lib/layouts/db_stdstarsections.inc b/lib/layouts/db_stdstarsections.inc index 3b01e9317e..fcdfdea875 100644 --- a/lib/layouts/db_stdstarsections.inc +++ b/lib/layouts/db_stdstarsections.inc @@ -28,7 +28,7 @@ Style Chapter* InnerTag "!-- --" LatexName bridgehead LabelType No_Label - OptionalArgs 0 + ResetArgs 1 LatexParam renderas="chapter" End @@ -40,7 +40,7 @@ Style Section* LatexType Paragraph InnerTag "!-- --" LabelType No_Label - OptionalArgs 0 + ResetArgs 1 LatexParam renderas="sect1" End @@ -52,7 +52,7 @@ Style Subsection* LatexType Paragraph InnerTag "!-- --" LabelType No_Label - OptionalArgs 0 + ResetArgs 1 LatexParam renderas="sect2" End @@ -76,7 +76,7 @@ Style Paragraph* LatexType Paragraph InnerTag "!-- --" LabelType No_Label - OptionalArgs 0 + ResetArgs 1 LatexParam renderas="sect4" End @@ -88,6 +88,6 @@ Style Subparagraph* LatexType Paragraph InnerTag "!-- --" LabelType No_Label - OptionalArgs 0 + ResetArgs 1 LatexParam renderas="sect5" End diff --git a/lib/layouts/dinbrief.layout b/lib/layouts/dinbrief.layout index c6825bf902..15f0e74787 100644 --- a/lib/layouts/dinbrief.layout +++ b/lib/layouts/dinbrief.layout @@ -193,7 +193,11 @@ Style Closing CopyStyle Opening LabelString "Closing:" LatexName closing - OptionalArgs 1 + Argument 1 + LabelString "Signature" + Shortcut S + Tooltip "Here you can insert a signature scan" + EndArgument KeepEmpty 1 End diff --git a/lib/layouts/ectaart.layout b/lib/layouts/ectaart.layout index 58994804ae..5daa68cece 100644 --- a/lib/layouts/ectaart.layout +++ b/lib/layouts/ectaart.layout @@ -63,7 +63,10 @@ End Style Address CopyStyle RunTitle LatexName address - OptionalArgs 1 + Argument 1 + LabelString "Address Option" + Tooltip "Optional argument for the address" + EndArgument LabelString "Address:" End @@ -71,7 +74,10 @@ Style Email Category FrontMatter LatexType Command LatexName lyxead - OptionalArgs 1 + Argument 1 + LabelString "E-Mail Option" + Tooltip "Optional argument for the E-Mail" + EndArgument InTitle 1 Margin First_Dynamic LabelType Static diff --git a/lib/layouts/elsart.layout b/lib/layouts/elsart.layout index dcf8b9b011..8baa75b768 100644 --- a/lib/layouts/elsart.layout +++ b/lib/layouts/elsart.layout @@ -122,7 +122,10 @@ Style Author ItemSep 0 ParSep 0 Align Center - OptionalArgs 1 + Argument 1 + LabelString "Author Option" + Tooltip "Optional argument for the author" + EndArgument Font Series Bold EndFont @@ -138,7 +141,10 @@ Style Author_Address Labeltype Static LabelSep M LabelString "Address:" - OptionalArgs 1 + Argument 1 + LabelString "Address Option" + Tooltip "Optional argument for the address" + EndArgument LabelFont Shape Italic EndFont @@ -194,7 +200,10 @@ Style Thanks LatexType Command LatexName thanks InTitle 1 - OptionalArgs 1 + Argument 1 + LabelString "Thanks Option" + Tooltip "Optional argument for the Thanks statement" + EndArgument Font Size Small Family Typewriter diff --git a/lib/layouts/elsarticle.layout b/lib/layouts/elsarticle.layout index 0b1ca9a5a1..60ff637954 100644 --- a/lib/layouts/elsarticle.layout +++ b/lib/layouts/elsarticle.layout @@ -84,7 +84,7 @@ Style Title LatexName title Category FrontMatter InTitle 0 - OptionalArgs 0 + ResetArgs 1 ParSkip 0.4 ItemSep 0 TopSep 0 @@ -127,7 +127,10 @@ Style "Title footnote" LatexName tnotetext Category FrontMatter InTitle 0 - OptionalArgs 1 + Argument 1 + LabelString "Footnote Option" + Tooltip "Optional argument for the footnote" + EndArgument ParSkip 0.4 BottomSep 0.5 Align Left @@ -146,7 +149,10 @@ Style Author LatexType Command Category FrontMatter InTitle 0 - OptionalArgs 1 + Argument 1 + LabelString "Author Option" + Tooltip "Optional argument for the author" + EndArgument LatexName author LabelSep xxx ParSkip 0.4 @@ -225,7 +231,10 @@ Style Address Category FrontMatter LatexName address InTitle 0 - OptionalArgs 1 + Argument 1 + LabelString "Address Option" + Tooltip "Optional argument for the address" + EndArgument ParSkip 0.4 Align Center AlignPossible Left, Right diff --git a/lib/layouts/enumitem.module b/lib/layouts/enumitem.module index bd70fae7ea..e3433a5aad 100644 --- a/lib/layouts/enumitem.module +++ b/lib/layouts/enumitem.module @@ -53,15 +53,24 @@ EndPreamble # argument. See enumitem.pdf_ for possible values. IfStyle Itemize - OptionalArgs 1 + Argument option + LabelString "Itemize Options" + Tooltip "Optional arguments for this list (see enumitem manual)" + EndArgument End IfStyle Enumerate - OptionalArgs 1 + Argument option + LabelString "Enumerate Options" + Tooltip "Optional arguments for this list (see enumitem manual)" + EndArgument End IfStyle Description - OptionalArgs 1 + Argument option + LabelString "Description Options" + Tooltip "Optional arguments for this list (see enumitem manual)" + EndArgument End @@ -93,7 +102,7 @@ End Style Enumerate-Resume CopyStyle Enumerate LatexParam [resume] - OptionalArgs 0 + ResetArgs 1 # a blue label to indicate that this is not a WYSIWYG label # because the numbering differs in the output LabelFont diff --git a/lib/layouts/europecv.layout b/lib/layouts/europecv.layout index 21d0e278ac..4789789359 100644 --- a/lib/layouts/europecv.layout +++ b/lib/layouts/europecv.layout @@ -33,7 +33,11 @@ Style Section LatexName ecvsection NeedProtect 1 NextNoIndent 1 - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Title as it appears in the header" + EndArgument ParSkip 0.4 TopSep 1.3 BottomSep 0.7 @@ -52,7 +56,11 @@ Style Item Margin Dynamic LatexType Command LatexName ecvitem - OptionalArgs 1 + Argument 1 + LabelString "Vertical Space (Item)" + Shortcut S + Tooltip "Adjust the vertical space of this item" + EndArgument ParSkip 0.4 Align Block LabelSep xx @@ -98,7 +106,11 @@ Style MotherTongue Margin Dynamic LatexType Command LatexName ecvmothertongue - OptionalArgs 1 + Argument 1 + LabelString "Vertical Space (Item)" + Shortcut S + Tooltip "Adjust the vertical space of this item" + EndArgument ParSkip 0.4 Align Block LabelSep xx @@ -113,7 +125,7 @@ End Style LangHeader CopyStyle MotherTongue LatexName ecvlanguageheader - OptionalArgs 0 + ResetArgs 1 LabelString "Language Header:" End @@ -132,7 +144,7 @@ End Style LangFooter CopyStyle MotherTongue LatexName ecvlanguagefooter - OptionalArgs 0 + ResetArgs 1 LabelString "Language Footer:" End diff --git a/lib/layouts/ijmpc.layout b/lib/layouts/ijmpc.layout index 4d324a9008..aa85dbf84d 100644 --- a/lib/layouts/ijmpc.layout +++ b/lib/layouts/ijmpc.layout @@ -103,7 +103,7 @@ Style Title LatexName title Category FrontMatter InTitle 1 - OptionalArgs 0 + ResetArgs 1 ParSkip 0.4 ItemSep 0 TopSep 0 @@ -121,7 +121,10 @@ Style Author LatexType Command Category FrontMatter InTitle 1 - OptionalArgs 1 + Argument 1 + LabelString "Author Option" + Tooltip "Optional argument for author" + EndArgument LatexName author LabelSep xxx ParSkip 0.4 @@ -294,7 +297,10 @@ Style RomanList Margin Static LatexType Item_Environment LatexName romanlist - OptionalArgs 1 + Argument 1 + LabelString "RomanList Option" + Tooltip "Optional argument for RomanList" + EndArgument NextNoIndent 1 LeftMargin MMN LabelSep xx @@ -334,7 +340,7 @@ Style Proof End Style Theorem - OptionalArgs 0 + ResetArgs 1 LabelString "Theorem \thetheorem." #Font #Shape Up diff --git a/lib/layouts/ijmpd.layout b/lib/layouts/ijmpd.layout index 04deab0378..177013e71e 100644 --- a/lib/layouts/ijmpd.layout +++ b/lib/layouts/ijmpd.layout @@ -108,7 +108,7 @@ Style Title LatexName title Category FrontMatter InTitle 1 - OptionalArgs 0 + ResetArgs 1 ParSkip 0.4 ItemSep 0 TopSep 0 @@ -126,7 +126,10 @@ Style Author LatexType Command Category FrontMatter InTitle 1 - OptionalArgs 1 + Argument 1 + LabelString "Author Option" + Tooltip "Optional argument for author" + EndArgument LatexName author LabelSep xxx ParSkip 0.4 @@ -297,7 +300,10 @@ Style RomanList Margin Static LatexType Item_Environment LatexName romanlist - OptionalArgs 1 + Argument 1 + LabelString "RomanList Option" + Tooltip "Optional argument for RomanList" + EndArgument NextNoIndent 1 LeftMargin MMN LabelSep xx @@ -340,7 +346,7 @@ Counter theorem Within section End Style Theorem - OptionalArgs 0 + ResetArgs 1 LabelString "Theorem \thetheorem." Font Shape Up diff --git a/lib/layouts/initials.module b/lib/layouts/initials.module index 8f979c0297..93d98154ad 100644 --- a/lib/layouts/initials.module +++ b/lib/layouts/initials.module @@ -29,8 +29,15 @@ Style Initial Margin First_Dynamic LabelType static LabelString Initial - OptionalArgs 1 - RequiredArgs 1 + Argument option + LabelString "Initial Option" + Tooltip "Optional argument for initial (see lettrine manual)" + EndArgument + Argument inital + Mandatory 1 + LabelString "Initial" + Tooltip "Initial letter" + EndArgument LabelSep x ParIndent MMM ParSkip 0.4 diff --git a/lib/layouts/iopart.layout b/lib/layouts/iopart.layout index ba4ea44838..a36b2dd97a 100644 --- a/lib/layouts/iopart.layout +++ b/lib/layouts/iopart.layout @@ -60,7 +60,11 @@ Style Title LatexName title Category FrontMatter InTitle 1 - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Title as it appears in the running headers" + EndArgument ParSkip 0.4 ItemSep 0 TopSep 0 @@ -119,7 +123,7 @@ End Style Letter CopyStyle Title - OptionalArgs 0 + ResetArgs 1 LatexName letter End diff --git a/lib/layouts/jasatex.layout b/lib/layouts/jasatex.layout index 58a81f3189..b73c72f45b 100644 --- a/lib/layouts/jasatex.layout +++ b/lib/layouts/jasatex.layout @@ -116,7 +116,10 @@ Style "Alternative Affiliation" CopyStyle Affiliation LatexType Command LatexName altaffiliation - OptionalArgs 1 + Argument 1 + LabelString "Alternative Affiliation Option" + Tooltip "Option to the Alternative Affiliation command" + EndArgument End diff --git a/lib/layouts/memoir.layout b/lib/layouts/memoir.layout index af04f6713b..1fdb6c14e4 100644 --- a/lib/layouts/memoir.layout +++ b/lib/layouts/memoir.layout @@ -51,49 +51,111 @@ Input numreport.inc Style Part - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Part as it appears in the TOC" + EndArgument TocLevel -1 End Style Chapter - OptionalArgs 2 + Argument 1 + LabelString "Short Title (TOC)" + Shortcut S + Tooltip "The Part as it appears in the TOC" + EndArgument + Argument 2 + LabelString "Short Title (Header)" + Tooltip "The Part as it appears in the Header" + Requires shorttitle + EndArgument TocLevel 0 End Style Chapter* - OptionalArgs 1 + Argument 1 + LabelString "Short Title (TOC)" + Shortcut S + Tooltip "The Part as it appears in the TOC" + EndArgument End Style Section - OptionalArgs 2 + Argument 1 + LabelString "Short Title (TOC)" + Shortcut S + Tooltip "The Part as it appears in the TOC" + EndArgument + Argument 2 + LabelString "Short Title (Header)" + Tooltip "The Part as it appears in the Header" + Requires shorttitle + EndArgument TocLevel 1 End Style Subsection - OptionalArgs 2 + Argument 1 + LabelString "Short Title (TOC)" + Shortcut S + Tooltip "The Part as it appears in the TOC" + EndArgument + Argument 2 + LabelString "Short Title (Header)" + Tooltip "The Part as it appears in the Header" + Requires shorttitle + EndArgument TocLevel 2 End Style Subsubsection - OptionalArgs 2 + Argument 1 + LabelString "Short Title (TOC)" + Shortcut S + Tooltip "The Part as it appears in the TOC" + EndArgument + Argument 2 + LabelString "Short Title (Header)" + Tooltip "The Part as it appears in the Header" + Requires shorttitle + EndArgument TocLevel 3 End Style Paragraph - OptionalArgs 2 + Argument 1 + LabelString "Short Title (TOC)" + Shortcut S + Tooltip "The Part as it appears in the TOC" + EndArgument + Argument 2 + LabelString "Short Title (Header)" + Tooltip "The Part as it appears in the Header" + Requires shorttitle + EndArgument TocLevel 4 End Style Subparagraph - OptionalArgs 2 + Argument 1 + LabelString "Short Title (TOC)" + Shortcut S + Tooltip "The Part as it appears in the TOC" + EndArgument + Argument 2 + LabelString "Short Title (Header)" + Tooltip "The Part as it appears in the Header" + Requires shorttitle + EndArgument TocLevel 5 End @@ -129,12 +191,10 @@ Style Epigraph Align Left End -#FIXME: what is actually documented is \PoemTitle -#but \poemtitle is defined nevertheless. Weird. Style Poemtitle Category Section LatexType Command - LatexName poemtitle + LatexName PoemTitle NeedProtect 1 NextNoIndent 1 LabelSep xxx @@ -142,7 +202,16 @@ Style Poemtitle TopSep 0.4 ParSep 0.4 Align center - OptionalArgs 1 + Argument 1 + LabelString "Short Title (TOC)" + Shortcut S + Tooltip "The Part as it appears in the TOC" + EndArgument + Argument 2 + LabelString "Short Title (Header)" + Tooltip "The Part as it appears in the Header" + Requires shorttitle + EndArgument Font Series Bold EndFont @@ -152,8 +221,12 @@ End Style Poemtitle* CopyStyle Poemtitle Category Unnumbered - LatexName poemtitle* - OptionalArgs 0 + LatexName PoemTitle* + Argument 1 + LabelString "Short Title (TOC)" + Shortcut S + Tooltip "The Part as it appears in the TOC" + EndArgument End diff --git a/lib/layouts/moderncv.layout b/lib/layouts/moderncv.layout index e0e091fb11..66e1eee2c4 100644 --- a/lib/layouts/moderncv.layout +++ b/lib/layouts/moderncv.layout @@ -68,7 +68,10 @@ Style Entry Margin Dynamic LatexType Command LatexName cventry - OptionalArgs 1 + Argument 1 + LabelString "Entry Option" + Tooltip "Optional Argument to the cventry command" + EndArgument ParSkip 0.4 Align Block LabelSep xx @@ -84,7 +87,10 @@ Style Item Margin Dynamic LatexType Command LatexName cvitem - OptionalArgs 1 + Argument 1 + LabelString "Item Option" + Tooltip "Optional Argument to the cvitem command" + EndArgument ParSkip 0.4 Align Block LabelSep xx diff --git a/lib/layouts/powerdot.layout b/lib/layouts/powerdot.layout index 31a8141985..5897ffafb2 100644 --- a/lib/layouts/powerdot.layout +++ b/lib/layouts/powerdot.layout @@ -131,7 +131,10 @@ Style Slide LabelType Counter LabelCounter subsection LabelString " " - OptionalArgs 1 + Argument 1 + LabelString "Slide Option" + Tooltip "Optional arguments to the slide command (see powerdot manual)" + EndArgument Font Series Bold Size Large @@ -154,7 +157,7 @@ Style EndSlide LabelBottomSep 0 LeftMargin MMMMMMM LabelString "~=~" - OptionalArgs 0 + ResetArgs 1 Font Color None @@ -207,7 +210,7 @@ Style Note LabelString "Note:" LeftMargin MMMMMMM KeepEmpty 1 - OptionalArgs 0 + ResetArgs 1 Font Series Bold Size Large diff --git a/lib/layouts/recipebook.layout b/lib/layouts/recipebook.layout index 7eb5bbee70..202e34140e 100644 --- a/lib/layouts/recipebook.layout +++ b/lib/layouts/recipebook.layout @@ -114,7 +114,10 @@ End Style Ingredients LatexType Command LatexName ingred - OptionalArgs 1 + Argument 1 + LabelString "Ingredients Header" + Tooltip "Ingredients Header" + EndArgument Margin Static LeftMargin Ingredients_for_some:xx LabelSep xx diff --git a/lib/layouts/revtex4-1.layout b/lib/layouts/revtex4-1.layout index 6615179d2c..3c3e57f3b4 100644 --- a/lib/layouts/revtex4-1.layout +++ b/lib/layouts/revtex4-1.layout @@ -99,7 +99,11 @@ Style Affiliation_(alternate) CopyStyle Affiliation LatexName altaffiliation LabelString "Affiliation (alternate):" - OptionalArgs 1 + Argument 1 + LabelString "Alternate Affiliation Option" + Shortcut S + Tooltip "Optional argument to the altaffiliation command" + EndArgument PassThru 1 End @@ -125,7 +129,11 @@ Style Author_Email CopyStyle Affiliation LatexName email LabelString "Electronic Address:" - OptionalArgs 1 + Argument 1 + LabelString "Electronic Address Option" + Shortcut S + Tooltip "Optional argument to the email command" + EndArgument PassThru 1 TextFont Family Typewriter @@ -140,7 +148,11 @@ Style Author_URL CopyStyle Author_Email LatexName homepage LabelString "URL:" - OptionalArgs 1 + Argument 1 + LabelString "Author URL Option" + Shortcut S + Tooltip "Optional argument to the homepage command" + EndArgument PassThru 1 End @@ -201,7 +213,11 @@ End Style Title - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "Short title as it appears in the running headers" + EndArgument Font Series Bold Size Large diff --git a/lib/layouts/revtex4.layout b/lib/layouts/revtex4.layout index d84c973a91..00abcdb99b 100644 --- a/lib/layouts/revtex4.layout +++ b/lib/layouts/revtex4.layout @@ -154,7 +154,11 @@ Style Affiliation_(alternate) PassThru 1 ParbreakIsNewline 1 LatexName altaffiliation - OptionalArgs 1 + Argument 1 + LabelString "Alternate Affiliation Option" + Shortcut S + Tooltip "Optional argument to the altaffiliation command" + EndArgument LabelString "Affiliation (alternate):" End @@ -200,7 +204,11 @@ Style Author_Email PassThru 1 ParbreakIsNewline 1 LatexName email - OptionalArgs 1 + Argument 1 + LabelString "Electronic Address Option" + Shortcut S + Tooltip "Optional argument to the email command" + EndArgument LabelString "Electronic Address:" TextFont Family Typewriter @@ -216,7 +224,11 @@ Style Author_URL PassThru 1 ParbreakIsNewline 1 LatexName homepage - OptionalArgs 1 + Argument 1 + LabelString "Author URL Option" + Shortcut S + Tooltip "Optional argument to the homepage command" + EndArgument LabelString "URL:" End diff --git a/lib/layouts/rsphrase.module b/lib/layouts/rsphrase.module index cf5dfe8bff..9a4fd4ec4f 100644 --- a/lib/layouts/rsphrase.module +++ b/lib/layouts/rsphrase.module @@ -44,7 +44,11 @@ Style "Safety phrase" LatexName rsphrase Category MainText NextNoIndent 1 - OptionalArgs 1 + Argument 1 + LabelString "Safety Phrase Option" + Shortcut S + Tooltip "Optional argument to the rsphrase command" + EndArgument KeepEmpty 1 Margin Dynamic LabelSep xx diff --git a/lib/layouts/scrclass.inc b/lib/layouts/scrclass.inc index 20f10d4739..71fd0c0072 100644 --- a/lib/layouts/scrclass.inc +++ b/lib/layouts/scrclass.inc @@ -110,21 +110,33 @@ Input stdstarsections.inc Style Addpart CopyStyle Part* LatexName addpart - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Part as it will appeasr in the TOC and Headers" + EndArgument End Style Addchap CopyStyle Chapter* LatexName addchap - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Chapter as it will appeasr in the TOC and Headers" + EndArgument End Style Addsec CopyStyle Section* LatexName addsec - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Section as it will appeasr in the TOC and Headers" + EndArgument End @@ -263,7 +275,11 @@ Style Captionabove Align Center LabelType Sensitive LabelString "Senseless!" - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Caption as it appears in the List of Figures/Tables" + EndArgument LabelFont Series Bold EndFont @@ -283,7 +299,11 @@ Style Captionbelow Align Center LabelType Sensitive LabelString "Senseless!" - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Caption as it appears in the List of Figures/Tables" + EndArgument LabelFont Series Bold EndFont @@ -300,7 +320,10 @@ Style Dictum BottomSep 1.5 ParSep 1.5 Align Left - OptionalArgs 1 + Argument 1 + LabelString "Dictum Author" + Tooltip "The author of this dictum" + EndArgument Font Size Normal EndFont diff --git a/lib/layouts/siamltex.layout b/lib/layouts/siamltex.layout index 7b533630d8..88d0a6c263 100644 --- a/lib/layouts/siamltex.layout +++ b/lib/layouts/siamltex.layout @@ -158,7 +158,10 @@ Style Proof LatexType Environment LatexName proof NextNoIndent 1 - OptionalArgs 1 + Argument 1 + LabelString "Alternative Proof String" + Tooltip "An alternative proof string" + EndArgument LabelSep xx ParIndent MMM ParSkip 0.4 @@ -198,7 +201,11 @@ Style Title ParSep 1 Align Center LabelType No_Label - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Title as it appears in the running headers" + EndArgument Font Shape Smallcaps Series Bold diff --git a/lib/layouts/simplecv.layout b/lib/layouts/simplecv.layout index 990b3bc424..d40c3a3e8b 100644 --- a/lib/layouts/simplecv.layout +++ b/lib/layouts/simplecv.layout @@ -45,7 +45,11 @@ Style Section Series Bold EndFont TocLevel 1 - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Section as it appears in the TOC/Headers" + EndArgument End diff --git a/lib/layouts/stdinsets.inc b/lib/layouts/stdinsets.inc index f0e434d6ed..1f4babeb7f 100644 --- a/lib/layouts/stdinsets.inc +++ b/lib/layouts/stdinsets.inc @@ -469,6 +469,11 @@ InsetLayout Info:shortcuts End InsetLayout Caption + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Caption as it appears in the List of Figures/Tables" + EndArgument HTMLStyle div.float-caption { text-align: center; diff --git a/lib/layouts/stdsections.inc b/lib/layouts/stdsections.inc index 613d764104..3c7167d7ee 100644 --- a/lib/layouts/stdsections.inc +++ b/lib/layouts/stdsections.inc @@ -27,7 +27,11 @@ Style Part ParSep 0.8 Align Center Alignpossible Center - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Part as it appears in the TOC" + EndArgument Font Series Bold Size Huge @@ -53,7 +57,11 @@ Style Chapter BottomSep 0.8 ParSep 0.8 Align Block - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Chapter as it appears in the TOC" + EndArgument Font Series Bold Size Huge @@ -78,7 +86,11 @@ Style Section BottomSep 0.7 ParSep 0.7 Align Block - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Section as it appears in the TOC" + EndArgument Font Series Bold Size Larger diff --git a/lib/layouts/stdstarsections.inc b/lib/layouts/stdstarsections.inc index 712cf7f4dd..a196ed03b5 100644 --- a/lib/layouts/stdstarsections.inc +++ b/lib/layouts/stdstarsections.inc @@ -17,7 +17,7 @@ Style Part* LatexName part* LabelType No_Label LabelCounter "" - OptionalArgs 0 + ResetArgs 1 End @@ -28,7 +28,7 @@ Style Chapter* LatexName chapter* LabelType No_Label LabelCounter "" - OptionalArgs 0 + ResetArgs 1 End @@ -39,7 +39,7 @@ Style Section* LatexName section* LabelType No_Label LabelCounter "" - OptionalArgs 0 + ResetArgs 1 End @@ -50,7 +50,7 @@ Style Subsection* LatexName subsection* LabelType No_Label LabelCounter "" - OptionalArgs 0 + ResetArgs 1 End @@ -61,7 +61,7 @@ Style Subsubsection* LatexName subsubsection* LabelType No_Label LabelCounter "" - OptionalArgs 0 + ResetArgs 1 End @@ -72,7 +72,7 @@ Style Paragraph* LatexName paragraph* LabelType No_Label LabelCounter "" - OptionalArgs 0 + ResetArgs 1 End @@ -83,5 +83,5 @@ Style Subparagraph* LatexName subparagraph* LabelType No_Label LabelCounter "" - OptionalArgs 0 + ResetArgs 1 End diff --git a/lib/layouts/svcommon.inc b/lib/layouts/svcommon.inc index 1e7d7fc99d..2eb1cfea7b 100644 --- a/lib/layouts/svcommon.inc +++ b/lib/layouts/svcommon.inc @@ -69,7 +69,7 @@ Style Front_Matter LatexType Command LatexName frontmatter KeepEmpty 1 - OptionalArgs 0 + ResetArgs 1 Margin First_Dynamic NextNoIndent 1 ParSkip 0 @@ -135,7 +135,11 @@ Style PartBacktext Shape Up Size normal EndFont - RequiredArgs 1 + Argument 1 + Mandatory 1 + LabelString "Part Title" + Tooltip "The title of this part" + EndArgument Preamble \newenvironment{svmultpartbacktext}[1]{\begin{partbacktext} \part{#1}}{\end{partbacktext}} @@ -510,7 +514,10 @@ Style Foreword BottomSep 0.8 ParSep 0.8 Align Block - OptionalArgs 1 + Argument 1 + LabelString "Alternative Foreword Heading" + Tooltip "Alternative foreword heading" + EndArgument Font Series Bold Size Huge @@ -586,7 +593,10 @@ Style Bibliography End Style Description - OptionalArgs 1 + Argument 1 + LabelString "Longest Description Label" + Tooltip "Longest description label" + EndArgument LabelFont Series Medium EndFont diff --git a/lib/layouts/theorems-ams-bytype.inc b/lib/layouts/theorems-ams-bytype.inc index 411cf3ca4b..46fb0b9d31 100644 --- a/lib/layouts/theorems-ams-bytype.inc +++ b/lib/layouts/theorems-ams-bytype.inc @@ -53,7 +53,10 @@ Style Theorem LatexType Environment LatexName thm NextNoIndent 1 - OptionalArgs 1 + Argument 1 + LabelString "Alternative Theorem String" + Tooltip "Alternative theorem string" + EndArgument LabelSep xx ParIndent MMM ParSkip 0.4 diff --git a/lib/layouts/theorems-ams.inc b/lib/layouts/theorems-ams.inc index f3af8d6f97..93eebcd4f0 100644 --- a/lib/layouts/theorems-ams.inc +++ b/lib/layouts/theorems-ams.inc @@ -27,7 +27,10 @@ Style Theorem LatexType Environment LatexName thm NextNoIndent 1 - OptionalArgs 1 + Argument 1 + LabelString "Alternative Theorem String" + Tooltip "Alternative theorem string" + EndArgument LabelSep xx ParIndent MMM ParSkip 0.4 diff --git a/lib/layouts/theorems-bytype.inc b/lib/layouts/theorems-bytype.inc index e193992af0..2e5003445c 100644 --- a/lib/layouts/theorems-bytype.inc +++ b/lib/layouts/theorems-bytype.inc @@ -29,7 +29,10 @@ Style Theorem LatexType Environment LatexName thm NextNoIndent 1 - OptionalArgs 1 + Argument 1 + LabelString "Alternative Theorem String" + Tooltip "Alternative theorem string" + EndArgument LabelSep xx ParIndent MMM ParSkip 0.4 diff --git a/lib/layouts/theorems-proof.inc b/lib/layouts/theorems-proof.inc index b722fe3983..bc83fed979 100644 --- a/lib/layouts/theorems-proof.inc +++ b/lib/layouts/theorems-proof.inc @@ -16,7 +16,10 @@ Style Proof LatexType Environment LatexName proof NextNoIndent 1 - OptionalArgs 1 + Argument 1 + LabelString "Alternative Proof String" + Tooltip "Alternative proof string" + EndArgument LabelSep xx ParIndent MMM ParSkip 0.4 diff --git a/lib/layouts/theorems-starred.inc b/lib/layouts/theorems-starred.inc index d275d48b73..c76cdd080b 100644 --- a/lib/layouts/theorems-starred.inc +++ b/lib/layouts/theorems-starred.inc @@ -28,7 +28,10 @@ Style Theorem* LabelType Static LabelString "Theorem." NextNoIndent 1 - OptionalArgs 1 + Argument 1 + LabelString "Alternative Theorem String" + Tooltip "Alternative theorem string" + EndArgument LabelSep xx ParIndent MMM ParSkip 0.4 diff --git a/lib/layouts/theorems-without-preamble.inc b/lib/layouts/theorems-without-preamble.inc index 3ba499e438..5ca15316a8 100644 --- a/lib/layouts/theorems-without-preamble.inc +++ b/lib/layouts/theorems-without-preamble.inc @@ -37,7 +37,10 @@ Style Theorem LatexType Environment LatexName theorem NextNoIndent 1 - OptionalArgs 1 + Argument 1 + LabelString "Alternative Theorem String" + Tooltip "Alternative theorem string" + EndArgument LabelSep xx ParIndent MMM ParSkip 0.4 @@ -243,7 +246,7 @@ Style Prob LabelString "\theprob." RefPrefix pro NextNoIndent 1 - OptionalArgs 0 + ResetArgs 1 LabelSep xx ParIndent MMM ParSkip 0.4 @@ -281,7 +284,11 @@ Style Sol LatexName sol LabelType Static LabelString "# [number of Prob]" - RequiredArgs 1 + Argument 1 + Mandatory 1 + LabelString "Solution" + Tooltip "Mandatory argument to the sol environment" + EndArgument End diff --git a/lib/layouts/theorems.inc b/lib/layouts/theorems.inc index 94bb4fcddd..ab0b47fd1d 100644 --- a/lib/layouts/theorems.inc +++ b/lib/layouts/theorems.inc @@ -27,7 +27,10 @@ Style Theorem LatexType Environment LatexName thm NextNoIndent 1 - OptionalArgs 1 + Argument 1 + LabelString "Alternative Theorem String" + Tooltip "Alternative theorem string" + EndArgument LabelSep xx ParIndent MMM ParSkip 0.4 diff --git a/lib/layouts/tufte-book.layout b/lib/layouts/tufte-book.layout index d712e71573..c6e7581ac4 100644 --- a/lib/layouts/tufte-book.layout +++ b/lib/layouts/tufte-book.layout @@ -76,7 +76,11 @@ Style Chapter ParSep 0.8 Align Block RefPrefix chap - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Chapter as it appears in the TOC/Headers" + EndArgument Font Series Bold Size Huge @@ -100,7 +104,11 @@ Style Section ParSep 0.7 Align Block RefPrefix sec - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Section as it appears in the TOC/Headers" + EndArgument Font Series Bold Size Larger diff --git a/lib/layouts/tufte-handout.layout b/lib/layouts/tufte-handout.layout index ea89f4e2c6..e97061ff3b 100644 --- a/lib/layouts/tufte-handout.layout +++ b/lib/layouts/tufte-handout.layout @@ -36,7 +36,11 @@ Style Part ParSep 0.8 Align Center Alignpossible Center - OptionalArgs 1 + Argument 1 + LabelString "Short Title" + Shortcut S + Tooltip "The Part as it appears in the TOC/Headers" + EndArgument Font Series Bold Size Huge diff --git a/lib/lyx2lyx/lyx_2_1.py b/lib/lyx2lyx/lyx_2_1.py index a4da821742..b22e749fd2 100644 --- a/lib/lyx2lyx/lyx_2_1.py +++ b/lib/lyx2lyx/lyx_2_1.py @@ -1130,6 +1130,31 @@ def revert_uop(document): document.header[i] = "\\font_sans default" +def convert_latexargs(document): + " Convert InsetArgument to new syntax " + + i = 0 + while True: + i = find_token(document.body, "\\begin_inset Argument", i) + if i == -1: + return + # We cannot do more here since we have no access to the layout + # InsetArgument itself will do the real work + document.body[i] = "\\begin_inset Argument 999" + i = i + 1 + + +def revert_latexargs(document): + " Revert InsetArgument to old syntax " + + # What needs to be done is this: + # * find all arguments in a paragraph and reorder them + # according to their name (which is deleted) + # So: \\begin_inset Argument 2 ... \\begin_inset Argument 1 + # => \\begin_inset Argument ... \\begin_inset Argument + # with correct order. + + ## # Conversion hub # @@ -1167,10 +1192,12 @@ convert = [ [442, []], [443, []], [444, []], - [445, []] + [445, []], + [446, [convert_latexargs]] ] revert = [ + [445, [revert_latexargs]], [444, [revert_uop]], [443, [revert_biolinum]], [442, []], diff --git a/lib/ui/stdmenus.inc b/lib/ui/stdmenus.inc index f1fd9e1487..323085d6b1 100644 --- a/lib/ui/stdmenus.inc +++ b/lib/ui/stdmenus.inc @@ -369,7 +369,7 @@ Menuset Item "Hyperlink...|k" "href-insert" Item "Footnote|F" "footnote-insert" Item "Marginal Note|M" "marginalnote-insert" - Item "Short Title|S" "argument-insert" + Arguments Item "TeX Code|X" "ert-insert" Item "Program Listing[[Menu]]" "listing-insert" Item "Date" "date-insert" diff --git a/src/Layout.cpp b/src/Layout.cpp index 97594b706e..1524f9c640 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -40,6 +40,7 @@ const int Layout::NOT_IN_TOC = -1000; enum LayoutTags { LT_ALIGN = 1, LT_ALIGNPOSSIBLE, + LT_ARGUMENT, LT_MARGIN, LT_BOTTOMSEP, LT_CATEGORY, @@ -67,7 +68,6 @@ enum LayoutTags { LT_ENDLABELTYPE, LT_LATEXNAME, LT_LATEXPARAM, - LT_OPTARGS, LT_LATEXTYPE, LT_LEFTMARGIN, LT_NEED_PROTECT, @@ -101,7 +101,7 @@ enum LayoutTags { LT_HTMLTITLE, LT_SPELLCHECK, LT_REFPREFIX, - LT_REQARGS, + LT_RESETARGS, LT_INTITLE // keep this last! }; @@ -143,8 +143,6 @@ Layout::Layout() htmlforcecss_ = false; htmltitle_ = false; spellcheck = true; - optargs = 0; - reqargs = 0; } @@ -154,6 +152,7 @@ bool Layout::read(Lexer & lex, TextClass const & tclass) LexerKeyword layoutTags[] = { { "align", LT_ALIGN }, { "alignpossible", LT_ALIGNPOSSIBLE }, + { "argument", LT_ARGUMENT }, { "babelpreamble", LT_BABELPREAMBLE }, { "bottomsep", LT_BOTTOMSEP }, { "category", LT_CATEGORY }, @@ -201,7 +200,6 @@ bool Layout::read(Lexer & lex, TextClass const & tclass) { "newline", LT_NEWLINE }, { "nextnoindent", LT_NEXTNOINDENT }, { "obsoletedby", LT_OBSOLETEDBY }, - { "optionalargs", LT_OPTARGS }, { "parbreakisnewline", LT_PARBREAK_IS_NEWLINE }, { "parindent", LT_PARINDENT }, { "parsep", LT_PARSEP }, @@ -209,8 +207,8 @@ bool Layout::read(Lexer & lex, TextClass const & tclass) { "passthru", LT_PASS_THRU }, { "preamble", LT_PREAMBLE }, { "refprefix", LT_REFPREFIX }, - { "requiredargs", LT_REQARGS }, { "requires", LT_REQUIRES }, + { "resetargs", LT_RESETARGS }, { "rightmargin", LT_RIGHTMARGIN }, { "spacing", LT_SPACING }, { "spellcheck", LT_SPELLCHECK }, @@ -317,12 +315,15 @@ bool Layout::read(Lexer & lex, TextClass const & tclass) lex >> toclevel; break; - case LT_OPTARGS: - lex >> optargs; + case LT_RESETARGS: + bool reset; + lex >> reset; + if (reset) + latexargs_.clear(); break; - case LT_REQARGS: - lex >> reqargs; + case LT_ARGUMENT: + readArgument(lex); break; case LT_NEED_PROTECT: @@ -858,6 +859,79 @@ void Layout::readSpacing(Lexer & lex) } +void Layout::readArgument(Lexer & lex) +{ + latexarg arg; + arg.mandatory = false; + bool error = false; + bool finished = false; + unsigned int nr; + lex >> nr; + while (!finished && lex.isOK() && !error) { + lex.next(); + string const tok = ascii_lowercase(lex.getString()); + + if (tok.empty()) { + continue; + } else if (tok == "endargument") { + finished = true; + } else if (tok == "labelstring") { + lex.next(); + arg.labelstring = lex.getDocString(); + } else if (tok == "mandatory") { + lex.next(); + arg.mandatory = lex.getBool(); + } else if (tok == "leftdelim") { + lex.next(); + arg.ldelim = lex.getDocString(); + } else if (tok == "rightdelim") { + lex.next(); + arg.rdelim = lex.getDocString(); + } else if (tok == "tooltip") { + lex.next(); + arg.tooltip = lex.getDocString(); + } else if (tok == "shortcut") { + lex.next(); + arg.shortcut = lex.getString(); + } else if (tok == "requires") { + lex.next(); + arg.requires = lex.getString(); + } else { + lex.printError("Unknown tag"); + error = true; + } + } + if (arg.labelstring.empty()) + LYXERR0("Incomplete Argument definition!"); + else + latexargs_[nr] = arg; +} + + +int Layout::optArgs() const +{ + int nr = 0; + LaTeXArgMap::const_iterator it = latexargs_.begin(); + for (; it != latexargs_.end(); ++it) { + if (!(*it).second.mandatory) + ++nr; + } + return nr; +} + + +int Layout::requiredArgs() const +{ + int nr = 0; + LaTeXArgMap::const_iterator it = latexargs_.begin(); + for (; it != latexargs_.end(); ++it) { + if ((*it).second.mandatory) + ++nr; + } + return nr; +} + + string const & Layout::htmltag() const { if (htmltag_.empty()) diff --git a/src/Layout.h b/src/Layout.h index 08c049d8d6..c115c549a8 100644 --- a/src/Layout.h +++ b/src/Layout.h @@ -17,8 +17,10 @@ #include "FontInfo.h" #include "LayoutEnums.h" #include "Spacing.h" +#include "support/debug.h" #include "support/docstring.h" +#include #include #include @@ -72,6 +74,8 @@ public: /// void readSpacing(Lexer &); /// + void readArgument(Lexer &); + /// docstring const & name() const { return name_; } /// void setName(docstring const & n) { name_ = n; } @@ -83,6 +87,24 @@ public: std::string const & latexname() const { return latexname_; } /// void setLatexName(std::string const & n) { latexname_ = n; } + /// The arguments of this layout + struct latexarg { + docstring labelstring; + bool mandatory; + docstring ldelim; + docstring rdelim; + docstring tooltip; + std::string shortcut; + std::string requires; + }; + /// + typedef std::map LaTeXArgMap; + /// + LaTeXArgMap const & latexargs() const { return latexargs_; } + /// + int optArgs() const; + /// + int requiredArgs() const; /// docstring const & labelstring(bool in_appendix) const { return in_appendix ? labelstring_appendix_ : labelstring_; } @@ -238,15 +260,6 @@ public: bool intitle; /// Is the content to go in the preamble rather than the body? bool inpreamble; - /// Number of requried arguments for this command or environment - unsigned int reqargs; - /// Number of optional arguments for this command or environment - /// These MUST come at the beginning, so: - /// \cmd[opt1][opt2]{req1}{here is the text from LyX} - /// is fine. But: - /// \cmd[opt1]{req1}[opt2]{here is the text from LyX} - /// is not. - unsigned int optargs; /// Which counter to step docstring counter; /// Prefix to use when creating labels @@ -374,6 +387,8 @@ private: docstring babelpreamble_; /// Packages needed for this layout std::set requires_; + /// + LaTeXArgMap latexargs_; }; } // namespace lyx diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 7f87d1f79d..47e1e7bf1a 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -319,7 +319,8 @@ void LyXAction::init() /*! * \var lyx::FuncCode lyx::LFUN_ARGUMENT_INSERT * \li Action: Inserts an argument (short title) inset. - * \li Syntax: argument-insert + * \li Syntax: argument-insert + * \li Params: : see layout declarations * \li Origin: vermeer, 12 Aug 2002 * \endvar */ diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 223d2eb53e..8429b015d6 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1461,9 +1461,9 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const // we have to provide all the optional arguments here, even though // the last one is the only one we care about. // Separate handling of optional argument inset. - if (layout_->optargs != 0 || layout_->reqargs != 0) + if (layout_->latexargs().size() != 0) latexArgInsets(*owner_, os, features.runparams(), - layout_->reqargs, layout_->optargs); + layout_->latexargs()); else os << from_ascii(layout_->latexparam()); } diff --git a/src/Text3.cpp b/src/Text3.cpp index ecb5d25764..5260053657 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -51,6 +51,7 @@ #include "frontends/Clipboard.h" #include "frontends/Selection.h" +#include "insets/InsetArgument.h" #include "insets/InsetCollapsable.h" #include "insets/InsetCommand.h" #include "insets/InsetExternal.h" @@ -2516,9 +2517,32 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, break; case LFUN_ARGUMENT_INSERT: { code = ARG_CODE; + string const arg = cmd.getArg(0); + if (arg.empty()) { + enable = false; + break; + } Layout const & lay = cur.paragraph().layout(); - int const numargs = lay.reqargs + lay.optargs; - enable = cur.paragraph().insetList().count(ARG_CODE) < numargs; + Layout::LaTeXArgMap args = lay.latexargs(); + Layout::LaTeXArgMap::const_iterator const lait = + args.find(convert(arg)); + if (lait != args.end()) { + InsetList::const_iterator it = cur.paragraph().insetList().begin(); + InsetList::const_iterator end = cur.paragraph().insetList().end(); + for (; it != end; ++it) { + if (it->inset->lyxCode() == ARG_CODE) { + InsetArgument const * ins = + static_cast(it->inset); + if (ins->name() == arg) { + // we have this already + enable = false; + break; + } + } + } + enable = true; + } else + enable = false; break; } case LFUN_INDEX_INSERT: diff --git a/src/factory.cpp b/src/factory.cpp index e25a263049..b640c6b2ae 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -154,8 +154,14 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd) case LFUN_MARGINALNOTE_INSERT: return new InsetMarginal(buf); - case LFUN_ARGUMENT_INSERT: - return new InsetArgument(buf); + case LFUN_ARGUMENT_INSERT: { + string arg = cmd.getArg(0); + if (arg.empty()) { + LYXERR0("argument-insert needs an argument!"); + return 0; + } + return new InsetArgument(buf, arg); + } case LFUN_FLOAT_INSERT: { string argument = to_utf8(cmd.argument()); @@ -618,7 +624,7 @@ Inset * readInset(Lexer & lex, Buffer * buf) } else if (tmptok == "Newline") { inset.reset(new InsetNewline); } else if (tmptok == "Argument") { - inset.reset(new InsetArgument(buf)); + inset.reset(new InsetArgument(buf, tmptok)); } else if (tmptok == "Float") { inset.reset(new InsetFloat(buf, string())); } else if (tmptok == "Wrap") { diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index 279ccaea3c..3e16879259 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -40,6 +40,7 @@ #include "IndicesList.h" #include "KeyMap.h" #include "Language.h" +#include "Layout.h" #include "Lexer.h" #include "LyXAction.h" #include "LyX.h" @@ -172,7 +173,10 @@ public: /// Words suggested by the spellchecker. SpellingSuggestions, /** Used Languages */ - LanguageSelector + LanguageSelector, + /** This is the list of arguments available + for insertion into the current layout. */ + Arguments }; explicit MenuItem(Kind kind) : kind_(kind), optional_(false) {} @@ -348,6 +352,7 @@ public: void expandGraphicsGroups(BufferView const *); void expandSpellingSuggestions(BufferView const *); void expandLanguageSelector(Buffer const * buf); + void expandArguments(BufferView const *); /// ItemList items_; /// @@ -455,10 +460,12 @@ void MenuDefinition::read(Lexer & lex) md_toolbars, md_graphicsgroups, md_spellingsuggestions, - md_languageselector + md_languageselector, + md_arguments }; LexerKeyword menutags[] = { + { "arguments", md_arguments }, { "bookmarks", md_bookmarks }, { "branches", md_branches }, { "charstyles", md_charstyles }, @@ -616,6 +623,10 @@ void MenuDefinition::read(Lexer & lex) add(MenuItem(MenuItem::IndicesListsContext)); break; + case md_arguments: + add(MenuItem(MenuItem::Arguments)); + break; + case md_optsubmenu: optional = true; // fallback to md_submenu @@ -1527,6 +1538,33 @@ void MenuDefinition::expandCiteStyles(BufferView const * bv) } } + +void MenuDefinition::expandArguments(BufferView const * bv) +{ + if (!bv) + return; + + Inset const * inset = &bv->cursor().inset(); + Layout::LaTeXArgMap args; + if (inset && bv->cursor().paragraph().layout().latexargs().empty()) + args = inset->getLayout().latexargs(); + else + args = bv->cursor().paragraph().layout().latexargs(); + if (args.empty()) + return; + Layout::LaTeXArgMap::const_iterator lait = args.begin(); + Layout::LaTeXArgMap::const_iterator const laend = args.end(); + for (; lait != laend; ++lait) { + Layout::latexarg arg = (*lait).second; + QString item = toqstr(translateIfPossible(arg.labelstring)); + if (!arg.shortcut.empty()) + item += "|" + toqstr(arg.shortcut); + add(MenuItem(MenuItem::Command, item, + FuncRequest(LFUN_ARGUMENT_INSERT, + convert((*lait).first)))); + } +} + } // namespace anon @@ -1670,7 +1708,8 @@ struct Menus::Impl { /// Expands some special entries of the menu /** The entries with the following kind are expanded to a sequence of Command MenuItems: Lastfiles, Documents, - ViewFormats, ExportFormats, UpdateFormats, Branches, Indices + ViewFormats, ExportFormats, UpdateFormats, Branches, + Indices, Arguments */ void expand(MenuDefinition const & frommenu, MenuDefinition & tomenu, BufferView const *) const; @@ -1891,6 +1930,10 @@ void Menus::Impl::expand(MenuDefinition const & frommenu, tomenu.expandLanguageSelector(buf); break; + case MenuItem::Arguments: + tomenu.expandArguments(bv); + break; + case MenuItem::Submenu: { MenuItem item(*cit); item.setSubmenu(MenuDefinition(cit->submenuname())); diff --git a/src/insets/InsetArgument.cpp b/src/insets/InsetArgument.cpp index fb78b227eb..9ca8b9e194 100644 --- a/src/insets/InsetArgument.cpp +++ b/src/insets/InsetArgument.cpp @@ -12,38 +12,120 @@ #include "InsetArgument.h" +#include "InsetList.h" +#include "Layout.h" +#include "Lexer.h" +#include "ParIterator.h" + +#include "support/convert.h" #include "support/debug.h" #include "support/docstream.h" #include "support/gettext.h" +#include "support/lstrings.h" using namespace std; namespace lyx { -InsetArgument::InsetArgument(Buffer * buf) - : InsetCollapsable(buf) +InsetArgument::InsetArgument(Buffer * buf, string const & name) + : InsetCollapsable(buf), name_(name), labelstring_(docstring()) {} void InsetArgument::write(ostream & os) const { - os << "Argument" << "\n"; + os << "Argument " << name_ << "\n"; InsetCollapsable::write(os); } +void InsetArgument::read(Lexer & lex) +{ + lex >> name_; + InsetCollapsable::read(lex); +} + +void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype) +{ + Layout::LaTeXArgMap args; + bool const insetlayout = &it.inset() && it.paragraph().layout().latexargs().empty(); + if (insetlayout) + args = it.inset().getLayout().latexargs(); + else + args = it.paragraph().layout().latexargs(); + + // Handle pre 2.1 ArgInsets (lyx2lyx cannot classify them) + if (name_ == "999") { + int req = insetlayout ? it.inset().getLayout().requiredArgs() + : it.paragraph().layout().requiredArgs(); + int opts = insetlayout ? it.inset().getLayout().optArgs() + : it.paragraph().layout().optArgs(); + int nr = 0; + int ours = 0; + InsetList::const_iterator parit = it.paragraph().insetList().begin(); + InsetList::const_iterator parend = it.paragraph().insetList().end(); + for (; parit != parend; ++parit) { + if (parit->inset->lyxCode() == ARG_CODE) { + ++nr; + if (parit->inset == this) + ours = nr; + } + } + bool done = false; + int realopts = 0; + if (nr > req) { + // We have optional arguments + realopts = nr - req; + if (ours <= realopts) { + name_ = convert(ours); + done = true; + } + } + if (!done) { + // This is a mandatory argument. We have to consider + // non-given optional arguments for the numbering + int offset = opts - realopts; + ours += offset; + name_ = convert(ours); + } + } + Layout::LaTeXArgMap::const_iterator const lait = + args.find(convert(name_)); + if (lait != args.end()) { + labelstring_ = translateIfPossible((*lait).second.labelstring); + tooltip_ = translateIfPossible((*lait).second.tooltip); + } else { + labelstring_ = _("Unknown Argument"); + tooltip_ = _("Argument not known in this Layout. Will be supressed in the output."); + } + setButtonLabel(); + InsetCollapsable::updateBuffer(it, utype); +} + +void InsetArgument::setButtonLabel() +{ + setLabel(labelstring_); +} + +docstring InsetArgument::toolTip(BufferView const & bv, int, int) const +{ + if (isOpen(bv)) + return tooltip_; + return toolTipText(tooltip_ + from_ascii(":\n")); +} + void InsetArgument::latexArgument(otexstream & os, - OutputParams const & runparams, bool optional) const + OutputParams const & runparams, docstring const & ldelim, + docstring const & rdelim) const { TexRow texrow; odocstringstream ss; otexstream ots(ss, texrow); InsetText::latex(ots, runparams); docstring str = ss.str(); - if (optional && str.find(']') != docstring::npos) + if (ldelim != "{" && support::contains(str, rdelim)) str = '{' + str + '}'; - os << (optional ? '[' : '{') << str - << (optional ? ']' : '}'); + os << ldelim << str << rdelim; } diff --git a/src/insets/InsetArgument.h b/src/insets/InsetArgument.h index 37805ce335..e3718b1b97 100644 --- a/src/insets/InsetArgument.h +++ b/src/insets/InsetArgument.h @@ -9,8 +9,8 @@ * Full author contact details are available in file CREDITS. */ -#ifndef INSETOPTARG_H -#define INSETOPTARG_H +#ifndef INSETARGUMENT_H +#define INSETARGUMENT_H #include "InsetCollapsable.h" @@ -27,11 +27,13 @@ class InsetArgument : public InsetCollapsable { public: /// - InsetArgument(Buffer *); + InsetArgument(Buffer *, std::string const &); /// Outputting the parameter of a LaTeX command void latexArgument(otexstream &, OutputParams const &, - bool optional) const; + docstring const&, docstring const &) const; + + std::string name() const { return name_; } /// \name Public functions inherited from Inset class //@{ @@ -41,6 +43,8 @@ public: InsetCode lyxCode() const { return ARG_CODE; } /// docstring layoutName() const { return from_ascii("Argument"); } + /// Update the label string of this inset + void updateBuffer(ParIterator const &, UpdateType); /// void latex(otexstream &, OutputParams const &) const { } /// @@ -49,12 +53,29 @@ public: int docbook(odocstream &, OutputParams const &) const { return 0; } /// docstring xhtml(XHTMLStream &, OutputParams const &) const - { return docstring(); }; + { return docstring(); } /// void write(std::ostream & os) const; /// + void read(Lexer & lex); + /// bool neverIndent() const { return true; } //@} + /// \name Public functions inherited from InsetCollapsable class + //@{ + /// + void setButtonLabel(); + //@} + +private: + /// + docstring toolTip(BufferView const & bv, int, int) const; + /// + std::string name_; + /// + docstring labelstring_; + /// + docstring tooltip_; protected: /// \name Protected functions inherited from Inset class @@ -67,4 +88,4 @@ protected: } // namespace lyx -#endif // INSETOPTARG_H +#endif // INSETARGUMENT_H diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp index b1c4e08d1a..a637d90e5a 100644 --- a/src/insets/InsetCaption.cpp +++ b/src/insets/InsetCaption.cpp @@ -201,10 +201,6 @@ bool InsetCaption::getStatus(Cursor & cur, FuncRequest const & cmd, status.setEnabled(false); return true; - case LFUN_ARGUMENT_INSERT: - status.setEnabled(cur.paragraph().insetList().find(ARG_CODE) == -1); - return true; - case LFUN_INSET_TOGGLE: // pass back to owner cur.undispatched(); @@ -232,7 +228,7 @@ void InsetCaption::latex(otexstream & os, // optional argument. runparams.moving_arg = true; os << "\\caption"; - latexArgInsets(paragraphs()[0], os, runparams, 0, 1); + getOptArg(os, runparams); os << '{'; InsetText::latex(os, runparams); os << "}\n"; @@ -287,7 +283,7 @@ void InsetCaption::getArgument(otexstream & os, void InsetCaption::getOptArg(otexstream & os, OutputParams const & runparams) const { - latexArgInsets(paragraphs()[0], os, runparams, 0, 1); + latexArgInsets(paragraphs()[0], os, runparams, getLayout().latexargs()); } diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp index f92a5e6ab7..8c34f0769c 100644 --- a/src/insets/InsetLayout.cpp +++ b/src/insets/InsetLayout.cpp @@ -15,6 +15,7 @@ #include "InsetLayout.h" #include "ColorSet.h" +#include "Layout.h" #include "Lexer.h" #include "TextClass.h" @@ -76,6 +77,7 @@ InsetLayout::InsetLaTeXType translateLaTeXType(std::string const & str) bool InsetLayout::read(Lexer & lex, TextClass const & tclass) { enum { + IL_ARGUMENT, IL_BABELPREAMBLE, IL_BGCOLOR, IL_CONTENTASLABEL, @@ -120,6 +122,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) LexerKeyword elementTags[] = { + { "argument", IL_ARGUMENT }, { "babelpreamble", IL_BABELPREAMBLE }, { "bgcolor", IL_BGCOLOR }, { "contentaslabel", IL_CONTENTASLABEL }, @@ -309,6 +312,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) labelfont_ = font_; break; } + case IL_ARGUMENT: + readArgument(lex); + break; case IL_BGCOLOR: lex >> tmp; bgcolor_ = lcolor.getFromLyXName(tmp); @@ -474,5 +480,76 @@ docstring InsetLayout::htmlstyle() const return retval; } +void InsetLayout::readArgument(Lexer & lex) +{ + Layout::latexarg arg; + arg.mandatory = false; + bool error = false; + bool finished = false; + unsigned int nr; + lex >> nr; + while (!finished && lex.isOK() && !error) { + lex.next(); + string const tok = support::ascii_lowercase(lex.getString()); + + if (tok.empty()) { + continue; + } else if (tok == "endargument") { + finished = true; + } else if (tok == "labelstring") { + lex.next(); + arg.labelstring = lex.getDocString(); + } else if (tok == "mandatory") { + lex.next(); + arg.mandatory = lex.getBool(); + } else if (tok == "leftdelim") { + lex.next(); + arg.ldelim = lex.getDocString(); + } else if (tok == "rightdelim") { + lex.next(); + arg.rdelim = lex.getDocString(); + } else if (tok == "tooltip") { + lex.next(); + arg.tooltip = lex.getDocString(); + } else if (tok == "shortcut") { + lex.next(); + arg.shortcut = lex.getString(); + } else if (tok == "requires") { + lex.next(); + arg.requires = lex.getString(); + } else { + lex.printError("Unknown tag"); + error = true; + } + } + if (arg.labelstring.empty()) + LYXERR0("Incomplete Argument definition!"); + else + latexargs_[nr] = arg; +} + +int InsetLayout::optArgs() const +{ + int nr = 0; + Layout::LaTeXArgMap::const_iterator it = latexargs_.begin(); + for (; it != latexargs_.end(); ++it) { + if (!(*it).second.mandatory) + ++nr; + } + return nr; +} + + +int InsetLayout::requiredArgs() const +{ + int nr = 0; + Layout::LaTeXArgMap::const_iterator it = latexargs_.begin(); + for (; it != latexargs_.end(); ++it) { + if ((*it).second.mandatory) + ++nr; + } + return nr; +} + } //namespace lyx diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h index 4619abcb0a..33fcffaddd 100644 --- a/src/insets/InsetLayout.h +++ b/src/insets/InsetLayout.h @@ -15,6 +15,7 @@ #include "ColorCode.h" #include "FontInfo.h" +#include "Layout.h" #include "support/docstring.h" @@ -81,6 +82,12 @@ public: /// ColorCode bgcolor() const { return bgcolor_; } /// + Layout::LaTeXArgMap latexargs() const { return latexargs_; } + /// + int optArgs() const; + /// + int requiredArgs() const; + /// docstring preamble() const { return preamble_; } /// Get language dependent macro definitions needed for this inset docstring const langpreamble() const { return langpreamble_; } @@ -159,6 +166,8 @@ private: /// std::string defaultCSSLabelClass() const { return defaultCSSClass() + "_label"; } /// + void readArgument(Lexer &); + /// docstring name_; /** * This is only used (at present) to decide where to put them on the menus. @@ -245,6 +254,8 @@ private: bool resetsfont_; /// bool display_; + /// + Layout::LaTeXArgMap latexargs_; }; /// diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 85eca0c305..e209e50215 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -13,6 +13,7 @@ #include "InsetText.h" #include "insets/InsetArgument.h" +#include "insets/InsetLayout.h" #include "buffer_funcs.h" #include "Buffer.h" @@ -30,6 +31,7 @@ #include "InsetList.h" #include "Intl.h" #include "Language.h" +#include "Layout.h" #include "LaTeXFeatures.h" #include "Lexer.h" #include "lyxfind.h" @@ -54,6 +56,7 @@ #include "frontends/alert.h" #include "frontends/Painter.h" +#include "support/convert.h" #include "support/debug.h" #include "support/gettext.h" #include "support/lstrings.h" @@ -329,6 +332,37 @@ bool InsetText::getStatus(Cursor & cur, FuncRequest const & cmd, return target_inset; } + case LFUN_ARGUMENT_INSERT: { + string const arg = cmd.getArg(0); + if (arg.empty()) { + status.setEnabled(false); + return true; + } + if (&buffer().inset() == this || !cur.paragraph().layout().latexargs().empty()) + return text_.getStatus(cur, cmd, status); + Layout::LaTeXArgMap args = getLayout().latexargs(); + Layout::LaTeXArgMap::const_iterator const lait = + args.find(convert(arg)); + if (lait != args.end()) { + InsetList::const_iterator it = cur.paragraph().insetList().begin(); + InsetList::const_iterator end = cur.paragraph().insetList().end(); + for (; it != end; ++it) { + if (it->inset->lyxCode() == ARG_CODE) { + InsetArgument const * ins = + static_cast(it->inset); + if (ins->name() == arg) { + // we have this already + status.setEnabled(false); + return true; + } + } + } + status.setEnabled(true); + } else + status.setEnabled(false); + return true; + } + default: // Dispatch only to text_ if the cursor is inside // the text_. It is not for context menus (bug 5797). diff --git a/src/output_latex.cpp b/src/output_latex.cpp index 585ef8a3ec..2112b80e70 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -30,9 +30,11 @@ #include "insets/InsetArgument.h" #include "support/lassert.h" +#include "support/convert.h" #include "support/debug.h" #include "support/lstrings.h" +#include #include #include @@ -160,8 +162,8 @@ static TeXEnvironmentData prepareEnvironment(Buffer const & buf, if (style.isEnvironment()) { os << "\\begin{" << from_ascii(style.latexname()) << '}'; - if (style.optargs != 0 || style.reqargs != 0) - latexArgInsets(*pit, os, runparams, style.reqargs, style.optargs); + if (style.latexargs().size() != 0) + latexArgInsets(*pit, os, runparams, style.latexargs()); if (style.latextype == LATEX_LIST_ENVIRONMENT) { os << '{' << pit->params().labelWidthString() @@ -311,53 +313,85 @@ void TeXEnvironment(Buffer const & buf, Text const & text, void latexArgInsets(Paragraph const & par, otexstream & os, - OutputParams const & runparams, unsigned int reqargs, - unsigned int optargs) + OutputParams const & runparams, Layout::LaTeXArgMap latexargs) { - unsigned int totalargs = reqargs + optargs; - list ilist; + map ilist; + vector required; InsetList::const_iterator it = par.insetList().begin(); InsetList::const_iterator end = par.insetList().end(); for (; it != end; ++it) { if (it->inset->lyxCode() == ARG_CODE) { - if (ilist.size() >= totalargs) { - LYXERR0("WARNING: Found extra argument inset."); - continue; - } InsetArgument const * ins = static_cast(it->inset); - ilist.push_back(ins); + if (ins->name().empty()) + LYXERR0("Error: Unnamed argument inset!"); + else { + unsigned int const nr = convert(ins->name()); + ilist[nr] = ins; + Layout::LaTeXArgMap::const_iterator const lit = + latexargs.find(nr); + if (lit != latexargs.end()) { + Layout::latexarg arg = (*lit).second; + if (!arg.requires.empty()) { + vector req = getVectorFromString(arg.requires); + required.insert(required.end(), req.begin(), req.end()); + } + } + } } } - if (!reqargs && ilist.empty()) + unsigned int const argnr = latexargs.size(); + if (argnr == 0) return; - bool const have_optional_args = ilist.size() > reqargs; - if (have_optional_args) { - unsigned int todo = ilist.size() - reqargs; - for (unsigned int i = 0; i < todo; ++i) { - InsetArgument const * ins = ilist.front(); - ilist.pop_front(); - ins->latexArgument(os, runparams, true); + for (unsigned int i = 1; i <= argnr; ++i) { + map::const_iterator lit = ilist.find(i); + bool inserted = false; + if (lit != ilist.end()) { + InsetArgument const * ins = (*lit).second; + if (ins) { + Layout::LaTeXArgMap::const_iterator const lait = + latexargs.find(convert(ins->name())); + if (lait != latexargs.end()) { + Layout::latexarg arg = (*lait).second; + docstring ldelim = arg.mandatory ? + from_ascii("{") : from_ascii("["); + docstring rdelim = arg.mandatory ? + from_ascii("}") : from_ascii("]"); + if (!arg.ldelim.empty()) + ldelim = arg.ldelim; + if (!arg.rdelim.empty()) + rdelim = arg.rdelim; + ins->latexArgument(os, runparams, ldelim, rdelim); + inserted = true; + } + } } - } - - // we should now have no more insets than there are required - // arguments. - LASSERT(ilist.size() <= reqargs, /* */); - if (!reqargs) - return; - - for (unsigned int i = 0; i < reqargs; ++i) { - if (ilist.empty()) - // a required argument wasn't given, so we output {} - os << "{}"; - else { - InsetArgument const * ins = ilist.front(); - ilist.pop_front(); - ins->latexArgument(os, runparams, false); + if (!inserted) { + Layout::LaTeXArgMap::const_iterator lait = latexargs.begin(); + Layout::LaTeXArgMap::const_iterator const laend = latexargs.end(); + for (; lait != laend; ++lait) { + if ((*lait).first == i) { + Layout::latexarg arg = (*lait).second; + if (arg.mandatory) { + docstring ldelim = arg.ldelim.empty() ? + from_ascii("{") : arg.ldelim; + docstring rdelim = arg.rdelim.empty() ? + from_ascii("}") : arg.rdelim; + os << ldelim << rdelim; + } else if (find(required.begin(), required.end(), + convert((*lait).first)) != required.end()) { + docstring ldelim = arg.ldelim.empty() ? + from_ascii("[") : arg.ldelim; + docstring rdelim = arg.rdelim.empty() ? + from_ascii("]") : arg.rdelim; + os << ldelim << rdelim; + } else + break; + } + } } } } @@ -373,8 +407,8 @@ void parStartCommand(Paragraph const & par, otexstream & os, os << '\\' << from_ascii(style.latexname()); // Separate handling of optional argument inset. - if (style.optargs != 0 || style.reqargs != 0) - latexArgInsets(par, os, runparams, style.reqargs, style.optargs); + if (style.latexargs().size() != 0) + latexArgInsets(par, os, runparams, style.latexargs()); else os << from_ascii(style.latexparam()); break; diff --git a/src/output_latex.h b/src/output_latex.h index d29c4b7f47..ee0419b231 100644 --- a/src/output_latex.h +++ b/src/output_latex.h @@ -15,6 +15,7 @@ #include #include "support/docstream.h" +#include "Layout.h" #include "Paragraph.h" #include "ParIterator.h" #include "ParagraphList.h" @@ -37,7 +38,7 @@ class Text; /// must all come first. void latexArgInsets(Paragraph const & par, otexstream & os, OutputParams const & runparams, - unsigned int reqargs, unsigned int optargs); + Layout::LaTeXArgMap latexargs); /** Export \p paragraphs of buffer \p buf to LaTeX. Don't use a temporary stringstream for \p os if the final output is diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 01626f3a50..cb1d377d7d 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -628,8 +628,8 @@ void output_command_layout(ostream & os, Parser & p, bool outer, } context.check_deeper(os); context.check_layout(os); - unsigned int optargs = 0; - while (optargs < context.layout->optargs) { + int optargs = 0; + while (optargs < context.layout->optArgs()) { eat_whitespace(p, os, context, false); if (p.next_token().cat() == catEscape || p.next_token().character() != '[') @@ -642,8 +642,8 @@ void output_command_layout(ostream & os, Parser & p, bool outer, eat_whitespace(p, os, context, false); ++optargs; } - unsigned int reqargs = 0; - while (reqargs < context.layout->reqargs) { + int reqargs = 0; + while (reqargs < context.layout->requiredArgs()) { eat_whitespace(p, os, context, false); if (p.next_token().cat() != catBegin) break; @@ -1603,8 +1603,8 @@ void parse_environment(Parser & p, ostream & os, bool outer, // but before the first \\item. if (context.layout->latextype == LATEX_ENVIRONMENT) { bool need_layout = true; - unsigned int optargs = 0; - while (optargs < context.layout->optargs) { + int optargs = 0; + while (optargs < context.layout->optArgs()) { eat_whitespace(p, os, context, false); if (p.next_token().cat() == catEscape || p.next_token().character() != '[') @@ -1621,8 +1621,8 @@ void parse_environment(Parser & p, ostream & os, bool outer, eat_whitespace(p, os, context, false); ++optargs; } - unsigned int reqargs = 0; - while (reqargs < context.layout->reqargs) { + int reqargs = 0; + while (reqargs < context.layout->requiredArgs()) { eat_whitespace(p, os, context, false); if (p.next_token().cat() != catBegin) break; diff --git a/src/version.h b/src/version.h index dbea8533d5..a305e9ce11 100644 --- a/src/version.h +++ b/src/version.h @@ -30,8 +30,8 @@ extern char const * const lyx_version_info; // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -#define LYX_FORMAT_LYX 445 // landroni: support for the URW Classico LaTeX font -#define LYX_FORMAT_TEX2LYX 445 // landroni: support for the URW Classico LaTeX font +#define LYX_FORMAT_LYX 446 // spitz: InsetArgument revision +#define LYX_FORMAT_TEX2LYX 446 // landroni: InsetArgument revision #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX #ifndef _MSC_VER