]> git.lyx.org Git - lyx.git/blob - src/lyx_main.h
Fix bug 2485 and crash on middle mouse paste on math
[lyx.git] / src / lyx_main.h
1 // -*- C++ -*-
2 /**
3  * \file lyx_main.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author Jean-Marc Lasgouttes
9  * \author John Levon
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef LYX_MAIN_H
15 #define LYX_MAIN_H
16
17 #include <boost/scoped_ptr.hpp>
18 #include <boost/shared_ptr.hpp>
19 #include <boost/utility.hpp>
20
21 #include <list>
22 #include <string>
23
24 class Buffer;
25 class ErrorItem;
26 class InsetBase;
27 class LyXView;
28 class kb_keymap;
29 namespace lyx {
30         class Session;
31 }
32
33
34 /// initial startup
35 class LyX : boost::noncopyable {
36 public:
37         static void exec(int & argc, char * argv[]);
38         static LyX & ref();
39         static LyX const & cref();
40
41         /// in the case of failure
42         void emergencyCleanup() const;
43
44         lyx::Session & session();
45         lyx::Session const & session() const;
46
47         void addLyXView(boost::shared_ptr<LyXView> const & lyxview);
48
49         /** redraw \c inset in all the BufferViews in which it is currently
50          *  visible. If successful return a pointer to the owning Buffer.
51          */
52         Buffer const * const updateInset(InsetBase const *) const;
53
54 private:
55         static boost::scoped_ptr<LyX> singleton_;
56
57         LyX();
58         void priv_exec(int & argc, char * argv[]);
59
60         /// initial LyX set up
61         void init(bool);
62         /// set up the default key bindings
63         void defaultKeyBindings(kb_keymap * kbmap);
64         /// set up the default dead key bindings if requested
65         void deadKeyBindings(kb_keymap * kbmap);
66         /** Check for the existence of the user's support directory and,
67          *  if not present, create it. Exits the program if the directory
68          *  cannot be created.
69          *  \returns true if the user-side configuration script
70          *  (lib/configure) should be re-run in this directory.
71          */
72         bool queryUserLyXDir(bool explicit_userdir);
73         /// read lyxrc/preferences
74         void readRcFile(std::string const & name);
75         /// read the given ui (menu/toolbar) file
76         void readUIFile(std::string const & name);
77         /// read the given languages file
78         void readLanguagesFile(std::string const & name);
79         /// read the given encodings file
80         void readEncodingsFile(std::string const & name);
81         /// parsing of non-gui LyX options. Returns true if gui
82         bool easyParse(int & argc, char * argv[]);
83         /// shows up a parsing error on screen
84         void printError(ErrorItem const &);
85
86         /// has this user started lyx for the first time?
87         bool first_start;
88         /// the parsed command line batch command if any
89         std::string batch_command;
90
91         /// lyx session, containing lastfiles, lastfilepos, and lastopened
92         boost::scoped_ptr<lyx::Session> session_;
93         ///
94         typedef std::list<boost::shared_ptr<LyXView> > ViewList;
95         ViewList views_;
96 };
97
98 #endif // LYX_MAIN_H