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 "Application.h"
15 #include "Application_pimpl.h"
20 #include "LyXAction.h"
24 #include "support/lstrings.h"
25 #include "support/os.h"
26 #include "support/package.h"
29 using lyx::support::package;
34 Application::Application(int &, char **)
36 pimpl_ = new Application_pimpl;
40 LyXFunc & Application::lyxFunc()
42 return *pimpl_->lyxfunc_.get();
46 LyXFunc const & Application::lyxFunc() const
48 return *pimpl_->lyxfunc_.get();
52 LyXServer & Application::server()
54 return *pimpl_->lyx_server_.get();
58 LyXServer const & Application::server() const
60 return *pimpl_->lyx_server_.get();
64 LyXServerSocket & Application::socket()
66 return *pimpl_->lyx_socket_.get();
70 LyXServerSocket const & Application::socket() const
72 return *pimpl_->lyx_socket_.get();
76 BufferList & Application::bufferList()
78 return pimpl_->buffer_list_;
82 BufferList const & Application::bufferList() const
84 return pimpl_->buffer_list_;
88 void Application::setBufferView(BufferView * buffer_view)
90 buffer_view_ = buffer_view;
94 // FIXME: this whole method needs to be moved to Application.
95 LyXView & Application::createView(unsigned int width,
100 // FIXME: please confirm: with unicode, I think initEncoding()
101 // is not needed anymore!
103 // this can't be done before because it needs the Languages object
106 int view_id = gui().newView(width, height);
107 LyXView & view = gui().view(view_id);
109 pimpl_->lyxfunc_.reset(new LyXFunc(&view));
111 // FIXME: for now we assume that there is only one LyXView with id = 0.
112 /*int workArea_id_ =*/ gui().newWorkArea(width, height, 0);
113 //WorkArea * workArea_ = & theApp->gui().workArea(workArea_id_);
116 view.setGeometry(width, height, posx, posy, maximize);
122 int Application::start(std::string const & batch)
124 pimpl_->lyx_server_.reset(new LyXServer(pimpl_->lyxfunc_.get(), lyxrc.lyxpipes));
125 pimpl_->lyx_socket_.reset(new LyXServerSocket(pimpl_->lyxfunc_.get(),
126 lyx::support::os::internal_path(package().temp_dir() + "/lyxsocket")));
128 // handle the batch commands the user asked for
129 if (!batch.empty()) {
130 pimpl_->lyxfunc_->dispatch(lyxaction.lookupFunc(batch));
137 } // namespace frontend