]> git.lyx.org Git - lyx.git/blob - src/LyX.h
Update of documentation in the source related to bug 4135 and the function callback...
[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/utility.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 LyXView;
37 class Messages;
38 class Mover;
39 class Movers;
40 class Session;
41 class KeyMap;
42
43 extern bool use_gui;
44
45 namespace frontend { class Application; }
46
47 /// initial startup
48 class LyX : boost::noncopyable {
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         Converters & converters();
89         Converters & systemConverters();
90
91         ///
92         Messages & getMessages(std::string const & language);
93         ///
94         Messages & getGuiMessages();
95         ///
96         void setGuiLanguage(std::string const & language);
97
98         ///
99         LyXView * newLyXView();
100
101         /** redraw \c inset in all the BufferViews in which it is currently
102          *  visible. If successful return a pointer to the owning Buffer.
103          */
104         Buffer const * const updateInset(Inset const *) const;
105
106         void hideDialogs(std::string const & name, Inset * inset) const;
107
108         /// Execute batch commands if available.
109         void execBatchCommands();
110
111         ///
112         void addFileToLoad(support::FileName const &);
113
114 private:
115         /// Do some cleanup in preparation of an exit.
116         void prepareExit();
117
118         /// Early exit during the initialisation process.
119         void earlyExit(int status);
120
121         /// Initialise LyX and fills-in the vector of files to be loaded.
122         /**
123         \return exit code failure if any.
124         */
125         int init(int & argc, char * argv[]);
126
127         /// Load files passed at command-line.
128         /**
129         This method is used only in non-GUI mode.
130         */
131         void loadFiles();
132
133         /// Create a View, load files and restore GUI Session.
134         void restoreGuiSession();
135
136         /// Initialize RC font for the GUI.
137         void initGuiFont();
138
139         /// initial LyX set up
140         bool init();
141         /// set up the default key bindings
142         void defaultKeyBindings(KeyMap * kbmap);
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         /// has this user started lyx for the first time?
169         bool first_start;
170         /// the parsed command line batch command if any
171         std::string batch_command;
172
173         /// Use the Pimpl idiom to hide the internals.
174         struct Singletons;
175         boost::scoped_ptr<Singletons> pimpl_;
176
177         friend Movers & theMovers();
178         friend Mover const & getMover(std::string  const & fmt);
179         friend void setMover(std::string const & fmt, std::string const & command);
180         friend Movers & theSystemMovers();
181         friend frontend::Application * theApp();
182 };
183
184 } // namespace lyx
185
186 #endif // LYX_H