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