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"
19 #include "bufferlist.h"
20 #include "funcrequest.h"
21 #include "LyXAction.h"
24 #include "lyxserver.h"
25 #include "lyxsocket.h"
27 #include "support/lstrings.h"
28 #include "support/os.h"
29 #include "support/package.h"
32 using lyx::support::package;
37 /// The main application class private implementation.
38 struct Application_pimpl
41 BufferList buffer_list_;
42 /// our function handler
43 boost::scoped_ptr<LyXFunc> lyxfunc_;
45 boost::scoped_ptr<LyXServer> lyx_server_;
47 boost::scoped_ptr<LyXServerSocket> lyx_socket_;
51 Application::Application(int &, char **)
53 pimpl_ = new Application_pimpl;
57 LyXFunc & Application::lyxFunc()
59 return *pimpl_->lyxfunc_.get();
63 LyXFunc const & Application::lyxFunc() const
65 return *pimpl_->lyxfunc_.get();
69 LyXServer & Application::server()
71 return *pimpl_->lyx_server_.get();
75 LyXServer const & Application::server() const
77 return *pimpl_->lyx_server_.get();
81 LyXServerSocket & Application::socket()
83 return *pimpl_->lyx_socket_.get();
87 LyXServerSocket const & Application::socket() const
89 return *pimpl_->lyx_socket_.get();
93 BufferList & Application::bufferList()
95 return pimpl_->buffer_list_;
99 BufferList const & Application::bufferList() const
101 return pimpl_->buffer_list_;
105 void Application::setBufferView(BufferView * buffer_view)
107 buffer_view_ = buffer_view;
111 LyXView & Application::createView(unsigned int width,
116 // FIXME: please confirm: with unicode, I think initEncoding()
117 // is not needed anymore!
119 // this can't be done before because it needs the Languages object
122 int view_id = gui().newView(width, height);
123 LyXView & view = gui().view(view_id);
125 pimpl_->lyxfunc_.reset(new LyXFunc(&view));
127 // FIXME: for now we assume that there is only one LyXView with id = 0.
128 /*int workArea_id_ =*/ gui().newWorkArea(width, height, 0);
129 //WorkArea * workArea_ = & theApp->gui().workArea(workArea_id_);
132 view.setGeometry(width, height, posx, posy, maximize);
138 int Application::start(std::string const & batch)
140 pimpl_->lyx_server_.reset(new LyXServer(pimpl_->lyxfunc_.get(), lyxrc.lyxpipes));
141 pimpl_->lyx_socket_.reset(new LyXServerSocket(pimpl_->lyxfunc_.get(),
142 lyx::support::os::internal_path(package().temp_dir() + "/lyxsocket")));
144 // handle the batch commands the user asked for
145 if (!batch.empty()) {
146 pimpl_->lyxfunc_->dispatch(lyxaction.lookupFunc(batch));
153 } // namespace frontend