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