The branch, master, has been updated.

- Log -----------------------------------------------------------------

commit e5ebe17b92eed6b27f22e444f98d0c6da1db812b
Author: Juergen Spitzmueller <[email protected]>
Date:   Mon Dec 17 13:32:40 2012 +0100

    AutoInsert option also for flex insets

diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx
index b852ed7..a7a8ca4 100644
--- a/lib/doc/Customization.lyx
+++ b/lib/doc/Customization.lyx
@@ -10974,7 +10974,7 @@ Classic
 
 \begin_layout Itemize
 
-\change_inserted -712698321 1355661160
+\change_inserted -712698321 1355747298
 \begin_inset Flex Code
 status collapsed
 
@@ -11013,8 +11013,8 @@ status collapsed
 \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.
+ Currently, only one argument per style\SpecialChar \slash{}
+layout can be automatically inserted.
 \change_inserted 155139281 1354198988
 
 \end_layout
diff --git a/lib/layouts/beamer.layout b/lib/layouts/beamer.layout
index f65a2ff..c180a9d 100644
--- a/lib/layouts/beamer.layout
+++ b/lib/layouts/beamer.layout
@@ -1348,6 +1348,7 @@ InsetLayout Flex:Alert
     Tooltip        "Specify the overlay settings (see beamer manual)"
     LeftDelim      <
     RightDelim     >
+    AutoInsert     1
   EndArgument
 End
 
@@ -1365,6 +1366,7 @@ InsetLayout Flex:Structure
     Tooltip        "Specify the overlay settings (see beamer manual)"
     LeftDelim      <
     RightDelim     >
+    AutoInsert     1
   EndArgument
 End
 
@@ -1382,6 +1384,7 @@ InsetLayout Flex:Only
     Tooltip        "Specify the overlay settings (see beamer manual)"
     LeftDelim      <
     RightDelim     >
+    AutoInsert     1
   EndArgument
 End
 
@@ -1399,6 +1402,7 @@ InsetLayout Flex:Uncover
     Tooltip        "Specify the overlay settings (see beamer manual)"
     LeftDelim      <
     RightDelim     >
+    AutoInsert     1
   EndArgument
 End
 
diff --git a/src/Text3.cpp b/src/Text3.cpp
index 9400526..22f4b99 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -295,6 +295,8 @@ static bool doInsertInset(Cursor & cur, Text * text,
                        // Merge multiple paragraphs -- hack
                        while (cur.lastpit() > 0)
                                mergeParagraph(bparams, 
cur.text()->paragraphs(), 0);
+                       if (cmd.action() == LFUN_FLEX_INSERT)
+                               return true;
                        Cursor old = cur;
                        cur.leaveInset(*inset);
                        if (cmd.action() == LFUN_PREVIEW_INSERT
@@ -1699,7 +1701,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_CAPTION_INSERT:
        case LFUN_FOOTNOTE_INSERT:
        case LFUN_NOTE_INSERT:
-       case LFUN_FLEX_INSERT:
        case LFUN_BOX_INSERT:
        case LFUN_BRANCH_INSERT:
        case LFUN_PHANTOM_INSERT:
@@ -1720,6 +1721,37 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                cur.forceBufferUpdate();
                break;
 
+       case LFUN_FLEX_INSERT: {
+               // Open the inset, and move the current selection
+               // inside it.
+               bool const sel = cur.selection();
+               doInsertInset(cur, this, cmd, true, true);
+               // Insert auto-insert arguments
+               bool autoargs = false;
+               Layout::LaTeXArgMap args = cur.inset().getLayout().latexargs();
+               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) {
+                               // The cursor might have been invalidated by 
the replaceSelection.
+                               cur.buffer()->changed(true);
+                               FuncRequest cmd(LFUN_ARGUMENT_INSERT, 
(*lait).first);
+                               lyx::dispatch(cmd);
+                               autoargs = true;
+                       }
+               }
+               if (!autoargs) {
+                       if (sel)
+                               cur.leaveInset(cur.inset());
+                       cur.posForward();
+               }
+               // Some insets are numbered, others are shown in the outline 
pane so
+               // let's update the labels and the toc backend.
+               cur.forceBufferUpdate();
+               break;
+       }
+
        case LFUN_TABULAR_INSERT:
                // if there were no arguments, just open the dialog
                if (doInsertInset(cur, this, cmd, false, true))
diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp
index 3fee6fb..b6dcf58 100644
--- a/src/insets/InsetLayout.cpp
+++ b/src/insets/InsetLayout.cpp
@@ -511,6 +511,7 @@ void InsetLayout::readArgument(Lexer & lex)
 {
        Layout::latexarg arg;
        arg.mandatory = false;
+       arg.autoinsert = false;
        bool error = false;
        bool finished = false;
        arg.font = inherit_font;
@@ -534,6 +535,9 @@ void InsetLayout::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();

-----------------------------------------------------------------------

Summary of changes:
 lib/doc/Customization.lyx  |    6 +++---
 lib/layouts/beamer.layout  |    4 ++++
 src/Text3.cpp              |   34 +++++++++++++++++++++++++++++++++-
 src/insets/InsetLayout.cpp |    4 ++++
 4 files changed, 44 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to