2003-02-25 14:51:38 +00:00
|
|
|
// -*- C++ -*-
|
2003-03-14 00:20:42 +00:00
|
|
|
/**
|
|
|
|
* \file Kernel.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Angus Leeming
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-03-14 00:20:42 +00:00
|
|
|
*/
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
|
|
#ifndef KERNEL_H
|
|
|
|
#define KERNEL_H
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
#include <string>
|
2003-02-25 14:51:38 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
class Buffer;
|
|
|
|
class BufferView;
|
|
|
|
class FuncRequest;
|
|
|
|
class LyXView;
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace frontend {
|
2003-02-25 14:51:38 +00:00
|
|
|
|
2003-06-28 01:23:11 +00:00
|
|
|
/** \c Kernel is a wrapper making the LyX kernel available to the dialog.
|
2003-03-14 00:20:42 +00:00
|
|
|
* (Ie, it provides an interface to the Model part of the Model-Controller-
|
|
|
|
* View split.
|
|
|
|
* In an ideal world, it will shrink as more info is passed to the
|
2003-07-16 20:10:59 +00:00
|
|
|
* Dialog::show() and Dialog::update() methods.
|
2003-03-14 00:20:42 +00:00
|
|
|
*/
|
2003-02-25 14:51:38 +00:00
|
|
|
class Kernel {
|
|
|
|
public:
|
2003-03-14 00:20:42 +00:00
|
|
|
/// \param lv is the access point for the dialog to the LyX kernel.
|
|
|
|
Kernel(LyXView & lv);
|
|
|
|
|
2005-04-13 09:43:58 +00:00
|
|
|
/** This method is the primary purpose of the class. It provides
|
2003-07-16 20:10:59 +00:00
|
|
|
* the "gateway" by which the dialog can send a request (of a
|
|
|
|
* change in the data, for more information) to the kernel.
|
|
|
|
* \param fr is the encoding of the request.
|
2003-03-14 00:20:42 +00:00
|
|
|
*/
|
2004-11-08 10:54:29 +00:00
|
|
|
void dispatch(FuncRequest const & fr) const;
|
2003-03-14 00:20:42 +00:00
|
|
|
|
|
|
|
/** The dialog has received a request from the user
|
2005-04-13 09:43:58 +00:00
|
|
|
* (who pressed the "Restore" button) to update contents.
|
2003-07-16 20:10:59 +00:00
|
|
|
* It must, therefore, ask the kernel to provide this information.
|
|
|
|
* \param name is used to identify the dialog to the kernel.
|
2003-03-14 00:20:42 +00:00
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
void updateDialog(std::string const & name) const;
|
2003-03-14 00:20:42 +00:00
|
|
|
|
|
|
|
/** A request from the Controller that future changes to the data
|
|
|
|
* stored by the dialog are not applied to the inset currently
|
|
|
|
* connected to the dialog. Instead, they will be used to generate
|
|
|
|
* a new inset at the cursor position.
|
2003-07-16 20:10:59 +00:00
|
|
|
* \param name is used to identify the dialog to the kernel.
|
2003-03-14 00:20:42 +00:00
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
void disconnect(std::string const & name) const;
|
2003-03-14 00:20:42 +00:00
|
|
|
|
2003-07-16 20:10:59 +00:00
|
|
|
/** \name Kernel Wrappers
|
|
|
|
* Simple wrapper functions to Buffer methods.
|
|
|
|
*/
|
2003-03-14 00:20:42 +00:00
|
|
|
//@{
|
|
|
|
bool isBufferAvailable() const;
|
|
|
|
bool isBufferReadonly() const;
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const bufferFilepath() const;
|
2003-03-14 00:20:42 +00:00
|
|
|
//@}
|
|
|
|
|
2005-05-12 22:37:43 +00:00
|
|
|
/** \enum DocType used to flag the different kinds of buffer
|
2003-03-14 00:20:42 +00:00
|
|
|
* without making the kernel header files available to the
|
|
|
|
* dialog's Controller or View.
|
|
|
|
*/
|
2005-05-12 22:37:43 +00:00
|
|
|
enum DocType {
|
2003-02-25 14:51:38 +00:00
|
|
|
LATEX,
|
|
|
|
LITERATE,
|
|
|
|
DOCBOOK
|
|
|
|
};
|
2003-03-14 00:20:42 +00:00
|
|
|
/// The type of the current buffer.
|
2005-05-12 22:37:43 +00:00
|
|
|
DocType docType() const;
|
2003-02-25 14:51:38 +00:00
|
|
|
|
2003-07-16 20:10:59 +00:00
|
|
|
/** \name Kernel Nasties
|
|
|
|
* Unpleasantly public internals of the LyX kernel.
|
2003-03-14 00:20:42 +00:00
|
|
|
* We should aim to reduce/remove these from the interface.
|
2003-02-25 14:51:38 +00:00
|
|
|
*/
|
2003-07-16 20:10:59 +00:00
|
|
|
//@{
|
2003-02-25 14:51:38 +00:00
|
|
|
LyXView & lyxview() { return lyxview_; }
|
|
|
|
LyXView const & lyxview() const { return lyxview_; }
|
2003-03-14 00:20:42 +00:00
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
Buffer & buffer();
|
|
|
|
Buffer const & buffer() const;
|
2003-03-14 00:20:42 +00:00
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
BufferView * bufferview();
|
|
|
|
BufferView const * bufferview() const;
|
2003-03-14 00:20:42 +00:00
|
|
|
//@}
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
LyXView & lyxview_;
|
|
|
|
};
|
|
|
|
|
2005-05-12 22:37:43 +00:00
|
|
|
|
|
|
|
/** \c KernelDocType is a wrapper for Kernel::DocType.
|
|
|
|
* It can be forward-declared and passed as a function argument without
|
|
|
|
* having to expose Kernel.h.
|
|
|
|
*/
|
|
|
|
class KernelDocType {
|
|
|
|
public:
|
|
|
|
KernelDocType(Kernel::DocType val) : val_(val) {}
|
|
|
|
operator Kernel::DocType() const { return val_; }
|
|
|
|
private:
|
|
|
|
Kernel::DocType val_;
|
|
|
|
};
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
|
|
#endif // KERNEL_H
|