4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
11 * Full author contact details are available in file CREDITS.
17 #include "support/strfwd.h"
54 extern RunMode run_mode;
55 extern OverwriteFiles force_overwrite;
63 friend class LyXConsoleApp;
69 int exec(int & argc, char * argv[]);
74 void operator=(LyX const &);
76 /// Do some cleanup in preparation of an exit.
79 /// Early exit during the initialisation process.
80 void earlyExit(int status);
82 /// Initialise LyX and fills-in the vector of files to be loaded.
84 \return exit code failure if any.
86 int init(int & argc, char * argv[]);
88 /// Execute commandline commands if no GUI was requested.
89 int execWithoutGui(int & argc, char * argv[]);
91 /// Execute batch commands if available.
94 /// Load files passed at command-line.
95 /// return true on success false if we encounter an error
97 This method is used only in non-GUI mode.
101 /// initial LyX set up
103 /** Check for the existence of the user's support directory and,
104 * if not present, create it. Exits the program if the directory
106 * \returns true if the user-side configuration script
107 * (lib/configure) should be re-run in this directory.
109 bool queryUserLyXDir(bool explicit_userdir);
110 /// read lyxrc/preferences
111 /// \param check_format: whether to try to convert the format of
112 /// the file, if there is a mismatch.
113 bool readRcFile(std::string const & name, bool check_format = false);
114 /// read the given languages file
115 bool readLanguagesFile(std::string const & name);
116 /// read the encodings.
117 /// \param enc_name encodings definition file
118 /// \param symbols_name unicode->LaTeX mapping file
119 bool readEncodingsFile(std::string const & enc_name,
120 std::string const & symbols_name);
121 /// parsing of non-gui LyX options.
122 void easyParse(int & argc, char * argv[]);
123 /// shows up a parsing error on screen
124 void printError(ErrorItem const &);
127 Messages & messages(std::string const & language);
129 /// Use the Pimpl idiom to hide the internals.
130 // Mostly used for singletons.
134 /// has this user started lyx for the first time?
137 friend FuncStatus getStatus(FuncRequest const & action);
138 friend DispatchResult const & dispatch(FuncRequest const & action);
139 friend void dispatch(FuncRequest const & action, DispatchResult & dr);
140 friend std::vector<std::string> & theFilesToLoad();
141 friend BufferList & theBufferList();
142 friend Server & theServer();
143 friend ServerSocket & theServerSocket();
144 friend Converters & theConverters();
145 friend Converters & theSystemConverters();
146 friend Messages const & getMessages(std::string const & language);
147 friend Messages const & getGuiMessages();
148 friend KeyMap & theTopLevelKeymap();
149 friend Movers & theMovers();
150 friend Mover const & getMover(std::string const & fmt);
151 friend void setMover(std::string const & fmt, std::string const & command);
152 friend Movers & theSystemMovers();
153 friend frontend::Application * theApp();
154 friend Session & theSession();
155 friend LaTeXFonts & theLaTeXFonts();
156 friend CmdDef & theTopLevelCmdDef();
157 friend SpellChecker * theSpellChecker();
158 friend void setSpellChecker();
159 friend void emergencyCleanup();
160 friend void execBatchCommands();
161 friend void lyx_exit(int exit_code);
165 /// in the case of failure
166 void emergencyCleanup();
167 /// Try to exit LyX properly.
168 /// \p exit_code is 0 by default, if a non zero value is passed,
169 /// emergencyCleanup() will be called before exiting.
170 void lyx_exit(int exit_code);
171 /// Execute batch commands if available.
172 void execBatchCommands();
175 FuncStatus getStatus(FuncRequest const & action);
178 DispatchResult const & dispatch(FuncRequest const & action);
181 void dispatch(FuncRequest const & action, DispatchResult & dr);