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>
32 class LyXServerSocket;
39 namespace frontend { class Application; }
42 class LyX : boost::noncopyable {
45 * Execute LyX. The startup sequence is as follows:
48 * -# lyx::createApplication()
50 * Step 3 is omitted if no gui is wanted. We need lyx::createApplication()
51 * only to create the QApplication object in the qt frontend. All
52 * attempts with static and dynamically allocated QApplication
53 * objects lead either to harmless error messages on exit
54 * ("Mutex destroy failure") or crashes (OS X).
56 static int exec(int & argc, char * argv[]);
57 /// Execute LyX (inner execution loop, \sa exec)
58 int exec2(int & argc, char * argv[]);
60 static LyX const & cref();
62 /// in the case of failure
63 void emergencyCleanup() const;
65 /// Ask the LyX class to exit.
67 In GUI mode, after this function has been called, application_ leaves
68 the main event loop and returns from the call to Application::start().
70 void quit(bool noask);
73 BufferList & bufferList();
74 BufferList const & bufferList() const;
77 Session const & session() const;
80 LyXFunc const & lyxFunc() const;
83 LyXServer const & server() const;
85 LyXServerSocket & socket();
86 LyXServerSocket const & socket() const;
89 frontend::Application & application();
90 frontend::Application const & application() const;
93 kb_keymap & topLevelKeymap();
94 kb_keymap const & topLevelKeymap() const;
96 void addLyXView(LyXView * lyxview);
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;
104 static boost::scoped_ptr<LyX> singleton_;
107 int priv_exec(int & argc, char * argv[]);
109 /// Do some cleanup in preparation of an exit.
112 /// Early exit during the initialisation process.
113 void earlyExit(int status);
115 /// Initialise LyX and execute batch commands if available.
117 \param files is filled in with the command-line file names.
118 \return exit code failure if any.
120 int execBatchCommands(int & argc, char * argv[],
121 std::vector<std::string> & files);
123 /// Create a View and restore GUI Session.
124 void restoreGuiSession(std::vector<std::string> const & files);
126 /// Initialize RC font for the GUI.
129 /// initial LyX set up
131 /// set up the default key bindings
132 void defaultKeyBindings(kb_keymap * kbmap);
133 /// set up the default dead key bindings if requested
134 void deadKeyBindings(kb_keymap * kbmap);
135 /** Check for the existence of the user's support directory and,
136 * if not present, create it. Exits the program if the directory
138 * \returns true if the user-side configuration script
139 * (lib/configure) should be re-run in this directory.
141 bool queryUserLyXDir(bool explicit_userdir);
142 /// read lyxrc/preferences
143 bool readRcFile(std::string const & name);
144 /// read the given ui (menu/toolbar) file
145 bool readUIFile(std::string const & name);
146 /// read the given languages file
147 bool readLanguagesFile(std::string const & name);
148 /// read the given encodings file
149 bool readEncodingsFile(std::string const & name);
150 /// parsing of non-gui LyX options.
151 void easyParse(int & argc, char * argv[]);
152 /// shows up a parsing error on screen
153 void printError(ErrorItem const &);
155 /// has this user started lyx for the first time?
157 /// the parsed command line batch command if any
158 std::string batch_command;
160 /// Use the Pimpl idiom to hide the internals.
162 boost::scoped_ptr<Singletons> pimpl_;
164 typedef std::list<LyXView *> ViewList;
168 bool geometryOption_;