]> git.lyx.org Git - lyx.git/blob - src/LyX.h
HTML for stackrel.
[lyx.git] / src / LyX.h
1 // -*- C++ -*-
2 /**
3  * \file LyX.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_H
15 #define LYX_H
16
17 #include "support/strfwd.h"
18
19 namespace lyx {
20
21 class BufferList;
22 class CmdDef;
23 class Converters;
24 class DispatchResult;
25 class ErrorItem;
26 class FuncRequest;
27 class FuncStatus;
28 class KeyMap;
29 class Messages;
30 class Mover;
31 class Movers;
32 class Server;
33 class ServerSocket;
34 class Session;
35 class SpellChecker;
36
37 extern bool use_gui;
38
39 namespace frontend {
40 class Application;
41 }
42
43 namespace graphics {
44 class Previews;
45 }
46
47 /// initial startup
48 class LyX {
49 public:
50
51         LyX();
52         ~LyX();
53
54         /// Execute LyX.
55         int exec(int & argc, char * argv[]);
56
57 private:
58         /// noncopyable
59         LyX(LyX const &);
60         void operator=(LyX const &);
61
62         /// Do some cleanup in preparation of an exit.
63         void prepareExit();
64
65         /// Early exit during the initialisation process.
66         void earlyExit(int status);
67
68         /// Initialise LyX and fills-in the vector of files to be loaded.
69         /**
70         \return exit code failure if any.
71         */
72         int init(int & argc, char * argv[]);
73
74         /// Execute batch commands if available.
75         void execCommands();
76
77         /// Load files passed at command-line.
78         /// return true on success false if we encounter an error
79         /**
80         This method is used only in non-GUI mode.
81         */
82         bool loadFiles();
83
84         /// initial LyX set up
85         bool init();
86         /** Check for the existence of the user's support directory and,
87          *  if not present, create it. Exits the program if the directory
88          *  cannot be created.
89          *  \returns true if the user-side configuration script
90          *  (lib/configure) should be re-run in this directory.
91          */
92         bool queryUserLyXDir(bool explicit_userdir);
93         /// read lyxrc/preferences
94         bool readRcFile(std::string const & name);
95         /// read the given languages file
96         bool readLanguagesFile(std::string const & name);
97         /// read the encodings.
98         /// \param enc_name encodings definition file
99         /// \param symbols_name unicode->LaTeX mapping file
100         bool readEncodingsFile(std::string const & enc_name,
101                                std::string const & symbols_name);
102         /// parsing of non-gui LyX options.
103         void easyParse(int & argc, char * argv[]);
104         /// shows up a parsing error on screen
105         void printError(ErrorItem const &);
106
107         ///
108         Messages & messages(std::string const & language);
109
110         /// Use the Pimpl idiom to hide the internals.
111         // Mostly used for singletons.
112         struct Impl;
113         Impl * pimpl_;
114
115         /// has this user started lyx for the first time?
116         bool first_start;
117
118         friend FuncStatus getStatus(FuncRequest const & action);
119         friend void dispatch(FuncRequest const & action);
120         friend void dispatch(FuncRequest const & action, DispatchResult & dr);
121         friend BufferList & theBufferList();
122         friend Server & theServer();
123         friend ServerSocket & theServerSocket();
124         friend Converters & theConverters();
125         friend Converters & theSystemConverters();
126         friend Messages const & getMessages(std::string const & language);
127         friend Messages const & getGuiMessages();
128         friend KeyMap & theTopLevelKeymap();
129         friend Movers & theMovers();
130         friend Mover const & getMover(std::string  const & fmt);
131         friend void setMover(std::string const & fmt, std::string const & command);
132         friend Movers & theSystemMovers();
133         friend frontend::Application * theApp();
134         friend graphics::Previews & thePreviews();
135         friend Session & theSession();
136         friend CmdDef & theTopLevelCmdDef();
137         friend SpellChecker * theSpellChecker();
138         friend void setSpellChecker();
139         friend void setRcGuiLanguage();
140         friend void emergencyCleanup();
141         friend void execBatchCommands();
142         friend void lyx_exit(int exit_code);
143 };
144
145
146 /// in the case of failure
147 void emergencyCleanup();
148 /// Try to exit LyX properly.
149 /// \p exit_code is 0 by default, if a non zero value is passed,
150 /// emergencyCleanup() will be called before exiting.
151 void lyx_exit(int exit_code);
152 /// Set the language defined by the user.
153 void setRcGuiLanguage();
154 /// Execute batch commands if available.
155 void execBatchCommands();
156
157 ///
158 FuncStatus getStatus(FuncRequest const & action);
159
160 ///
161 void dispatch(FuncRequest const & action);
162
163 } // namespace lyx
164
165 #endif // LYX_H
166