2003-03-14 00:20:42 +00:00
|
|
|
/**
|
2003-06-28 01:23:11 +00:00
|
|
|
* \file Kernel.C
|
2003-03-14 00:20:42 +00:00
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
#include "Kernel.h"
|
|
|
|
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "BufferView.h"
|
|
|
|
#include "funcrequest.h"
|
|
|
|
#include "lyxfunc.h"
|
|
|
|
#include "frontends/Dialogs.h"
|
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
Kernel::Kernel(LyXView & lyxview)
|
|
|
|
: lyxview_(lyxview)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2004-11-08 10:54:29 +00:00
|
|
|
void Kernel::dispatch(FuncRequest const & fr) const
|
2003-02-25 14:51:38 +00:00
|
|
|
{
|
2004-11-08 10:54:29 +00:00
|
|
|
lyxview_.getLyXFunc().dispatch(fr);
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Kernel::updateDialog(string const & name) const
|
|
|
|
{
|
|
|
|
dispatch(FuncRequest(LFUN_DIALOG_UPDATE, name));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Kernel::disconnect(string const & name) const
|
|
|
|
{
|
|
|
|
lyxview_.getDialogs().disconnect(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Kernel::isBufferAvailable() const
|
|
|
|
{
|
|
|
|
if (!lyxview_.view().get())
|
2004-10-05 10:11:42 +00:00
|
|
|
return false;
|
|
|
|
return lyxview_.view()->available();
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Kernel::isBufferReadonly() const
|
|
|
|
{
|
|
|
|
if (!lyxview_.buffer())
|
2004-10-05 10:11:42 +00:00
|
|
|
return true;
|
|
|
|
return lyxview_.buffer()->isReadonly();
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-23 09:07:28 +00:00
|
|
|
string const Kernel::bufferFilepath() const
|
|
|
|
{
|
2003-08-28 07:41:31 +00:00
|
|
|
return buffer().filePath();
|
2003-07-23 09:07:28 +00:00
|
|
|
}
|
|
|
|
|
2003-08-28 08:45:32 +00:00
|
|
|
|
2005-05-12 22:37:43 +00:00
|
|
|
Kernel::DocType Kernel::docType() const
|
2003-02-25 14:51:38 +00:00
|
|
|
{
|
2003-08-28 07:41:31 +00:00
|
|
|
if (buffer().isLatex())
|
2003-02-25 14:51:38 +00:00
|
|
|
return LATEX;
|
2003-08-28 07:41:31 +00:00
|
|
|
if (buffer().isLiterate())
|
2003-02-25 14:51:38 +00:00
|
|
|
return LITERATE;
|
2003-08-28 07:41:31 +00:00
|
|
|
if (buffer().isLinuxDoc())
|
2003-02-25 14:51:38 +00:00
|
|
|
return LINUXDOC;
|
|
|
|
|
|
|
|
return DOCBOOK;
|
|
|
|
}
|
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
|
2004-03-31 18:51:11 +00:00
|
|
|
void Kernel::redrawGUI() const
|
|
|
|
{
|
|
|
|
lyxview_.getDialogs().redrawGUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
BufferView * Kernel::bufferview()
|
|
|
|
{
|
|
|
|
return lyxview_.view().get();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BufferView const * Kernel::bufferview() const
|
|
|
|
{
|
|
|
|
return lyxview_.view().get();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
Buffer & Kernel::buffer()
|
2003-02-25 14:51:38 +00:00
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
BOOST_ASSERT(lyxview_.buffer());
|
2003-08-28 07:41:31 +00:00
|
|
|
return *lyxview_.buffer();
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
Buffer const & Kernel::buffer() const
|
2003-02-25 14:51:38 +00:00
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
BOOST_ASSERT(lyxview_.buffer());
|
2003-08-28 07:41:31 +00:00
|
|
|
return *lyxview_.buffer();
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|