2 * \file frontend/Application.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Abdelrazak Younes
8 * Full author contact details are available in file CREDITS.
13 #include "frontends/Application.h"
15 #include "frontends/FontLoader.h"
16 #include "frontends/FontMetrics.h"
17 #include "frontends/Gui.h"
18 #include "frontends/LyXView.h"
19 #include "frontends/WorkArea.h"
21 #include "bufferlist.h"
22 #include "funcrequest.h"
23 #include "FuncStatus.h"
24 #include "LyXAction.h"
28 #include "lyxserver.h"
29 #include "lyxsocket.h"
31 #include "support/lstrings.h"
32 #include "support/os.h"
33 #include "support/package.h"
36 using lyx::support::package;
41 /// The main application class private implementation.
42 struct Application_pimpl
44 /// our function handler
45 boost::scoped_ptr<LyXFunc> lyxfunc_;
47 boost::scoped_ptr<LyXServer> lyx_server_;
49 boost::scoped_ptr<LyXServerSocket> lyx_socket_;
53 Application::Application(int &, char **)
55 pimpl_ = new Application_pimpl;
59 LyXFunc & Application::lyxFunc()
61 return *pimpl_->lyxfunc_.get();
65 LyXFunc const & Application::lyxFunc() const
67 return *pimpl_->lyxfunc_.get();
71 LyXServer & Application::server()
73 return *pimpl_->lyx_server_.get();
77 LyXServer const & Application::server() const
79 return *pimpl_->lyx_server_.get();
83 LyXServerSocket & Application::socket()
85 return *pimpl_->lyx_socket_.get();
89 LyXServerSocket const & Application::socket() const
91 return *pimpl_->lyx_socket_.get();
95 void Application::setBufferView(BufferView * buffer_view)
97 buffer_view_ = buffer_view;
101 LyXView & Application::createView(unsigned int width,
106 // FIXME: please confirm: with unicode, I think initEncoding()
107 // is not needed anymore!
109 // this can't be done before because it needs the Languages object
112 int view_id = gui().newView(width, height);
113 LyXView & view = gui().view(view_id);
115 pimpl_->lyxfunc_.reset(new LyXFunc(&view));
117 // FIXME: for now we assume that there is only one LyXView with id = 0.
118 /*int workArea_id_ =*/ gui().newWorkArea(width, height, 0);
119 //WorkArea * workArea_ = & theApp->gui().workArea(workArea_id_);
122 view.setGeometry(width, height, posx, posy, maximize);
128 int Application::start(std::string const & batch)
130 pimpl_->lyx_server_.reset(new LyXServer(pimpl_->lyxfunc_.get(), lyxrc.lyxpipes));
131 pimpl_->lyx_socket_.reset(new LyXServerSocket(pimpl_->lyxfunc_.get(),
132 lyx::support::os::internal_path(package().temp_dir() + "/lyxsocket")));
134 // handle the batch commands the user asked for
135 if (!batch.empty()) {
136 pimpl_->lyxfunc_->dispatch(lyxaction.lookupFunc(batch));
143 } // namespace frontend
146 FuncStatus getStatus(FuncRequest const & action)
148 return theApp->lyxFunc().getStatus(action);
152 void dispatch(FuncRequest const & action)
154 theApp->lyxFunc().dispatch(action);
160 LyXFunc & theLyXFunc()
162 return theApp->lyxFunc();
166 lyx::frontend::FontLoader & theFontLoader()
168 return theApp->fontLoader();
172 lyx::frontend::FontMetrics const & theFontMetrics(LyXFont const & f)
174 return theApp->fontLoader().metrics(f);
178 lyx::frontend::Clipboard & theClipboard()
180 return theApp->clipboard();
184 lyx::frontend::Selection & theSelection()
186 return theApp->selection();