mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +00:00
This commit transfers the singletons defined in the Application class to the private LyX::Singletons implementation. It also put the session_ member and top_level_keymap global variable into this Singleton structure.
This commit also modifies the LyXFunc class. A LyXView is not needed any more at construction. Neither is the top level keymap. The LyXFunc key sequences are initialized only if we are in GUI mode (lyx::use_gui = true). The next step is to rename LyXFunc::owner to LyXFunc::lyx_view_ and to put some BOOST_ASSERT. A classification between Gui and Kernel oriented LFUNs would also be welcome. *LyX/lyx_main.[Ch]: - LyX::Singletons: new private structure containing all the singletons (except the main LyX one of course). - buffer_list_, top_level_keymap, session_: transfered to the LyX::Singletons structure. * LyXFunc: - LyXFunc: default constructor does not need any arguments. - setupLocalKeymap(): deleted (was not used anywhere). - initKeySequences(): new public method called from lyx_main.C, useful only in lyx::use_gui mode. - new private member accessor methods * Application: - Application_pimpl: deleted (transfered to LyX) - global singleton accessors: transfered to lyx_main.C - start(): code transfered to LyX::priv_exec() git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15367 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
cbe1309573
commit
1f8fe29384
@ -65,8 +65,6 @@ using std::string;
|
|||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
|
||||||
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class MenuNamesEqual : public std::unary_function<Menu, bool> {
|
class MenuNamesEqual : public std::unary_function<Menu, bool> {
|
||||||
@ -139,7 +137,7 @@ docstring const MenuItem::binding() const
|
|||||||
|
|
||||||
// Get the keys bound to this action, but keep only the
|
// Get the keys bound to this action, but keep only the
|
||||||
// first one later
|
// first one later
|
||||||
kb_keymap::Bindings bindings = toplevel_keymap->findbindings(func_);
|
kb_keymap::Bindings bindings = theTopLevelKeymap().findbindings(func_);
|
||||||
|
|
||||||
if (bindings.size()) {
|
if (bindings.size()) {
|
||||||
return lyx::from_utf8(bindings.begin()->print());
|
return lyx::from_utf8(bindings.begin()->print());
|
||||||
|
@ -312,7 +312,7 @@ bool Formats::view(Buffer const & buffer, string const & filename,
|
|||||||
|
|
||||||
command = subst(command, token_from, quoteName(filename));
|
command = subst(command, token_from, quoteName(filename));
|
||||||
command = subst(command, token_path, quoteName(onlyPath(filename)));
|
command = subst(command, token_path, quoteName(onlyPath(filename)));
|
||||||
command = subst(command, token_socket, quoteName(theApp->socket().address()));
|
command = subst(command, token_socket, quoteName(theLyXServerSocket().address()));
|
||||||
lyxerr[Debug::FILES] << "Executing command: " << command << std::endl;
|
lyxerr[Debug::FILES] << "Executing command: " << command << std::endl;
|
||||||
buffer.message(_("Executing command: ") + lyx::from_utf8(command));
|
buffer.message(_("Executing command: ") + lyx::from_utf8(command));
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ bool Formats::edit(Buffer const & buffer, string const & filename,
|
|||||||
|
|
||||||
command = subst(command, token_from, quoteName(filename));
|
command = subst(command, token_from, quoteName(filename));
|
||||||
command = subst(command, token_path, quoteName(onlyPath(filename)));
|
command = subst(command, token_path, quoteName(onlyPath(filename)));
|
||||||
command = subst(command, token_socket, quoteName(theApp->socket().address()));
|
command = subst(command, token_socket, quoteName(theLyXServerSocket().address()));
|
||||||
lyxerr[Debug::FILES] << "Executing command: " << command << std::endl;
|
lyxerr[Debug::FILES] << "Executing command: " << command << std::endl;
|
||||||
buffer.message(_("Executing command: ") + lyx::from_utf8(command));
|
buffer.message(_("Executing command: ") + lyx::from_utf8(command));
|
||||||
|
|
||||||
|
@ -20,16 +20,12 @@
|
|||||||
#include "frontends/LyXView.h"
|
#include "frontends/LyXView.h"
|
||||||
#include "frontends/WorkArea.h"
|
#include "frontends/WorkArea.h"
|
||||||
|
|
||||||
#include "bufferlist.h"
|
|
||||||
#include "funcrequest.h"
|
#include "funcrequest.h"
|
||||||
#include "FuncStatus.h"
|
#include "FuncStatus.h"
|
||||||
#include "lyx_main.h"
|
#include "lyx_main.h"
|
||||||
#include "LyXAction.h"
|
|
||||||
#include "lyxfont.h"
|
#include "lyxfont.h"
|
||||||
#include "lyxfunc.h"
|
#include "lyxfunc.h"
|
||||||
#include "lyxrc.h"
|
#include "lyxrc.h"
|
||||||
#include "lyxserver.h"
|
|
||||||
#include "lyxsocket.h"
|
|
||||||
|
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
#include "support/os.h"
|
#include "support/os.h"
|
||||||
@ -43,57 +39,9 @@ using lyx::support::package;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
/// 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_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
Application::Application(int &, char **)
|
Application::Application(int &, char **)
|
||||||
{
|
{
|
||||||
pimpl_ = new Application_pimpl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
LyXFunc & Application::lyxFunc()
|
|
||||||
{
|
|
||||||
return *pimpl_->lyxfunc_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
LyXFunc const & Application::lyxFunc() const
|
|
||||||
{
|
|
||||||
return *pimpl_->lyxfunc_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
LyXServer & Application::server()
|
|
||||||
{
|
|
||||||
return *pimpl_->lyx_server_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
LyXServer const & Application::server() const
|
|
||||||
{
|
|
||||||
return *pimpl_->lyx_server_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
LyXServerSocket & Application::socket()
|
|
||||||
{
|
|
||||||
return *pimpl_->lyx_socket_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
LyXServerSocket const & Application::socket() const
|
|
||||||
{
|
|
||||||
return *pimpl_->lyx_socket_.get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -117,7 +65,7 @@ LyXView & Application::createView(unsigned int width,
|
|||||||
int view_id = gui().newView();
|
int view_id = gui().newView();
|
||||||
LyXView & view = gui().view(view_id);
|
LyXView & view = gui().view(view_id);
|
||||||
|
|
||||||
pimpl_->lyxfunc_.reset(new LyXFunc(&view));
|
theLyXFunc().setLyXView(&view);
|
||||||
|
|
||||||
// FIXME: for now we assume that there is only one LyXView with id = 0.
|
// FIXME: for now we assume that there is only one LyXView with id = 0.
|
||||||
/*int workArea_id_ =*/ gui().newWorkArea(width, height, 0);
|
/*int workArea_id_ =*/ gui().newWorkArea(width, height, 0);
|
||||||
@ -132,42 +80,13 @@ LyXView & Application::createView(unsigned int width,
|
|||||||
|
|
||||||
int Application::start(std::string const & batch)
|
int Application::start(std::string const & batch)
|
||||||
{
|
{
|
||||||
pimpl_->lyx_server_.reset(new LyXServer(pimpl_->lyxfunc_.get(), lyxrc.lyxpipes));
|
|
||||||
pimpl_->lyx_socket_.reset(new LyXServerSocket(pimpl_->lyxfunc_.get(),
|
|
||||||
lyx::support::os::internal_path(package().temp_dir() + "/lyxsocket")));
|
|
||||||
|
|
||||||
// handle the batch commands the user asked for
|
|
||||||
if (!batch.empty()) {
|
|
||||||
pimpl_->lyxfunc_->dispatch(lyxaction.lookupFunc(batch));
|
|
||||||
}
|
|
||||||
|
|
||||||
return exec();
|
return exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
|
||||||
|
|
||||||
FuncStatus getStatus(FuncRequest const & action)
|
|
||||||
{
|
|
||||||
return theApp->lyxFunc().getStatus(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void dispatch(FuncRequest const & action)
|
|
||||||
{
|
|
||||||
theApp->lyxFunc().dispatch(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
|
|
||||||
LyXFunc & theLyXFunc()
|
|
||||||
{
|
|
||||||
BOOST_ASSERT(theApp);
|
|
||||||
return theApp->lyxFunc();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
lyx::frontend::FontLoader & theFontLoader()
|
lyx::frontend::FontLoader & theFontLoader()
|
||||||
{
|
{
|
||||||
static lyx::frontend::NoGuiFontLoader no_gui_font_loader;
|
static lyx::frontend::NoGuiFontLoader no_gui_font_loader;
|
||||||
|
@ -15,11 +15,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class BufferList;
|
|
||||||
class BufferView;
|
class BufferView;
|
||||||
class LyXFunc;
|
|
||||||
class LyXServer;
|
|
||||||
class LyXServerSocket;
|
|
||||||
class LyXView;
|
class LyXView;
|
||||||
class LColor_color;
|
class LColor_color;
|
||||||
|
|
||||||
@ -29,7 +25,6 @@ struct RGBColor;
|
|||||||
|
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
struct Application_pimpl;
|
|
||||||
class Clipboard;
|
class Clipboard;
|
||||||
class FontLoader;
|
class FontLoader;
|
||||||
class Gui;
|
class Gui;
|
||||||
@ -116,16 +111,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void unregisterSocketCallback(int fd) = 0;
|
virtual void unregisterSocketCallback(int fd) = 0;
|
||||||
|
|
||||||
///
|
|
||||||
LyXFunc & lyxFunc();
|
|
||||||
LyXFunc const & lyxFunc() const;
|
|
||||||
///
|
|
||||||
LyXServer & server();
|
|
||||||
LyXServer const & server() const;
|
|
||||||
///
|
|
||||||
LyXServerSocket & socket();
|
|
||||||
LyXServerSocket const & socket() const;
|
|
||||||
|
|
||||||
/// Create the main window with given geometry settings.
|
/// Create the main window with given geometry settings.
|
||||||
LyXView & createView(unsigned int width, unsigned int height,
|
LyXView & createView(unsigned int width, unsigned int height,
|
||||||
int posx, int posy, bool maximize);
|
int posx, int posy, bool maximize);
|
||||||
@ -139,10 +124,6 @@ protected:
|
|||||||
/// FIXME: \todo use Gui::currentView() in the future
|
/// FIXME: \todo use Gui::currentView() in the future
|
||||||
BufferView * buffer_view_;
|
BufferView * buffer_view_;
|
||||||
|
|
||||||
private:
|
|
||||||
/// Application private implementation.
|
|
||||||
Application_pimpl * pimpl_;
|
|
||||||
|
|
||||||
}; // Application
|
}; // Application
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#ifdef Q_WS_MACX
|
#ifdef Q_WS_MACX
|
||||||
#include "kbmap.h"
|
#include "kbmap.h"
|
||||||
#include "QLyXKeySym.h"
|
#include "QLyXKeySym.h"
|
||||||
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
@ -137,7 +136,7 @@ void QLPopupMenu::populate(Menu * menu)
|
|||||||
needed (JMarc)
|
needed (JMarc)
|
||||||
*/
|
*/
|
||||||
pair<LyXKeySym const *, key_modifier::state>
|
pair<LyXKeySym const *, key_modifier::state>
|
||||||
binding = toplevel_keymap->find1keybinding(m->func());
|
binding = theTopLevelKeymap().find1keybinding(m->func());
|
||||||
if (binding.first) {
|
if (binding.first) {
|
||||||
QLyXKeySym const *key = static_cast<QLyXKeySym const *>(binding.first);
|
QLyXKeySym const *key = static_cast<QLyXKeySym const *>(binding.first);
|
||||||
label += '\t' + key->qprint(binding.second);
|
label += '\t' + key->qprint(binding.second);
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#ifdef Q_WS_MACX
|
#ifdef Q_WS_MACX
|
||||||
#include "kbmap.h"
|
#include "kbmap.h"
|
||||||
#include "QLyXKeySym.h"
|
#include "QLyXKeySym.h"
|
||||||
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using std::make_pair;
|
using std::make_pair;
|
||||||
|
@ -126,4 +126,7 @@ private:
|
|||||||
Table table;
|
Table table;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Implementation is in lyx_main.C
|
||||||
|
extern kb_keymap & theTopLevelKeymap();
|
||||||
|
|
||||||
#endif // KBMAP_H
|
#endif // KBMAP_H
|
||||||
|
235
src/lyx_main.C
235
src/lyx_main.C
@ -31,10 +31,12 @@
|
|||||||
#include "session.h"
|
#include "session.h"
|
||||||
#include "LColor.h"
|
#include "LColor.h"
|
||||||
#include "lyx_cb.h"
|
#include "lyx_cb.h"
|
||||||
|
#include "LyXAction.h"
|
||||||
#include "lyxfunc.h"
|
#include "lyxfunc.h"
|
||||||
#include "lyxlex.h"
|
#include "lyxlex.h"
|
||||||
#include "lyxrc.h"
|
#include "lyxrc.h"
|
||||||
#include "lyxserver.h"
|
#include "lyxserver.h"
|
||||||
|
#include "lyxsocket.h"
|
||||||
#include "lyxtextclasslist.h"
|
#include "lyxtextclasslist.h"
|
||||||
#include "MenuBackend.h"
|
#include "MenuBackend.h"
|
||||||
#include "mover.h"
|
#include "mover.h"
|
||||||
@ -92,10 +94,6 @@ using std::signal;
|
|||||||
using std::system;
|
using std::system;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/// convenient to have it here.
|
|
||||||
boost::scoped_ptr<kb_keymap> toplevel_keymap;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
lyx::frontend::Application * theApp = 0;
|
lyx::frontend::Application * theApp = 0;
|
||||||
|
|
||||||
@ -107,7 +105,8 @@ namespace lyx {
|
|||||||
*/
|
*/
|
||||||
bool use_gui = true;
|
bool use_gui = true;
|
||||||
|
|
||||||
}
|
} // namespace lyx
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -139,8 +138,29 @@ void reconfigureUserLyXDir()
|
|||||||
} // namespace anon
|
} // namespace anon
|
||||||
|
|
||||||
|
|
||||||
|
/// The main application class private implementation.
|
||||||
|
struct LyX::Singletons
|
||||||
|
{
|
||||||
|
/// our function handler
|
||||||
|
LyXFunc lyxfunc_;
|
||||||
|
///
|
||||||
|
BufferList buffer_list_;
|
||||||
|
///
|
||||||
|
boost::scoped_ptr<kb_keymap> toplevel_keymap_;
|
||||||
|
///
|
||||||
|
boost::scoped_ptr<LyXServer> lyx_server_;
|
||||||
|
///
|
||||||
|
boost::scoped_ptr<LyXServerSocket> lyx_socket_;
|
||||||
|
///
|
||||||
|
boost::scoped_ptr<lyx::frontend::Application> application_;
|
||||||
|
/// lyx session, containing lastfiles, lastfilepos, and lastopened
|
||||||
|
boost::scoped_ptr<lyx::Session> session_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
boost::scoped_ptr<LyX> LyX::singleton_;
|
boost::scoped_ptr<LyX> LyX::singleton_;
|
||||||
|
|
||||||
|
|
||||||
int LyX::exec(int & argc, char * argv[])
|
int LyX::exec(int & argc, char * argv[])
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(!singleton_.get());
|
BOOST_ASSERT(!singleton_.get());
|
||||||
@ -167,45 +187,106 @@ LyX const & LyX::cref()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BufferList & theBufferList()
|
|
||||||
{
|
|
||||||
return LyX::ref().bufferList();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
LyX::LyX()
|
LyX::LyX()
|
||||||
: first_start(false), geometryOption_(false)
|
: first_start(false), geometryOption_(false)
|
||||||
{
|
{
|
||||||
buffer_list_.reset(new BufferList);
|
pimpl_.reset(new Singletons);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BufferList & LyX::bufferList()
|
BufferList & LyX::bufferList()
|
||||||
{
|
{
|
||||||
return *buffer_list_.get();
|
return pimpl_->buffer_list_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BufferList const & LyX::bufferList() const
|
BufferList const & LyX::bufferList() const
|
||||||
{
|
{
|
||||||
return *buffer_list_.get();
|
return pimpl_->buffer_list_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lyx::Session & LyX::session()
|
lyx::Session & LyX::session()
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(session_.get());
|
BOOST_ASSERT(pimpl_->session_.get());
|
||||||
return *session_.get();
|
return *pimpl_->session_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lyx::Session const & LyX::session() const
|
lyx::Session const & LyX::session() const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(session_.get());
|
BOOST_ASSERT(pimpl_->session_.get());
|
||||||
return *session_.get();
|
return *pimpl_->session_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LyXFunc & LyX::lyxFunc()
|
||||||
|
{
|
||||||
|
return pimpl_->lyxfunc_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LyXFunc const & LyX::lyxFunc() const
|
||||||
|
{
|
||||||
|
return pimpl_->lyxfunc_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LyXServer & LyX::server()
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(pimpl_->lyx_server_.get());
|
||||||
|
return *pimpl_->lyx_server_.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LyXServer const & LyX::server() const
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(pimpl_->lyx_server_.get());
|
||||||
|
return *pimpl_->lyx_server_.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LyXServerSocket & LyX::socket()
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(pimpl_->lyx_socket_.get());
|
||||||
|
return *pimpl_->lyx_socket_.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LyXServerSocket const & LyX::socket() const
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(pimpl_->lyx_socket_.get());
|
||||||
|
return *pimpl_->lyx_socket_.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
lyx::frontend::Application & LyX::application()
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(pimpl_->application_.get());
|
||||||
|
return *pimpl_->application_.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
lyx::frontend::Application const & LyX::application() const
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(pimpl_->application_.get());
|
||||||
|
return *pimpl_->application_.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
kb_keymap & LyX::topLevelKeymap()
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(pimpl_->toplevel_keymap_.get());
|
||||||
|
return *pimpl_->toplevel_keymap_.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
kb_keymap const & LyX::topLevelKeymap() const
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(pimpl_->toplevel_keymap_.get());
|
||||||
|
return *pimpl_->toplevel_keymap_.get();
|
||||||
|
}
|
||||||
|
|
||||||
void LyX::addLyXView(LyXView * lyxview)
|
void LyX::addLyXView(LyXView * lyxview)
|
||||||
{
|
{
|
||||||
views_.push_back(lyxview);
|
views_.push_back(lyxview);
|
||||||
@ -243,20 +324,36 @@ int LyX::priv_exec(int & argc, char * argv[])
|
|||||||
|
|
||||||
if (exit_status)
|
if (exit_status)
|
||||||
return exit_status;
|
return exit_status;
|
||||||
|
|
||||||
if (lyx::use_gui) {
|
if (lyx::use_gui) {
|
||||||
// Force adding of font path _before_ Application is initialized
|
// Force adding of font path _before_ Application is initialized
|
||||||
lyx::support::addFontResources();
|
lyx::support::addFontResources();
|
||||||
application_.reset(lyx::createApplication(argc, argv));
|
pimpl_->application_.reset(lyx::createApplication(argc, argv));
|
||||||
initGuiFont();
|
initGuiFont();
|
||||||
// FIXME: this global pointer should probably go.
|
// FIXME: this global pointer should probably go.
|
||||||
theApp = application_.get();
|
theApp = pimpl_->application_.get();
|
||||||
restoreGuiSession(files);
|
restoreGuiSession(files);
|
||||||
// Start the real execution loop.
|
// Start the real execution loop.
|
||||||
exit_status = application_->start(batch_command);
|
|
||||||
|
// FIXME
|
||||||
|
/* Create a CoreApplication class that will provide the main event loop and
|
||||||
|
* the socket callback registering. With Qt4, only QtCore library would be needed.
|
||||||
|
* When this done, a lyx::server_mode could be created and the following two
|
||||||
|
* line would be moved out from here.
|
||||||
|
*/
|
||||||
|
pimpl_->lyx_server_.reset(new LyXServer(&pimpl_->lyxfunc_, lyxrc.lyxpipes));
|
||||||
|
pimpl_->lyx_socket_.reset(new LyXServerSocket(&pimpl_->lyxfunc_,
|
||||||
|
lyx::support::os::internal_path(package().temp_dir() + "/lyxsocket")));
|
||||||
|
|
||||||
|
// handle the batch commands the user asked for
|
||||||
|
if (!batch_command.empty()) {
|
||||||
|
pimpl_->lyxfunc_.dispatch(lyxaction.lookupFunc(batch_command));
|
||||||
|
}
|
||||||
|
|
||||||
|
exit_status = pimpl_->application_->start(batch_command);
|
||||||
// Kill the application object before exiting. This avoid crash
|
// Kill the application object before exiting. This avoid crash
|
||||||
// on exit on Linux.
|
// on exit on Linux.
|
||||||
application_.reset();
|
pimpl_->application_.reset();
|
||||||
// Restore original font resources after Application is destroyed.
|
// Restore original font resources after Application is destroyed.
|
||||||
lyx::support::restoreFontResources();
|
lyx::support::restoreFontResources();
|
||||||
}
|
}
|
||||||
@ -276,7 +373,7 @@ void LyX::prepareExit()
|
|||||||
quitting = true;
|
quitting = true;
|
||||||
|
|
||||||
// close buffers first
|
// close buffers first
|
||||||
buffer_list_->closeAll();
|
pimpl_->buffer_list_.closeAll();
|
||||||
|
|
||||||
// do any other cleanup procedures now
|
// do any other cleanup procedures now
|
||||||
lyxerr[Debug::INFO] << "Deleting tmp dir " << package().temp_dir() << endl;
|
lyxerr[Debug::INFO] << "Deleting tmp dir " << package().temp_dir() << endl;
|
||||||
@ -292,8 +389,8 @@ void LyX::prepareExit()
|
|||||||
|
|
||||||
void LyX::earlyExit(int status)
|
void LyX::earlyExit(int status)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(application_.get());
|
BOOST_ASSERT(pimpl_->application_.get());
|
||||||
// LyX::application_ is not initialised at this
|
// LyX::pimpl_::application_ is not initialised at this
|
||||||
// point so it's safe to just exit after some cleanup.
|
// point so it's safe to just exit after some cleanup.
|
||||||
prepareExit();
|
prepareExit();
|
||||||
exit(status);
|
exit(status);
|
||||||
@ -305,16 +402,16 @@ void LyX::quit(bool noask)
|
|||||||
lyxerr[Debug::INFO] << "Running QuitLyX." << endl;
|
lyxerr[Debug::INFO] << "Running QuitLyX." << endl;
|
||||||
|
|
||||||
if (lyx::use_gui) {
|
if (lyx::use_gui) {
|
||||||
if (!noask && !buffer_list_->quitWriteAll())
|
if (!noask && !pimpl_->buffer_list_.quitWriteAll())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
session_->writeFile();
|
pimpl_->session_->writeFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareExit();
|
prepareExit();
|
||||||
|
|
||||||
if (lyx::use_gui) {
|
if (lyx::use_gui) {
|
||||||
application_->exit(0);
|
pimpl_->application_->exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +463,7 @@ int LyX::execBatchCommands(int & argc, char * argv[],
|
|||||||
if (b)
|
if (b)
|
||||||
last_loaded = b;
|
last_loaded = b;
|
||||||
} else {
|
} else {
|
||||||
Buffer * buf = buffer_list_->newBuffer(s, false);
|
Buffer * buf = pimpl_->buffer_list_.newBuffer(s, false);
|
||||||
if (loadLyXFile(buf, s)) {
|
if (loadLyXFile(buf, s)) {
|
||||||
last_loaded = buf;
|
last_loaded = buf;
|
||||||
ErrorList const & el = buf->errorList("Parse");
|
ErrorList const & el = buf->errorList("Parse");
|
||||||
@ -375,7 +472,7 @@ int LyX::execBatchCommands(int & argc, char * argv[],
|
|||||||
boost::bind(&LyX::printError, this, _1));
|
boost::bind(&LyX::printError, this, _1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
buffer_list_->release(buf);
|
pimpl_->buffer_list_.release(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,7 +531,7 @@ void LyX::restoreGuiSession(vector<string> const & files)
|
|||||||
height = 0;
|
height = 0;
|
||||||
}
|
}
|
||||||
// create the main window
|
// create the main window
|
||||||
LyXView * view = &application_->createView(width, height, posx, posy, maximize);
|
LyXView * view = &pimpl_->application_->createView(width, height, posx, posy, maximize);
|
||||||
ref().addLyXView(view);
|
ref().addLyXView(view);
|
||||||
|
|
||||||
// load files
|
// load files
|
||||||
@ -443,7 +540,7 @@ void LyX::restoreGuiSession(vector<string> const & files)
|
|||||||
|
|
||||||
// if a file is specified, I assume that user wants to edit *that* file
|
// if a file is specified, I assume that user wants to edit *that* file
|
||||||
if (files.empty() && lyxrc.load_session) {
|
if (files.empty() && lyxrc.load_session) {
|
||||||
vector<string> const & lastopened = session_->lastOpenedFiles();
|
vector<string> const & lastopened = pimpl_->session_->lastOpenedFiles();
|
||||||
// do not add to the lastfile list since these files are restored from
|
// do not add to the lastfile list since these files are restored from
|
||||||
// last seesion, and should be already there (regular files), or should
|
// last seesion, and should be already there (regular files), or should
|
||||||
// not be added at all (help files).
|
// not be added at all (help files).
|
||||||
@ -451,7 +548,7 @@ void LyX::restoreGuiSession(vector<string> const & files)
|
|||||||
bind(&LyXView::loadLyXFile, view, _1, false));
|
bind(&LyXView::loadLyXFile, view, _1, false));
|
||||||
}
|
}
|
||||||
// clear this list to save a few bytes of RAM
|
// clear this list to save a few bytes of RAM
|
||||||
session_->clearLastOpenedFiles();
|
pimpl_->session_->clearLastOpenedFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -565,14 +662,14 @@ void LyX::printError(ErrorItem const & ei)
|
|||||||
void LyX::initGuiFont()
|
void LyX::initGuiFont()
|
||||||
{
|
{
|
||||||
if (lyxrc.roman_font_name.empty())
|
if (lyxrc.roman_font_name.empty())
|
||||||
lyxrc.roman_font_name = application_->romanFontName();
|
lyxrc.roman_font_name = pimpl_->application_->romanFontName();
|
||||||
|
|
||||||
if (lyxrc.sans_font_name.empty())
|
if (lyxrc.sans_font_name.empty())
|
||||||
lyxrc.sans_font_name = application_->sansFontName();
|
lyxrc.sans_font_name = pimpl_->application_->sansFontName();
|
||||||
|
|
||||||
if (lyxrc.typewriter_font_name.empty())
|
if (lyxrc.typewriter_font_name.empty())
|
||||||
lyxrc.typewriter_font_name
|
lyxrc.typewriter_font_name
|
||||||
= application_->typewriterFontName();
|
= pimpl_->application_->typewriterFontName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -651,9 +748,11 @@ bool LyX::init()
|
|||||||
|
|
||||||
if (lyx::use_gui) {
|
if (lyx::use_gui) {
|
||||||
// Set up bindings
|
// Set up bindings
|
||||||
toplevel_keymap.reset(new kb_keymap);
|
pimpl_->toplevel_keymap_.reset(new kb_keymap);
|
||||||
defaultKeyBindings(toplevel_keymap.get());
|
defaultKeyBindings(pimpl_->toplevel_keymap_.get());
|
||||||
toplevel_keymap->read(lyxrc.bind_file);
|
pimpl_->toplevel_keymap_->read(lyxrc.bind_file);
|
||||||
|
|
||||||
|
pimpl_->lyxfunc_.initKeySequences(pimpl_->toplevel_keymap_.get());
|
||||||
|
|
||||||
// Read menus
|
// Read menus
|
||||||
if (!readUIFile(lyxrc.ui_file))
|
if (!readUIFile(lyxrc.ui_file))
|
||||||
@ -691,7 +790,7 @@ bool LyX::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
lyxerr[Debug::INIT] << "Reading session information '.lyx/session'..." << endl;
|
lyxerr[Debug::INIT] << "Reading session information '.lyx/session'..." << endl;
|
||||||
session_.reset(new lyx::Session(lyxrc.num_lastfiles));
|
pimpl_->session_.reset(new lyx::Session(lyxrc.num_lastfiles));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -755,9 +854,9 @@ void LyX::emergencyCleanup() const
|
|||||||
// contain documents etc. which might be helpful on
|
// contain documents etc. which might be helpful on
|
||||||
// a crash
|
// a crash
|
||||||
|
|
||||||
buffer_list_->emergencyWriteAll();
|
pimpl_->buffer_list_.emergencyWriteAll();
|
||||||
if (lyx::use_gui)
|
if (lyx::use_gui)
|
||||||
application_->server().emergencyCleanup();
|
pimpl_->lyx_server_->emergencyCleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1150,3 +1249,53 @@ void LyX::easyParse(int & argc, char * argv[])
|
|||||||
|
|
||||||
batch_command = batch;
|
batch_command = batch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
|
||||||
|
FuncStatus getStatus(FuncRequest const & action)
|
||||||
|
{
|
||||||
|
return LyX::ref().lyxFunc().getStatus(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void dispatch(FuncRequest const & action)
|
||||||
|
{
|
||||||
|
LyX::ref().lyxFunc().dispatch(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
|
||||||
|
BufferList & theBufferList()
|
||||||
|
{
|
||||||
|
return LyX::ref().bufferList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LyXFunc & theLyXFunc()
|
||||||
|
{
|
||||||
|
return LyX::ref().lyxFunc();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LyXServer & theLyXServer()
|
||||||
|
{
|
||||||
|
// FIXME: this should not be use_gui dependent
|
||||||
|
BOOST_ASSERT(lyx::use_gui);
|
||||||
|
return LyX::ref().server();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LyXServerSocket & theLyXServerSocket()
|
||||||
|
{
|
||||||
|
// FIXME: this should not be use_gui dependent
|
||||||
|
BOOST_ASSERT(lyx::use_gui);
|
||||||
|
return LyX::ref().socket();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
kb_keymap & theTopLevelKeymap()
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(lyx::use_gui);
|
||||||
|
return LyX::ref().topLevelKeymap();
|
||||||
|
}
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#define LYX_MAIN_H
|
#define LYX_MAIN_H
|
||||||
|
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
@ -26,9 +25,13 @@ class Buffer;
|
|||||||
class BufferList;
|
class BufferList;
|
||||||
class ErrorItem;
|
class ErrorItem;
|
||||||
class InsetBase;
|
class InsetBase;
|
||||||
|
class LyXFunc;
|
||||||
|
class LyXServer;
|
||||||
|
class LyXServerSocket;
|
||||||
class LyXView;
|
class LyXView;
|
||||||
class kb_keymap;
|
class kb_keymap;
|
||||||
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
extern bool use_gui;
|
extern bool use_gui;
|
||||||
class Session;
|
class Session;
|
||||||
@ -74,6 +77,23 @@ public:
|
|||||||
///
|
///
|
||||||
lyx::Session & session();
|
lyx::Session & session();
|
||||||
lyx::Session const & session() const;
|
lyx::Session const & session() const;
|
||||||
|
///
|
||||||
|
LyXFunc & lyxFunc();
|
||||||
|
LyXFunc const & lyxFunc() const;
|
||||||
|
///
|
||||||
|
LyXServer & server();
|
||||||
|
LyXServer const & server() const;
|
||||||
|
///
|
||||||
|
LyXServerSocket & socket();
|
||||||
|
LyXServerSocket const & socket() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
lyx::frontend::Application & application();
|
||||||
|
lyx::frontend::Application const & application() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
kb_keymap & topLevelKeymap();
|
||||||
|
kb_keymap const & topLevelKeymap() const;
|
||||||
|
|
||||||
void addLyXView(LyXView * lyxview);
|
void addLyXView(LyXView * lyxview);
|
||||||
|
|
||||||
@ -139,19 +159,15 @@ private:
|
|||||||
/// the parsed command line batch command if any
|
/// the parsed command line batch command if any
|
||||||
std::string batch_command;
|
std::string batch_command;
|
||||||
|
|
||||||
///
|
/// Use the Pimpl idiom to hide the internals.
|
||||||
boost::scoped_ptr<BufferList> buffer_list_;
|
struct Singletons;
|
||||||
/// lyx session, containing lastfiles, lastfilepos, and lastopened
|
boost::scoped_ptr<Singletons> pimpl_;
|
||||||
boost::scoped_ptr<lyx::Session> session_;
|
|
||||||
///
|
///
|
||||||
typedef std::list<LyXView *> ViewList;
|
typedef std::list<LyXView *> ViewList;
|
||||||
ViewList views_;
|
ViewList views_;
|
||||||
|
|
||||||
///
|
///
|
||||||
bool geometryOption_;
|
bool geometryOption_;
|
||||||
|
|
||||||
///
|
|
||||||
boost::scoped_ptr<lyx::frontend::Application> application_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LYX_MAIN_H
|
#endif // LYX_MAIN_H
|
||||||
|
@ -141,8 +141,6 @@ namespace biblio = lyx::biblio;
|
|||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
|
|
||||||
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
|
|
||||||
|
|
||||||
// (alkis)
|
// (alkis)
|
||||||
extern tex_accent_struct get_accent(kb_action action);
|
extern tex_accent_struct get_accent(kb_action action);
|
||||||
|
|
||||||
@ -202,26 +200,32 @@ Change::Type lookupChangeType(DocIterator const & dit, bool outer = false)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LyXFunc::LyXFunc(LyXView * lv)
|
LyXFunc::LyXFunc()
|
||||||
: owner(lv),
|
: owner(0),
|
||||||
encoded_last_key(0),
|
encoded_last_key(0),
|
||||||
keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
|
|
||||||
cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get()),
|
|
||||||
meta_fake_bit(key_modifier::none)
|
meta_fake_bit(key_modifier::none)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LyXFunc::initKeySequences(kb_keymap * kb)
|
||||||
|
{
|
||||||
|
keyseq.reset(new kb_sequence(kb, kb));
|
||||||
|
cancel_meta_seq.reset(new kb_sequence(kb, kb));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXFunc::setLyXView(LyXView * lv)
|
void LyXFunc::setLyXView(LyXView * lv)
|
||||||
{
|
{
|
||||||
owner = lv;
|
owner = lv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXFunc::handleKeyFunc(kb_action action)
|
void LyXFunc::handleKeyFunc(kb_action action)
|
||||||
{
|
{
|
||||||
char c = encoded_last_key;
|
char c = encoded_last_key;
|
||||||
|
|
||||||
if (keyseq.length()) {
|
if (keyseq->length()) {
|
||||||
c = 0;
|
c = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +233,7 @@ void LyXFunc::handleKeyFunc(kb_action action)
|
|||||||
.deadkey(c, get_accent(action).accent, view()->getLyXText());
|
.deadkey(c, get_accent(action).accent, view()->getLyXText());
|
||||||
// Need to clear, in case the minibuffer calls these
|
// Need to clear, in case the minibuffer calls these
|
||||||
// actions
|
// actions
|
||||||
keyseq.clear();
|
keyseq->clear();
|
||||||
// copied verbatim from do_accent_char
|
// copied verbatim from do_accent_char
|
||||||
view()->cursor().resetAnchor();
|
view()->cursor().resetAnchor();
|
||||||
view()->update();
|
view()->update();
|
||||||
@ -259,9 +263,9 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
|
|||||||
|
|
||||||
// Do a one-deep top-level lookup for
|
// Do a one-deep top-level lookup for
|
||||||
// cancel and meta-fake keys. RVDK_PATCH_5
|
// cancel and meta-fake keys. RVDK_PATCH_5
|
||||||
cancel_meta_seq.reset();
|
cancel_meta_seq->reset();
|
||||||
|
|
||||||
FuncRequest func = cancel_meta_seq.addkey(keysym, state);
|
FuncRequest func = cancel_meta_seq->addkey(keysym, state);
|
||||||
lyxerr[Debug::KEY] << BOOST_CURRENT_FUNCTION
|
lyxerr[Debug::KEY] << BOOST_CURRENT_FUNCTION
|
||||||
<< " action first set to [" << func.action << ']'
|
<< " action first set to [" << func.action << ']'
|
||||||
<< endl;
|
<< endl;
|
||||||
@ -271,7 +275,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
|
|||||||
// Mostly, meta_fake_bit = key_modifier::none. RVDK_PATCH_5.
|
// Mostly, meta_fake_bit = key_modifier::none. RVDK_PATCH_5.
|
||||||
if ((func.action != LFUN_CANCEL) && (func.action != LFUN_META_PREFIX)) {
|
if ((func.action != LFUN_CANCEL) && (func.action != LFUN_META_PREFIX)) {
|
||||||
// remove Caps Lock and Mod2 as a modifiers
|
// remove Caps Lock and Mod2 as a modifiers
|
||||||
func = keyseq.addkey(keysym, (state | meta_fake_bit));
|
func = keyseq->addkey(keysym, (state | meta_fake_bit));
|
||||||
lyxerr[Debug::KEY] << BOOST_CURRENT_FUNCTION
|
lyxerr[Debug::KEY] << BOOST_CURRENT_FUNCTION
|
||||||
<< "action now set to ["
|
<< "action now set to ["
|
||||||
<< func.action << ']' << endl;
|
<< func.action << ']' << endl;
|
||||||
@ -289,7 +293,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
|
|||||||
lyxerr << BOOST_CURRENT_FUNCTION
|
lyxerr << BOOST_CURRENT_FUNCTION
|
||||||
<< " Key [action="
|
<< " Key [action="
|
||||||
<< func.action << "]["
|
<< func.action << "]["
|
||||||
<< keyseq.print() << ']'
|
<< keyseq->print() << ']'
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,8 +301,8 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
|
|||||||
// why not return already here if action == -1 and
|
// why not return already here if action == -1 and
|
||||||
// num_bytes == 0? (Lgb)
|
// num_bytes == 0? (Lgb)
|
||||||
|
|
||||||
if (keyseq.length() > 1) {
|
if (keyseq->length() > 1) {
|
||||||
owner->message(lyx::from_utf8(keyseq.print()));
|
owner->message(lyx::from_utf8(keyseq->print()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -307,7 +311,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
|
|||||||
if (func.action == LFUN_UNKNOWN_ACTION &&
|
if (func.action == LFUN_UNKNOWN_ACTION &&
|
||||||
state == key_modifier::shift) {
|
state == key_modifier::shift) {
|
||||||
lyxerr[Debug::KEY] << "Trying without shift" << endl;
|
lyxerr[Debug::KEY] << "Trying without shift" << endl;
|
||||||
func = keyseq.addkey(keysym, key_modifier::none);
|
func = keyseq->addkey(keysym, key_modifier::none);
|
||||||
lyxerr[Debug::KEY] << "Action now " << func.action << endl;
|
lyxerr[Debug::KEY] << "Action now " << func.action << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,7 +319,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
|
|||||||
// Hmm, we didn't match any of the keysequences. See
|
// Hmm, we didn't match any of the keysequences. See
|
||||||
// if it's normal insertable text not already covered
|
// if it's normal insertable text not already covered
|
||||||
// by a binding
|
// by a binding
|
||||||
if (keysym->isText() && keyseq.length() == 1) {
|
if (keysym->isText() && keyseq->length() == 1) {
|
||||||
lyxerr[Debug::KEY] << "isText() is true, inserting." << endl;
|
lyxerr[Debug::KEY] << "isText() is true, inserting." << endl;
|
||||||
func = FuncRequest(LFUN_SELF_INSERT,
|
func = FuncRequest(LFUN_SELF_INSERT,
|
||||||
FuncRequest::KEYBOARD);
|
FuncRequest::KEYBOARD);
|
||||||
@ -765,7 +769,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_COMMAND_PREFIX:
|
case LFUN_COMMAND_PREFIX:
|
||||||
owner->message(lyx::from_utf8(keyseq.printOptions()));
|
owner->message(lyx::from_utf8(keyseq->printOptions()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_COMMAND_EXECUTE:
|
case LFUN_COMMAND_EXECUTE:
|
||||||
@ -774,7 +778,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_CANCEL:
|
case LFUN_CANCEL:
|
||||||
keyseq.reset();
|
keyseq->reset();
|
||||||
meta_fake_bit = key_modifier::none;
|
meta_fake_bit = key_modifier::none;
|
||||||
if (view()->buffer())
|
if (view()->buffer())
|
||||||
// cancel any selection
|
// cancel any selection
|
||||||
@ -784,7 +788,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
|
|
||||||
case LFUN_META_PREFIX:
|
case LFUN_META_PREFIX:
|
||||||
meta_fake_bit = key_modifier::alt;
|
meta_fake_bit = key_modifier::alt;
|
||||||
setMessage(lyx::from_utf8(keyseq.print()));
|
setMessage(lyx::from_utf8(keyseq->print()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_BUFFER_TOGGLE_READ_ONLY:
|
case LFUN_BUFFER_TOGGLE_READ_ONLY:
|
||||||
@ -1120,8 +1124,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_SERVER_NOTIFY:
|
case LFUN_SERVER_NOTIFY:
|
||||||
dispatch_buffer = lyx::from_utf8(keyseq.print());
|
dispatch_buffer = lyx::from_utf8(keyseq->print());
|
||||||
theApp->server().notifyClient(lyx::to_utf8(dispatch_buffer));
|
theLyXServer().notifyClient(lyx::to_utf8(dispatch_buffer));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_SERVER_GOTO_FILE_ROW: {
|
case LFUN_SERVER_GOTO_FILE_ROW: {
|
||||||
@ -1656,7 +1660,7 @@ void LyXFunc::sendDispatchMessage(docstring const & msg, FuncRequest const & cmd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string const shortcuts = toplevel_keymap->printbindings(cmd);
|
string const shortcuts = theTopLevelKeymap().printbindings(cmd);
|
||||||
|
|
||||||
if (!shortcuts.empty())
|
if (!shortcuts.empty())
|
||||||
comname += ": " + shortcuts;
|
comname += ": " + shortcuts;
|
||||||
@ -1675,15 +1679,6 @@ void LyXFunc::sendDispatchMessage(docstring const & msg, FuncRequest const & cmd
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXFunc::setupLocalKeymap()
|
|
||||||
{
|
|
||||||
keyseq.stdmap = toplevel_keymap.get();
|
|
||||||
keyseq.curmap = toplevel_keymap.get();
|
|
||||||
cancel_meta_seq.stdmap = toplevel_keymap.get();
|
|
||||||
cancel_meta_seq.curmap = toplevel_keymap.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void LyXFunc::menuNew(string const & name, bool fromTemplate)
|
void LyXFunc::menuNew(string const & name, bool fromTemplate)
|
||||||
{
|
{
|
||||||
string initpath = lyxrc.document_path;
|
string initpath = lyxrc.document_path;
|
||||||
@ -1930,12 +1925,12 @@ string const LyXFunc::viewStatusMessage()
|
|||||||
{
|
{
|
||||||
// When meta-fake key is pressed, show the key sequence so far + "M-".
|
// When meta-fake key is pressed, show the key sequence so far + "M-".
|
||||||
if (wasMetaKey())
|
if (wasMetaKey())
|
||||||
return keyseq.print() + "M-";
|
return keyseq->print() + "M-";
|
||||||
|
|
||||||
// Else, when a non-complete key sequence is pressed,
|
// Else, when a non-complete key sequence is pressed,
|
||||||
// show the available options.
|
// show the available options.
|
||||||
if (keyseq.length() > 0 && !keyseq.deleted())
|
if (keyseq->length() > 0 && !keyseq->deleted())
|
||||||
return keyseq.printOptions();
|
return keyseq->printOptions();
|
||||||
|
|
||||||
if (!view()->buffer())
|
if (!view()->buffer())
|
||||||
return lyx::to_utf8(_("Welcome to LyX!"));
|
return lyx::to_utf8(_("Welcome to LyX!"));
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "support/docstring.h"
|
#include "support/docstring.h"
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
#include <boost/signals/trackable.hpp>
|
#include <boost/signals/trackable.hpp>
|
||||||
|
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ class LyXView;
|
|||||||
class LyXFunc : public boost::signals::trackable {
|
class LyXFunc : public boost::signals::trackable {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
explicit LyXFunc(LyXView * lv = 0);
|
explicit LyXFunc();
|
||||||
|
|
||||||
/// LyX dispatcher, executes lyx actions.
|
/// LyX dispatcher, executes lyx actions.
|
||||||
void dispatch(FuncRequest const &);
|
void dispatch(FuncRequest const &);
|
||||||
@ -49,6 +49,9 @@ public:
|
|||||||
///
|
///
|
||||||
void setLyXView(LyXView * lv);
|
void setLyXView(LyXView * lv);
|
||||||
|
|
||||||
|
///
|
||||||
|
void initKeySequences(kb_keymap * kb);
|
||||||
|
|
||||||
/// return the status bar state string
|
/// return the status bar state string
|
||||||
std::string const viewStatusMessage();
|
std::string const viewStatusMessage();
|
||||||
|
|
||||||
@ -83,13 +86,12 @@ private:
|
|||||||
lyx::char_type encoded_last_key;
|
lyx::char_type encoded_last_key;
|
||||||
|
|
||||||
///
|
///
|
||||||
kb_sequence keyseq;
|
boost::scoped_ptr<kb_sequence> keyseq;
|
||||||
///
|
///
|
||||||
kb_sequence cancel_meta_seq;
|
boost::scoped_ptr<kb_sequence> cancel_meta_seq;
|
||||||
///
|
///
|
||||||
key_modifier::state meta_fake_bit;
|
key_modifier::state meta_fake_bit;
|
||||||
///
|
|
||||||
void setupLocalKeymap();
|
|
||||||
/// Error status, only Dispatch can change this flag
|
/// Error status, only Dispatch can change this flag
|
||||||
mutable bool errorstat;
|
mutable bool errorstat;
|
||||||
|
|
||||||
@ -115,14 +117,15 @@ private:
|
|||||||
bool ensureBufferClean(BufferView * bv);
|
bool ensureBufferClean(BufferView * bv);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Implementation is in lyx_main.C
|
||||||
extern LyXFunc & theLyXFunc();
|
extern LyXFunc & theLyXFunc();
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
/// Implementation is in frontends/Application.C
|
/// Implementation is in lyx_main.C
|
||||||
extern FuncStatus getStatus(FuncRequest const & action);
|
extern FuncStatus getStatus(FuncRequest const & action);
|
||||||
|
|
||||||
/// Implementation is in frontends/Application.C
|
/// Implementation is in lyx_main.C
|
||||||
extern void dispatch(FuncRequest const & action);
|
extern void dispatch(FuncRequest const & action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,6 +140,9 @@ private:
|
|||||||
LyXComm pipes;
|
LyXComm pipes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Implementation is in lyx_main.C
|
||||||
|
extern LyXServer & theLyXServer();
|
||||||
|
|
||||||
#endif /* _LYXSERVER_H_ */
|
#endif /* _LYXSERVER_H_ */
|
||||||
|
|
||||||
/* === End of File: lyxserver.h ========================================== */
|
/* === End of File: lyxserver.h ========================================== */
|
||||||
|
@ -89,4 +89,7 @@ private:
|
|||||||
std::string buffer_;
|
std::string buffer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Implementation is in lyx_main.C
|
||||||
|
extern LyXServerSocket & theLyXServerSocket();
|
||||||
|
|
||||||
#endif // LYXSOCKET_H
|
#endif // LYXSOCKET_H
|
||||||
|
Loading…
Reference in New Issue
Block a user