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