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;
70 BufferList & bufferList();
71 BufferList const & bufferList() const;
74 Session const & session() const;
77 LyXFunc const & lyxFunc() const;
80 LyXServer const & server() const;
82 LyXServerSocket & socket();
83 LyXServerSocket const & socket() const;
86 frontend::Application & application();
87 frontend::Application const & application() const;
90 kb_keymap & topLevelKeymap();
91 kb_keymap const & topLevelKeymap() const;
94 IconvProcessor & iconvProcessor();
96 LyXView * newLyXView();
98 /** redraw \c inset in all the BufferViews in which it is currently
99 * visible. If successful return a pointer to the owning Buffer.
101 Buffer const * const updateInset(InsetBase const *) const;
103 /// Execute batch commands if available.
104 void execBatchCommands();
107 /// Do some cleanup in preparation of an exit.
110 /// Early exit during the initialisation process.
111 void earlyExit(int status);
113 /// Initialise LyX and load files if asked.
115 \param files is filled in with the command-line file names.
116 \return exit code failure if any.
118 int loadFiles(int & argc, char * argv[],
119 std::vector<support::FileName> & files);
121 /// Create a View and restore GUI Session.
122 void restoreGuiSession(std::vector<support::FileName> const & files);
124 /// Initialize RC font for the GUI.
127 /// initial LyX set up
129 /// set up the default key bindings
130 void defaultKeyBindings(kb_keymap * kbmap);
131 /// set up the default dead key bindings if requested
132 void deadKeyBindings(kb_keymap * kbmap);
133 /** Check for the existence of the user's support directory and,
134 * if not present, create it. Exits the program if the directory
136 * \returns true if the user-side configuration script
137 * (lib/configure) should be re-run in this directory.
139 bool queryUserLyXDir(bool explicit_userdir);
140 /// read lyxrc/preferences
141 bool readRcFile(std::string const & name);
142 /// read the given ui (menu/toolbar) file
143 bool readUIFile(std::string const & name);
144 /// read the given languages file
145 bool readLanguagesFile(std::string const & name);
146 /// read the given encodings file
147 bool readEncodingsFile(std::string const & name);
148 /// parsing of non-gui LyX options.
149 void easyParse(int & argc, char * argv[]);
150 /// shows up a parsing error on screen
151 void printError(ErrorItem const &);
153 /// has this user started lyx for the first time?
155 /// the parsed command line batch command if any
156 std::string batch_command;
158 /// Use the Pimpl idiom to hide the internals.
160 boost::scoped_ptr<Singletons> pimpl_;