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