whitespace.
[lyx.git] / src / LyX.h
blobc27e2045cf056399596fb69bc680b9ab6ac12b85
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.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
9 * \author John Levon
11 * Full author contact details are available in file CREDITS.
14 #ifndef LYX_H
15 #define LYX_H
17 #include "support/strfwd.h"
19 namespace lyx {
21 class BufferList;
22 class CmdDef;
23 class Converters;
24 class ErrorItem;
25 class FuncRequest;
26 class FuncStatus;
27 class KeyMap;
28 class LyXFunc;
29 class Messages;
30 class Mover;
31 class Movers;
32 class Server;
33 class ServerSocket;
34 class Session;
36 extern bool use_gui;
38 namespace frontend {
39 class Application;
40 class LyXView;
43 namespace graphics {
44 class Previews;
47 /// initial startup
48 class LyX {
49 public:
51 LyX();
52 ~LyX();
54 /// Execute LyX.
55 int exec(int & argc, char * argv[]);
57 ///
58 frontend::LyXView * newLyXView();
60 private:
61 /// noncopyable
62 LyX(LyX const &);
63 void operator=(LyX const &);
65 /// Do some cleanup in preparation of an exit.
66 void prepareExit();
68 /// Early exit during the initialisation process.
69 void earlyExit(int status);
71 /// Initialise LyX and fills-in the vector of files to be loaded.
72 /**
73 \return exit code failure if any.
75 int init(int & argc, char * argv[]);
77 /// Execute batch commands if available.
78 void execCommands();
80 /// Load files passed at command-line.
81 /// return true on success false if we encounter an error
82 /**
83 This method is used only in non-GUI mode.
85 bool loadFiles();
87 /// initial LyX set up
88 bool init();
89 /** Check for the existence of the user's support directory and,
90 * if not present, create it. Exits the program if the directory
91 * cannot be created.
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 languages file
99 bool readLanguagesFile(std::string const & name);
100 /// read the encodings.
101 /// \param enc_name encodings definition file
102 /// \param symbols_name unicode->LaTeX mapping file
103 bool readEncodingsFile(std::string const & enc_name,
104 std::string const & symbols_name);
105 /// parsing of non-gui LyX options.
106 void easyParse(int & argc, char * argv[]);
107 /// shows up a parsing error on screen
108 void printError(ErrorItem const &);
111 Messages & messages(std::string const & language);
113 /// Use the Pimpl idiom to hide the internals.
114 // Mostly used for singletons.
115 struct Impl;
116 Impl * pimpl_;
118 /// has this user started lyx for the first time?
119 bool first_start;
121 friend FuncStatus getStatus(FuncRequest const & action);
122 friend void dispatch(FuncRequest const & action);
123 friend BufferList & theBufferList();
124 friend LyXFunc & theLyXFunc();
125 friend Server & theServer();
126 friend ServerSocket & theServerSocket();
127 friend Converters & theConverters();
128 friend Converters & theSystemConverters();
129 friend Messages & getMessages(std::string const & language);
130 friend Messages & getGuiMessages();
131 friend KeyMap & theTopLevelKeymap();
132 friend Movers & theMovers();
133 friend Mover const & getMover(std::string const & fmt);
134 friend void setMover(std::string const & fmt, std::string const & command);
135 friend Movers & theSystemMovers();
136 friend frontend::Application * theApp();
137 friend graphics::Previews & thePreviews();
138 friend Session & theSession();
139 friend CmdDef & theTopLevelCmdDef();
140 friend void setRcGuiLanguage();
141 friend void emergencyCleanup();
142 friend void execBatchCommands();
143 friend void lyx_exit(int exit_code);
147 /// in the case of failure
148 void emergencyCleanup();
149 /// Try to exit LyX properly.
150 /// \p exit_code is 0 by default, if a non zero value is passed,
151 /// emergencyCleanup() will be called before exiting.
152 void lyx_exit(int exit_code);
153 /// Set the language defined by the user.
154 void setRcGuiLanguage();
155 /// Execute batch commands if available.
156 void execBatchCommands();
158 } // namespace lyx
160 #endif // LYX_H