]> git.lyx.org Git - lyx.git/blob - src/insets/ExternalTemplate.h
Angus insetindex patch + protect patch from Dekel
[lyx.git] / src / insets / ExternalTemplate.h
1 // -*- C++ -*-
2 /* This file is part of*
3  * ====================================================== 
4  *
5  *           LyX, The Document Processor
6  *       
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2000 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef EXTERNALTEMPLATE_H
13 #define EXTERNALTEMPLATE_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include <iosfwd>
20 #include <map>
21 #include "LString.h"
22
23 class LyXLex;
24
25 struct ExternalTemplate {
26         /// What is the name of this template in the LyX format?
27         string lyxName;
28         /// What will the button in the GUI say?
29         string guiName;
30         /// A short help text
31         string helpText;
32         /// A file extension regular expression for the file browser
33         string fileRegExp;
34         /// What command should be executed to view the file?
35         string viewCommand;
36         /// What command should be executed to edit the file?
37         string editCommand;
38         /// Should we do automatic production of the output?
39         bool automaticProduction;
40         /// This is the information needed to support a specific output format
41         struct FormatTemplate {
42                 /// The text that should be inserted into the exported file
43                 string product;
44                 /// The shell command to produce a resulting file
45                 string updateCommand;
46                 /// What features does this external inset require?
47                 string requirement;
48                 /// What should be inserted into the preamble
49                 string preamble;
50                 ///
51                 void readFormat(LyXLex &);
52                 /// This constructor has to default a command for safety reasons!
53                 FormatTemplate();
54         };
55         void readTemplate(LyXLex &);
56         
57         typedef std::map<string, FormatTemplate> Formats;
58
59         Formats formats;
60
61         void dumpFormats(std::ostream &) const;
62         
63         /// We have to have default commands for safety reasons!
64         ExternalTemplate();
65                 
66 };
67
68
69 /**
70  * A singleton class that manages the external inset templates
71  */
72 class ExternalTemplateManager {
73 public:
74         /// Map from the LyX name of the template to the template structure
75         typedef std::map<string, ExternalTemplate> Templates;
76
77         static ExternalTemplateManager & get();
78         Templates & getTemplates();
79         Templates const & getTemplates() const;
80 private:
81         ExternalTemplateManager();
82         void readTemplates(string const & path);
83         void dumpTemplates() const;
84         Templates templates;
85 };
86
87 #endif
88