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