1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-06-12 02:54:19 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file lyx_main.h
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-06-12 02:54:19 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
* \author John Levon
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-06-12 02:54:19 +00:00
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
|
#ifndef LYX_MAIN_H
|
|
|
|
|
#define LYX_MAIN_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-05-22 01:16:37 +00:00
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
2000-10-02 00:55:02 +00:00
|
|
|
|
#include <boost/utility.hpp>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
#include <string>
|
2006-10-17 08:36:04 +00:00
|
|
|
|
#include <vector>
|
2002-05-22 01:16:37 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2003-10-14 21:30:23 +00:00
|
|
|
|
class Buffer;
|
2006-10-11 22:30:31 +00:00
|
|
|
|
class BufferList;
|
2003-09-04 03:54:04 +00:00
|
|
|
|
class ErrorItem;
|
2004-04-13 13:10:33 +00:00
|
|
|
|
class InsetBase;
|
2006-10-19 07:20:32 +00:00
|
|
|
|
class LyXFunc;
|
|
|
|
|
class LyXServer;
|
|
|
|
|
class LyXServerSocket;
|
2003-10-14 21:30:23 +00:00
|
|
|
|
class LyXView;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
class Session;
|
2000-05-10 11:50:11 +00:00
|
|
|
|
class kb_keymap;
|
2006-10-12 22:02:45 +00:00
|
|
|
|
|
2006-10-15 21:47:29 +00:00
|
|
|
|
extern bool use_gui;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace frontend { class Application; }
|
1999-10-02 16:21:10 +00:00
|
|
|
|
|
2002-08-07 23:43:38 +00:00
|
|
|
|
/// initial startup
|
2001-04-17 14:00:20 +00:00
|
|
|
|
class LyX : boost::noncopyable {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
public:
|
2006-06-07 20:08:37 +00:00
|
|
|
|
/**
|
|
|
|
|
* Execute LyX. The startup sequence is as follows:
|
|
|
|
|
* -# LyX::exec()
|
|
|
|
|
* -# LyX::priv_exec()
|
2006-10-12 14:10:13 +00:00
|
|
|
|
* -# lyx::createApplication()
|
2006-06-07 20:08:37 +00:00
|
|
|
|
* -# LyX::exec2()
|
2006-10-12 14:10:13 +00:00
|
|
|
|
* Step 3 is omitted if no gui is wanted. We need lyx::createApplication()
|
2006-06-07 20:08:37 +00:00
|
|
|
|
* only to create the QApplication object in the qt frontend. All
|
|
|
|
|
* attempts with static and dynamically allocated QApplication
|
|
|
|
|
* objects lead either to harmless error messages on exit
|
|
|
|
|
* ("Mutex destroy failure") or crashes (OS X).
|
|
|
|
|
*/
|
2006-07-05 17:01:26 +00:00
|
|
|
|
static int exec(int & argc, char * argv[]);
|
2006-06-07 20:08:37 +00:00
|
|
|
|
/// Execute LyX (inner execution loop, \sa exec)
|
2006-07-05 17:01:26 +00:00
|
|
|
|
int exec2(int & argc, char * argv[]);
|
2003-10-14 21:30:23 +00:00
|
|
|
|
static LyX & ref();
|
|
|
|
|
static LyX const & cref();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-10-19 15:13:49 +00:00
|
|
|
|
/// in the case of failure
|
2003-10-14 21:30:23 +00:00
|
|
|
|
void emergencyCleanup() const;
|
|
|
|
|
|
2006-10-17 08:36:04 +00:00
|
|
|
|
/// Ask the LyX class to exit.
|
|
|
|
|
/**
|
|
|
|
|
In GUI mode, after this function has been called, application_ leaves
|
|
|
|
|
the main event loop and returns from the call to Application::start().
|
|
|
|
|
*/
|
|
|
|
|
void quit(bool noask);
|
|
|
|
|
|
2006-10-11 22:30:31 +00:00
|
|
|
|
///
|
|
|
|
|
BufferList & bufferList();
|
|
|
|
|
BufferList const & bufferList() const;
|
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
Session & session();
|
|
|
|
|
Session const & session() const;
|
2006-10-19 07:20:32 +00:00
|
|
|
|
///
|
|
|
|
|
LyXFunc & lyxFunc();
|
|
|
|
|
LyXFunc const & lyxFunc() const;
|
|
|
|
|
///
|
|
|
|
|
LyXServer & server();
|
|
|
|
|
LyXServer const & server() const;
|
|
|
|
|
///
|
|
|
|
|
LyXServerSocket & socket();
|
|
|
|
|
LyXServerSocket const & socket() const;
|
|
|
|
|
|
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
frontend::Application & application();
|
|
|
|
|
frontend::Application const & application() const;
|
2006-10-19 07:20:32 +00:00
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
kb_keymap & topLevelKeymap();
|
|
|
|
|
kb_keymap const & topLevelKeymap() const;
|
2003-10-14 21:30:23 +00:00
|
|
|
|
|
2006-10-21 09:45:11 +00:00
|
|
|
|
LyXView * newLyXView();
|
2003-10-14 21:30:23 +00:00
|
|
|
|
|
|
|
|
|
/** redraw \c inset in all the BufferViews in which it is currently
|
|
|
|
|
* visible. If successful return a pointer to the owning Buffer.
|
|
|
|
|
*/
|
2004-04-13 13:10:33 +00:00
|
|
|
|
Buffer const * const updateInset(InsetBase const *) const;
|
2001-12-10 15:59:20 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
private:
|
2003-10-14 21:30:23 +00:00
|
|
|
|
static boost::scoped_ptr<LyX> singleton_;
|
|
|
|
|
|
|
|
|
|
LyX();
|
2006-07-05 17:01:26 +00:00
|
|
|
|
int priv_exec(int & argc, char * argv[]);
|
2003-10-14 21:30:23 +00:00
|
|
|
|
|
2006-10-17 08:36:04 +00:00
|
|
|
|
/// Do some cleanup in preparation of an exit.
|
|
|
|
|
void prepareExit();
|
|
|
|
|
|
|
|
|
|
/// Early exit during the initialisation process.
|
|
|
|
|
void earlyExit(int status);
|
|
|
|
|
|
|
|
|
|
/// Initialise LyX and execute batch commands if available.
|
|
|
|
|
/**
|
|
|
|
|
\param files is filled in with the command-line file names.
|
|
|
|
|
\return exit code failure if any.
|
|
|
|
|
*/
|
|
|
|
|
int execBatchCommands(int & argc, char * argv[],
|
|
|
|
|
std::vector<std::string> & files);
|
|
|
|
|
|
|
|
|
|
/// Create a View and restore GUI Session.
|
|
|
|
|
void restoreGuiSession(std::vector<std::string> const & files);
|
|
|
|
|
|
|
|
|
|
/// Initialize RC font for the GUI.
|
|
|
|
|
void initGuiFont();
|
|
|
|
|
|
2002-08-07 23:43:38 +00:00
|
|
|
|
/// initial LyX set up
|
2006-07-05 17:01:26 +00:00
|
|
|
|
bool init();
|
2002-08-07 23:43:38 +00:00
|
|
|
|
/// set up the default key bindings
|
2000-05-10 11:50:11 +00:00
|
|
|
|
void defaultKeyBindings(kb_keymap * kbmap);
|
2002-08-07 23:43:38 +00:00
|
|
|
|
/// set up the default dead key bindings if requested
|
2000-05-10 11:50:11 +00:00
|
|
|
|
void deadKeyBindings(kb_keymap * kbmap);
|
2005-01-16 21:01:41 +00:00
|
|
|
|
/** Check for the existence of the user's support directory and,
|
|
|
|
|
* if not present, create it. Exits the program if the directory
|
|
|
|
|
* cannot be created.
|
|
|
|
|
* \returns true if the user-side configuration script
|
|
|
|
|
* (lib/configure) should be re-run in this directory.
|
|
|
|
|
*/
|
|
|
|
|
bool queryUserLyXDir(bool explicit_userdir);
|
2003-04-02 18:08:05 +00:00
|
|
|
|
/// read lyxrc/preferences
|
2006-07-05 17:01:26 +00:00
|
|
|
|
bool readRcFile(std::string const & name);
|
2002-08-07 23:43:38 +00:00
|
|
|
|
/// read the given ui (menu/toolbar) file
|
2006-07-05 17:01:26 +00:00
|
|
|
|
bool readUIFile(std::string const & name);
|
2002-08-07 23:43:38 +00:00
|
|
|
|
/// read the given languages file
|
2006-07-05 17:01:26 +00:00
|
|
|
|
bool readLanguagesFile(std::string const & name);
|
2002-08-07 23:43:38 +00:00
|
|
|
|
/// read the given encodings file
|
2006-07-05 17:01:26 +00:00
|
|
|
|
bool readEncodingsFile(std::string const & name);
|
2006-10-12 14:10:13 +00:00
|
|
|
|
/// parsing of non-gui LyX options.
|
|
|
|
|
void easyParse(int & argc, char * argv[]);
|
2003-06-20 23:03:43 +00:00
|
|
|
|
/// shows up a parsing error on screen
|
|
|
|
|
void printError(ErrorItem const &);
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
2002-08-07 23:43:38 +00:00
|
|
|
|
/// has this user started lyx for the first time?
|
|
|
|
|
bool first_start;
|
|
|
|
|
/// the parsed command line batch command if any
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string batch_command;
|
2003-10-14 21:30:23 +00:00
|
|
|
|
|
2006-10-19 07:20:32 +00:00
|
|
|
|
/// Use the Pimpl idiom to hide the internals.
|
|
|
|
|
struct Singletons;
|
|
|
|
|
boost::scoped_ptr<Singletons> pimpl_;
|
2006-06-21 10:30:32 +00:00
|
|
|
|
|
2006-06-26 16:55:35 +00:00
|
|
|
|
///
|
2006-06-21 10:30:32 +00:00
|
|
|
|
bool geometryOption_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2002-08-07 23:43:38 +00:00
|
|
|
|
#endif // LYX_MAIN_H
|