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/filename.h"
19 #include <boost/scoped_ptr.hpp>
20 #include <boost/utility.hpp>
34 class LyXServerSocket;
41 namespace frontend { class Application; }
44 class LyX : boost::noncopyable {
51 * Execute LyX. The startup sequence is as follows:
54 * -# lyx::createApplication()
55 * Step 3 is omitted if no gui is wanted. We need lyx::createApplication()
56 * only to create the QApplication object in the qt frontend. All
57 * attempts with static and dynamically allocated QApplication
58 * objects lead either to harmless error messages on exit
59 * ("Mutex destroy failure") or crashes (OS X).
61 int exec(int & argc, char * argv[]);
64 static LyX const & cref();
66 /// in the case of failure
67 void emergencyCleanup() const;
69 /// Ask the LyX class to exit.
71 In GUI mode, after this function has been called, application_ leaves
72 the main event loop and returns from the call to Application::start().
77 BufferList & bufferList();
78 BufferList const & bufferList() const;
81 Session const & session() const;
84 LyXFunc const & lyxFunc() const;
87 LyXServer const & server() const;
89 LyXServerSocket & socket();
90 LyXServerSocket const & socket() const;
93 frontend::Application & application();
94 frontend::Application const & application() const;
97 kb_keymap & topLevelKeymap();
98 kb_keymap const & topLevelKeymap() const;
101 IconvProcessor & iconvProcessor();
103 LyXView * newLyXView();
105 /** redraw \c inset in all the BufferViews in which it is currently
106 * visible. If successful return a pointer to the owning Buffer.
108 Buffer const * const updateInset(InsetBase const *) const;
110 /// Execute batch commands if available.
111 void execBatchCommands();
114 /// Do some cleanup in preparation of an exit.
117 /// Early exit during the initialisation process.
118 void earlyExit(int status);
120 /// Initialise LyX and load files if asked.
122 \param files is filled in with the command-line file names.
123 \return exit code failure if any.
125 int loadFiles(int & argc, char * argv[],
126 std::vector<support::FileName> & files);
128 /// Create a View and restore GUI Session.
129 void restoreGuiSession(std::vector<support::FileName> const & files);
131 /// Initialize RC font for the GUI.
134 /// initial LyX set up
136 /// set up the default key bindings
137 void defaultKeyBindings(kb_keymap * kbmap);
138 /// set up the default dead key bindings if requested
139 void deadKeyBindings(kb_keymap * kbmap);
140 /** Check for the existence of the user's support directory and,
141 * if not present, create it. Exits the program if the directory
143 * \returns true if the user-side configuration script
144 * (lib/configure) should be re-run in this directory.
146 bool queryUserLyXDir(bool explicit_userdir);
147 /// read lyxrc/preferences
148 bool readRcFile(std::string const & name);
149 /// read the given ui (menu/toolbar) file
150 bool readUIFile(std::string const & name);
151 /// read the given languages file
152 bool readLanguagesFile(std::string const & name);
153 /// read the given encodings file
154 bool readEncodingsFile(std::string const & name);
155 /// parsing of non-gui LyX options.
156 void easyParse(int & argc, char * argv[]);
157 /// shows up a parsing error on screen
158 void printError(ErrorItem const &);
160 /// has this user started lyx for the first time?
162 /// the parsed command line batch command if any
163 std::string batch_command;
165 /// Use the Pimpl idiom to hide the internals.
167 boost::scoped_ptr<Singletons> pimpl_;