]> git.lyx.org Git - lyx.git/blob - src/LyX.h
Fix scons and CmdDef.h for the introduction of CmdDef.
[lyx.git] / src / LyX.h
1 // -*- C++ -*-
2 /**
3  * \file LyX.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author Jean-Marc Lasgouttes
9  * \author John Levon
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef LYX_H
15 #define LYX_H
16
17 #include <boost/scoped_ptr.hpp>
18 #include <boost/noncopyable.hpp>
19
20 #include <string>
21
22 namespace lyx {
23
24 namespace support {
25 class FileName;
26 }
27
28 class Buffer;
29 class BufferList;
30 class Converters;
31 class ErrorItem;
32 class Inset;
33 class LyXFunc;
34 class Server;
35 class ServerSocket;
36 class Messages;
37 class Mover;
38 class Movers;
39 class Session;
40 class KeyMap;
41 class CmdDef;
42
43 extern bool use_gui;
44
45 namespace frontend {
46 class Application;
47 class LyXView;
48 }
49
50 /// initial startup
51 class LyX : boost::noncopyable {
52 public:
53
54         LyX();
55         ~LyX();
56
57         /// Execute LyX.
58         int exec(int & argc, char * argv[]);
59
60         static LyX & ref();
61         static LyX const & cref();
62
63         /// in the case of failure
64         void emergencyCleanup() const;
65
66         ///
67         BufferList & bufferList();
68         BufferList const & bufferList() const;
69         ///
70         Session & session();
71         Session const & session() const;
72         ///
73         LyXFunc & lyxFunc();
74         LyXFunc const & lyxFunc() const;
75         ///
76         Server & server();
77         Server const & server() const;
78         ///
79         ServerSocket & socket();
80         ServerSocket const & socket() const;
81
82         ///
83         frontend::Application & application();
84         frontend::Application const & application() const;
85
86         ///
87         KeyMap & topLevelKeymap();
88         KeyMap const & topLevelKeymap() const;
89
90         ///
91         CmdDef & topLevelCmdDef();
92
93         ///
94         Converters & converters();
95         Converters & systemConverters();
96
97         ///
98         Messages & getMessages(std::string const & language);
99         ///
100         Messages & getGuiMessages();
101         ///
102         void setGuiLanguage(std::string const & language);
103
104         ///
105         frontend::LyXView * newLyXView();
106
107         /** redraw \c inset in all the BufferViews in which it is currently
108          *  visible. If successful return a pointer to the owning Buffer.
109          */
110         Buffer const * updateInset(Inset const *) const;
111
112         void hideDialogs(std::string const & name, Inset * inset) const;
113
114         /// Execute batch commands if available.
115         void execBatchCommands();
116
117         ///
118         void addFileToLoad(support::FileName const &);
119
120 private:
121         /// Do some cleanup in preparation of an exit.
122         void prepareExit();
123
124         /// Early exit during the initialisation process.
125         void earlyExit(int status);
126
127         /// Initialise LyX and fills-in the vector of files to be loaded.
128         /**
129         \return exit code failure if any.
130         */
131         int init(int & argc, char * argv[]);
132
133         /// Load files passed at command-line.
134         /**
135         This method is used only in non-GUI mode.
136         */
137         void loadFiles();
138
139         /// Create a View, load files and restore GUI Session.
140         void restoreGuiSession();
141
142         /// Initialize RC font for the GUI.
143         void initGuiFont();
144
145         /// initial LyX set up
146         bool init();
147         /// set up the default key bindings
148         void defaultKeyBindings(KeyMap * kbmap);
149         /// set up the default dead key bindings if requested
150         void deadKeyBindings(KeyMap * kbmap);
151         /** Check for the existence of the user's support directory and,
152          *  if not present, create it. Exits the program if the directory
153          *  cannot be created.
154          *  \returns true if the user-side configuration script
155          *  (lib/configure) should be re-run in this directory.
156          */
157         bool queryUserLyXDir(bool explicit_userdir);
158         /// read lyxrc/preferences
159         bool readRcFile(std::string const & name);
160         /// read the given ui (menu/toolbar) file
161         bool readUIFile(std::string const & name, bool include = false);
162         /// read the given languages file
163         bool readLanguagesFile(std::string const & name);
164         /// read the encodings.
165         /// \param enc_name encodings definition file
166         /// \param symbols_name unicode->LaTeX mapping file
167         bool readEncodingsFile(std::string const & enc_name,
168                                std::string const & symbols_name);
169         /// parsing of non-gui LyX options.
170         void easyParse(int & argc, char * argv[]);
171         /// shows up a parsing error on screen
172         void printError(ErrorItem const &);
173
174         /// has this user started lyx for the first time?
175         bool first_start;
176         /// the parsed command line batch command if any
177         std::string batch_command;
178
179         /// Use the Pimpl idiom to hide the internals.
180         struct Singletons;
181         boost::scoped_ptr<Singletons> pimpl_;
182
183         friend Movers & theMovers();
184         friend Mover const & getMover(std::string  const & fmt);
185         friend void setMover(std::string const & fmt, std::string const & command);
186         friend Movers & theSystemMovers();
187         friend frontend::Application * theApp();
188 };
189
190 } // namespace lyx
191
192 #endif // LYX_H