]> git.lyx.org Git - lyx.git/blob - src/LyX.h
Allow autoconf 2.69 and automake 1.12
[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 #include <vector>
20
21 namespace lyx {
22
23 class BufferList;
24 class CmdDef;
25 class Converters;
26 class DispatchResult;
27 class ErrorItem;
28 class FuncRequest;
29 class FuncStatus;
30 class KeyMap;
31 class Messages;
32 class Mover;
33 class Movers;
34 class Server;
35 class ServerSocket;
36 class Session;
37 class SpellChecker;
38
39 enum RunMode {
40         NEW_INSTANCE,
41         USE_REMOTE,
42         PREFERRED
43 };
44
45 enum OverwriteFiles {
46         NO_FILES,
47         MAIN_FILE,
48         ALL_FILES,
49         UNSPECIFIED
50 };
51
52 extern bool use_gui;
53 extern RunMode run_mode;
54 extern OverwriteFiles force_overwrite;
55
56 namespace frontend {
57 class Application;
58 }
59
60 /// initial startup
61 class LyX {
62 public:
63
64         LyX();
65         ~LyX();
66
67         /// Execute LyX.
68         int exec(int & argc, char * argv[]);
69
70 private:
71         /// noncopyable
72         LyX(LyX const &);
73         void operator=(LyX const &);
74
75         /// Do some cleanup in preparation of an exit.
76         void prepareExit();
77
78         /// Early exit during the initialisation process.
79         void earlyExit(int status);
80
81         /// Initialise LyX and fills-in the vector of files to be loaded.
82         /**
83         \return exit code failure if any.
84         */
85         int init(int & argc, char * argv[]);
86
87         /// Execute batch commands if available.
88         void execCommands();
89
90         /// Load files passed at command-line.
91         /// return true on success false if we encounter an error
92         /**
93         This method is used only in non-GUI mode.
94         */
95         bool loadFiles();
96
97         /// initial LyX set up
98         bool init();
99         /** Check for the existence of the user's support directory and,
100          *  if not present, create it. Exits the program if the directory
101          *  cannot be created.
102          *  \returns true if the user-side configuration script
103          *  (lib/configure) should be re-run in this directory.
104          */
105         bool queryUserLyXDir(bool explicit_userdir);
106         /// read lyxrc/preferences
107         /// \param check_format: whether to try to convert the format of
108         /// the file, if there is a mismatch.
109         bool readRcFile(std::string const & name, bool check_format = false);
110         /// read the given languages file
111         bool readLanguagesFile(std::string const & name);
112         /// read the encodings.
113         /// \param enc_name encodings definition file
114         /// \param symbols_name unicode->LaTeX mapping file
115         bool readEncodingsFile(std::string const & enc_name,
116                                std::string const & symbols_name);
117         /// parsing of non-gui LyX options.
118         void easyParse(int & argc, char * argv[]);
119         /// shows up a parsing error on screen
120         void printError(ErrorItem const &);
121
122         ///
123         Messages & messages(std::string const & language);
124
125         /// Use the Pimpl idiom to hide the internals.
126         // Mostly used for singletons.
127         struct Impl;
128         Impl * pimpl_;
129
130         /// has this user started lyx for the first time?
131         bool first_start;
132
133         friend FuncStatus getStatus(FuncRequest const & action);
134         friend void dispatch(FuncRequest const & action);
135         friend void dispatch(FuncRequest const & action, DispatchResult & dr);
136         friend std::vector<std::string> & theFilesToLoad();
137         friend BufferList & theBufferList();
138         friend Server & theServer();
139         friend ServerSocket & theServerSocket();
140         friend Converters & theConverters();
141         friend Converters & theSystemConverters();
142         friend Messages const & getMessages(std::string const & language);
143         friend Messages const & getGuiMessages();
144         friend KeyMap & theTopLevelKeymap();
145         friend Movers & theMovers();
146         friend Mover const & getMover(std::string  const & fmt);
147         friend void setMover(std::string const & fmt, std::string const & command);
148         friend Movers & theSystemMovers();
149         friend frontend::Application * theApp();
150         friend Session & theSession();
151         friend CmdDef & theTopLevelCmdDef();
152         friend SpellChecker * theSpellChecker();
153         friend void setSpellChecker();
154         friend void setRcGuiLanguage();
155         friend void emergencyCleanup();
156         friend void execBatchCommands();
157         friend void lyx_exit(int exit_code);
158 };
159
160
161 /// in the case of failure
162 void emergencyCleanup();
163 /// Try to exit LyX properly.
164 /// \p exit_code is 0 by default, if a non zero value is passed,
165 /// emergencyCleanup() will be called before exiting.
166 void lyx_exit(int exit_code);
167 /// Set the language defined by the user.
168 void setRcGuiLanguage();
169 /// Execute batch commands if available.
170 void execBatchCommands();
171
172 ///
173 FuncStatus getStatus(FuncRequest const & action);
174
175 ///
176 void dispatch(FuncRequest const & action);
177
178 ///
179 void dispatch(FuncRequest const & action, DispatchResult & dr);
180
181 } // namespace lyx
182
183 #endif // LYX_H
184