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