]> git.lyx.org Git - lyx.git/blob - src/LyX.h
revert r22574 to be able to compile
[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 "support/strfwd.h"
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         /// Try to exit LyX properly.
58         /// \p exit_code is 0 by default, if a non zero value is passed,
59         /// emergencyCleanup() will be called before exiting.
60         void exit(int exit_code = 0) const;
61
62         static LyX & ref();
63         static LyX const & cref();
64
65         /// in the case of failure
66         void emergencyCleanup() const;
67
68         ///
69         BufferList & bufferList();
70         BufferList const & bufferList() const;
71         ///
72         Session & session();
73         Session const & session() const;
74         ///
75         LyXFunc & lyxFunc();
76         LyXFunc const & lyxFunc() const;
77         ///
78         Server & server();
79         Server const & server() const;
80         ///
81         ServerSocket & socket();
82         ServerSocket const & socket() const;
83
84         ///
85         frontend::Application & application();
86         frontend::Application const & application() const;
87
88         ///
89         KeyMap & topLevelKeymap();
90         KeyMap const & topLevelKeymap() const;
91
92         ///
93         CmdDef & topLevelCmdDef();
94
95         ///
96         Converters & converters();
97         Converters & systemConverters();
98
99         ///
100         Messages & getMessages(std::string const & language);
101         ///
102         Messages & getGuiMessages();
103         ///
104         void setGuiLanguage(std::string const & language);
105
106         ///
107         frontend::LyXView * newLyXView();
108
109         /// Execute batch commands if available.
110         void execBatchCommands();
111
112         ///
113         void addFileToLoad(support::FileName const &);
114
115 private:
116         /// noncopyable
117         LyX(LyX const &);
118         void operator=(LyX const &);
119
120         /// Do some cleanup in preparation of an exit.
121         void prepareExit();
122
123         /// Early exit during the initialisation process.
124         void earlyExit(int status);
125
126         /// Initialise LyX and fills-in the vector of files to be loaded.
127         /**
128         \return exit code failure if any.
129         */
130         int init(int & argc, char * argv[]);
131
132         /// Load files passed at command-line.
133         /**
134         This method is used only in non-GUI mode.
135         */
136         void loadFiles();
137
138         /// Create a View, load files and restore GUI Session.
139         void restoreGuiSession();
140
141         /// initial LyX set up
142         bool init();
143         /// set up the default dead key bindings if requested
144         void deadKeyBindings(KeyMap * kbmap);
145         /** Check for the existence of the user's support directory and,
146          *  if not present, create it. Exits the program if the directory
147          *  cannot be created.
148          *  \returns true if the user-side configuration script
149          *  (lib/configure) should be re-run in this directory.
150          */
151         bool queryUserLyXDir(bool explicit_userdir);
152         /// read lyxrc/preferences
153         bool readRcFile(std::string const & name);
154         /// read the given ui (menu/toolbar) file
155         bool readUIFile(std::string const & name, bool include = false);
156         /// read the given languages file
157         bool readLanguagesFile(std::string const & name);
158         /// read the encodings.
159         /// \param enc_name encodings definition file
160         /// \param symbols_name unicode->LaTeX mapping file
161         bool readEncodingsFile(std::string const & enc_name,
162                                std::string const & symbols_name);
163         /// parsing of non-gui LyX options.
164         void easyParse(int & argc, char * argv[]);
165         /// shows up a parsing error on screen
166         void printError(ErrorItem const &);
167
168         /// Use the Pimpl idiom to hide the internals.
169         // Mostly used for singletons.
170         struct Impl;
171         Impl * pimpl_;
172
173         /// has this user started lyx for the first time?
174         bool first_start;
175
176         friend Movers & theMovers();
177         friend Mover const & getMover(std::string  const & fmt);
178         friend void setMover(std::string const & fmt, std::string const & command);
179         friend Movers & theSystemMovers();
180         friend frontend::Application * theApp();
181 };
182
183 } // namespace lyx
184
185 #endif // LYX_H