From dd21e57bd339c3d3ca722a66769c53a5d6e19bfc Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sun, 16 Dec 2012 13:37:14 +0100 Subject: [PATCH] Option to auto-insert a paragraph style option, particularly useful for specific mandatory arguments (such as beamer block or frame titles) --- lib/doc/Customization.lyx | 50 +++++++++++++++++++++++++++++++++++++-- lib/layouts/beamer.layout | 1 + src/Layout.cpp | 4 ++++ src/Layout.h | 1 + src/Text3.cpp | 14 +++++++++++ 5 files changed, 68 insertions(+), 2 deletions(-) diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx index 6d06e09c12..b852ed7a43 100644 --- a/lib/doc/Customization.lyx +++ b/lib/doc/Customization.lyx @@ -1,5 +1,5 @@ #LyX 2.1 created this file. For more info see http://www.lyx.org/ -\lyxformat 452 +\lyxformat 453 \begin_document \begin_header \textclass scrbook @@ -105,6 +105,7 @@ End \use_package mathdots 1 \use_package mathtools 0 \use_package mhchem 0 +\use_package stmaryrd 0 \use_package undertilde 0 \cite_engine basic \cite_engine_type numerical @@ -10907,7 +10908,7 @@ reference "sub:Font-description" \begin_layout Itemize -\change_inserted -712698321 1353917320 +\change_inserted -712698321 1355661048 \begin_inset Flex Code status collapsed @@ -10969,6 +10970,51 @@ Classic \end_inset . +\end_layout + +\begin_layout Itemize + +\change_inserted -712698321 1355661160 +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1355661057 +AutoInsert +\end_layout + +\end_inset + + +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1355661049 +[int=0] +\end_layout + +\end_inset + + If this is set to +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1355661077 +1 +\change_unchanged + +\end_layout + +\end_inset + +, this argument is automatically inserted when the respective style is selected. + This option is currently only available for paragraph styles, not for InsetLayo +uts. \change_inserted 155139281 1354198988 \end_layout diff --git a/lib/layouts/beamer.layout b/lib/layouts/beamer.layout index 75e5c9d8c2..f65a2ff54f 100644 --- a/lib/layouts/beamer.layout +++ b/lib/layouts/beamer.layout @@ -841,6 +841,7 @@ Style Block Color blue Size large EndFont + AutoInsert 1 EndArgument End diff --git a/src/Layout.cpp b/src/Layout.cpp index e53e99171b..43a6c185dd 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -881,6 +881,7 @@ void Layout::readArgument(Lexer & lex) { latexarg arg; arg.mandatory = false; + arg.autoinsert = false; bool error = false; bool finished = false; arg.font = inherit_font; @@ -906,6 +907,9 @@ void Layout::readArgument(Lexer & lex) } else if (tok == "mandatory") { lex.next(); arg.mandatory = lex.getBool(); + } else if (tok == "autoinsert") { + lex.next(); + arg.autoinsert = lex.getBool(); } else if (tok == "leftdelim") { lex.next(); arg.ldelim = lex.getDocString(); diff --git a/src/Layout.h b/src/Layout.h index a76dca6e89..7e5281d5dd 100644 --- a/src/Layout.h +++ b/src/Layout.h @@ -100,6 +100,7 @@ public: std::string decoration; FontInfo font; FontInfo labelfont; + bool autoinsert; }; /// typedef std::map LaTeXArgMap; diff --git a/src/Text3.cpp b/src/Text3.cpp index 421d8f428d..9400526c84 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -1372,6 +1372,20 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) if (change_layout) setLayout(cur, layout); + Layout::LaTeXArgMap args = tclass[layout].latexargs(); + Layout::LaTeXArgMap itemargs = tclass[layout].itemargs(); + if (!itemargs.empty()) + args.insert(itemargs.begin(), itemargs.end()); + Layout::LaTeXArgMap::const_iterator lait = args.begin(); + Layout::LaTeXArgMap::const_iterator const laend = args.end(); + for (; lait != laend; ++lait) { + Layout::latexarg arg = (*lait).second; + if (arg.autoinsert) { + FuncRequest cmd(LFUN_ARGUMENT_INSERT, (*lait).first); + lyx::dispatch(cmd); + } + } + break; } -- 2.39.2