2006-09-22 17:50:33 +00:00
|
|
|
/**
|
|
|
|
* \file frontend/Application.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Abdelrazak Younes
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2006-10-11 17:24:46 +00:00
|
|
|
#include "frontends/Application.h"
|
2006-09-22 17:50:33 +00:00
|
|
|
|
2006-10-11 17:24:46 +00:00
|
|
|
#include "frontends/FontLoader.h"
|
|
|
|
#include "frontends/FontMetrics.h"
|
|
|
|
#include "frontends/Gui.h"
|
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
#include "frontends/WorkArea.h"
|
2006-09-29 22:06:28 +00:00
|
|
|
|
2006-10-03 08:43:32 +00:00
|
|
|
#include "bufferlist.h"
|
|
|
|
#include "funcrequest.h"
|
2006-10-11 17:24:46 +00:00
|
|
|
#include "FuncStatus.h"
|
2006-09-22 17:50:33 +00:00
|
|
|
#include "LyXAction.h"
|
2006-10-11 17:24:46 +00:00
|
|
|
#include "lyxfont.h"
|
2006-09-29 22:06:28 +00:00
|
|
|
#include "lyxfunc.h"
|
2006-09-22 17:50:33 +00:00
|
|
|
#include "lyxrc.h"
|
2006-10-03 08:43:32 +00:00
|
|
|
#include "lyxserver.h"
|
|
|
|
#include "lyxsocket.h"
|
2006-09-22 17:50:33 +00:00
|
|
|
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
#include "support/os.h"
|
|
|
|
#include "support/package.h"
|
|
|
|
|
2006-10-12 14:10:13 +00:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
#include <boost/shared_ptr.hpp>
|
2006-09-22 17:50:33 +00:00
|
|
|
|
|
|
|
using lyx::support::package;
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2006-10-03 08:43:32 +00:00
|
|
|
/// The main application class private implementation.
|
|
|
|
struct Application_pimpl
|
|
|
|
{
|
|
|
|
/// our function handler
|
|
|
|
boost::scoped_ptr<LyXFunc> lyxfunc_;
|
|
|
|
///
|
|
|
|
boost::scoped_ptr<LyXServer> lyx_server_;
|
|
|
|
///
|
|
|
|
boost::scoped_ptr<LyXServerSocket> lyx_socket_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-09-22 19:17:29 +00:00
|
|
|
Application::Application(int &, char **)
|
2006-09-22 17:50:33 +00:00
|
|
|
{
|
2006-09-29 22:06:28 +00:00
|
|
|
pimpl_ = new Application_pimpl;
|
2006-09-22 17:50:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LyXFunc & Application::lyxFunc()
|
|
|
|
{
|
2006-09-29 22:06:28 +00:00
|
|
|
return *pimpl_->lyxfunc_.get();
|
2006-09-22 17:50:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LyXFunc const & Application::lyxFunc() const
|
|
|
|
{
|
2006-09-29 22:06:28 +00:00
|
|
|
return *pimpl_->lyxfunc_.get();
|
2006-09-22 17:50:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LyXServer & Application::server()
|
|
|
|
{
|
2006-09-29 22:06:28 +00:00
|
|
|
return *pimpl_->lyx_server_.get();
|
2006-09-22 17:50:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LyXServer const & Application::server() const
|
|
|
|
{
|
2006-09-29 22:06:28 +00:00
|
|
|
return *pimpl_->lyx_server_.get();
|
2006-09-22 17:50:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LyXServerSocket & Application::socket()
|
|
|
|
{
|
2006-09-29 22:06:28 +00:00
|
|
|
return *pimpl_->lyx_socket_.get();
|
2006-09-22 17:50:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LyXServerSocket const & Application::socket() const
|
|
|
|
{
|
2006-09-29 22:06:28 +00:00
|
|
|
return *pimpl_->lyx_socket_.get();
|
2006-09-22 17:50:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Application::setBufferView(BufferView * buffer_view)
|
|
|
|
{
|
|
|
|
buffer_view_ = buffer_view;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-29 23:10:17 +00:00
|
|
|
LyXView & Application::createView(unsigned int width,
|
|
|
|
unsigned int height,
|
|
|
|
int posx, int posy,
|
|
|
|
bool maximize)
|
|
|
|
{
|
|
|
|
// FIXME: please confirm: with unicode, I think initEncoding()
|
|
|
|
// is not needed anymore!
|
|
|
|
|
|
|
|
// this can't be done before because it needs the Languages object
|
|
|
|
//initEncodings();
|
|
|
|
|
2006-10-12 22:30:42 +00:00
|
|
|
int view_id = gui().newView();
|
2006-09-29 23:10:17 +00:00
|
|
|
LyXView & view = gui().view(view_id);
|
|
|
|
|
|
|
|
pimpl_->lyxfunc_.reset(new LyXFunc(&view));
|
|
|
|
|
|
|
|
// FIXME: for now we assume that there is only one LyXView with id = 0.
|
|
|
|
/*int workArea_id_ =*/ gui().newWorkArea(width, height, 0);
|
|
|
|
//WorkArea * workArea_ = & theApp->gui().workArea(workArea_id_);
|
|
|
|
|
|
|
|
view.init();
|
|
|
|
view.setGeometry(width, height, posx, posy, maximize);
|
|
|
|
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-22 17:50:33 +00:00
|
|
|
int Application::start(std::string const & batch)
|
|
|
|
{
|
2006-09-29 22:06:28 +00:00
|
|
|
pimpl_->lyx_server_.reset(new LyXServer(pimpl_->lyxfunc_.get(), lyxrc.lyxpipes));
|
|
|
|
pimpl_->lyx_socket_.reset(new LyXServerSocket(pimpl_->lyxfunc_.get(),
|
2006-09-22 17:50:33 +00:00
|
|
|
lyx::support::os::internal_path(package().temp_dir() + "/lyxsocket")));
|
|
|
|
|
|
|
|
// handle the batch commands the user asked for
|
|
|
|
if (!batch.empty()) {
|
2006-09-29 22:06:28 +00:00
|
|
|
pimpl_->lyxfunc_->dispatch(lyxaction.lookupFunc(batch));
|
2006-09-22 17:50:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
2006-10-11 17:24:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
FuncStatus getStatus(FuncRequest const & action)
|
|
|
|
{
|
|
|
|
return theApp->lyxFunc().getStatus(action);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void dispatch(FuncRequest const & action)
|
|
|
|
{
|
|
|
|
theApp->lyxFunc().dispatch(action);
|
|
|
|
}
|
|
|
|
|
2006-09-22 17:50:33 +00:00
|
|
|
} // namespace lyx
|
2006-10-11 17:24:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
LyXFunc & theLyXFunc()
|
|
|
|
{
|
|
|
|
return theApp->lyxFunc();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lyx::frontend::FontLoader & theFontLoader()
|
|
|
|
{
|
|
|
|
return theApp->fontLoader();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lyx::frontend::FontMetrics const & theFontMetrics(LyXFont const & f)
|
|
|
|
{
|
|
|
|
return theApp->fontLoader().metrics(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lyx::frontend::Clipboard & theClipboard()
|
|
|
|
{
|
|
|
|
return theApp->clipboard();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lyx::frontend::Selection & theSelection()
|
|
|
|
{
|
|
|
|
return theApp->selection();
|
|
|
|
}
|
2006-10-12 14:10:13 +00:00
|
|
|
|