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