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 <boost/scoped_ptr.hpp>
18 #include <boost/utility.hpp>
31 class LyXServerSocket;
38 namespace frontend { class Application; }
41 class LyX : boost::noncopyable {
44 * Execute LyX. The startup sequence is as follows:
47 * -# lyx::createApplication()
49 * Step 3 is omitted if no gui is wanted. We need lyx::createApplication()
50 * only to create the QApplication object in the qt frontend. All
51 * attempts with static and dynamically allocated QApplication
52 * objects lead either to harmless error messages on exit
53 * ("Mutex destroy failure") or crashes (OS X).
55 static int exec(int & argc, char * argv[]);
56 /// Execute LyX (inner execution loop, \sa exec)
57 int exec2(int & argc, char * argv[]);
59 static LyX const & cref();
61 /// in the case of failure
62 void emergencyCleanup() const;
64 /// Ask the LyX class to exit.
66 In GUI mode, after this function has been called, application_ leaves
67 the main event loop and returns from the call to Application::start().
72 BufferList & bufferList();
73 BufferList const & bufferList() const;
76 Session const & session() const;
79 LyXFunc const & lyxFunc() const;
82 LyXServer const & server() const;
84 LyXServerSocket & socket();
85 LyXServerSocket const & socket() const;
88 frontend::Application & application();
89 frontend::Application const & application() const;
92 kb_keymap & topLevelKeymap();
93 kb_keymap const & topLevelKeymap() const;
95 LyXView * newLyXView();
97 /** redraw \c inset in all the BufferViews in which it is currently
98 * visible. If successful return a pointer to the owning Buffer.
100 Buffer const * const updateInset(InsetBase const *) const;
103 static boost::scoped_ptr<LyX> singleton_;
106 int priv_exec(int & argc, char * argv[]);
108 /// Do some cleanup in preparation of an exit.
111 /// Early exit during the initialisation process.
112 void earlyExit(int status);
114 /// Initialise LyX and execute batch commands if available.
116 \param files is filled in with the command-line file names.
117 \return exit code failure if any.
119 int execBatchCommands(int & argc, char * argv[],
120 std::vector<std::string> & files);
122 /// Create a View and restore GUI Session.
123 void restoreGuiSession(std::vector<std::string> const & files);
125 /// Initialize RC font for the GUI.
128 /// initial LyX set up
130 /// set up the default key bindings
131 void defaultKeyBindings(kb_keymap * kbmap);
132 /// set up the default dead key bindings if requested
133 void deadKeyBindings(kb_keymap * kbmap);
134 /** Check for the existence of the user's support directory and,
135 * if not present, create it. Exits the program if the directory
137 * \returns true if the user-side configuration script
138 * (lib/configure) should be re-run in this directory.
140 bool queryUserLyXDir(bool explicit_userdir);
141 /// read lyxrc/preferences
142 bool readRcFile(std::string const & name);
143 /// read the given ui (menu/toolbar) file
144 bool readUIFile(std::string const & name);
145 /// read the given languages file
146 bool readLanguagesFile(std::string const & name);
147 /// read the given encodings file
148 bool readEncodingsFile(std::string const & name);
149 /// parsing of non-gui LyX options.
150 void easyParse(int & argc, char * argv[]);
151 /// shows up a parsing error on screen
152 void printError(ErrorItem const &);
154 /// has this user started lyx for the first time?
156 /// the parsed command line batch command if any
157 std::string batch_command;
159 /// Use the Pimpl idiom to hide the internals.
161 boost::scoped_ptr<Singletons> pimpl_;
164 bool geometryOption_;