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