]> git.lyx.org Git - lyx.git/blobdiff - src/insets/ExternalTemplate.cpp
Context menu item to add unknown branch (rest of #7643)
[lyx.git] / src / insets / ExternalTemplate.cpp
index 7861e8a59fa0fd869143385a689a5ded1289272b..6bd02ac47a603b84803a2377c1a95b5744a9bc10 100644 (file)
@@ -20,6 +20,7 @@
 #include "support/lstrings.h"
 #include "support/Package.h"
 #include "support/Path.h"
+#include "support/Translator.h"
 
 #include <ostream>
 
@@ -50,7 +51,7 @@ static TransformIDTranslator const & transformIDTranslator()
 
 // We have to have dummy default commands for security reasons!
 Template::Template()
-       : inputFormat("*")
+       : inputFormat("*"), automaticProduction(false), preview_mode(PREVIEW_OFF)
 {}
 
 
@@ -102,8 +103,19 @@ public:
                    << "\tHelpTextEnd\n"
                    << "\tInputFormat " << et.inputFormat << '\n'
                    << "\tFileFilter " << et.fileRegExp << '\n'
-                   << "\tAutomaticProduction " << et.automaticProduction << '\n';
-
+                   << "\tAutomaticProduction " << et.automaticProduction << '\n'
+                   << "\tPreview ";
+               switch (et.preview_mode) {
+                       case PREVIEW_OFF:
+                               os_ << "Off\n";
+                               break;
+                       case PREVIEW_GRAPHICS:
+                               os_ << "Graphics\n";
+                               break;
+                       case PREVIEW_INSTANT:
+                               os_ << "InstantPreview\n";
+                               break;
+               }
                typedef vector<TransformID> IDs;
                IDs::const_iterator it  = et.transformIds.begin();
                IDs::const_iterator end = et.transformIds.end();
@@ -299,6 +311,7 @@ void Template::readTemplate(Lexer & lex)
                TO_INPUTFORMAT,
                TO_FILTER,
                TO_AUTOMATIC,
+               TO_PREVIEW,
                TO_TRANSFORM,
                TO_FORMAT,
                TO_END
@@ -311,6 +324,7 @@ void Template::readTemplate(Lexer & lex)
                { "guiname", TO_GUINAME },
                { "helptext", TO_HELPTEXT },
                { "inputformat", TO_INPUTFORMAT },
+               { "preview", TO_PREVIEW },
                { "templateend", TO_END },
                { "transform", TO_TRANSFORM }
        };
@@ -345,6 +359,16 @@ void Template::readTemplate(Lexer & lex)
                        automaticProduction = lex.getBool();
                        break;
 
+               case TO_PREVIEW:
+                       lex >> token;
+                       if (token == "InstantPreview")
+                               preview_mode = PREVIEW_INSTANT;
+                       else if (token == "Graphics")
+                               preview_mode = PREVIEW_GRAPHICS;
+                       else
+                               preview_mode = PREVIEW_OFF;
+                       break;
+
                case TO_TRANSFORM: {
                        lex >> token;
                        TransformID id = transformIDTranslator().find(token);