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>
40 class LyX : boost::noncopyable {
43 * Execute LyX. The startup sequence is as follows:
46 * -# lyx::createApplication()
48 * Step 3 is omitted if no gui is wanted. We need lyx::createApplication()
49 * only to create the QApplication object in the qt frontend. All
50 * attempts with static and dynamically allocated QApplication
51 * objects lead either to harmless error messages on exit
52 * ("Mutex destroy failure") or crashes (OS X).
54 static int exec(int & argc, char * argv[]);
55 /// Execute LyX (inner execution loop, \sa exec)
56 int exec2(int & argc, char * argv[]);
58 static LyX const & cref();
60 /// in the case of failure
61 void emergencyCleanup() const;
64 BufferList & bufferList();
65 BufferList const & bufferList() const;
67 lyx::Session & session();
68 lyx::Session const & session() const;
70 void addLyXView(LyXView * lyxview);
72 /** redraw \c inset in all the BufferViews in which it is currently
73 * visible. If successful return a pointer to the owning Buffer.
75 Buffer const * const updateInset(InsetBase const *) const;
78 static boost::scoped_ptr<LyX> singleton_;
81 int priv_exec(int & argc, char * argv[]);
83 /// initial LyX set up
85 /// set up the default key bindings
86 void defaultKeyBindings(kb_keymap * kbmap);
87 /// set up the default dead key bindings if requested
88 void deadKeyBindings(kb_keymap * kbmap);
89 /** Check for the existence of the user's support directory and,
90 * if not present, create it. Exits the program if the directory
92 * \returns true if the user-side configuration script
93 * (lib/configure) should be re-run in this directory.
95 bool queryUserLyXDir(bool explicit_userdir);
96 /// read lyxrc/preferences
97 bool readRcFile(std::string const & name);
98 /// read the given ui (menu/toolbar) file
99 bool readUIFile(std::string const & name);
100 /// read the given languages file
101 bool readLanguagesFile(std::string const & name);
102 /// read the given encodings file
103 bool readEncodingsFile(std::string const & name);
104 /// parsing of non-gui LyX options.
105 void easyParse(int & argc, char * argv[]);
106 /// shows up a parsing error on screen
107 void printError(ErrorItem const &);
109 /// has this user started lyx for the first time?
111 /// the parsed command line batch command if any
112 std::string batch_command;
115 boost::scoped_ptr<BufferList> buffer_list_;
116 /// lyx session, containing lastfiles, lastfilepos, and lastopened
117 boost::scoped_ptr<lyx::Session> session_;
119 typedef std::list<LyXView *> ViewList;
123 bool geometryOption_;
126 boost::scoped_ptr<lyx::frontend::Application> application_;