2003-08-23 00:17:00 +00:00
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
* \file LyXFunc.cpp
|
2003-08-23 00:17:00 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author Alfredo Braunstein
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
* \author Angus Leeming
|
|
|
|
* \author John Levon
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author Allan Rae
|
|
|
|
* \author Dekel Tsur
|
|
|
|
* \author Martin Vermeer
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Jürgen Vigna
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
2000-04-11 22:55:29 +00:00
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "LyXFunc.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
2008-03-07 03:53:21 +00:00
|
|
|
#include "LayoutFile.h"
|
2003-09-09 17:00:19 +00:00
|
|
|
#include "BranchList.h"
|
2003-06-20 12:46:28 +00:00
|
|
|
#include "buffer_funcs.h"
|
2007-09-19 22:37:22 +00:00
|
|
|
#include "Buffer.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "BufferList.h"
|
|
|
|
#include "BufferParams.h"
|
2007-09-19 22:37:22 +00:00
|
|
|
#include "BufferView.h"
|
2007-10-20 23:27:03 +00:00
|
|
|
#include "CmdDef.h"
|
2007-11-02 23:42:27 +00:00
|
|
|
#include "Color.h"
|
2007-10-25 06:09:38 +00:00
|
|
|
#include "Converter.h"
|
2007-04-26 14:56:30 +00:00
|
|
|
#include "Cursor.h"
|
2004-03-30 16:19:50 +00:00
|
|
|
#include "CutAndPaste.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "DispatchResult.h"
|
|
|
|
#include "Encoding.h"
|
|
|
|
#include "ErrorList.h"
|
|
|
|
#include "Format.h"
|
|
|
|
#include "FuncRequest.h"
|
2006-10-12 14:10:13 +00:00
|
|
|
#include "FuncStatus.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "InsetIterator.h"
|
|
|
|
#include "Intl.h"
|
2007-04-27 08:05:58 +00:00
|
|
|
#include "KeyMap.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Language.h"
|
2009-09-26 17:19:18 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
2007-09-19 22:37:22 +00:00
|
|
|
#include "Lexer.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
#include "LyXAction.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
#include "lyxfind.h"
|
2007-09-19 22:37:22 +00:00
|
|
|
#include "LyX.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "LyXRC.h"
|
|
|
|
#include "LyXVC.h"
|
|
|
|
#include "Paragraph.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
#include "ParagraphParameters.h"
|
2007-09-19 22:37:22 +00:00
|
|
|
#include "ParIterator.h"
|
|
|
|
#include "Row.h"
|
|
|
|
#include "Server.h"
|
|
|
|
#include "Session.h"
|
2009-08-08 17:26:18 +00:00
|
|
|
#include "SpellChecker.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
2007-04-28 20:44:46 +00:00
|
|
|
#include "frontends/alert.h"
|
2007-11-18 00:01:14 +00:00
|
|
|
#include "frontends/Application.h"
|
2007-04-27 08:43:38 +00:00
|
|
|
#include "frontends/KeySymbol.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
#include "frontends/LyXView.h"
|
2007-07-06 17:03:45 +00:00
|
|
|
#include "frontends/Selection.h"
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/debug.h"
|
2005-02-15 13:45:41 +00:00
|
|
|
#include "support/environment.h"
|
2007-11-19 12:03:38 +00:00
|
|
|
#include "support/FileName.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
#include "support/filetools.h"
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/gettext.h"
|
2009-09-26 17:19:18 +00:00
|
|
|
#include "support/lassert.h"
|
2004-03-28 14:12:33 +00:00
|
|
|
#include "support/lstrings.h"
|
Rename files in src/support, step one.
src/support/package.h src/support/Package.h Package
src/support/package.C.in src/support/Package.C.in Package
src/support/path.h src/support/Path.h Path
src/support/fs_extras.h src/support/fs_extras.h NOCLASSES
src/support/RandomAccessList.h src/support/RandomAccessList.h RandomAccessList
src/support/lyxmanip.h src/support/lyxmanip.h NOCLASSES
src/support/rename.C src/support/rename.cpp NOCLASSES
src/support/abort.C src/support/abort.cpp NOCLASSES
src/support/lyxlib.h src/support/lyxlib.h NOCLASSES
src/support/ExceptionMessage.h src/support/ExceptionMessage.h ExceptionMessage
src/support/copy.C src/support/copy.cpp NOCLASSES
src/support/limited_stack.h src/support/limited_stack.h limited_stack
src/support/filefilterlist.C src/support/FileFilterList.cpp ['FileFilterList', 'Filter']
src/support/cow_ptr.h src/support/cow_ptr.h cow_ptr
src/support/os_unix.C src/support/os_unix.cpp NOCLASSES
src/support/socktools.h src/support/socktools.h NOCLASSES
src/support/forkedcontr.h src/support/ForkedcallsController.h ForkedcallsController
src/support/os.h src/support/os.h NOCLASSES
src/support/FileMonitor.h src/support/FileMonitor.h FileMonitor
src/support/copied_ptr.h src/support/copied_ptr.h copied_ptr
src/support/translator.h src/support/Translator.h Translator
src/support/filetools.C src/support/filetools.cpp NOCLASSES
src/support/unlink.C src/support/unlink.cpp NOCLASSES
src/support/os_win32.C src/support/os_win32.cpp GetFolderPath
src/support/lstrings.C src/support/lstrings.cpp NOCLASSES
src/support/qstring_helpers.C src/support/qstring_helpers.cpp NOCLASSES
src/support/getcwd.C src/support/getcwd.cpp NOCLASSES
src/support/systemcall.C src/support/Systemcall.cpp Systemcall
src/support/lyxalgo.h src/support/lyxalgo.h NOCLASSES
src/support/filefilterlist.h src/support/FileFilterList.h ['FileFilterList', 'Filter']
src/support/unicode.C src/support/unicode.cpp IconvProcessor
src/support/userinfo.C src/support/userinfo.cpp NOCLASSES
src/support/lyxtime.C src/support/lyxtime.cpp NOCLASSES
src/support/kill.C src/support/kill.cpp NOCLASSES
src/support/docstring.C src/support/docstring.cpp to_local8bit_failure
src/support/os_cygwin.C src/support/os_cygwin.cpp NOCLASSES
src/support/lyxsum.C src/support/lyxsum.cpp NOCLASSES
src/support/environment.C src/support/environment.cpp NOCLASSES
src/support/filetools.h src/support/filetools.h NOCLASSES
src/support/textutils.C src/support/textutils.cpp NOCLASSES
src/support/mkdir.C src/support/mkdir.cpp NOCLASSES
src/support/forkedcall.C src/support/Forkedcall.cpp ['ForkedProcess', 'Forkedcall']
src/support/tempname.C src/support/tempname.cpp NOCLASSES
src/support/os_win32.h src/support/os_win32.h GetFolderPath
src/support/types.h src/support/types.h NOCLASSES
src/support/lstrings.h src/support/lstrings.h NOCLASSES
src/support/forkedcallqueue.C src/support/ForkedCallQueue.cpp ForkedCallQueue
src/support/qstring_helpers.h src/support/qstring_helpers.h NOCLASSES
src/support/convert.C src/support/convert.cpp NOCLASSES
src/support/filename.C src/support/FileName.cpp ['FileName', 'DocFileName']
src/support/tests/convert.C src/support/tests/convert.cpp NOCLASSES
src/support/tests/filetools.C src/support/tests/filetools.cpp NOCLASSES
src/support/tests/lstrings.C src/support/tests/lstrings.cpp NOCLASSES
src/support/tests/boost.C src/support/tests/boost.cpp NOCLASSES
src/support/docstream.C src/support/docstream.cpp ['iconv_codecvt_facet_exception', 'idocfstream', 'odocfstream']
src/support/std_istream.h src/support/std_istream.h NOCLASSES
src/support/systemcall.h src/support/Systemcall.h Systemcall
src/support/chdir.C src/support/chdir.cpp NOCLASSES
src/support/std_ostream.h src/support/std_ostream.h NOCLASSES
src/support/unicode.h src/support/unicode.h IconvProcessor
src/support/path.C src/support/Path.cpp Path
src/support/fs_extras.C src/support/fs_extras.cpp NOCLASSES
src/support/userinfo.h src/support/userinfo.h NOCLASSES
src/support/lyxtime.h src/support/lyxtime.h NOCLASSES
src/support/docstring.h src/support/docstring.h to_local8bit_failure
src/support/debugstream.h src/support/debugstream.h basic_debugstream
src/support/environment.h src/support/environment.h NOCLASSES
src/support/textutils.h src/support/textutils.h NOCLASSES
src/support/forkedcall.h src/support/Forkedcall.h ['ForkedProcess', 'Forkedcall']
src/support/socktools.C src/support/socktools.cpp NOCLASSES
src/support/forkedcallqueue.h src/support/ForkedCallQueue.h ForkedCallQueue
src/support/forkedcontr.C src/support/ForkedcallsController.cpp ForkedcallsController
src/support/os.C src/support/os.cpp NOCLASSES
src/support/convert.h src/support/convert.h NOCLASSES
src/support/filename.h src/support/FileName.h ['FileName', 'DocFileName']
src/support/docstream.h src/support/docstream.h ['iconv_codecvt_facet_exception', 'idocfstream', 'odocfstream']
src/support/FileMonitor.C src/support/FileMonitor.cpp FileMonitor
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18024 a592a061-630c-0410-9148-cb99ea01b6c8
2007-04-26 05:12:52 +00:00
|
|
|
#include "support/Path.h"
|
|
|
|
#include "support/Package.h"
|
|
|
|
#include "support/Systemcall.h"
|
2005-01-06 16:39:35 +00:00
|
|
|
#include "support/convert.h"
|
2003-10-14 11:35:50 +00:00
|
|
|
#include "support/os.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
#include <sstream>
|
2008-02-19 09:10:59 +00:00
|
|
|
#include <vector>
|
2004-07-24 10:55:30 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2007-12-12 18:57:56 +00:00
|
|
|
using namespace lyx::support;
|
2007-08-14 08:53:34 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2007-08-14 09:54:59 +00:00
|
|
|
using frontend::LyXView;
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace Alert = frontend::Alert;
|
2004-05-19 15:11:37 +00:00
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
namespace {
|
|
|
|
|
2007-10-25 06:09:38 +00:00
|
|
|
|
2007-10-03 18:34:32 +00:00
|
|
|
// This function runs "configure" and then rereads lyx.defaults to
|
|
|
|
// reconfigure the automatic settings.
|
2008-03-14 16:33:16 +00:00
|
|
|
void reconfigure(LyXView * lv, string const & option)
|
2007-10-03 18:34:32 +00:00
|
|
|
{
|
|
|
|
// emit message signal.
|
2008-03-14 16:33:16 +00:00
|
|
|
if (lv)
|
|
|
|
lv->message(_("Running configure..."));
|
2007-10-03 18:34:32 +00:00
|
|
|
|
|
|
|
// Run configure in user lyx directory
|
2007-12-12 19:57:42 +00:00
|
|
|
PathChanger p(package().user_support());
|
2007-10-03 18:34:32 +00:00
|
|
|
string configure_command = package().configure_command();
|
|
|
|
configure_command += option;
|
|
|
|
Systemcall one;
|
2007-10-14 14:51:05 +00:00
|
|
|
int ret = one.startscript(Systemcall::Wait, configure_command);
|
2007-10-03 18:34:32 +00:00
|
|
|
p.pop();
|
|
|
|
// emit message signal.
|
2008-03-14 16:33:16 +00:00
|
|
|
if (lv)
|
|
|
|
lv->message(_("Reloading configuration..."));
|
2007-12-12 19:57:42 +00:00
|
|
|
lyxrc.read(libFileSearch(string(), "lyxrc.defaults"));
|
2007-10-03 18:34:32 +00:00
|
|
|
// Re-read packages.lst
|
|
|
|
LaTeXFeatures::getAvailable();
|
|
|
|
|
2007-10-14 14:51:05 +00:00
|
|
|
if (ret)
|
|
|
|
Alert::information(_("System reconfiguration failed"),
|
|
|
|
_("The system reconfiguration has failed.\n"
|
|
|
|
"Default textclass is used but LyX may "
|
|
|
|
"not be able to work properly.\n"
|
|
|
|
"Please reconfigure again if needed."));
|
|
|
|
else
|
|
|
|
|
|
|
|
Alert::information(_("System reconfigured"),
|
2007-10-03 18:34:32 +00:00
|
|
|
_("The system has been reconfigured.\n"
|
|
|
|
"You need to restart LyX to make use of any\n"
|
|
|
|
"updated document class specifications."));
|
|
|
|
}
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
}
|
|
|
|
|
2007-09-17 22:51:03 +00:00
|
|
|
|
2006-10-19 07:20:32 +00:00
|
|
|
LyXFunc::LyXFunc()
|
2009-09-22 21:25:32 +00:00
|
|
|
: encoded_last_key(0), meta_fake_bit(NoModifier)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
2007-04-27 08:05:58 +00:00
|
|
|
void LyXFunc::initKeySequences(KeyMap * kb)
|
2006-10-19 07:20:32 +00:00
|
|
|
{
|
2007-09-17 22:51:03 +00:00
|
|
|
keyseq = KeySequence(kb, kb);
|
|
|
|
cancel_meta_seq = KeySequence(kb, kb);
|
2006-10-19 07:20:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-15 01:20:36 +00:00
|
|
|
void LyXFunc::handleKeyFunc(FuncCode action)
|
2001-02-23 16:10:03 +00:00
|
|
|
{
|
2006-10-22 10:15:23 +00:00
|
|
|
char_type c = encoded_last_key;
|
2001-02-23 16:10:03 +00:00
|
|
|
|
2007-09-17 22:51:03 +00:00
|
|
|
if (keyseq.length())
|
2001-11-30 13:25:38 +00:00
|
|
|
c = 0;
|
2009-09-22 21:25:32 +00:00
|
|
|
LyXView * lv = theApp()->currentWindow();
|
|
|
|
LASSERT(lv && lv->currentBufferView(), /**/);
|
|
|
|
BufferView * bv = lv->currentBufferView();
|
2009-09-05 15:42:53 +00:00
|
|
|
bv->getIntl().getTransManager().deadkey(
|
|
|
|
c, get_accent(action).accent, bv->cursor().innerText(),
|
|
|
|
bv->cursor());
|
2001-11-30 13:25:38 +00:00
|
|
|
// Need to clear, in case the minibuffer calls these
|
2001-02-23 16:10:03 +00:00
|
|
|
// actions
|
2007-09-17 22:51:03 +00:00
|
|
|
keyseq.clear();
|
2001-02-23 16:10:03 +00:00
|
|
|
// copied verbatim from do_accent_char
|
2009-09-05 15:42:53 +00:00
|
|
|
bv->cursor().resetAnchor();
|
|
|
|
bv->processUpdateFlags(Update::FitCursor);
|
2001-02-23 16:10:03 +00:00
|
|
|
}
|
|
|
|
|
2008-02-27 11:05:58 +00:00
|
|
|
//FIXME: bookmark handling is a frontend issue. This code should be transferred
|
|
|
|
// to GuiView and be GuiView and be window dependent.
|
2007-01-11 16:01:10 +00:00
|
|
|
void LyXFunc::gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer)
|
|
|
|
{
|
2009-09-22 21:25:32 +00:00
|
|
|
LyXView * lv = theApp()->currentWindow();
|
|
|
|
LASSERT(lv, /**/);
|
2008-07-14 08:35:00 +00:00
|
|
|
if (!theSession().bookmarks().isValid(idx))
|
2007-01-11 16:01:10 +00:00
|
|
|
return;
|
2008-07-14 08:35:00 +00:00
|
|
|
BookmarksSection::Bookmark const & bm = theSession().bookmarks().bookmark(idx);
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(!bm.filename.empty(), /**/);
|
2007-01-11 16:01:10 +00:00
|
|
|
string const file = bm.filename.absFilename();
|
|
|
|
// if the file is not opened, open it.
|
2008-07-29 07:53:08 +00:00
|
|
|
if (!theBufferList().exists(bm.filename)) {
|
2007-01-11 16:01:10 +00:00
|
|
|
if (openFile)
|
|
|
|
dispatch(FuncRequest(LFUN_FILE_OPEN, file));
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// open may fail, so we need to test it again
|
2008-07-29 07:53:08 +00:00
|
|
|
if (!theBufferList().exists(bm.filename))
|
2007-08-22 14:36:18 +00:00
|
|
|
return;
|
2007-08-22 14:25:51 +00:00
|
|
|
|
2009-02-13 13:46:08 +00:00
|
|
|
// bm can be changed when saving
|
|
|
|
BookmarksSection::Bookmark tmp = bm;
|
|
|
|
|
|
|
|
// Special case idx == 0 used for back-from-back jump navigation
|
|
|
|
if (idx == 0)
|
|
|
|
dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
|
|
|
|
|
2007-08-22 14:36:18 +00:00
|
|
|
// if the current buffer is not that one, switch to it.
|
2009-09-22 21:25:32 +00:00
|
|
|
if (!lv->documentBufferView()
|
|
|
|
|| lv->documentBufferView()->buffer().fileName() != tmp.filename) {
|
2007-08-22 14:36:18 +00:00
|
|
|
if (!switchToBuffer)
|
|
|
|
return;
|
|
|
|
dispatch(FuncRequest(LFUN_BUFFER_SWITCH, file));
|
|
|
|
}
|
2009-02-13 13:46:08 +00:00
|
|
|
|
2007-08-22 14:36:18 +00:00
|
|
|
// moveToPosition try paragraph id first and then paragraph (pit, pos).
|
2009-09-22 21:25:32 +00:00
|
|
|
if (!lv->documentBufferView()->moveToPosition(
|
2009-09-05 15:42:53 +00:00
|
|
|
tmp.bottom_pit, tmp.bottom_pos, tmp.top_id, tmp.top_pos))
|
2009-02-13 13:46:08 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// bm changed
|
|
|
|
if (idx == 0)
|
2007-08-22 14:36:18 +00:00
|
|
|
return;
|
2007-08-22 14:25:51 +00:00
|
|
|
|
2007-08-22 14:36:18 +00:00
|
|
|
// Cursor jump succeeded!
|
2009-09-22 21:25:32 +00:00
|
|
|
Cursor const & cur = lv->documentBufferView()->cursor();
|
2007-08-22 14:36:18 +00:00
|
|
|
pit_type new_pit = cur.pit();
|
|
|
|
pos_type new_pos = cur.pos();
|
|
|
|
int new_id = cur.paragraph().id();
|
|
|
|
|
|
|
|
// if bottom_pit, bottom_pos or top_id has been changed, update bookmark
|
|
|
|
// see http://bugzilla.lyx.org/show_bug.cgi?id=3092
|
|
|
|
if (bm.bottom_pit != new_pit || bm.bottom_pos != new_pos
|
|
|
|
|| bm.top_id != new_id) {
|
|
|
|
const_cast<BookmarksSection::Bookmark &>(bm).updatePos(
|
|
|
|
new_pit, new_pos, new_id);
|
2007-05-28 22:27:45 +00:00
|
|
|
}
|
2007-01-11 16:01:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-02 21:51:54 +00:00
|
|
|
void LyXFunc::processKeySym(KeySymbol const & keysym, KeyModifier state)
|
2000-08-14 15:31:16 +00:00
|
|
|
{
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::KEY, "KeySym is " << keysym.getSymbolName());
|
2002-11-04 02:12:42 +00:00
|
|
|
|
2009-09-22 21:25:32 +00:00
|
|
|
LyXView * lv = theApp()->currentWindow();
|
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
// Do nothing if we have nothing (JMarc)
|
2007-09-17 18:41:03 +00:00
|
|
|
if (!keysym.isOK()) {
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::KEY, "Empty kbd action (probably composing)");
|
2009-09-22 21:25:32 +00:00
|
|
|
lv->restartCursor();
|
2001-05-17 01:23:29 +00:00
|
|
|
return;
|
2000-08-14 15:31:16 +00:00
|
|
|
}
|
2000-10-12 01:18:11 +00:00
|
|
|
|
2007-09-17 18:41:03 +00:00
|
|
|
if (keysym.isModifier()) {
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::KEY, "isModifier true");
|
2009-09-22 21:25:32 +00:00
|
|
|
if (lv)
|
|
|
|
lv->restartCursor();
|
2001-05-17 01:23:29 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2009-09-22 21:25:32 +00:00
|
|
|
//Encoding const * encoding = lv->documentBufferView()->cursor().getEncoding();
|
2007-09-17 18:41:03 +00:00
|
|
|
//encoded_last_key = keysym.getISOEncoded(encoding ? encoding->name() : "");
|
2007-01-24 14:01:34 +00:00
|
|
|
// FIXME: encoded_last_key shadows the member variable of the same
|
|
|
|
// name. Is that intended?
|
2007-09-17 18:41:03 +00:00
|
|
|
char_type encoded_last_key = keysym.getUCSEncoded();
|
2003-01-05 22:38:42 +00:00
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
// Do a one-deep top-level lookup for
|
|
|
|
// cancel and meta-fake keys. RVDK_PATCH_5
|
2007-09-17 22:51:03 +00:00
|
|
|
cancel_meta_seq.reset();
|
2000-08-14 15:31:16 +00:00
|
|
|
|
2007-09-17 22:51:03 +00:00
|
|
|
FuncRequest func = cancel_meta_seq.addkey(keysym, state);
|
2007-11-29 21:10:35 +00:00
|
|
|
LYXERR(Debug::KEY, "action first set to [" << func.action << ']');
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
// When not cancel or meta-fake, do the normal lookup.
|
2000-08-14 15:31:16 +00:00
|
|
|
// Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
|
2007-10-02 21:51:54 +00:00
|
|
|
// Mostly, meta_fake_bit = NoModifier. RVDK_PATCH_5.
|
2006-05-05 20:23:12 +00:00
|
|
|
if ((func.action != LFUN_CANCEL) && (func.action != LFUN_META_PREFIX)) {
|
2000-08-14 15:31:16 +00:00
|
|
|
// remove Caps Lock and Mod2 as a modifiers
|
2007-09-17 22:51:03 +00:00
|
|
|
func = keyseq.addkey(keysym, (state | meta_fake_bit));
|
2007-11-29 21:10:35 +00:00
|
|
|
LYXERR(Debug::KEY, "action now set to [" << func.action << ']');
|
2000-08-14 15:31:16 +00:00
|
|
|
}
|
2002-08-10 15:21:07 +00:00
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
// Dont remove this unless you know what you are doing.
|
2007-10-02 21:51:54 +00:00
|
|
|
meta_fake_bit = NoModifier;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2005-02-08 02:06:39 +00:00
|
|
|
// Can this happen now ?
|
2007-10-02 21:51:54 +00:00
|
|
|
if (func.action == LFUN_NOACTION)
|
2006-05-05 20:23:12 +00:00
|
|
|
func = FuncRequest(LFUN_COMMAND_PREFIX);
|
2000-08-14 15:31:16 +00:00
|
|
|
|
2007-11-29 21:10:35 +00:00
|
|
|
LYXERR(Debug::KEY, " Key [action=" << func.action << "]["
|
|
|
|
<< keyseq.print(KeySequence::Portable) << ']');
|
2000-08-14 15:31:16 +00:00
|
|
|
|
|
|
|
// already here we know if it any point in going further
|
|
|
|
// why not return already here if action == -1 and
|
|
|
|
// num_bytes == 0? (Lgb)
|
|
|
|
|
2007-10-02 21:51:54 +00:00
|
|
|
if (keyseq.length() > 1)
|
2009-09-22 21:25:32 +00:00
|
|
|
lv->message(keyseq.print(KeySequence::ForGui));
|
2000-08-14 15:31:16 +00:00
|
|
|
|
2003-02-13 16:53:15 +00:00
|
|
|
|
2002-12-12 13:46:06 +00:00
|
|
|
// Maybe user can only reach the key via holding down shift.
|
|
|
|
// Let's see. But only if shift is the only modifier
|
2007-10-02 21:51:54 +00:00
|
|
|
if (func.action == LFUN_UNKNOWN_ACTION && state == ShiftModifier) {
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::KEY, "Trying without shift");
|
2007-10-02 21:51:54 +00:00
|
|
|
func = keyseq.addkey(keysym, NoModifier);
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::KEY, "Action now " << func.action);
|
2002-12-12 13:46:06 +00:00
|
|
|
}
|
2003-02-13 16:53:15 +00:00
|
|
|
|
2003-09-21 23:00:47 +00:00
|
|
|
if (func.action == LFUN_UNKNOWN_ACTION) {
|
2002-12-12 13:46:06 +00:00
|
|
|
// Hmm, we didn't match any of the keysequences. See
|
|
|
|
// if it's normal insertable text not already covered
|
|
|
|
// by a binding
|
2007-09-17 22:51:03 +00:00
|
|
|
if (keysym.isText() && keyseq.length() == 1) {
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::KEY, "isText() is true, inserting.");
|
2006-05-05 20:23:12 +00:00
|
|
|
func = FuncRequest(LFUN_SELF_INSERT,
|
2006-01-18 17:44:01 +00:00
|
|
|
FuncRequest::KEYBOARD);
|
2002-12-12 13:46:06 +00:00
|
|
|
} else {
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::KEY, "Unknown, !isText() - giving up");
|
2009-09-22 21:25:32 +00:00
|
|
|
lv->message(_("Unknown function."));
|
|
|
|
lv->restartCursor();
|
2001-05-17 01:23:29 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
if (func.action == LFUN_SELF_INSERT) {
|
2003-01-05 22:38:42 +00:00
|
|
|
if (encoded_last_key != 0) {
|
2006-09-01 15:41:38 +00:00
|
|
|
docstring const arg(1, encoded_last_key);
|
2006-05-05 20:23:12 +00:00
|
|
|
dispatch(FuncRequest(LFUN_SELF_INSERT, arg,
|
2006-01-18 17:44:01 +00:00
|
|
|
FuncRequest::KEYBOARD));
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::KEY, "SelfInsert arg[`" << to_utf8(arg) << "']");
|
2003-01-05 22:38:42 +00:00
|
|
|
}
|
2002-06-18 17:22:17 +00:00
|
|
|
} else {
|
2003-09-21 23:00:47 +00:00
|
|
|
dispatch(func);
|
2009-09-22 21:25:32 +00:00
|
|
|
if (!lv)
|
2008-02-25 07:32:02 +00:00
|
|
|
return;
|
2002-06-18 17:22:17 +00:00
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
}
|
2000-08-14 15:31:16 +00:00
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
2004-02-13 07:30:59 +00:00
|
|
|
FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
2004-03-18 13:57:20 +00:00
|
|
|
//lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl;
|
2002-01-09 09:36:35 +00:00
|
|
|
FuncStatus flag;
|
2006-10-23 16:29:24 +00:00
|
|
|
|
2004-02-13 07:30:59 +00:00
|
|
|
if (cmd.action == LFUN_NOACTION) {
|
2006-10-21 00:16:43 +00:00
|
|
|
flag.message(from_utf8(N_("Nothing to do")));
|
2008-05-29 15:14:00 +00:00
|
|
|
flag.setEnabled(false);
|
2003-10-21 16:15:14 +00:00
|
|
|
return flag;
|
2002-03-27 23:27:12 +00:00
|
|
|
}
|
|
|
|
|
2004-02-13 07:30:59 +00:00
|
|
|
switch (cmd.action) {
|
2002-12-18 14:24:32 +00:00
|
|
|
case LFUN_UNKNOWN_ACTION:
|
|
|
|
flag.unknown(true);
|
2008-05-29 15:14:00 +00:00
|
|
|
flag.setEnabled(false);
|
2002-12-18 14:24:32 +00:00
|
|
|
break;
|
2006-10-05 16:52:04 +00:00
|
|
|
|
2002-12-18 14:24:32 +00:00
|
|
|
default:
|
2006-10-05 16:52:04 +00:00
|
|
|
break;
|
2002-12-18 14:24:32 +00:00
|
|
|
}
|
2003-02-13 16:53:15 +00:00
|
|
|
|
2002-12-18 14:24:32 +00:00
|
|
|
if (flag.unknown()) {
|
2006-10-21 00:16:43 +00:00
|
|
|
flag.message(from_utf8(N_("Unknown action")));
|
2002-12-18 14:24:32 +00:00
|
|
|
return flag;
|
2000-06-12 11:27:15 +00:00
|
|
|
}
|
2002-02-06 15:12:40 +00:00
|
|
|
|
2004-12-02 11:32:14 +00:00
|
|
|
if (!flag.enabled()) {
|
|
|
|
if (flag.message().empty())
|
2006-10-21 00:16:43 +00:00
|
|
|
flag.message(from_utf8(N_("Command disabled")));
|
2004-06-23 14:04:09 +00:00
|
|
|
return flag;
|
2004-12-02 11:32:14 +00:00
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-01-06 02:44:26 +00:00
|
|
|
// I would really like to avoid having this switch and rather try to
|
|
|
|
// encode this in the function itself.
|
2004-03-18 13:57:20 +00:00
|
|
|
// -- And I'd rather let an inset decide which LFUNs it is willing
|
|
|
|
// to handle (Andre')
|
|
|
|
bool enable = true;
|
2004-02-13 07:30:59 +00:00
|
|
|
switch (cmd.action) {
|
2007-11-19 20:56:05 +00:00
|
|
|
|
2007-12-04 22:21:25 +00:00
|
|
|
// This could be used for the no-GUI version. The GUI version is handled in
|
2007-12-28 17:11:39 +00:00
|
|
|
// LyXView::getStatus(). See above.
|
2007-12-04 22:21:25 +00:00
|
|
|
/*
|
|
|
|
case LFUN_BUFFER_WRITE:
|
|
|
|
case LFUN_BUFFER_WRITE_AS: {
|
2008-07-29 08:16:09 +00:00
|
|
|
Buffer * b = theBufferList().getBuffer(FileName(cmd.getArg(0)));
|
2007-12-04 22:21:25 +00:00
|
|
|
enable = b && (b->isUnnamed() || !b->isClean());
|
2006-03-16 13:12:40 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-12-04 22:21:25 +00:00
|
|
|
*/
|
2007-08-06 15:34:02 +00:00
|
|
|
|
2007-01-22 14:43:45 +00:00
|
|
|
case LFUN_BOOKMARK_GOTO: {
|
|
|
|
const unsigned int num = convert<unsigned int>(to_utf8(cmd.argument()));
|
2008-07-14 08:35:00 +00:00
|
|
|
enable = theSession().bookmarks().isValid(num);
|
2007-01-22 14:43:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case LFUN_BOOKMARK_CLEAR:
|
2009-01-07 01:48:47 +00:00
|
|
|
enable = theSession().bookmarks().hasValid();
|
2007-01-22 14:43:45 +00:00
|
|
|
break;
|
|
|
|
|
2004-05-04 14:12:50 +00:00
|
|
|
// this one is difficult to get right. As a half-baked
|
|
|
|
// solution, we consider only the first action of the sequence
|
2006-05-05 20:23:12 +00:00
|
|
|
case LFUN_COMMAND_SEQUENCE: {
|
2004-05-04 14:12:50 +00:00
|
|
|
// argument contains ';'-terminated commands
|
2006-10-21 00:16:43 +00:00
|
|
|
string const firstcmd = token(to_utf8(cmd.argument()), ';', 0);
|
2004-11-16 10:46:23 +00:00
|
|
|
FuncRequest func(lyxaction.lookupFunc(firstcmd));
|
|
|
|
func.origin = cmd.origin;
|
|
|
|
flag = getStatus(func);
|
2007-10-20 23:27:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-09-24 15:08:46 +00:00
|
|
|
// we want to check if at least one of these is enabled
|
|
|
|
case LFUN_COMMAND_ALTERNATIVES: {
|
|
|
|
// argument contains ';'-terminated commands
|
|
|
|
string arg = to_utf8(cmd.argument());
|
|
|
|
while (!arg.empty()) {
|
|
|
|
string first;
|
|
|
|
arg = split(arg, first, ';');
|
|
|
|
FuncRequest func(lyxaction.lookupFunc(first));
|
|
|
|
func.origin = cmd.origin;
|
|
|
|
flag = getStatus(func);
|
|
|
|
// if this one is enabled, the whole thing is
|
|
|
|
if (flag.enabled())
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-10-20 23:27:03 +00:00
|
|
|
case LFUN_CALL: {
|
|
|
|
FuncRequest func;
|
2007-12-12 19:28:07 +00:00
|
|
|
string name = to_utf8(cmd.argument());
|
2008-07-14 08:35:00 +00:00
|
|
|
if (theTopLevelCmdDef().lock(name, func)) {
|
2007-10-20 23:27:03 +00:00
|
|
|
func.origin = cmd.origin;
|
|
|
|
flag = getStatus(func);
|
2008-07-14 08:35:00 +00:00
|
|
|
theTopLevelCmdDef().release(name);
|
2007-10-20 23:27:03 +00:00
|
|
|
} else {
|
2009-05-27 15:51:56 +00:00
|
|
|
// catch recursion or unknown command
|
|
|
|
// definition. all operations until the
|
|
|
|
// recursion or unknown command definition
|
|
|
|
// occurs are performed, so set the state to
|
|
|
|
// enabled
|
2007-10-20 23:27:03 +00:00
|
|
|
enable = true;
|
|
|
|
}
|
|
|
|
break;
|
2004-05-04 14:12:50 +00:00
|
|
|
}
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
case LFUN_COMMAND_PREFIX:
|
2004-03-18 13:57:20 +00:00
|
|
|
case LFUN_CANCEL:
|
2006-05-05 20:23:12 +00:00
|
|
|
case LFUN_META_PREFIX:
|
2004-03-18 13:57:20 +00:00
|
|
|
case LFUN_RECONFIGURE:
|
|
|
|
case LFUN_DROP_LAYOUTS_CHOICE:
|
2008-07-07 19:09:06 +00:00
|
|
|
case LFUN_SERVER_GET_FILENAME:
|
2006-05-05 20:23:12 +00:00
|
|
|
case LFUN_SERVER_NOTIFY:
|
2008-03-09 21:23:37 +00:00
|
|
|
case LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE:
|
2004-03-18 13:57:20 +00:00
|
|
|
case LFUN_REPEAT:
|
2006-05-05 20:23:12 +00:00
|
|
|
case LFUN_PREFERENCES_SAVE:
|
2008-04-27 16:20:12 +00:00
|
|
|
case LFUN_INSET_EDIT:
|
2006-05-05 20:23:12 +00:00
|
|
|
case LFUN_BUFFER_SAVE_AS_DEFAULT:
|
2004-03-31 16:50:59 +00:00
|
|
|
case LFUN_LYXRC_APPLY:
|
2004-03-18 13:57:20 +00:00
|
|
|
// these are handled in our dispatch()
|
2003-03-07 15:58:02 +00:00
|
|
|
break;
|
|
|
|
|
2001-07-19 08:52:59 +00:00
|
|
|
default:
|
2008-05-23 09:53:27 +00:00
|
|
|
if (!theApp()) {
|
|
|
|
enable = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (theApp()->getStatus(cmd, flag))
|
|
|
|
break;
|
|
|
|
|
2008-05-22 15:01:36 +00:00
|
|
|
// Does the view know something?
|
2009-09-23 09:07:24 +00:00
|
|
|
LyXView * lv = theApp()->currentWindow();
|
2009-07-14 11:36:08 +00:00
|
|
|
if (!lv) {
|
2008-05-22 15:01:36 +00:00
|
|
|
enable = false;
|
|
|
|
break;
|
|
|
|
}
|
2009-07-14 11:36:08 +00:00
|
|
|
if (lv->getStatus(cmd, flag))
|
2008-05-22 15:01:36 +00:00
|
|
|
break;
|
|
|
|
|
2009-09-05 15:42:53 +00:00
|
|
|
BufferView * bv = lv->currentBufferView();
|
2009-09-19 14:05:52 +00:00
|
|
|
BufferView * doc_bv = lv->documentBufferView();
|
2009-04-06 12:12:06 +00:00
|
|
|
// If we do not have a BufferView, then other functions are disabled
|
2009-09-05 15:42:53 +00:00
|
|
|
if (!bv) {
|
2007-10-11 10:05:04 +00:00
|
|
|
enable = false;
|
2007-10-11 09:57:52 +00:00
|
|
|
break;
|
2007-10-11 10:05:04 +00:00
|
|
|
}
|
2009-09-23 09:07:24 +00:00
|
|
|
// try the BufferView
|
|
|
|
bool decided = bv->getStatus(cmd, flag);
|
2009-04-06 12:12:06 +00:00
|
|
|
if (!decided)
|
|
|
|
// try the Buffer
|
2009-09-19 14:05:52 +00:00
|
|
|
decided = bv->buffer().getStatus(cmd, flag);
|
|
|
|
if (!decided && doc_bv)
|
|
|
|
// try the Document Buffer
|
|
|
|
decided = doc_bv->buffer().getStatus(cmd, flag);
|
2002-07-21 15:51:07 +00:00
|
|
|
}
|
|
|
|
|
2004-03-23 11:22:11 +00:00
|
|
|
if (!enable)
|
2008-05-29 15:14:00 +00:00
|
|
|
flag.setEnabled(false);
|
2004-03-23 11:22:11 +00:00
|
|
|
|
2004-12-02 11:32:14 +00:00
|
|
|
// the default error message if we disable the command
|
|
|
|
if (!flag.enabled() && flag.message().empty())
|
2006-10-21 00:16:43 +00:00
|
|
|
flag.message(from_utf8(N_("Command disabled")));
|
2004-12-02 11:32:14 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-17 10:51:59 +00:00
|
|
|
namespace {
|
|
|
|
|
2005-01-16 21:01:41 +00:00
|
|
|
void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new);
|
|
|
|
|
2003-07-10 12:26:40 +00:00
|
|
|
} //namespace anon
|
2002-01-12 20:00:47 +00:00
|
|
|
|
2003-07-25 21:20:24 +00:00
|
|
|
|
2004-11-08 10:54:29 +00:00
|
|
|
void LyXFunc::dispatch(FuncRequest const & cmd)
|
2002-01-12 20:00:47 +00:00
|
|
|
{
|
2006-10-21 00:16:43 +00:00
|
|
|
string const argument = to_utf8(cmd.argument());
|
2008-03-15 01:20:36 +00:00
|
|
|
FuncCode const action = cmd.action;
|
2003-09-21 23:00:47 +00:00
|
|
|
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::ACTION, "\nLyXFunc::dispatch: cmd: " << cmd);
|
2004-03-08 21:14:45 +00:00
|
|
|
//lyxerr << "LyXFunc::dispatch: cmd: " << cmd << endl;
|
2002-01-12 20:00:47 +00:00
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
// we have not done anything wrong yet.
|
|
|
|
errorstat = false;
|
2002-01-12 20:00:47 +00:00
|
|
|
dispatch_buffer.erase();
|
|
|
|
|
2006-04-20 14:51:23 +00:00
|
|
|
// redraw the screen at the end (first of the two drawing steps).
|
2006-06-26 16:55:35 +00:00
|
|
|
//This is done unless explicitely requested otherwise
|
2006-10-22 11:46:36 +00:00
|
|
|
Update::flags updateFlags = Update::FitCursor;
|
2004-04-20 08:51:15 +00:00
|
|
|
|
2009-09-22 21:25:32 +00:00
|
|
|
LyXView * lv = theApp()->currentWindow();
|
|
|
|
|
2004-11-25 09:15:26 +00:00
|
|
|
FuncStatus const flag = getStatus(cmd);
|
|
|
|
if (!flag.enabled()) {
|
|
|
|
// We cannot use this function here
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::ACTION, "LyXFunc::dispatch: "
|
2002-01-12 20:00:47 +00:00
|
|
|
<< lyxaction.getActionName(action)
|
2007-11-15 20:04:51 +00:00
|
|
|
<< " [" << action << "] is disabled at this location");
|
2004-11-25 09:15:26 +00:00
|
|
|
setErrorMessage(flag.message());
|
2009-09-22 21:25:32 +00:00
|
|
|
if (lv)
|
|
|
|
lv->restartCursor();
|
2003-11-13 13:43:44 +00:00
|
|
|
} else {
|
|
|
|
switch (action) {
|
2007-11-24 07:58:12 +00:00
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
case LFUN_COMMAND_PREFIX:
|
2009-09-26 17:39:19 +00:00
|
|
|
dispatch(FuncRequest(LFUN_MESSAGE, keyseq.printOptions(true)));
|
2003-11-13 13:43:44 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
case LFUN_CANCEL:
|
2007-09-17 22:51:03 +00:00
|
|
|
keyseq.reset();
|
2007-10-02 21:51:54 +00:00
|
|
|
meta_fake_bit = NoModifier;
|
2009-09-26 18:10:28 +00:00
|
|
|
if (lv && lv->currentBufferView())
|
2003-11-13 13:43:44 +00:00
|
|
|
// cancel any selection
|
|
|
|
dispatch(FuncRequest(LFUN_MARK_OFF));
|
2007-02-14 19:11:09 +00:00
|
|
|
setMessage(from_ascii(N_("Cancel")));
|
2003-11-13 13:43:44 +00:00
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
case LFUN_META_PREFIX:
|
2007-10-02 21:51:54 +00:00
|
|
|
meta_fake_bit = AltModifier;
|
2007-10-20 20:28:05 +00:00
|
|
|
setMessage(keyseq.print(KeySequence::ForGui));
|
2003-11-13 13:43:44 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
// --- Menus -----------------------------------------------
|
|
|
|
case LFUN_RECONFIGURE:
|
2007-09-26 19:36:09 +00:00
|
|
|
// argument is any additional parameter to the configure.py command
|
2009-09-22 21:25:32 +00:00
|
|
|
reconfigure(lv, argument);
|
2000-07-24 13:53:19 +00:00
|
|
|
break;
|
2003-11-13 13:43:44 +00:00
|
|
|
|
|
|
|
// --- lyxserver commands ----------------------------
|
2009-09-26 18:10:28 +00:00
|
|
|
case LFUN_SERVER_GET_FILENAME: {
|
|
|
|
LASSERT(lv && lv->documentBufferView(), return);
|
|
|
|
docstring const fname = from_utf8(
|
|
|
|
lv->documentBufferView()->buffer().absFileName());
|
|
|
|
setMessage(fname);
|
|
|
|
LYXERR(Debug::INFO, "FNAME[" << fname << ']');
|
2003-11-13 13:43:44 +00:00
|
|
|
break;
|
2009-09-26 18:10:28 +00:00
|
|
|
}
|
2006-05-05 20:23:12 +00:00
|
|
|
case LFUN_SERVER_NOTIFY:
|
2007-10-20 20:28:05 +00:00
|
|
|
dispatch_buffer = keyseq.print(KeySequence::Portable);
|
2007-04-29 16:22:46 +00:00
|
|
|
theServer().notifyClient(to_utf8(dispatch_buffer));
|
2003-11-13 13:43:44 +00:00
|
|
|
break;
|
2001-02-23 16:10:03 +00:00
|
|
|
|
2008-03-09 21:23:37 +00:00
|
|
|
case LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE:
|
2003-11-13 13:43:44 +00:00
|
|
|
lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
case LFUN_REPEAT: {
|
|
|
|
// repeat command
|
|
|
|
string countstr;
|
2004-03-18 12:53:43 +00:00
|
|
|
string rest = split(argument, countstr, ' ');
|
2003-11-13 13:43:44 +00:00
|
|
|
istringstream is(countstr);
|
|
|
|
int count = 0;
|
|
|
|
is >> count;
|
2008-10-23 07:08:12 +00:00
|
|
|
//lyxerr << "repeat: count: " << count << " cmd: " << rest << endl;
|
2003-11-13 13:43:44 +00:00
|
|
|
for (int i = 0; i < count; ++i)
|
2004-03-18 12:53:43 +00:00
|
|
|
dispatch(lyxaction.lookupFunc(rest));
|
2003-11-13 13:43:44 +00:00
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
case LFUN_COMMAND_SEQUENCE: {
|
2003-11-13 13:43:44 +00:00
|
|
|
// argument contains ';'-terminated commands
|
2004-05-04 14:12:50 +00:00
|
|
|
string arg = argument;
|
2009-09-26 18:10:28 +00:00
|
|
|
// FIXME: this LFUN should also work without any view.
|
|
|
|
Buffer * buffer = (lv && lv->documentBufferView())
|
|
|
|
? &(lv->documentBufferView()->buffer()) : 0;
|
|
|
|
buffer = &lv->currentBufferView()->buffer();
|
|
|
|
if (buffer && !theBufferList().isLoaded(buffer))
|
|
|
|
buffer = 0;
|
|
|
|
if (buffer)
|
2008-11-17 12:26:19 +00:00
|
|
|
buffer->undo().beginUndoGroup();
|
2004-05-04 14:12:50 +00:00
|
|
|
while (!arg.empty()) {
|
2003-11-13 13:43:44 +00:00
|
|
|
string first;
|
2004-05-04 14:12:50 +00:00
|
|
|
arg = split(arg, first, ';');
|
2004-11-16 10:46:23 +00:00
|
|
|
FuncRequest func(lyxaction.lookupFunc(first));
|
|
|
|
func.origin = cmd.origin;
|
|
|
|
dispatch(func);
|
2003-11-13 13:43:44 +00:00
|
|
|
}
|
2009-09-26 18:10:28 +00:00
|
|
|
if (buffer)
|
2008-11-17 12:26:19 +00:00
|
|
|
buffer->undo().endUndoGroup();
|
2003-11-13 13:43:44 +00:00
|
|
|
break;
|
2004-05-04 14:12:50 +00:00
|
|
|
}
|
2000-08-14 05:24:35 +00:00
|
|
|
|
2008-09-24 15:08:46 +00:00
|
|
|
case LFUN_COMMAND_ALTERNATIVES: {
|
|
|
|
// argument contains ';'-terminated commands
|
|
|
|
string arg = argument;
|
|
|
|
while (!arg.empty()) {
|
|
|
|
string first;
|
|
|
|
arg = split(arg, first, ';');
|
|
|
|
FuncRequest func(lyxaction.lookupFunc(first));
|
|
|
|
func.origin = cmd.origin;
|
|
|
|
FuncStatus stat = getStatus(func);
|
|
|
|
if (stat.enabled()) {
|
|
|
|
dispatch(func);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-10-20 23:27:03 +00:00
|
|
|
case LFUN_CALL: {
|
|
|
|
FuncRequest func;
|
2008-07-14 08:35:00 +00:00
|
|
|
if (theTopLevelCmdDef().lock(argument, func)) {
|
2007-10-20 23:27:03 +00:00
|
|
|
func.origin = cmd.origin;
|
|
|
|
dispatch(func);
|
2008-07-14 08:35:00 +00:00
|
|
|
theTopLevelCmdDef().release(argument);
|
2007-10-20 23:27:03 +00:00
|
|
|
} else {
|
|
|
|
if (func.action == LFUN_UNKNOWN_ACTION) {
|
|
|
|
// unknown command definition
|
|
|
|
lyxerr << "Warning: unknown command definition `"
|
|
|
|
<< argument << "'"
|
|
|
|
<< endl;
|
|
|
|
} else {
|
|
|
|
// recursion detected
|
|
|
|
lyxerr << "Warning: Recursion in the command definition `"
|
|
|
|
<< argument << "' detected"
|
|
|
|
<< endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
case LFUN_PREFERENCES_SAVE: {
|
2006-12-27 10:56:11 +00:00
|
|
|
lyxrc.write(makeAbsPath("preferences",
|
2007-05-28 22:27:45 +00:00
|
|
|
package().user_support().absFilename()),
|
|
|
|
false);
|
2000-06-26 15:33:13 +00:00
|
|
|
break;
|
2003-10-27 12:41:26 +00:00
|
|
|
}
|
2000-06-26 15:33:13 +00:00
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
case LFUN_BUFFER_SAVE_AS_DEFAULT: {
|
2004-08-08 22:36:34 +00:00
|
|
|
string const fname =
|
2007-04-06 13:09:54 +00:00
|
|
|
addName(addPath(package().user_support().absFilename(), "templates/"),
|
2004-08-08 22:36:34 +00:00
|
|
|
"defaults.lyx");
|
|
|
|
Buffer defaults(fname);
|
|
|
|
|
|
|
|
istringstream ss(argument);
|
2008-04-02 23:06:22 +00:00
|
|
|
Lexer lex;
|
2004-08-08 22:36:34 +00:00
|
|
|
lex.setStream(ss);
|
|
|
|
int const unknown_tokens = defaults.readHeader(lex);
|
|
|
|
|
|
|
|
if (unknown_tokens != 0) {
|
2006-05-05 20:23:12 +00:00
|
|
|
lyxerr << "Warning in LFUN_BUFFER_SAVE_AS_DEFAULT!\n"
|
2004-08-08 22:36:34 +00:00
|
|
|
<< unknown_tokens << " unknown token"
|
|
|
|
<< (unknown_tokens == 1 ? "" : "s")
|
|
|
|
<< endl;
|
|
|
|
}
|
2004-10-05 10:11:42 +00:00
|
|
|
|
2007-10-20 10:03:45 +00:00
|
|
|
if (defaults.writeFile(FileName(defaults.absFileName())))
|
2007-02-14 19:11:09 +00:00
|
|
|
setMessage(bformat(_("Document defaults saved in %1$s"),
|
2007-05-28 22:27:45 +00:00
|
|
|
makeDisplayPath(fname)));
|
2004-08-08 22:36:34 +00:00
|
|
|
else
|
2007-02-14 19:11:09 +00:00
|
|
|
setErrorMessage(from_ascii(N_("Unable to save document defaults")));
|
2004-08-08 22:36:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-03-31 16:50:59 +00:00
|
|
|
case LFUN_LYXRC_APPLY: {
|
2009-07-25 06:16:46 +00:00
|
|
|
// reset active key sequences, since the bindings
|
|
|
|
// are updated (bug 6064)
|
|
|
|
keyseq.reset();
|
2005-01-16 21:01:41 +00:00
|
|
|
LyXRC const lyxrc_orig = lyxrc;
|
|
|
|
|
2004-03-31 16:50:59 +00:00
|
|
|
istringstream ss(argument);
|
|
|
|
bool const success = lyxrc.read(ss) == 0;
|
2004-04-03 08:37:12 +00:00
|
|
|
|
2004-03-31 16:50:59 +00:00
|
|
|
if (!success) {
|
|
|
|
lyxerr << "Warning in LFUN_LYXRC_APPLY!\n"
|
|
|
|
<< "Unable to read lyxrc data"
|
|
|
|
<< endl;
|
2005-01-16 21:01:41 +00:00
|
|
|
break;
|
2004-03-31 16:50:59 +00:00
|
|
|
}
|
2005-01-16 21:01:41 +00:00
|
|
|
|
|
|
|
actOnUpdatedPrefs(lyxrc_orig, lyxrc);
|
2007-01-15 15:51:45 +00:00
|
|
|
|
2009-08-08 17:05:31 +00:00
|
|
|
setSpellChecker();
|
|
|
|
|
2007-11-21 15:12:47 +00:00
|
|
|
theApp()->resetGui();
|
|
|
|
|
2007-01-15 15:51:45 +00:00
|
|
|
/// We force the redraw in any case because there might be
|
|
|
|
/// some screen font changes.
|
|
|
|
/// FIXME: only the current view will be updated. the Gui
|
|
|
|
/// class is able to furnish the list of views.
|
|
|
|
updateFlags = Update::Force;
|
2004-03-31 16:50:59 +00:00
|
|
|
break;
|
2004-04-03 08:37:12 +00:00
|
|
|
}
|
2004-03-31 16:50:59 +00:00
|
|
|
|
2007-01-11 16:01:10 +00:00
|
|
|
case LFUN_BOOKMARK_GOTO:
|
|
|
|
// go to bookmark, open unopened file and switch to buffer if necessary
|
|
|
|
gotoBookmark(convert<unsigned int>(to_utf8(cmd.argument())), true, true);
|
2007-12-22 10:19:26 +00:00
|
|
|
updateFlags = Update::FitCursor;
|
2006-11-01 15:55:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_BOOKMARK_CLEAR:
|
2008-07-14 08:35:00 +00:00
|
|
|
theSession().bookmarks().clear();
|
2006-11-01 15:55:17 +00:00
|
|
|
break;
|
|
|
|
|
2007-12-21 10:42:59 +00:00
|
|
|
default:
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(theApp(), /**/);
|
2007-11-26 14:36:50 +00:00
|
|
|
// Let the frontend dispatch its own actions.
|
|
|
|
if (theApp()->dispatch(cmd))
|
|
|
|
// Nothing more to do.
|
|
|
|
return;
|
|
|
|
|
2009-09-22 21:25:32 +00:00
|
|
|
// Everything below is only for active window
|
|
|
|
if (lv == 0)
|
2008-03-14 16:33:16 +00:00
|
|
|
break;
|
|
|
|
|
2009-09-26 18:10:28 +00:00
|
|
|
Buffer * doc_buffer = (lv && lv->documentBufferView())
|
|
|
|
? &(lv->documentBufferView()->buffer()) : 0;
|
|
|
|
if (doc_buffer && !theBufferList().isLoaded(doc_buffer))
|
|
|
|
doc_buffer = 0;
|
2008-09-15 15:44:49 +00:00
|
|
|
// Start an undo group. This may be needed for
|
|
|
|
// some stuff like inset-apply on labels.
|
2009-09-26 18:10:28 +00:00
|
|
|
if (doc_buffer)
|
|
|
|
doc_buffer->undo().beginUndoGroup();
|
|
|
|
|
2007-11-26 14:36:50 +00:00
|
|
|
// Let the current LyXView dispatch its own actions.
|
2009-09-22 21:25:32 +00:00
|
|
|
if (lv->dispatch(cmd)) {
|
|
|
|
BufferView * bv = lv->currentBufferView();
|
2009-09-20 21:41:21 +00:00
|
|
|
if (bv) {
|
2009-09-26 18:10:28 +00:00
|
|
|
Buffer * buffer = &(bv->buffer());
|
2009-09-20 21:41:21 +00:00
|
|
|
updateFlags = bv->cursor().result().update();
|
2009-09-26 18:10:28 +00:00
|
|
|
if (buffer == doc_buffer && theBufferList().isLoaded(buffer))
|
2008-10-23 06:59:31 +00:00
|
|
|
buffer->undo().endUndoGroup();
|
2008-09-15 15:44:49 +00:00
|
|
|
}
|
2007-11-26 14:36:50 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-09-22 21:25:32 +00:00
|
|
|
BufferView * bv = lv->currentBufferView();
|
2009-09-20 21:41:21 +00:00
|
|
|
LASSERT(bv, /**/);
|
2008-08-15 19:24:56 +00:00
|
|
|
|
2007-12-21 10:42:59 +00:00
|
|
|
// Let the current BufferView dispatch its own actions.
|
2009-09-20 21:41:21 +00:00
|
|
|
if (bv->dispatch(cmd)) {
|
|
|
|
// The BufferView took care of its own updates if needed.
|
2009-09-26 18:10:28 +00:00
|
|
|
Buffer * buffer = &(bv->buffer());
|
2009-09-20 21:41:21 +00:00
|
|
|
updateFlags = Update::None;
|
2009-09-26 18:10:28 +00:00
|
|
|
if (buffer == doc_buffer && theBufferList().isLoaded(buffer))
|
2009-09-20 21:41:21 +00:00
|
|
|
buffer->undo().endUndoGroup();
|
|
|
|
break;
|
|
|
|
}
|
2009-09-21 16:52:04 +00:00
|
|
|
|
2009-09-22 21:25:32 +00:00
|
|
|
BufferView * doc_bv = lv->documentBufferView();
|
2009-09-20 21:41:21 +00:00
|
|
|
// Try with the document BufferView dispatch if any.
|
|
|
|
if (doc_bv && doc_bv->dispatch(cmd)) {
|
2007-12-21 10:42:59 +00:00
|
|
|
// The BufferView took care of its own updates if needed.
|
2009-09-26 18:10:28 +00:00
|
|
|
Buffer * buffer = &(doc_bv->buffer());
|
2007-12-21 10:42:59 +00:00
|
|
|
updateFlags = Update::None;
|
2009-09-26 18:10:28 +00:00
|
|
|
if (buffer == doc_buffer && theBufferList().isLoaded(buffer))
|
2008-10-23 06:59:31 +00:00
|
|
|
buffer->undo().endUndoGroup();
|
2007-12-21 10:42:59 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-11-26 14:36:50 +00:00
|
|
|
|
2009-09-20 21:41:21 +00:00
|
|
|
// OK, so try the current Buffer itself...
|
2009-04-06 12:12:06 +00:00
|
|
|
DispatchResult dr;
|
2009-09-05 15:42:53 +00:00
|
|
|
bv->buffer().dispatch(cmd, dr);
|
2009-04-06 12:12:06 +00:00
|
|
|
if (dr.dispatched()) {
|
|
|
|
updateFlags = dr.update();
|
|
|
|
break;
|
|
|
|
}
|
2009-09-20 21:41:21 +00:00
|
|
|
// and with the document Buffer.
|
2009-09-19 14:05:52 +00:00
|
|
|
if (doc_bv) {
|
2009-09-20 21:41:21 +00:00
|
|
|
doc_bv->buffer().dispatch(cmd, dr);
|
2009-09-19 14:05:52 +00:00
|
|
|
if (dr.dispatched()) {
|
|
|
|
updateFlags = dr.update();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-04-06 12:12:06 +00:00
|
|
|
|
2009-03-30 13:49:52 +00:00
|
|
|
// Is this a function that acts on inset at point?
|
2009-09-05 15:42:53 +00:00
|
|
|
Inset * inset = bv->cursor().nextInset();
|
2009-03-30 13:49:52 +00:00
|
|
|
if (lyxaction.funcHasFlag(action, LyXAction::AtPoint)
|
|
|
|
&& inset) {
|
2009-09-05 15:42:53 +00:00
|
|
|
bv->cursor().result().dispatched(true);
|
|
|
|
bv->cursor().result().update(Update::FitCursor | Update::Force);
|
2009-03-30 13:49:52 +00:00
|
|
|
FuncRequest tmpcmd = cmd;
|
2009-09-05 15:42:53 +00:00
|
|
|
inset->dispatch(bv->cursor(), tmpcmd);
|
|
|
|
if (bv->cursor().result().dispatched()) {
|
|
|
|
updateFlags = bv->cursor().result().update();
|
2009-03-30 13:49:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-26 14:36:50 +00:00
|
|
|
// Let the current Cursor dispatch its own actions.
|
2009-09-05 15:42:53 +00:00
|
|
|
Cursor old = bv->cursor();
|
|
|
|
bv->cursor().getPos(cursorPosBeforeDispatchX_,
|
2007-12-17 18:13:02 +00:00
|
|
|
cursorPosBeforeDispatchY_);
|
2009-09-05 15:42:53 +00:00
|
|
|
bv->cursor().dispatch(cmd);
|
2008-02-22 20:45:18 +00:00
|
|
|
|
|
|
|
// notify insets we just left
|
2009-09-05 15:42:53 +00:00
|
|
|
if (bv->cursor() != old) {
|
2008-02-22 20:45:18 +00:00
|
|
|
old.fixIfBroken();
|
2009-09-05 15:42:53 +00:00
|
|
|
bool badcursor = notifyCursorLeavesOrEnters(old, bv->cursor());
|
2008-02-22 20:45:18 +00:00
|
|
|
if (badcursor)
|
2009-09-05 15:42:53 +00:00
|
|
|
bv->cursor().fixIfBroken();
|
2007-12-21 11:22:17 +00:00
|
|
|
}
|
2009-09-26 18:10:28 +00:00
|
|
|
Buffer * buffer = &(bv->buffer());
|
|
|
|
if (buffer == doc_buffer && theBufferList().isLoaded(buffer))
|
2008-10-23 06:59:31 +00:00
|
|
|
buffer->undo().endUndoGroup();
|
2008-09-18 14:34:33 +00:00
|
|
|
|
2008-02-29 09:18:46 +00:00
|
|
|
// update completion. We do it here and not in
|
|
|
|
// processKeySym to avoid another redraw just for a
|
|
|
|
// changed inline completion
|
|
|
|
if (cmd.origin == FuncRequest::KEYBOARD) {
|
2009-07-12 14:56:38 +00:00
|
|
|
if (cmd.action == LFUN_SELF_INSERT
|
2009-09-05 15:42:53 +00:00
|
|
|
|| (cmd.action == LFUN_ERT_INSERT && bv->cursor().inMathed()))
|
2009-09-22 21:25:32 +00:00
|
|
|
lv->updateCompletion(bv->cursor(), true, true);
|
2008-02-29 09:18:46 +00:00
|
|
|
else if (cmd.action == LFUN_CHAR_DELETE_BACKWARD)
|
2009-09-22 21:25:32 +00:00
|
|
|
lv->updateCompletion(bv->cursor(), false, true);
|
2008-02-29 09:18:46 +00:00
|
|
|
else
|
2009-09-22 21:25:32 +00:00
|
|
|
lv->updateCompletion(bv->cursor(), false, false);
|
2008-02-29 09:18:46 +00:00
|
|
|
}
|
|
|
|
|
2009-09-05 15:42:53 +00:00
|
|
|
updateFlags = bv->cursor().result().update();
|
2004-03-18 12:53:43 +00:00
|
|
|
}
|
2001-02-23 16:10:03 +00:00
|
|
|
|
2008-10-23 06:59:31 +00:00
|
|
|
// if we executed a mutating lfun, mark the buffer as dirty
|
2009-09-26 18:10:28 +00:00
|
|
|
Buffer * doc_buffer = (lv && lv->documentBufferView())
|
|
|
|
? &(lv->documentBufferView()->buffer()) : 0;
|
|
|
|
if (doc_buffer && theBufferList().isLoaded(doc_buffer)
|
|
|
|
&& flag.enabled()
|
2008-10-23 06:59:31 +00:00
|
|
|
&& !lyxaction.funcHasFlag(action, LyXAction::NoBuffer)
|
|
|
|
&& !lyxaction.funcHasFlag(action, LyXAction::ReadOnly))
|
2009-09-26 18:10:28 +00:00
|
|
|
doc_buffer->markDirty();
|
2008-10-23 06:59:31 +00:00
|
|
|
|
2009-09-22 21:25:32 +00:00
|
|
|
if (lv && lv->currentBufferView()) {
|
2006-11-21 09:04:54 +00:00
|
|
|
// BufferView::update() updates the ViewMetricsInfo and
|
|
|
|
// also initializes the position cache for all insets in
|
|
|
|
// (at least partially) visible top-level paragraphs.
|
2006-12-07 11:46:27 +00:00
|
|
|
// We will redraw the screen only if needed.
|
2009-09-22 21:25:32 +00:00
|
|
|
lv->currentBufferView()->processUpdateFlags(updateFlags);
|
2006-07-13 16:37:55 +00:00
|
|
|
|
2008-03-10 19:08:03 +00:00
|
|
|
// Do we have a selection?
|
2009-09-05 15:42:53 +00:00
|
|
|
theSelection().haveSelection(
|
2009-09-22 21:25:32 +00:00
|
|
|
lv->currentBufferView()->cursor().selection());
|
2008-03-10 19:08:03 +00:00
|
|
|
|
|
|
|
// update gui
|
2009-09-22 21:25:32 +00:00
|
|
|
lv->restartCursor();
|
2004-03-25 09:16:36 +00:00
|
|
|
}
|
2004-03-18 12:53:43 +00:00
|
|
|
}
|
2009-09-22 21:25:32 +00:00
|
|
|
if (lv) {
|
2007-02-14 19:11:09 +00:00
|
|
|
// Some messages may already be translated, so we cannot use _()
|
|
|
|
sendDispatchMessage(translateIfPossible(getMessage()), cmd);
|
2006-11-09 14:56:57 +00:00
|
|
|
}
|
2002-07-18 20:15:29 +00:00
|
|
|
}
|
1999-11-22 16:19:48 +00:00
|
|
|
|
|
|
|
|
2006-09-11 08:54:10 +00:00
|
|
|
void LyXFunc::sendDispatchMessage(docstring const & msg, FuncRequest const & cmd)
|
2002-07-18 20:15:29 +00:00
|
|
|
{
|
2006-11-09 14:56:57 +00:00
|
|
|
const bool verbose = (cmd.origin == FuncRequest::MENU
|
|
|
|
|| cmd.origin == FuncRequest::TOOLBAR
|
2004-11-08 10:54:29 +00:00
|
|
|
|| cmd.origin == FuncRequest::COMMANDBUFFER);
|
|
|
|
|
2009-09-22 21:25:32 +00:00
|
|
|
LyXView * lv = theApp()->currentWindow();
|
2006-05-05 20:23:12 +00:00
|
|
|
if (cmd.action == LFUN_SELF_INSERT || !verbose) {
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::ACTION, "dispatch msg is " << to_utf8(msg));
|
2002-07-18 20:15:29 +00:00
|
|
|
if (!msg.empty())
|
2009-09-22 21:25:32 +00:00
|
|
|
lv->message(msg);
|
2002-07-18 20:15:29 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2006-09-11 08:54:10 +00:00
|
|
|
docstring dispatch_msg = msg;
|
2002-07-18 20:15:29 +00:00
|
|
|
if (!dispatch_msg.empty())
|
2002-11-27 10:30:28 +00:00
|
|
|
dispatch_msg += ' ';
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2006-12-22 09:23:10 +00:00
|
|
|
docstring comname = from_utf8(lyxaction.getActionName(cmd.action));
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-07-18 20:15:29 +00:00
|
|
|
bool argsadded = false;
|
|
|
|
|
2006-09-01 15:41:38 +00:00
|
|
|
if (!cmd.argument().empty()) {
|
2004-01-30 11:41:12 +00:00
|
|
|
if (cmd.action != LFUN_UNKNOWN_ACTION) {
|
2006-12-22 09:23:10 +00:00
|
|
|
comname += ' ' + cmd.argument();
|
2002-07-18 20:15:29 +00:00
|
|
|
argsadded = true;
|
|
|
|
}
|
|
|
|
}
|
1999-11-22 16:19:48 +00:00
|
|
|
|
2008-10-31 11:19:16 +00:00
|
|
|
docstring const shortcuts = theTopLevelKeymap().printBindings(cmd, KeySequence::ForGui);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-14 22:09:22 +00:00
|
|
|
if (!shortcuts.empty())
|
2002-07-18 20:15:29 +00:00
|
|
|
comname += ": " + shortcuts;
|
2006-09-01 15:41:38 +00:00
|
|
|
else if (!argsadded && !cmd.argument().empty())
|
2006-12-22 09:23:10 +00:00
|
|
|
comname += ' ' + cmd.argument();
|
2002-07-18 20:15:29 +00:00
|
|
|
|
|
|
|
if (!comname.empty()) {
|
2002-07-28 22:50:13 +00:00
|
|
|
comname = rtrim(comname);
|
2006-12-22 09:23:10 +00:00
|
|
|
dispatch_msg += '(' + rtrim(comname) + ')';
|
2002-07-18 20:15:29 +00:00
|
|
|
}
|
|
|
|
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::ACTION, "verbose dispatch msg " << to_utf8(dispatch_msg));
|
2002-07-18 20:15:29 +00:00
|
|
|
if (!dispatch_msg.empty())
|
2009-09-22 21:25:32 +00:00
|
|
|
lv->message(dispatch_msg);
|
2002-07-18 20:15:29 +00:00
|
|
|
}
|
|
|
|
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2009-09-22 21:25:32 +00:00
|
|
|
// Each LyXView should have it's own message method. lyxview and
|
1999-09-27 18:44:28 +00:00
|
|
|
// the minibuffer would use the minibuffer, but lyxserver would
|
|
|
|
// send an ERROR signal to its client. Alejandro 970603
|
2004-01-30 11:41:12 +00:00
|
|
|
// This function is bit problematic when it comes to NLS, to make the
|
1999-09-27 18:44:28 +00:00
|
|
|
// lyx servers client be language indepenent we must not translate
|
|
|
|
// strings sent to this func.
|
2006-09-11 08:54:10 +00:00
|
|
|
void LyXFunc::setErrorMessage(docstring const & m) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
dispatch_buffer = m;
|
|
|
|
errorstat = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-11 08:54:10 +00:00
|
|
|
void LyXFunc::setMessage(docstring const & m) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
dispatch_buffer = m;
|
|
|
|
}
|
2001-04-17 15:15:59 +00:00
|
|
|
|
|
|
|
|
2008-03-15 01:20:36 +00:00
|
|
|
docstring LyXFunc::viewStatusMessage()
|
2001-04-17 15:15:59 +00:00
|
|
|
{
|
|
|
|
// When meta-fake key is pressed, show the key sequence so far + "M-".
|
2004-02-20 08:44:11 +00:00
|
|
|
if (wasMetaKey())
|
2007-10-20 20:28:05 +00:00
|
|
|
return keyseq.print(KeySequence::ForGui) + "M-";
|
2001-04-17 15:15:59 +00:00
|
|
|
|
|
|
|
// Else, when a non-complete key sequence is pressed,
|
|
|
|
// show the available options.
|
2007-09-17 22:51:03 +00:00
|
|
|
if (keyseq.length() > 0 && !keyseq.deleted())
|
|
|
|
return keyseq.printOptions(true);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2009-09-30 07:40:27 +00:00
|
|
|
return docstring();
|
2001-04-17 15:15:59 +00:00
|
|
|
}
|
2003-07-28 22:34:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool LyXFunc::wasMetaKey() const
|
|
|
|
{
|
2007-10-02 21:51:54 +00:00
|
|
|
return (meta_fake_bit != NoModifier);
|
2003-07-28 22:34:48 +00:00
|
|
|
}
|
2005-01-16 21:01:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
|
|
|
|
{
|
|
|
|
// Why the switch you might ask. It is a trick to ensure that all
|
|
|
|
// the elements in the LyXRCTags enum is handled. As you can see
|
|
|
|
// there are no breaks at all. So it is just a huge fall-through.
|
|
|
|
// The nice thing is that we will get a warning from the compiler
|
|
|
|
// if we forget an element.
|
|
|
|
LyXRC::LyXRCTags tag = LyXRC::RC_LAST;
|
|
|
|
switch (tag) {
|
|
|
|
case LyXRC::RC_ACCEPT_COMPOUND:
|
|
|
|
case LyXRC::RC_ALT_LANG:
|
2007-01-15 22:49:14 +00:00
|
|
|
case LyXRC::RC_PLAINTEXT_LINELEN:
|
2008-11-16 17:49:00 +00:00
|
|
|
case LyXRC::RC_PLAINTEXT_ROFF_COMMAND:
|
2009-01-17 13:49:49 +00:00
|
|
|
case LyXRC::RC_AUTOCORRECTION_MATH:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_AUTOREGIONDELETE:
|
|
|
|
case LyXRC::RC_AUTORESET_OPTIONS:
|
|
|
|
case LyXRC::RC_AUTOSAVE:
|
|
|
|
case LyXRC::RC_AUTO_NUMBER:
|
|
|
|
case LyXRC::RC_BACKUPDIR_PATH:
|
2009-05-08 10:07:32 +00:00
|
|
|
case LyXRC::RC_BIBTEX_ALTERNATIVES:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_BIBTEX_COMMAND:
|
|
|
|
case LyXRC::RC_BINDFILE:
|
|
|
|
case LyXRC::RC_CHECKLASTFILES:
|
2008-03-16 17:07:10 +00:00
|
|
|
case LyXRC::RC_COMPLETION_CURSOR_TEXT:
|
2008-02-21 19:42:34 +00:00
|
|
|
case LyXRC::RC_COMPLETION_INLINE_DELAY:
|
2008-02-22 15:38:26 +00:00
|
|
|
case LyXRC::RC_COMPLETION_INLINE_DOTS:
|
2008-02-21 19:42:34 +00:00
|
|
|
case LyXRC::RC_COMPLETION_INLINE_MATH:
|
|
|
|
case LyXRC::RC_COMPLETION_INLINE_TEXT:
|
2008-02-22 15:38:26 +00:00
|
|
|
case LyXRC::RC_COMPLETION_POPUP_AFTER_COMPLETE:
|
2008-02-21 19:42:34 +00:00
|
|
|
case LyXRC::RC_COMPLETION_POPUP_DELAY:
|
|
|
|
case LyXRC::RC_COMPLETION_POPUP_MATH:
|
|
|
|
case LyXRC::RC_COMPLETION_POPUP_TEXT:
|
2006-04-05 22:56:18 +00:00
|
|
|
case LyXRC::RC_USELASTFILEPOS:
|
|
|
|
case LyXRC::RC_LOADSESSION:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_CHKTEX_COMMAND:
|
|
|
|
case LyXRC::RC_CONVERTER:
|
2006-11-13 19:52:05 +00:00
|
|
|
case LyXRC::RC_CONVERTER_CACHE_MAXAGE:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_COPIER:
|
|
|
|
case LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR:
|
2009-03-27 17:41:58 +00:00
|
|
|
case LyXRC::RC_SCROLL_BELOW_DOCUMENT:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_DATE_INSERT_FORMAT:
|
|
|
|
case LyXRC::RC_DEFAULT_LANGUAGE:
|
2008-06-24 12:55:40 +00:00
|
|
|
case LyXRC::RC_GUI_LANGUAGE:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_DEFAULT_PAPERSIZE:
|
2009-04-07 05:01:08 +00:00
|
|
|
case LyXRC::RC_DEFAULT_VIEW_FORMAT:
|
2007-11-10 11:22:19 +00:00
|
|
|
case LyXRC::RC_DEFFILE:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN:
|
|
|
|
case LyXRC::RC_DISPLAY_GRAPHICS:
|
|
|
|
case LyXRC::RC_DOCUMENTPATH:
|
|
|
|
if (lyxrc_orig.document_path != lyxrc_new.document_path) {
|
2007-10-18 21:10:35 +00:00
|
|
|
FileName path(lyxrc_new.document_path);
|
|
|
|
if (path.exists() && path.isDirectory())
|
2007-12-12 19:57:42 +00:00
|
|
|
package().document_dir() = FileName(lyxrc.document_path);
|
2005-01-16 21:01:41 +00:00
|
|
|
}
|
2009-09-05 15:11:43 +00:00
|
|
|
case LyXRC::RC_EDITOR_ALTERNATIVES:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_ESC_CHARS:
|
2007-11-30 00:04:44 +00:00
|
|
|
case LyXRC::RC_EXAMPLEPATH:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_FONT_ENCODING:
|
|
|
|
case LyXRC::RC_FORMAT:
|
2008-03-14 16:35:44 +00:00
|
|
|
case LyXRC::RC_GROUP_LAYOUTS:
|
2009-08-08 17:05:31 +00:00
|
|
|
case LyXRC::RC_HUNSPELLDIR_PATH:
|
2009-05-08 10:07:32 +00:00
|
|
|
case LyXRC::RC_INDEX_ALTERNATIVES:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_INDEX_COMMAND:
|
2009-04-13 09:53:40 +00:00
|
|
|
case LyXRC::RC_JBIBTEX_COMMAND:
|
|
|
|
case LyXRC::RC_JINDEX_COMMAND:
|
2008-08-23 09:44:00 +00:00
|
|
|
case LyXRC::RC_NOMENCL_COMMAND:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_INPUT:
|
|
|
|
case LyXRC::RC_KBMAP:
|
|
|
|
case LyXRC::RC_KBMAP_PRIMARY:
|
|
|
|
case LyXRC::RC_KBMAP_SECONDARY:
|
|
|
|
case LyXRC::RC_LABEL_INIT_LENGTH:
|
|
|
|
case LyXRC::RC_LANGUAGE_AUTO_BEGIN:
|
|
|
|
case LyXRC::RC_LANGUAGE_AUTO_END:
|
|
|
|
case LyXRC::RC_LANGUAGE_COMMAND_BEGIN:
|
|
|
|
case LyXRC::RC_LANGUAGE_COMMAND_END:
|
|
|
|
case LyXRC::RC_LANGUAGE_COMMAND_LOCAL:
|
|
|
|
case LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS:
|
|
|
|
case LyXRC::RC_LANGUAGE_PACKAGE:
|
|
|
|
case LyXRC::RC_LANGUAGE_USE_BABEL:
|
2008-07-14 12:41:36 +00:00
|
|
|
case LyXRC::RC_MAC_LIKE_WORD_MOVEMENT:
|
2008-01-25 22:02:38 +00:00
|
|
|
case LyXRC::RC_MACRO_EDIT_STYLE:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_MAKE_BACKUP:
|
|
|
|
case LyXRC::RC_MARK_FOREIGN_LANGUAGE:
|
2008-01-30 21:20:29 +00:00
|
|
|
case LyXRC::RC_MOUSE_WHEEL_SPEED:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_NUMLASTFILES:
|
2009-08-19 23:02:27 +00:00
|
|
|
case LyXRC::RC_PARAGRAPH_MARKERS:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_PATH_PREFIX:
|
|
|
|
if (lyxrc_orig.path_prefix != lyxrc_new.path_prefix) {
|
2007-12-12 19:57:42 +00:00
|
|
|
prependEnvPath("PATH", lyxrc.path_prefix);
|
2005-01-16 21:01:41 +00:00
|
|
|
}
|
|
|
|
case LyXRC::RC_PERS_DICT:
|
|
|
|
case LyXRC::RC_PREVIEW:
|
|
|
|
case LyXRC::RC_PREVIEW_HASHED_LABELS:
|
|
|
|
case LyXRC::RC_PREVIEW_SCALE_FACTOR:
|
|
|
|
case LyXRC::RC_PRINTCOLLCOPIESFLAG:
|
|
|
|
case LyXRC::RC_PRINTCOPIESFLAG:
|
|
|
|
case LyXRC::RC_PRINTER:
|
|
|
|
case LyXRC::RC_PRINTEVENPAGEFLAG:
|
|
|
|
case LyXRC::RC_PRINTEXSTRAOPTIONS:
|
|
|
|
case LyXRC::RC_PRINTFILEEXTENSION:
|
|
|
|
case LyXRC::RC_PRINTLANDSCAPEFLAG:
|
|
|
|
case LyXRC::RC_PRINTODDPAGEFLAG:
|
|
|
|
case LyXRC::RC_PRINTPAGERANGEFLAG:
|
|
|
|
case LyXRC::RC_PRINTPAPERDIMENSIONFLAG:
|
|
|
|
case LyXRC::RC_PRINTPAPERFLAG:
|
|
|
|
case LyXRC::RC_PRINTREVERSEFLAG:
|
|
|
|
case LyXRC::RC_PRINTSPOOL_COMMAND:
|
|
|
|
case LyXRC::RC_PRINTSPOOL_PRINTERPREFIX:
|
|
|
|
case LyXRC::RC_PRINTTOFILE:
|
|
|
|
case LyXRC::RC_PRINTTOPRINTER:
|
|
|
|
case LyXRC::RC_PRINT_ADAPTOUTPUT:
|
|
|
|
case LyXRC::RC_PRINT_COMMAND:
|
|
|
|
case LyXRC::RC_RTL_SUPPORT:
|
|
|
|
case LyXRC::RC_SCREEN_DPI:
|
|
|
|
case LyXRC::RC_SCREEN_FONT_ROMAN:
|
|
|
|
case LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY:
|
|
|
|
case LyXRC::RC_SCREEN_FONT_SANS:
|
|
|
|
case LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY:
|
|
|
|
case LyXRC::RC_SCREEN_FONT_SCALABLE:
|
|
|
|
case LyXRC::RC_SCREEN_FONT_SIZES:
|
|
|
|
case LyXRC::RC_SCREEN_FONT_TYPEWRITER:
|
|
|
|
case LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
|
2007-11-15 12:58:44 +00:00
|
|
|
case LyXRC::RC_GEOMETRY_SESSION:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_SCREEN_ZOOM:
|
|
|
|
case LyXRC::RC_SERVERPIPE:
|
|
|
|
case LyXRC::RC_SET_COLOR:
|
|
|
|
case LyXRC::RC_SHOW_BANNER:
|
2008-03-14 23:27:31 +00:00
|
|
|
case LyXRC::RC_OPEN_BUFFERS_IN_TABS:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_SPELL_COMMAND:
|
2009-08-08 17:05:31 +00:00
|
|
|
case LyXRC::RC_SPELLCHECKER:
|
2009-03-29 19:57:30 +00:00
|
|
|
case LyXRC::RC_SPELLCHECK_CONTINUOUSLY:
|
2009-04-16 07:29:01 +00:00
|
|
|
case LyXRC::RC_SPLITINDEX_COMMAND:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_TEMPDIRPATH:
|
|
|
|
case LyXRC::RC_TEMPLATEPATH:
|
2005-04-19 09:04:25 +00:00
|
|
|
case LyXRC::RC_TEX_ALLOWS_SPACES:
|
2006-06-27 10:51:24 +00:00
|
|
|
case LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS:
|
|
|
|
if (lyxrc_orig.windows_style_tex_paths != lyxrc_new.windows_style_tex_paths) {
|
2007-12-12 19:57:42 +00:00
|
|
|
os::windows_style_tex_paths(lyxrc_new.windows_style_tex_paths);
|
2006-06-27 10:51:24 +00:00
|
|
|
}
|
2008-11-16 18:48:25 +00:00
|
|
|
case LyXRC::RC_THESAURUSDIRPATH:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_UIFILE:
|
|
|
|
case LyXRC::RC_USER_EMAIL:
|
|
|
|
case LyXRC::RC_USER_NAME:
|
|
|
|
case LyXRC::RC_USETEMPDIR:
|
|
|
|
case LyXRC::RC_USE_ALT_LANG:
|
2006-11-13 19:52:05 +00:00
|
|
|
case LyXRC::RC_USE_CONVERTER_CACHE:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_USE_ESC_CHARS:
|
|
|
|
case LyXRC::RC_USE_INP_ENC:
|
|
|
|
case LyXRC::RC_USE_PERS_DICT:
|
2007-12-26 13:52:56 +00:00
|
|
|
case LyXRC::RC_USE_TOOLTIP:
|
2007-11-05 15:50:00 +00:00
|
|
|
case LyXRC::RC_USE_PIXMAP_CACHE:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_USE_SPELL_LIB:
|
|
|
|
case LyXRC::RC_VIEWDVI_PAPEROPTION:
|
2007-11-10 00:21:42 +00:00
|
|
|
case LyXRC::RC_SORT_LAYOUTS:
|
2008-02-21 14:34:41 +00:00
|
|
|
case LyXRC::RC_FULL_SCREEN_LIMIT:
|
|
|
|
case LyXRC::RC_FULL_SCREEN_SCROLLBAR:
|
2009-05-26 21:41:45 +00:00
|
|
|
case LyXRC::RC_FULL_SCREEN_MENUBAR:
|
2008-02-21 14:34:41 +00:00
|
|
|
case LyXRC::RC_FULL_SCREEN_TABBAR:
|
|
|
|
case LyXRC::RC_FULL_SCREEN_TOOLBARS:
|
|
|
|
case LyXRC::RC_FULL_SCREEN_WIDTH:
|
|
|
|
case LyXRC::RC_VISUAL_CURSOR:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_VIEWER:
|
2009-09-05 15:11:43 +00:00
|
|
|
case LyXRC::RC_VIEWER_ALTERNATIVES:
|
2005-01-16 21:01:41 +00:00
|
|
|
case LyXRC::RC_LAST:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace anon
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|