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"
55 extern RunMode run_mode;
56 extern OverwriteFiles force_overwrite;
64 friend class LyXConsoleApp;
70 int exec(int & argc, char * argv[]);
75 void operator=(LyX const &);
77 /// Do some cleanup in preparation of an exit.
80 /// Early exit during the initialisation process.
81 void earlyExit(int status);
83 /// Initialise LyX and fills-in the vector of files to be loaded.
85 \return exit code failure if any.
87 int init(int & argc, char * argv[]);
89 /// Execute commandline commands if no GUI was requested.
90 int execWithoutGui(int & argc, char * argv[]);
92 /// Execute batch commands if available.
95 /// initial LyX set up
97 /** Check for the existence of the user's support directory and,
98 * if not present, create it. Exits the program if the directory
100 * \returns true if the user-side configuration script
101 * (lib/configure) should be re-run in this directory.
103 bool queryUserLyXDir(bool explicit_userdir);
104 /// read lyxrc/preferences
105 /// \param check_format: whether to try to convert the format of
106 /// the file, if there is a mismatch.
107 bool readRcFile(std::string const & name, bool check_format = false);
108 /// read the given languages file
109 bool readLanguagesFile(std::string const & name);
110 /// read the encodings.
111 /// \param enc_name encodings definition file
112 /// \param symbols_name unicode->LaTeX mapping file
113 bool readEncodingsFile(std::string const & enc_name,
114 std::string const & symbols_name);
115 /// parsing of non-gui LyX options.
116 void easyParse(int & argc, char * argv[]);
117 /// shows up a parsing error on screen
118 void printError(ErrorItem const &);
121 Messages & messages(std::string const & language);
123 /// Use the Pimpl idiom to hide the internals.
124 // Mostly used for singletons.
128 /// has this user started lyx for the first time?
131 friend FuncStatus getStatus(FuncRequest const & action);
132 friend DispatchResult const & dispatch(FuncRequest const & action);
133 friend void dispatch(FuncRequest const & action, DispatchResult & dr);
134 friend std::vector<std::string> & theFilesToLoad();
135 friend BufferList & theBufferList();
136 friend Server & theServer();
137 friend ServerSocket & theServerSocket();
138 friend Converters & theConverters();
139 friend Converters & theSystemConverters();
140 friend Messages const & getMessages(std::string const & language);
141 friend Messages const & getGuiMessages();
142 friend KeyMap & theTopLevelKeymap();
143 friend Movers & theMovers();
144 friend Mover const & getMover(std::string const & fmt);
145 friend void setMover(std::string const & fmt, std::string const & command);
146 friend Movers & theSystemMovers();
147 friend frontend::Application * theApp();
148 friend Session & theSession();
149 friend LaTeXFonts & theLaTeXFonts();
150 friend CmdDef & theTopLevelCmdDef();
151 friend SpellChecker * theSpellChecker();
152 friend void setSpellChecker();
153 friend void emergencyCleanup();
154 friend void execBatchCommands();
155 friend void lyx_exit(int exit_code);
159 /// in the case of failure
160 void emergencyCleanup();
161 /// Try to exit LyX properly.
162 /// \p exit_code is 0 by default, if a non zero value is passed,
163 /// emergencyCleanup() will be called before exiting.
164 void lyx_exit(int exit_code);
165 /// Execute batch commands if available.
166 void execBatchCommands();
169 FuncStatus getStatus(FuncRequest const & action);
172 DispatchResult const & dispatch(FuncRequest const & action);
175 void dispatch(FuncRequest const & action, DispatchResult & dr);