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/shared_ptr.hpp>
19 #include <boost/utility.hpp>
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().
69 void quit(bool noask);
72 BufferList & bufferList();
73 BufferList const & bufferList() const;
75 lyx::Session & session();
76 lyx::Session const & session() const;
78 void addLyXView(LyXView * lyxview);
80 /** redraw \c inset in all the BufferViews in which it is currently
81 * visible. If successful return a pointer to the owning Buffer.
83 Buffer const * const updateInset(InsetBase const *) const;
86 static boost::scoped_ptr<LyX> singleton_;
89 int priv_exec(int & argc, char * argv[]);
91 /// Do some cleanup in preparation of an exit.
94 /// Early exit during the initialisation process.
95 void earlyExit(int status);
97 /// Initialise LyX and execute batch commands if available.
99 \param files is filled in with the command-line file names.
100 \return exit code failure if any.
102 int execBatchCommands(int & argc, char * argv[],
103 std::vector<std::string> & files);
105 /// Create a View and restore GUI Session.
106 void restoreGuiSession(std::vector<std::string> const & files);
108 /// Initialize RC font for the GUI.
111 /// initial LyX set up
113 /// set up the default key bindings
114 void defaultKeyBindings(kb_keymap * kbmap);
115 /// set up the default dead key bindings if requested
116 void deadKeyBindings(kb_keymap * kbmap);
117 /** Check for the existence of the user's support directory and,
118 * if not present, create it. Exits the program if the directory
120 * \returns true if the user-side configuration script
121 * (lib/configure) should be re-run in this directory.
123 bool queryUserLyXDir(bool explicit_userdir);
124 /// read lyxrc/preferences
125 bool readRcFile(std::string const & name);
126 /// read the given ui (menu/toolbar) file
127 bool readUIFile(std::string const & name);
128 /// read the given languages file
129 bool readLanguagesFile(std::string const & name);
130 /// read the given encodings file
131 bool readEncodingsFile(std::string const & name);
132 /// parsing of non-gui LyX options.
133 void easyParse(int & argc, char * argv[]);
134 /// shows up a parsing error on screen
135 void printError(ErrorItem const &);
137 /// has this user started lyx for the first time?
139 /// the parsed command line batch command if any
140 std::string batch_command;
143 boost::scoped_ptr<BufferList> buffer_list_;
144 /// lyx session, containing lastfiles, lastfilepos, and lastopened
145 boost::scoped_ptr<lyx::Session> session_;
147 typedef std::list<LyXView *> ViewList;
151 bool geometryOption_;
154 boost::scoped_ptr<lyx::frontend::Application> application_;