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 {
49 * Execute LyX. The startup sequence is as follows:
52 * -# lyx::createApplication()
53 * Step 3 is omitted if no gui is wanted. We need lyx::createApplication()
54 * only to create the QApplication object in the qt frontend. All
55 * attempts with static and dynamically allocated QApplication
56 * objects lead either to harmless error messages on exit
57 * ("Mutex destroy failure") or crashes (OS X).
59 int exec(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;
99 IconvProcessor & iconvProcessor();
101 LyXView * newLyXView();
103 /** redraw \c inset in all the BufferViews in which it is currently
104 * visible. If successful return a pointer to the owning Buffer.
106 Buffer const * const updateInset(InsetBase const *) const;
108 /// Execute batch commands if available.
109 void execBatchCommands();
112 /// Do some cleanup in preparation of an exit.
115 /// Early exit during the initialisation process.
116 void earlyExit(int status);
118 /// Initialise LyX and load files if asked.
120 \param files is filled in with the command-line file names.
121 \return exit code failure if any.
123 int loadFiles(int & argc, char * argv[],
124 std::vector<std::string> & files);
126 /// Create a View and restore GUI Session.
127 void restoreGuiSession(std::vector<std::string> const & files);
129 /// Initialize RC font for the GUI.
132 /// initial LyX set up
134 /// set up the default key bindings
135 void defaultKeyBindings(kb_keymap * kbmap);
136 /// set up the default dead key bindings if requested
137 void deadKeyBindings(kb_keymap * kbmap);
138 /** Check for the existence of the user's support directory and,
139 * if not present, create it. Exits the program if the directory
141 * \returns true if the user-side configuration script
142 * (lib/configure) should be re-run in this directory.
144 bool queryUserLyXDir(bool explicit_userdir);
145 /// read lyxrc/preferences
146 bool readRcFile(std::string const & name);
147 /// read the given ui (menu/toolbar) file
148 bool readUIFile(std::string const & name);
149 /// read the given languages file
150 bool readLanguagesFile(std::string const & name);
151 /// read the given encodings file
152 bool readEncodingsFile(std::string const & name);
153 /// parsing of non-gui LyX options.
154 void easyParse(int & argc, char * argv[]);
155 /// shows up a parsing error on screen
156 void printError(ErrorItem const &);
158 /// has this user started lyx for the first time?
160 /// the parsed command line batch command if any
161 std::string batch_command;
163 /// Use the Pimpl idiom to hide the internals.
165 boost::scoped_ptr<Singletons> pimpl_;
168 bool geometryOption_;