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