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
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
* \author Angus Leeming
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
* \author Allan Rae
|
|
|
|
|
* \author Dekel Tsur
|
|
|
|
|
* \author Martin Vermeer
|
|
|
|
|
* \author J<EFBFBD>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"
|
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"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "insets/InsetBox.h"
|
|
|
|
|
#include "insets/InsetBranch.h"
|
|
|
|
|
#include "insets/InsetCommand.h"
|
|
|
|
|
#include "insets/InsetERT.h"
|
|
|
|
|
#include "insets/InsetExternal.h"
|
|
|
|
|
#include "insets/InsetFloat.h"
|
|
|
|
|
#include "insets/InsetGraphics.h"
|
|
|
|
|
#include "insets/InsetInclude.h"
|
2008-06-24 07:37:14 +00:00
|
|
|
|
#include "insets/InsetListings.h"
|
|
|
|
|
#include "insets/InsetNote.h"
|
*** File Format Change: UI and enhancement for InsetSpace ***
* src/insets/InsetSpace.{cpp,h}:
- merge in HFill inset, add support for dotfill, hrulefill,
hspace and hspace*
* src/insets/InsetHFill.{cpp,h}:
- remove
* src/frontends/qt4/GuiHSpace.{cpp,h}:
* src/frontends/qt4/ui/HSpaceUi.ui:
* src/frontends/qt4/GuiView:
- new GUI for Space insets.
* src/insets/Inset.{cpp,h}:
* src/insets/InsetCode.h:
* src/insets/InsetCollapsable.cpp:
* src/insets/InsetCommandParams.cpp:
- remove HFILL_CODE and LFUN_HFILL_INSERT, add SPACE_CODE where necessary,
new Inset member isStretchableSpace() to indicate HFill and friends.
* Buffer.cpp:
- increase format to 319
* lib/lyx2lyx/LyX.py:
* lib/lyx2lyx/lyx_1_6.py:
- conversion/reversion routines
* development/FORMAT:
- document file format change
* src/Makefile.am:
* src/frontends/qt4/Makefile.am:
* development/scons/scons_manifest.py:
- deal with UI changes.
* src/LyXAction.cpp:
- remove LFUN_HFILL_INSERT
* src/LyXFunc.cpp:
- handle space dialog.
* src/factory.cpp:
* src/Paragraph.cpp (isHFill):
* src/Text.cpp:
* src/Text3.cpp:
* src/TextMetrics.cpp:
- adapt to changes
* lib/ui/classic.ui:
* lib/ui/stdmenus.ui:
- add HSpace dialog, remove HFill.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23787 a592a061-630c-0410-9148-cb99ea01b6c8
2008-03-17 09:23:43 +00:00
|
|
|
|
#include "insets/InsetSpace.h"
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "insets/InsetTabular.h"
|
|
|
|
|
#include "insets/InsetVSpace.h"
|
|
|
|
|
#include "insets/InsetWrap.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"
|
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."));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-29 11:00:18 +00:00
|
|
|
|
bool getLocalStatus(Cursor cursor, FuncRequest const & cmd, FuncStatus & status)
|
2005-01-05 20:21:27 +00:00
|
|
|
|
{
|
2005-02-15 17:34:54 +00:00
|
|
|
|
// Try to fix cursor in case it is broken.
|
|
|
|
|
cursor.fixIfBroken();
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
// This is, of course, a mess. Better create a new doc iterator and use
|
|
|
|
|
// this in Inset::getStatus. This might require an additional
|
|
|
|
|
// BufferView * arg, though (which should be avoided)
|
2007-04-26 14:56:30 +00:00
|
|
|
|
//Cursor safe = *this;
|
2005-01-05 20:21:27 +00:00
|
|
|
|
bool res = false;
|
2005-02-08 13:18:05 +00:00
|
|
|
|
for ( ; cursor.depth(); cursor.pop()) {
|
2007-04-26 14:56:30 +00:00
|
|
|
|
//lyxerr << "\nCursor::getStatus: cmd: " << cmd << endl << *this << endl;
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(cursor.idx() <= cursor.lastidx(), /**/);
|
|
|
|
|
LASSERT(cursor.pit() <= cursor.lastpit(), /**/);
|
|
|
|
|
LASSERT(cursor.pos() <= cursor.lastpos(), /**/);
|
2005-01-05 20:21:27 +00:00
|
|
|
|
|
|
|
|
|
// The inset's getStatus() will return 'true' if it made
|
|
|
|
|
// a definitive decision on whether it want to handle the
|
|
|
|
|
// request or not. The result of this decision is put into
|
|
|
|
|
// the 'status' parameter.
|
|
|
|
|
if (cursor.inset().getStatus(cursor, cmd, status)) {
|
|
|
|
|
res = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-07 10:37:05 +00:00
|
|
|
|
|
|
|
|
|
/** Return the change status at cursor position, taking in account the
|
|
|
|
|
* status at each level of the document iterator (a table in a deleted
|
|
|
|
|
* footnote is deleted).
|
|
|
|
|
* When \param outer is true, the top slice is not looked at.
|
|
|
|
|
*/
|
2006-05-05 23:11:19 +00:00
|
|
|
|
Change::Type lookupChangeType(DocIterator const & dit, bool outer = false)
|
2005-09-07 10:37:05 +00:00
|
|
|
|
{
|
2005-09-08 12:06:49 +00:00
|
|
|
|
size_t const depth = dit.depth() - (outer ? 1 : 0);
|
2005-09-07 10:37:05 +00:00
|
|
|
|
|
|
|
|
|
for (size_t i = 0 ; i < depth ; ++i) {
|
|
|
|
|
CursorSlice const & slice = dit[i];
|
2006-04-05 23:56:29 +00:00
|
|
|
|
if (!slice.inset().inMathed()
|
2005-09-07 10:37:05 +00:00
|
|
|
|
&& slice.pos() < slice.paragraph().size()) {
|
2006-05-08 20:30:52 +00:00
|
|
|
|
Change::Type const ch = slice.paragraph().lookupChange(slice.pos()).type;
|
2005-09-07 10:37:05 +00:00
|
|
|
|
if (ch != Change::UNCHANGED)
|
|
|
|
|
return ch;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Change::UNCHANGED;
|
|
|
|
|
}
|
|
|
|
|
|
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()
|
2007-10-02 21:51:54 +00:00
|
|
|
|
: lyx_view_(0), 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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-12 14:58:57 +00:00
|
|
|
|
void LyXFunc::setLyXView(LyXView * lv)
|
|
|
|
|
{
|
2008-02-27 12:30:41 +00:00
|
|
|
|
if (lyx_view_ && lyx_view_->view() && lyx_view_ != lv)
|
2007-07-06 17:03:45 +00:00
|
|
|
|
// save current selection to the selection buffer to allow
|
|
|
|
|
// middle-button paste in another window
|
|
|
|
|
cap::saveSelection(lyx_view_->view()->cursor());
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_ = lv;
|
2006-10-12 14:58:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
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;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_ && lyx_view_->view(), /**/);
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
|
lyx_view_->view()->getIntl().getTransManager().deadkey(
|
2007-02-01 19:27:37 +00:00
|
|
|
|
c, get_accent(action).accent, view()->cursor().innerText(), view()->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
|
2004-01-20 14:25:24 +00:00
|
|
|
|
view()->cursor().resetAnchor();
|
2007-10-10 08:52:55 +00:00
|
|
|
|
view()->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)
|
|
|
|
|
{
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_, /**/);
|
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
|
|
|
|
|
2007-08-22 14:36:18 +00:00
|
|
|
|
// if the current buffer is not that one, switch to it.
|
2008-07-29 07:59:58 +00:00
|
|
|
|
if (lyx_view_->buffer()->fileName() != bm.filename) {
|
2007-08-22 14:36:18 +00:00
|
|
|
|
if (!switchToBuffer)
|
|
|
|
|
return;
|
|
|
|
|
dispatch(FuncRequest(LFUN_BUFFER_SWITCH, file));
|
|
|
|
|
}
|
|
|
|
|
// moveToPosition try paragraph id first and then paragraph (pit, pos).
|
|
|
|
|
if (!view()->moveToPosition(bm.bottom_pit, bm.bottom_pos,
|
|
|
|
|
bm.top_id, bm.top_pos))
|
|
|
|
|
return;
|
2007-08-22 14:25:51 +00:00
|
|
|
|
|
2007-08-22 14:36:18 +00:00
|
|
|
|
// Cursor jump succeeded!
|
|
|
|
|
Cursor const & cur = view()->cursor();
|
|
|
|
|
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
|
|
|
|
|
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)");
|
2007-11-13 09:52:28 +00:00
|
|
|
|
lyx_view_->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");
|
2008-03-14 16:33:16 +00:00
|
|
|
|
if (lyx_view_)
|
|
|
|
|
lyx_view_->restartCursor();
|
2001-05-17 01:23:29 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-10-19 21:00:33 +00:00
|
|
|
|
//Encoding const * encoding = view()->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)
|
2007-10-20 20:28:05 +00:00
|
|
|
|
lyx_view_->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");
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->message(_("Unknown function."));
|
2007-11-13 09:52:28 +00:00
|
|
|
|
lyx_view_->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);
|
2008-02-25 07:32:02 +00:00
|
|
|
|
if (!lyx_view_)
|
|
|
|
|
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
|
|
|
|
|
2008-03-14 16:33:16 +00:00
|
|
|
|
Buffer * buf = lyx_view_ ? lyx_view_->buffer() : 0;
|
2004-11-16 10:46:23 +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:
|
|
|
|
|
#ifndef HAVE_LIBAIKSAURUS
|
|
|
|
|
case LFUN_THESAURUS_ENTRY:
|
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
|
// Check whether we need a buffer
|
2004-03-23 11:22:11 +00:00
|
|
|
|
if (!lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer) && !buf) {
|
|
|
|
|
// no, exit directly
|
2006-10-21 00:16:43 +00:00
|
|
|
|
flag.message(from_utf8(N_("Command not allowed with"
|
2006-09-11 08:54:10 +00:00
|
|
|
|
"out any document open")));
|
2008-05-29 15:14:00 +00:00
|
|
|
|
flag.setEnabled(false);
|
2004-03-23 11:22:11 +00:00
|
|
|
|
return flag;
|
1999-12-10 00:07:59 +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
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_TOGGLE_READ_ONLY:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
flag.setOnOff(buf->isReadonly());
|
|
|
|
|
break;
|
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_SWITCH:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
// toggle on the current buffer, but do not toggle off
|
|
|
|
|
// the other ones (is that a good idea?)
|
2007-10-20 10:03:45 +00:00
|
|
|
|
if (buf && to_utf8(cmd.argument()) == buf->absFileName())
|
2004-03-18 13:57:20 +00:00
|
|
|
|
flag.setOnOff(true);
|
|
|
|
|
break;
|
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_EXPORT:
|
2006-09-01 15:41:38 +00:00
|
|
|
|
enable = cmd.argument() == "custom"
|
2007-10-20 10:51:13 +00:00
|
|
|
|
|| buf->isExportable(to_utf8(cmd.argument()));
|
2000-11-06 11:20:22 +00:00
|
|
|
|
break;
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_CHKTEX:
|
2006-09-21 09:46:52 +00:00
|
|
|
|
enable = buf->isLatex() && !lyxrc.chktex_command.empty();
|
1999-12-16 06:43:25 +00:00
|
|
|
|
break;
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUILD_PROGRAM:
|
2007-10-20 10:51:13 +00:00
|
|
|
|
enable = buf->isExportable("program");
|
2000-07-31 12:51:19 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
case LFUN_VC_REGISTER:
|
2008-07-29 18:17:20 +00:00
|
|
|
|
enable = !buf->lyxvc().inUse() && !buf->isUnnamed();
|
2000-07-24 13:53:19 +00:00
|
|
|
|
break;
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_VC_CHECK_IN:
|
2008-07-21 01:55:58 +00:00
|
|
|
|
enable = buf->lyxvc().checkInEnabled();
|
2000-07-24 13:53:19 +00:00
|
|
|
|
break;
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_VC_CHECK_OUT:
|
2008-07-21 01:55:58 +00:00
|
|
|
|
enable = buf->lyxvc().checkOutEnabled();
|
2000-07-24 13:53:19 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_VC_REVERT:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
enable = buf->lyxvc().inUse();
|
2000-07-24 13:53:19 +00:00
|
|
|
|
break;
|
2008-07-21 01:55:58 +00:00
|
|
|
|
case LFUN_VC_UNDO_LAST:
|
|
|
|
|
enable = buf->lyxvc().undoLastEnabled();
|
|
|
|
|
break;
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_RELOAD:
|
2007-11-03 17:37:37 +00:00
|
|
|
|
enable = !buf->isUnnamed() && buf->fileName().exists()
|
2007-08-09 20:46:22 +00:00
|
|
|
|
&& (!buf->isClean() || buf->isExternallyModified(Buffer::timestamp_method));
|
2003-02-17 18:40:04 +00:00
|
|
|
|
break;
|
2003-10-29 12:18:08 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_CITATION_INSERT: {
|
2005-10-07 14:51:39 +00:00
|
|
|
|
FuncRequest fr(LFUN_INSET_INSERT, "citation");
|
|
|
|
|
enable = getStatus(fr).enabled();
|
|
|
|
|
break;
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
|
case LFUN_BUFFER_WRITE_ALL: {
|
2007-12-04 22:21:25 +00:00
|
|
|
|
// We enable the command only if there are some modified buffers
|
2007-08-06 15:34:02 +00:00
|
|
|
|
Buffer * first = theBufferList().first();
|
2007-12-04 22:21:25 +00:00
|
|
|
|
enable = false;
|
|
|
|
|
if (!first)
|
|
|
|
|
break;
|
|
|
|
|
Buffer * b = first;
|
2007-08-06 15:34:02 +00:00
|
|
|
|
// We cannot use a for loop as the buffer list is a cycle.
|
2007-12-04 22:21:25 +00:00
|
|
|
|
do {
|
|
|
|
|
if (!b->isClean()) {
|
|
|
|
|
enable = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
b = theBufferList().next(b);
|
|
|
|
|
} while (b != first);
|
2007-08-06 15:34:02 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
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:
|
2008-07-14 08:35:00 +00:00
|
|
|
|
enable = theSession().bookmarks().size() > 0;
|
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 {
|
|
|
|
|
// catch recursion or unknown command definiton
|
|
|
|
|
// all operations until the recursion or unknown command
|
|
|
|
|
// definiton occures are performed, so set the state to enabled
|
|
|
|
|
enable = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2004-05-04 14:12:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-01-14 10:41:20 +00:00
|
|
|
|
case LFUN_VC_COMMAND: {
|
|
|
|
|
if (cmd.argument().empty())
|
|
|
|
|
enable = false;
|
|
|
|
|
|
|
|
|
|
if (!buf && contains(cmd.getArg(0), 'D'))
|
|
|
|
|
enable = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_WORD_FIND_FORWARD:
|
|
|
|
|
case LFUN_WORD_FIND_BACKWARD:
|
|
|
|
|
case LFUN_COMMAND_PREFIX:
|
|
|
|
|
case LFUN_COMMAND_EXECUTE:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
case LFUN_CANCEL:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_META_PREFIX:
|
|
|
|
|
case LFUN_BUFFER_CLOSE:
|
|
|
|
|
case LFUN_BUFFER_UPDATE:
|
|
|
|
|
case LFUN_BUFFER_VIEW:
|
2007-09-20 05:00:23 +00:00
|
|
|
|
case LFUN_MASTER_BUFFER_UPDATE:
|
|
|
|
|
case LFUN_MASTER_BUFFER_VIEW:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_IMPORT:
|
|
|
|
|
case LFUN_BUFFER_AUTO_SAVE:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
case LFUN_RECONFIGURE:
|
|
|
|
|
case LFUN_HELP_OPEN:
|
|
|
|
|
case LFUN_DROP_LAYOUTS_CHOICE:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_MENU_OPEN:
|
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:
|
|
|
|
|
case LFUN_SERVER_GOTO_FILE_ROW:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
case LFUN_DIALOG_HIDE:
|
|
|
|
|
case LFUN_DIALOG_DISCONNECT_INSET:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_CHILD_OPEN:
|
2008-03-09 21:23:37 +00:00
|
|
|
|
case LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_KEYMAP_OFF:
|
|
|
|
|
case LFUN_KEYMAP_PRIMARY:
|
|
|
|
|
case LFUN_KEYMAP_SECONDARY:
|
|
|
|
|
case LFUN_KEYMAP_TOGGLE:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
case LFUN_REPEAT:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_EXPORT_CUSTOM:
|
|
|
|
|
case LFUN_BUFFER_PRINT:
|
|
|
|
|
case LFUN_PREFERENCES_SAVE:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
case LFUN_MESSAGE:
|
2008-04-27 16:20:12 +00:00
|
|
|
|
case LFUN_INSET_EDIT:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_LANGUAGE:
|
2004-03-30 16:19:50 +00:00
|
|
|
|
case LFUN_TEXTCLASS_APPLY:
|
|
|
|
|
case LFUN_TEXTCLASS_LOAD:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_SAVE_AS_DEFAULT:
|
|
|
|
|
case LFUN_BUFFER_PARAMS_APPLY:
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the backend. The ModuleList class holds a list of the available modules, which are retrieved from lyxmodules.lst, itself generated by configure.py. There are two LFUNs available: modules-clear and module-add, which do the obvious thing; you can test by typing these into the minibuffer, along with the name of one of the available modules: URL (a CharStyle), Endnote (a Custom Inset), and---with the spaces---End To Foot (View>LaTeX and look at the user preamble), which are themselves in lib/layouts. There are some others, too, that allow theorems to be added to classes like article and book.
The GUI will come next.
Issues: (i) The configure.py script could be improved. It'd be nice, for example, if it tested for the presence of the LaTeX packages a particular module needs. But this would mean re-working the LaTeX script, and I don't know how to do that. Note that at present, the packages are ignored. This will change shortly. (ii) I've used std::string in LyXModule, following what seemed to be a precedent in TextClass. If some of these should be docstrings, please let me know, and I'll change them. (iii) There is at present no distinction between LaTeX and DocBook modules. Should there be? That is: Should there be modules that are available when the document class is a LaTeX class and others that are available only when it is DocBook? Or should there just be one set of modules? Each module can of course indicate for what it is suitable in its description.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19893 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-29 17:59:49 +00:00
|
|
|
|
case LFUN_LAYOUT_MODULES_CLEAR:
|
|
|
|
|
case LFUN_LAYOUT_MODULE_ADD:
|
2007-09-11 16:42:22 +00:00
|
|
|
|
case LFUN_LAYOUT_RELOAD:
|
2004-03-31 16:50:59 +00:00
|
|
|
|
case LFUN_LYXRC_APPLY:
|
2006-05-08 18:09:19 +00:00
|
|
|
|
case LFUN_BUFFER_NEXT:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_PREVIOUS:
|
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?
|
|
|
|
|
if (!lyx_view_) {
|
|
|
|
|
enable = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (lyx_view_->getStatus(cmd, flag))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// If we have a BufferView, try cursor position and
|
|
|
|
|
// then the BufferView.
|
2007-10-11 13:20:21 +00:00
|
|
|
|
if (!view()) {
|
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
|
|
|
|
}
|
2007-10-11 13:20:21 +00:00
|
|
|
|
if (!getLocalStatus(view()->cursor(), cmd, flag))
|
2005-01-05 20:21:27 +00:00
|
|
|
|
flag = view()->getStatus(cmd);
|
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
|
|
|
|
|
|
|
|
|
// Can we use a readonly buffer?
|
2004-03-30 16:19:50 +00:00
|
|
|
|
if (buf && buf->isReadonly()
|
2004-03-23 11:22:11 +00:00
|
|
|
|
&& !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly)
|
|
|
|
|
&& !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)) {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
flag.message(from_utf8(N_("Document is read-only")));
|
2008-05-29 15:14:00 +00:00
|
|
|
|
flag.setEnabled(false);
|
2004-03-23 11:22:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-09-07 10:37:05 +00:00
|
|
|
|
// Are we in a DELETED change-tracking region?
|
2007-10-11 13:20:21 +00:00
|
|
|
|
if (buf && view()
|
|
|
|
|
&& lookupChangeType(view()->cursor(), true) == Change::DELETED
|
2005-09-07 10:37:05 +00:00
|
|
|
|
&& !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly)
|
|
|
|
|
&& !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)) {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
flag.message(from_utf8(N_("This portion of the document is deleted.")));
|
2008-05-29 15:14:00 +00:00
|
|
|
|
flag.setEnabled(false);
|
2005-09-07 10:37:05 +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
|
|
|
|
bool LyXFunc::ensureBufferClean(BufferView * bv)
|
2003-10-13 00:38:09 +00:00
|
|
|
|
{
|
2007-08-21 13:03:55 +00:00
|
|
|
|
Buffer & buf = bv->buffer();
|
2003-10-13 00:38:09 +00:00
|
|
|
|
if (buf.isClean())
|
|
|
|
|
return true;
|
|
|
|
|
|
2007-11-03 17:37:37 +00:00
|
|
|
|
docstring const file = buf.fileName().displayName(30);
|
2006-09-11 08:54:10 +00:00
|
|
|
|
docstring text = bformat(_("The document %1$s has unsaved "
|
2006-09-09 15:27:44 +00:00
|
|
|
|
"changes.\n\nDo you want to save "
|
2006-09-11 08:54:10 +00:00
|
|
|
|
"the document?"), file);
|
|
|
|
|
int const ret = Alert::prompt(_("Save changed document?"),
|
|
|
|
|
text, 0, 1, _("&Save"),
|
|
|
|
|
_("&Cancel"));
|
2003-10-13 00:38:09 +00:00
|
|
|
|
|
|
|
|
|
if (ret == 0)
|
2006-09-17 10:51:59 +00:00
|
|
|
|
dispatch(FuncRequest(LFUN_BUFFER_WRITE));
|
2003-10-13 00:38:09 +00:00
|
|
|
|
|
|
|
|
|
return buf.isClean();
|
|
|
|
|
}
|
2003-07-25 21:20:24 +00:00
|
|
|
|
|
2004-03-31 09:44:40 +00:00
|
|
|
|
|
2006-09-17 10:51:59 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
2004-03-28 14:12:33 +00:00
|
|
|
|
void showPrintError(string const & name)
|
|
|
|
|
{
|
2006-09-11 08:54:10 +00:00
|
|
|
|
docstring str = bformat(_("Could not print the document %1$s.\n"
|
|
|
|
|
"Check that your printer is set up correctly."),
|
2006-04-08 22:31:11 +00:00
|
|
|
|
makeDisplayPath(name, 50));
|
2006-09-11 08:54:10 +00:00
|
|
|
|
Alert::error(_("Print document failed"), str);
|
2004-03-28 14:12:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-31 09:44:40 +00:00
|
|
|
|
|
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
|
|
|
|
bool loadLayoutFile(string const & name, string const & buf_path)
|
2004-03-31 09:44:40 +00:00
|
|
|
|
{
|
2008-03-07 03:53:21 +00:00
|
|
|
|
if (!LayoutFileList::get().haveClass(name)) {
|
2004-03-31 09:44:40 +00:00
|
|
|
|
lyxerr << "Document class \"" << name
|
|
|
|
|
<< "\" does not exist."
|
2007-12-12 19:28:07 +00:00
|
|
|
|
<< endl;
|
2008-02-28 21:04:55 +00:00
|
|
|
|
return false;
|
2004-03-31 09:44:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-03-07 03:53:21 +00:00
|
|
|
|
LayoutFile & tc = LayoutFileList::get()[name];
|
2008-02-28 21:04:55 +00:00
|
|
|
|
if (!tc.load(buf_path)) {
|
2008-03-16 13:05:42 +00:00
|
|
|
|
docstring s = bformat(_("The document class %1$s "
|
2008-02-28 21:04:55 +00:00
|
|
|
|
"could not be loaded."), from_utf8(name));
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This first patch does some reworking of the infrastructrue. We need to distinguish between the TextClass that a particular document is using and the layout of that document, since modules, in particular, can modify the layout. The solution adopted here is to add a TextClass pointer to BufferParams, which will hold the layout. The layout itself is then constructed from the TextClass the document is using. At present, this is completely trivial, but that will change when modules are added.
The pointer in question is a boost::shared_ptr. This is needed because CutAndPaste saves a copy of the layout with each cut or copied selection. We cannot assume the selection vanishes when the document is closed, so there are two options: (i) keep a list of all the layouts that have ever been used by any document; (ii) used some kind of smart pointer. The latter seems preferable, as the former would waste memory. More importantly, the use of a smart pointer allows modules to be modified on disk and then reloaded while LyX is running, and it will eventually allow the same for layout files.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19756 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-23 16:41:13 +00:00
|
|
|
|
Alert::error(_("Could not load class"), s);
|
2008-02-28 21:04:55 +00:00
|
|
|
|
return false;
|
2004-03-31 09:44:40 +00:00
|
|
|
|
}
|
2008-02-28 21:04:55 +00:00
|
|
|
|
return true;
|
2004-03-31 09:44:40 +00:00
|
|
|
|
}
|
2004-04-03 08:37:12 +00:00
|
|
|
|
|
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
|
|
|
|
|
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());
|
2008-09-26 12:35:35 +00:00
|
|
|
|
if (lyx_view_)
|
|
|
|
|
lyx_view_->restartCursor();
|
2003-11-13 13:43:44 +00:00
|
|
|
|
} else {
|
2008-10-23 06:59:31 +00:00
|
|
|
|
Buffer * buffer = lyx_view_ ? lyx_view_->buffer() : 0;
|
2003-11-13 13:43:44 +00:00
|
|
|
|
switch (action) {
|
2007-11-24 07:58:12 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_WORD_FIND_FORWARD:
|
|
|
|
|
case LFUN_WORD_FIND_BACKWARD: {
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_ && lyx_view_->view(), /**/);
|
2006-12-10 11:52:46 +00:00
|
|
|
|
static docstring last_search;
|
|
|
|
|
docstring searched_string;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-12-10 11:52:46 +00:00
|
|
|
|
if (!cmd.argument().empty()) {
|
|
|
|
|
last_search = cmd.argument();
|
|
|
|
|
searched_string = cmd.argument();
|
2004-03-18 16:12:51 +00:00
|
|
|
|
} else {
|
2003-11-13 13:43:44 +00:00
|
|
|
|
searched_string = last_search;
|
2004-03-18 16:12:51 +00:00
|
|
|
|
}
|
2004-01-07 17:00:03 +00:00
|
|
|
|
|
|
|
|
|
if (searched_string.empty())
|
|
|
|
|
break;
|
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
bool const fw = action == LFUN_WORD_FIND_FORWARD;
|
2006-12-10 11:52:46 +00:00
|
|
|
|
docstring const data =
|
2006-10-21 00:16:43 +00:00
|
|
|
|
find2string(searched_string, true, false, fw);
|
|
|
|
|
find(view(), FuncRequest(LFUN_WORD_FIND, data));
|
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_COMMAND_PREFIX:
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_, /**/);
|
2007-09-17 22:51:03 +00:00
|
|
|
|
lyx_view_->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:
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_ && lyx_view_->view(), /**/);
|
2007-09-17 22:51:03 +00:00
|
|
|
|
keyseq.reset();
|
2007-10-02 21:51:54 +00:00
|
|
|
|
meta_fake_bit = NoModifier;
|
2008-10-23 07:08:12 +00:00
|
|
|
|
if (buffer)
|
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
|
|
|
|
|
2007-10-02 21:51:54 +00:00
|
|
|
|
case LFUN_BUFFER_TOGGLE_READ_ONLY: {
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && lyx_view_->view() && buffer, /**/);
|
|
|
|
|
if (buffer->lyxvc().inUse())
|
|
|
|
|
buffer->lyxvc().toggleReadOnly();
|
2003-11-13 13:43:44 +00:00
|
|
|
|
else
|
2008-10-23 07:08:12 +00:00
|
|
|
|
buffer->setReadonly(!buffer->isReadonly());
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2007-10-02 21:51:54 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
// --- Menus -----------------------------------------------
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_CLOSE:
|
2008-02-27 11:05:58 +00:00
|
|
|
|
lyx_view_->closeBuffer();
|
2008-10-23 07:08:12 +00:00
|
|
|
|
buffer = 0;
|
2007-08-21 07:33:46 +00:00
|
|
|
|
updateFlags = Update::None;
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_RELOAD: {
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && buffer, /**/);
|
|
|
|
|
docstring const file = makeDisplayPath(buffer->absFileName(), 20);
|
2006-09-11 08:54:10 +00:00
|
|
|
|
docstring text = bformat(_("Any changes will be lost. Are you sure "
|
|
|
|
|
"you want to revert to the saved version of the document %1$s?"), file);
|
|
|
|
|
int const ret = Alert::prompt(_("Revert to saved document?"),
|
2007-05-26 17:42:23 +00:00
|
|
|
|
text, 1, 1, _("&Revert"), _("&Cancel"));
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
if (ret == 0)
|
2007-01-17 14:49:48 +00:00
|
|
|
|
reloadBuffer();
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_UPDATE:
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && buffer, /**/);
|
|
|
|
|
buffer->doExport(argument, true);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_VIEW:
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && buffer, /**/);
|
|
|
|
|
buffer->preview(argument);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2002-03-19 03:56:23 +00:00
|
|
|
|
|
2007-09-20 05:00:23 +00:00
|
|
|
|
case LFUN_MASTER_BUFFER_UPDATE:
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && buffer && buffer->masterBuffer(), /**/);
|
|
|
|
|
buffer->masterBuffer()->doExport(argument, true);
|
2007-09-20 05:00:23 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_MASTER_BUFFER_VIEW:
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && buffer && buffer->masterBuffer(), /**/);
|
|
|
|
|
buffer->masterBuffer()->preview(argument);
|
2007-09-20 05:00:23 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUILD_PROGRAM:
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && buffer, /**/);
|
|
|
|
|
buffer->doExport("program", true);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_CHKTEX:
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && buffer, /**/);
|
|
|
|
|
buffer->runChktex();
|
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_BUFFER_EXPORT:
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && buffer, /**/);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
if (argument == "custom")
|
2007-11-21 22:48:13 +00:00
|
|
|
|
dispatch(FuncRequest(LFUN_DIALOG_SHOW, "sendto"));
|
2007-10-20 10:51:13 +00:00
|
|
|
|
else
|
2008-10-23 07:08:12 +00:00
|
|
|
|
buffer->doExport(argument, false);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_EXPORT_CUSTOM: {
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && buffer, /**/);
|
2004-03-27 23:11:46 +00:00
|
|
|
|
string format_name;
|
|
|
|
|
string command = split(argument, format_name, ' ');
|
|
|
|
|
Format const * format = formats.getFormat(format_name);
|
|
|
|
|
if (!format) {
|
|
|
|
|
lyxerr << "Format \"" << format_name
|
|
|
|
|
<< "\" not recognized!"
|
2007-12-12 19:28:07 +00:00
|
|
|
|
<< endl;
|
2004-03-27 23:11:46 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The name of the file created by the conversion process
|
|
|
|
|
string filename;
|
|
|
|
|
|
|
|
|
|
// Output to filename
|
|
|
|
|
if (format->name() == "lyx") {
|
2007-10-20 10:03:45 +00:00
|
|
|
|
string const latexname = buffer->latexName(false);
|
2006-04-08 22:31:11 +00:00
|
|
|
|
filename = changeExtension(latexname,
|
2004-03-27 23:11:46 +00:00
|
|
|
|
format->extension());
|
2006-04-08 22:31:11 +00:00
|
|
|
|
filename = addName(buffer->temppath(), filename);
|
2004-03-27 23:11:46 +00:00
|
|
|
|
|
2006-11-30 16:59:50 +00:00
|
|
|
|
if (!buffer->writeFile(FileName(filename)))
|
2004-03-27 23:11:46 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
} else {
|
2007-10-20 10:51:13 +00:00
|
|
|
|
buffer->doExport(format_name, true, filename);
|
2004-03-27 23:11:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Substitute $$FName for filename
|
|
|
|
|
if (!contains(command, "$$FName"))
|
|
|
|
|
command = "( " + command + " ) < $$FName";
|
|
|
|
|
command = subst(command, "$$FName", filename);
|
|
|
|
|
|
|
|
|
|
// Execute the command in the background
|
|
|
|
|
Systemcall call;
|
|
|
|
|
call.startscript(Systemcall::DontWait, command);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_PRINT: {
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && buffer, /**/);
|
2007-06-28 21:21:05 +00:00
|
|
|
|
// FIXME: cmd.getArg() might fail if one of the arguments
|
|
|
|
|
// contains double quotes
|
|
|
|
|
string target = cmd.getArg(0);
|
|
|
|
|
string target_name = cmd.getArg(1);
|
|
|
|
|
string command = cmd.getArg(2);
|
2004-03-28 14:12:33 +00:00
|
|
|
|
|
|
|
|
|
if (target.empty()
|
|
|
|
|
|| target_name.empty()
|
|
|
|
|
|| command.empty()) {
|
|
|
|
|
lyxerr << "Unable to parse \""
|
2007-06-28 21:21:05 +00:00
|
|
|
|
<< argument << '"' << endl;
|
2004-03-28 14:12:33 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (target != "printer" && target != "file") {
|
|
|
|
|
lyxerr << "Unrecognized target \""
|
2007-06-28 21:21:05 +00:00
|
|
|
|
<< target << '"' << endl;
|
2004-03-28 14:12:33 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-20 10:51:13 +00:00
|
|
|
|
if (!buffer->doExport("dvi", true)) {
|
2007-10-20 10:03:45 +00:00
|
|
|
|
showPrintError(buffer->absFileName());
|
2004-03-28 14:12:33 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Push directory path.
|
2007-10-03 09:21:15 +00:00
|
|
|
|
string const path = buffer->temppath();
|
2007-04-06 18:03:29 +00:00
|
|
|
|
// Prevent the compiler from optimizing away p
|
|
|
|
|
FileName pp(path);
|
2007-12-12 19:57:42 +00:00
|
|
|
|
PathChanger p(pp);
|
2004-03-28 14:12:33 +00:00
|
|
|
|
|
|
|
|
|
// there are three cases here:
|
|
|
|
|
// 1. we print to a file
|
|
|
|
|
// 2. we print directly to a printer
|
|
|
|
|
// 3. we print using a spool command (print to file first)
|
|
|
|
|
Systemcall one;
|
|
|
|
|
int res = 0;
|
|
|
|
|
string const dviname =
|
2007-10-20 10:03:45 +00:00
|
|
|
|
changeExtension(buffer->latexName(true), "dvi");
|
2004-03-28 14:12:33 +00:00
|
|
|
|
|
|
|
|
|
if (target == "printer") {
|
|
|
|
|
if (!lyxrc.print_spool_command.empty()) {
|
|
|
|
|
// case 3: print using a spool
|
|
|
|
|
string const psname =
|
2006-04-08 22:31:11 +00:00
|
|
|
|
changeExtension(dviname,".ps");
|
2007-06-28 21:21:05 +00:00
|
|
|
|
command += ' ' + lyxrc.print_to_file
|
2006-04-08 22:31:11 +00:00
|
|
|
|
+ quoteName(psname)
|
2004-03-28 14:12:33 +00:00
|
|
|
|
+ ' '
|
2006-04-08 22:31:11 +00:00
|
|
|
|
+ quoteName(dviname);
|
2004-03-28 14:12:33 +00:00
|
|
|
|
|
|
|
|
|
string command2 =
|
2007-06-28 21:21:05 +00:00
|
|
|
|
lyxrc.print_spool_command + ' ';
|
2004-03-28 14:12:33 +00:00
|
|
|
|
if (target_name != "default") {
|
|
|
|
|
command2 += lyxrc.print_spool_printerprefix
|
|
|
|
|
+ target_name
|
|
|
|
|
+ ' ';
|
|
|
|
|
}
|
2006-04-08 22:31:11 +00:00
|
|
|
|
command2 += quoteName(psname);
|
2004-03-28 14:12:33 +00:00
|
|
|
|
// First run dvips.
|
|
|
|
|
// If successful, then spool command
|
|
|
|
|
res = one.startscript(
|
|
|
|
|
Systemcall::Wait,
|
|
|
|
|
command);
|
|
|
|
|
|
|
|
|
|
if (res == 0)
|
|
|
|
|
res = one.startscript(
|
|
|
|
|
Systemcall::DontWait,
|
|
|
|
|
command2);
|
|
|
|
|
} else {
|
|
|
|
|
// case 2: print directly to a printer
|
2007-06-05 17:42:01 +00:00
|
|
|
|
if (target_name != "default")
|
2007-06-28 21:21:05 +00:00
|
|
|
|
command += ' ' + lyxrc.print_to_printer + target_name + ' ';
|
2004-03-28 14:12:33 +00:00
|
|
|
|
res = one.startscript(
|
|
|
|
|
Systemcall::DontWait,
|
2006-04-08 22:31:11 +00:00
|
|
|
|
command + quoteName(dviname));
|
2004-03-28 14:12:33 +00:00
|
|
|
|
}
|
2004-03-30 16:19:50 +00:00
|
|
|
|
|
2004-03-28 14:12:33 +00:00
|
|
|
|
} else {
|
|
|
|
|
// case 1: print to a file
|
2007-06-28 21:21:05 +00:00
|
|
|
|
FileName const filename(makeAbsPath(target_name,
|
2008-10-23 07:08:12 +00:00
|
|
|
|
buffer->filePath()));
|
2007-06-28 21:21:05 +00:00
|
|
|
|
FileName const dvifile(makeAbsPath(dviname, path));
|
2007-10-18 19:29:32 +00:00
|
|
|
|
if (filename.exists()) {
|
2007-02-01 12:55:57 +00:00
|
|
|
|
docstring text = bformat(
|
|
|
|
|
_("The file %1$s already exists.\n\n"
|
2007-06-07 07:50:27 +00:00
|
|
|
|
"Do you want to overwrite that file?"),
|
2007-02-01 12:55:57 +00:00
|
|
|
|
makeDisplayPath(filename.absFilename()));
|
2007-06-07 07:50:27 +00:00
|
|
|
|
if (Alert::prompt(_("Overwrite file?"),
|
|
|
|
|
text, 0, 1, _("&Overwrite"), _("&Cancel")) != 0)
|
2007-02-01 12:55:57 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2007-06-28 21:21:05 +00:00
|
|
|
|
command += ' ' + lyxrc.print_to_file
|
2007-02-01 12:55:57 +00:00
|
|
|
|
+ quoteName(filename.toFilesystemEncoding())
|
2004-03-28 14:12:33 +00:00
|
|
|
|
+ ' '
|
2007-06-28 21:21:05 +00:00
|
|
|
|
+ quoteName(dvifile.toFilesystemEncoding());
|
2004-03-28 14:12:33 +00:00
|
|
|
|
res = one.startscript(Systemcall::DontWait,
|
|
|
|
|
command);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (res != 0)
|
2007-10-20 10:03:45 +00:00
|
|
|
|
showPrintError(buffer->absFileName());
|
2004-03-28 14:12:33 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-06 23:54:13 +00:00
|
|
|
|
// FIXME: There is need for a command-line import.
|
|
|
|
|
/*
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_IMPORT:
|
2003-11-13 13:43:44 +00:00
|
|
|
|
doImport(argument);
|
|
|
|
|
break;
|
2008-02-06 23:54:13 +00:00
|
|
|
|
*/
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_AUTO_SAVE:
|
2008-10-23 07:08:12 +00:00
|
|
|
|
buffer->autoSave();
|
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_RECONFIGURE:
|
2007-09-26 19:36:09 +00:00
|
|
|
|
// argument is any additional parameter to the configure.py command
|
2008-03-14 16:33:16 +00:00
|
|
|
|
reconfigure(lyx_view_, argument);
|
2000-07-24 13:53:19 +00:00
|
|
|
|
break;
|
2003-11-13 13:43:44 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_HELP_OPEN: {
|
2008-10-22 18:15:09 +00:00
|
|
|
|
if (lyx_view_ == 0)
|
|
|
|
|
theApp()->dispatch(FuncRequest(LFUN_WINDOW_NEW));
|
2003-11-13 13:43:44 +00:00
|
|
|
|
string const arg = argument;
|
|
|
|
|
if (arg.empty()) {
|
2008-12-11 09:26:41 +00:00
|
|
|
|
setErrorMessage(from_utf8(N_("Missing argument")));
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2008-12-12 15:56:39 +00:00
|
|
|
|
FileName fname = i18nLibFileSearch("doc", arg, "lyx");
|
|
|
|
|
if (fname.empty())
|
|
|
|
|
fname = i18nLibFileSearch("examples", arg, "lyx");
|
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
if (fname.empty()) {
|
|
|
|
|
lyxerr << "LyX: unable to find documentation file `"
|
|
|
|
|
<< arg << "'. Bad installation?" << endl;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->message(bformat(_("Opening help file %1$s..."),
|
2006-12-02 16:07:15 +00:00
|
|
|
|
makeDisplayPath(fname.absFilename())));
|
2008-02-06 23:02:57 +00:00
|
|
|
|
Buffer * buf = lyx_view_->loadDocument(fname, false);
|
2007-08-21 07:33:46 +00:00
|
|
|
|
if (buf) {
|
|
|
|
|
updateLabels(*buf);
|
|
|
|
|
lyx_view_->setBuffer(buf);
|
2007-11-23 11:53:10 +00:00
|
|
|
|
buf->errors("Parse");
|
2007-08-21 07:33:46 +00:00
|
|
|
|
}
|
|
|
|
|
updateFlags = Update::None;
|
2000-07-24 13:53:19 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
// --- version control -------------------------------
|
|
|
|
|
case LFUN_VC_REGISTER:
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && buffer, /**/);
|
|
|
|
|
if (!ensureBufferClean(view()) || buffer->isUnnamed())
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2008-10-23 07:08:12 +00:00
|
|
|
|
if (!buffer->lyxvc().inUse()) {
|
|
|
|
|
buffer->lyxvc().registrer();
|
2007-01-17 14:46:20 +00:00
|
|
|
|
reloadBuffer();
|
2003-11-13 13:43:44 +00:00
|
|
|
|
}
|
2007-01-17 14:46:20 +00:00
|
|
|
|
updateFlags = Update::Force;
|
2003-07-10 12:26:40 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_VC_CHECK_IN:
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && buffer, /**/);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
if (!ensureBufferClean(view()))
|
|
|
|
|
break;
|
2008-10-23 07:08:12 +00:00
|
|
|
|
if (buffer->lyxvc().inUse()
|
|
|
|
|
&& !buffer->isReadonly()) {
|
|
|
|
|
setMessage(from_utf8(buffer->lyxvc().checkIn()));
|
2007-01-17 14:49:48 +00:00
|
|
|
|
reloadBuffer();
|
2003-11-13 13:43:44 +00:00
|
|
|
|
}
|
2003-07-10 12:26:40 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_VC_CHECK_OUT:
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && buffer, /**/);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
if (!ensureBufferClean(view()))
|
|
|
|
|
break;
|
2008-10-23 07:08:12 +00:00
|
|
|
|
if (buffer->lyxvc().inUse()) {
|
|
|
|
|
setMessage(from_utf8(buffer->lyxvc().checkOut()));
|
2007-01-17 14:49:48 +00:00
|
|
|
|
reloadBuffer();
|
2003-11-13 13:43:44 +00:00
|
|
|
|
}
|
2003-07-10 12:26:40 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
case LFUN_VC_REVERT:
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && buffer, /**/);
|
|
|
|
|
buffer->lyxvc().revert();
|
2007-01-17 14:49:48 +00:00
|
|
|
|
reloadBuffer();
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_VC_UNDO_LAST:
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && buffer, /**/);
|
|
|
|
|
buffer->lyxvc().undoLast();
|
2007-01-17 14:49:48 +00:00
|
|
|
|
reloadBuffer();
|
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
|
|
|
|
// --- lyxserver commands ----------------------------
|
2008-07-07 19:09:06 +00:00
|
|
|
|
case LFUN_SERVER_GET_FILENAME:
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && buffer, /**/);
|
|
|
|
|
setMessage(from_utf8(buffer->absFileName()));
|
2007-11-15 20:04:51 +00:00
|
|
|
|
LYXERR(Debug::INFO, "FNAME["
|
2008-10-23 07:08:12 +00:00
|
|
|
|
<< buffer->absFileName() << ']');
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +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
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_SERVER_GOTO_FILE_ROW: {
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_, /**/);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
string file_name;
|
|
|
|
|
int row;
|
|
|
|
|
istringstream is(argument);
|
|
|
|
|
is >> file_name >> row;
|
2007-08-21 07:33:46 +00:00
|
|
|
|
Buffer * buf = 0;
|
|
|
|
|
bool loaded = false;
|
|
|
|
|
if (prefixIs(file_name, package().temp_dir().absFilename()))
|
2003-11-13 13:43:44 +00:00
|
|
|
|
// Needed by inverse dvi search. If it is a file
|
|
|
|
|
// in tmpdir, call the apropriated function
|
2007-08-21 07:33:46 +00:00
|
|
|
|
buf = theBufferList().getBufferFromTmp(file_name);
|
|
|
|
|
else {
|
2003-11-13 13:43:44 +00:00
|
|
|
|
// Must replace extension of the file to be .lyx
|
|
|
|
|
// and get full path
|
2006-12-02 16:07:15 +00:00
|
|
|
|
FileName const s = fileSearch(string(), changeExtension(file_name, ".lyx"), "lyx");
|
2003-11-13 13:43:44 +00:00
|
|
|
|
// Either change buffer or load the file
|
2008-07-29 07:53:08 +00:00
|
|
|
|
if (theBufferList().exists(s))
|
2008-07-29 08:16:09 +00:00
|
|
|
|
buf = theBufferList().getBuffer(s);
|
2007-08-21 07:33:46 +00:00
|
|
|
|
else {
|
2008-02-06 23:02:57 +00:00
|
|
|
|
buf = lyx_view_->loadDocument(s);
|
2007-08-21 07:33:46 +00:00
|
|
|
|
loaded = true;
|
2003-11-13 13:43:44 +00:00
|
|
|
|
}
|
2003-10-14 11:35:50 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
|
if (!buf) {
|
|
|
|
|
updateFlags = Update::None;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
|
updateLabels(*buf);
|
|
|
|
|
lyx_view_->setBuffer(buf);
|
|
|
|
|
view()->setCursorFromRow(row);
|
|
|
|
|
if (loaded)
|
2007-11-23 11:53:10 +00:00
|
|
|
|
buf->errors("Parse");
|
2007-01-22 15:00:33 +00:00
|
|
|
|
updateFlags = Update::FitCursor;
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2000-07-25 10:46:18 +00:00
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
case LFUN_DIALOG_SHOW_NEW_INSET: {
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_, /**/);
|
2004-01-30 11:41:12 +00:00
|
|
|
|
string const name = cmd.getArg(0);
|
2007-10-18 05:08:16 +00:00
|
|
|
|
InsetCode code = insetCode(name);
|
2006-10-21 00:16:43 +00:00
|
|
|
|
string data = trim(to_utf8(cmd.argument()).substr(name.size()));
|
2007-10-18 05:08:16 +00:00
|
|
|
|
bool insetCodeOK = true;
|
|
|
|
|
switch (code) {
|
|
|
|
|
case BIBITEM_CODE:
|
|
|
|
|
case BIBTEX_CODE:
|
|
|
|
|
case INDEX_CODE:
|
|
|
|
|
case LABEL_CODE:
|
|
|
|
|
case NOMENCL_CODE:
|
|
|
|
|
case REF_CODE:
|
|
|
|
|
case TOC_CODE:
|
|
|
|
|
case HYPERLINK_CODE: {
|
2007-10-19 17:22:55 +00:00
|
|
|
|
InsetCommandParams p(code);
|
2008-03-27 22:26:24 +00:00
|
|
|
|
data = InsetCommand::params2string(name, p);
|
2007-10-18 05:08:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case INCLUDE_CODE: {
|
2006-12-18 16:45:20 +00:00
|
|
|
|
// data is the include type: one of "include",
|
|
|
|
|
// "input", "verbatiminput" or "verbatiminput*"
|
|
|
|
|
if (data.empty())
|
|
|
|
|
// default type is requested
|
|
|
|
|
data = "include";
|
2007-10-19 17:22:55 +00:00
|
|
|
|
InsetCommandParams p(INCLUDE_CODE, data);
|
2008-03-27 22:26:24 +00:00
|
|
|
|
data = InsetCommand::params2string("include", p);
|
2007-10-18 05:08:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case BOX_CODE: {
|
2003-12-10 22:10:38 +00:00
|
|
|
|
// \c data == "Boxed" || "Frameless" etc
|
|
|
|
|
InsetBoxParams p(data);
|
2008-03-27 07:26:37 +00:00
|
|
|
|
data = InsetBox::params2string(p);
|
2007-10-18 05:08:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case BRANCH_CODE: {
|
2003-12-10 22:10:38 +00:00
|
|
|
|
InsetBranchParams p;
|
2008-03-27 22:26:24 +00:00
|
|
|
|
data = InsetBranch::params2string(p);
|
2007-10-18 05:08:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case CITE_CODE: {
|
2007-10-19 17:22:55 +00:00
|
|
|
|
InsetCommandParams p(CITE_CODE);
|
2008-03-27 22:26:24 +00:00
|
|
|
|
data = InsetCommand::params2string(name, p);
|
2007-10-18 05:08:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ERT_CODE: {
|
2008-07-14 12:38:43 +00:00
|
|
|
|
data = InsetERT::params2string(InsetCollapsable::Open);
|
2007-10-18 05:08:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case EXTERNAL_CODE: {
|
2003-12-10 22:10:38 +00:00
|
|
|
|
InsetExternalParams p;
|
2008-10-23 07:08:12 +00:00
|
|
|
|
data = InsetExternal::params2string(p, *buffer);
|
2007-10-18 05:08:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case FLOAT_CODE: {
|
2003-12-10 22:10:38 +00:00
|
|
|
|
InsetFloatParams p;
|
2008-03-27 22:26:24 +00:00
|
|
|
|
data = InsetFloat::params2string(p);
|
2007-10-18 05:08:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case LISTINGS_CODE: {
|
Add support for listings package. Two listings command \lstinline, \lstinputlisting and an environment \lstlisting are supported, along with preamble \lstset. \lstinputlisting is implemented through Include dialog, and the other two are implemented with a new inset listings, along with its dialog.
* src/LyXAction.cpp: listing-insert action
* src/insets/Inset.h,cpp: LISTINGS_CODE
* src/insets/InsetInclude.cpp: handle \lstinputlisting
* src/insets/InsetListings.h,cpp: new listings inset
* src/insets/InsetListingsParams.h,cpp: parameters from listings package
* src/insets/InsetCommandParams.h,cpp: handle lstinputlisting option
* src/Bidi.cpp: handle LISTINGS_CODE
* src/frontends/qt4/ui/TextLayoutUi.ui: update UI
* src/frontends/qt4/ui/ListingsUi.ui: new dialog
* src/frontends/qt4/ui/IncludeUi.ui: update UI
* src/frontends/qt4/QInclude.h,cpp: add lstinputlisting
* src/frontends/qt4/QDocument.h,cpp: add textedit for preamble listings_params
* src/frontends/qt4/QListings.h,cpp: new listings inset
* src/frontends/qt4/Dialogs.cpp: new listings dialog
* src/frontends/controllers/ControlInclude.h,cpp: add lstinputlisting
* src/frontends/controllers/ControlListings.h,cpp: new listings inset
* src/LyXFunc.cpp: handle LISTING_CODE
* src/Paragraph.cpp: handle LISTING_CODE
* src/factory.cpp: new listings inset
* src/CutAndPaste.cpp: handle LISTINGS_CODE
* src/LaTeXFeatures.cpp: require listings
* src/Text3.cpp: Handle LISTINGS_CODE
* src/lfuns.h: add LFUN_LISTING_INSERT
* src/Buffer.cpp: change lyx file format to 269
* src/BufferParams.h,cpp: add listings_params to preamble
* lib/lyx2lyx/LyX.py: lyx2lyx
* lib/lyx2lyx/lyx_1_5.py: lyx2lyx
* lib/ui/stdmenus.inc: new menu item (no shortcut!)
* src/insets/Makefile.am: update autotools
* src/frontends/controllers/Makefile.am
* src/frontends/qt4/Makefile.dialogs
* src/frontends/qt4/Makefile.am
* po/POTFILES.in: a few more translatable files.
* development/scons/scons_manifest.py: scons build system
* development/FORMAT: document format changes
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18243 a592a061-630c-0410-9148-cb99ea01b6c8
2007-05-09 19:11:42 +00:00
|
|
|
|
InsetListingsParams p;
|
2008-03-27 22:26:24 +00:00
|
|
|
|
data = InsetListings::params2string(p);
|
2007-10-18 05:08:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case GRAPHICS_CODE: {
|
2003-12-10 22:10:38 +00:00
|
|
|
|
InsetGraphicsParams p;
|
2008-10-23 07:08:12 +00:00
|
|
|
|
data = InsetGraphics::params2string(p, *buffer);
|
2007-10-18 05:08:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case NOTE_CODE: {
|
2003-12-10 22:10:38 +00:00
|
|
|
|
InsetNoteParams p;
|
2008-03-27 22:26:24 +00:00
|
|
|
|
data = InsetNote::params2string(p);
|
2007-10-18 05:08:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
*** File Format Change: UI and enhancement for InsetSpace ***
* src/insets/InsetSpace.{cpp,h}:
- merge in HFill inset, add support for dotfill, hrulefill,
hspace and hspace*
* src/insets/InsetHFill.{cpp,h}:
- remove
* src/frontends/qt4/GuiHSpace.{cpp,h}:
* src/frontends/qt4/ui/HSpaceUi.ui:
* src/frontends/qt4/GuiView:
- new GUI for Space insets.
* src/insets/Inset.{cpp,h}:
* src/insets/InsetCode.h:
* src/insets/InsetCollapsable.cpp:
* src/insets/InsetCommandParams.cpp:
- remove HFILL_CODE and LFUN_HFILL_INSERT, add SPACE_CODE where necessary,
new Inset member isStretchableSpace() to indicate HFill and friends.
* Buffer.cpp:
- increase format to 319
* lib/lyx2lyx/LyX.py:
* lib/lyx2lyx/lyx_1_6.py:
- conversion/reversion routines
* development/FORMAT:
- document file format change
* src/Makefile.am:
* src/frontends/qt4/Makefile.am:
* development/scons/scons_manifest.py:
- deal with UI changes.
* src/LyXAction.cpp:
- remove LFUN_HFILL_INSERT
* src/LyXFunc.cpp:
- handle space dialog.
* src/factory.cpp:
* src/Paragraph.cpp (isHFill):
* src/Text.cpp:
* src/Text3.cpp:
* src/TextMetrics.cpp:
- adapt to changes
* lib/ui/classic.ui:
* lib/ui/stdmenus.ui:
- add HSpace dialog, remove HFill.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23787 a592a061-630c-0410-9148-cb99ea01b6c8
2008-03-17 09:23:43 +00:00
|
|
|
|
case SPACE_CODE: {
|
|
|
|
|
InsetSpaceParams p;
|
2008-03-27 22:26:24 +00:00
|
|
|
|
data = InsetSpace::params2string(p);
|
*** File Format Change: UI and enhancement for InsetSpace ***
* src/insets/InsetSpace.{cpp,h}:
- merge in HFill inset, add support for dotfill, hrulefill,
hspace and hspace*
* src/insets/InsetHFill.{cpp,h}:
- remove
* src/frontends/qt4/GuiHSpace.{cpp,h}:
* src/frontends/qt4/ui/HSpaceUi.ui:
* src/frontends/qt4/GuiView:
- new GUI for Space insets.
* src/insets/Inset.{cpp,h}:
* src/insets/InsetCode.h:
* src/insets/InsetCollapsable.cpp:
* src/insets/InsetCommandParams.cpp:
- remove HFILL_CODE and LFUN_HFILL_INSERT, add SPACE_CODE where necessary,
new Inset member isStretchableSpace() to indicate HFill and friends.
* Buffer.cpp:
- increase format to 319
* lib/lyx2lyx/LyX.py:
* lib/lyx2lyx/lyx_1_6.py:
- conversion/reversion routines
* development/FORMAT:
- document file format change
* src/Makefile.am:
* src/frontends/qt4/Makefile.am:
* development/scons/scons_manifest.py:
- deal with UI changes.
* src/LyXAction.cpp:
- remove LFUN_HFILL_INSERT
* src/LyXFunc.cpp:
- handle space dialog.
* src/factory.cpp:
* src/Paragraph.cpp (isHFill):
* src/Text.cpp:
* src/Text3.cpp:
* src/TextMetrics.cpp:
- adapt to changes
* lib/ui/classic.ui:
* lib/ui/stdmenus.ui:
- add HSpace dialog, remove HFill.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23787 a592a061-630c-0410-9148-cb99ea01b6c8
2008-03-17 09:23:43 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2007-10-18 05:08:16 +00:00
|
|
|
|
case VSPACE_CODE: {
|
2003-11-28 15:53:34 +00:00
|
|
|
|
VSpace space;
|
2008-03-27 00:21:35 +00:00
|
|
|
|
data = InsetVSpace::params2string(space);
|
2007-10-18 05:08:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case WRAP_CODE: {
|
2003-12-10 22:10:38 +00:00
|
|
|
|
InsetWrapParams p;
|
2008-03-27 00:07:54 +00:00
|
|
|
|
data = InsetWrap::params2string(p);
|
2007-10-18 05:08:16 +00:00
|
|
|
|
break;
|
2003-11-13 13:43:44 +00:00
|
|
|
|
}
|
2007-10-18 05:08:16 +00:00
|
|
|
|
default:
|
|
|
|
|
lyxerr << "Inset type '" << name <<
|
2007-12-12 19:28:07 +00:00
|
|
|
|
"' not recognized in LFUN_DIALOG_SHOW_NEW_INSET" << endl;
|
2007-10-18 05:08:16 +00:00
|
|
|
|
insetCodeOK = false;
|
|
|
|
|
break;
|
|
|
|
|
} // end switch(code)
|
|
|
|
|
if (insetCodeOK)
|
2007-11-21 22:48:13 +00:00
|
|
|
|
dispatch(FuncRequest(LFUN_DIALOG_SHOW, name + " " + data));
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_CITATION_INSERT: {
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_, /**/);
|
2005-10-07 14:51:39 +00:00
|
|
|
|
if (!argument.empty()) {
|
|
|
|
|
// we can have one optional argument, delimited by '|'
|
|
|
|
|
// citation-insert <key>|<text_before>
|
2006-04-05 23:56:29 +00:00
|
|
|
|
// this should be enhanced to also support text_after
|
2005-10-07 14:51:39 +00:00
|
|
|
|
// and citation style
|
|
|
|
|
string arg = argument;
|
|
|
|
|
string opt1;
|
|
|
|
|
if (contains(argument, "|")) {
|
|
|
|
|
arg = token(argument, '|', 0);
|
2007-04-05 13:49:01 +00:00
|
|
|
|
opt1 = token(argument, '|', 1);
|
2005-10-07 14:51:39 +00:00
|
|
|
|
}
|
2007-10-19 17:22:55 +00:00
|
|
|
|
InsetCommandParams icp(CITE_CODE);
|
2007-04-05 13:49:01 +00:00
|
|
|
|
icp["key"] = from_utf8(arg);
|
|
|
|
|
if (!opt1.empty())
|
|
|
|
|
icp["before"] = from_utf8(opt1);
|
2008-03-27 22:26:24 +00:00
|
|
|
|
string icstr = InsetCommand::params2string("citation", icp);
|
2007-04-05 13:49:01 +00:00
|
|
|
|
FuncRequest fr(LFUN_INSET_INSERT, icstr);
|
2005-10-07 14:51:39 +00:00
|
|
|
|
dispatch(fr);
|
|
|
|
|
} else
|
2007-04-05 15:55:04 +00:00
|
|
|
|
dispatch(FuncRequest(LFUN_DIALOG_SHOW_NEW_INSET, "citation"));
|
2005-10-07 14:51:39 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_CHILD_OPEN: {
|
2008-10-23 07:08:12 +00:00
|
|
|
|
LASSERT(lyx_view_ && buffer, /**/);
|
|
|
|
|
FileName filename = makeAbsPath(argument, buffer->filePath());
|
2006-11-01 15:55:17 +00:00
|
|
|
|
view()->saveBookmark(false);
|
2007-08-21 07:33:46 +00:00
|
|
|
|
Buffer * child = 0;
|
|
|
|
|
bool parsed = false;
|
2008-07-29 07:53:08 +00:00
|
|
|
|
if (theBufferList().exists(filename)) {
|
2008-07-29 08:16:09 +00:00
|
|
|
|
child = theBufferList().getBuffer(filename);
|
2007-08-21 07:33:46 +00:00
|
|
|
|
} else {
|
|
|
|
|
setMessage(bformat(_("Opening child document %1$s..."),
|
|
|
|
|
makeDisplayPath(filename.absFilename())));
|
2008-02-06 23:02:57 +00:00
|
|
|
|
child = lyx_view_->loadDocument(filename, false);
|
2007-08-21 07:33:46 +00:00
|
|
|
|
parsed = true;
|
|
|
|
|
}
|
|
|
|
|
if (child) {
|
|
|
|
|
// Set the parent name of the child document.
|
|
|
|
|
// This makes insertion of citations and references in the child work,
|
|
|
|
|
// when the target is in the parent or another child document.
|
2008-10-23 07:08:12 +00:00
|
|
|
|
child->setParent(buffer);
|
2007-10-20 10:03:45 +00:00
|
|
|
|
updateLabels(*child->masterBuffer());
|
2007-08-21 07:33:46 +00:00
|
|
|
|
lyx_view_->setBuffer(child);
|
|
|
|
|
if (parsed)
|
2007-11-23 11:53:10 +00:00
|
|
|
|
child->errors("Parse");
|
2007-08-21 07:33:46 +00:00
|
|
|
|
}
|
2007-06-19 15:53:49 +00:00
|
|
|
|
|
2007-07-05 08:18:25 +00:00
|
|
|
|
// If a screen update is required (in case where auto_open is false),
|
2007-08-21 07:33:46 +00:00
|
|
|
|
// setBuffer() would have taken care of it already. Otherwise we shall
|
2007-07-05 08:18:25 +00:00
|
|
|
|
// reset the update flag because it can cause a circular problem.
|
|
|
|
|
// See bug 3970.
|
|
|
|
|
updateFlags = Update::None;
|
2007-06-19 15:53:49 +00:00
|
|
|
|
break;
|
2003-11-13 13:43:44 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2008-03-09 21:23:37 +00:00
|
|
|
|
case LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE:
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_, /**/);
|
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
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_KEYMAP_OFF:
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_ && lyx_view_->view(), /**/);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->view()->getIntl().keyMapOn(false);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_KEYMAP_PRIMARY:
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_ && lyx_view_->view(), /**/);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->view()->getIntl().keyMapPrim();
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_KEYMAP_SECONDARY:
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_ && lyx_view_->view(), /**/);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->view()->getIntl().keyMapSec();
|
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_KEYMAP_TOGGLE:
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_ && lyx_view_->view(), /**/);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->view()->getIntl().toggleKeyMap();
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2003-10-27 12:41:26 +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;
|
2008-11-17 12:42:53 +00:00
|
|
|
|
if (theBufferList().isLoaded(buffer))
|
|
|
|
|
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
|
|
|
|
}
|
2008-11-17 12:42:53 +00:00
|
|
|
|
if (theBufferList().isLoaded(buffer))
|
|
|
|
|
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
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
case LFUN_MESSAGE:
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_, /**/);
|
2006-10-21 00:16:43 +00:00
|
|
|
|
lyx_view_->message(from_utf8(argument));
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2001-04-17 15:15:59 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_LANGUAGE: {
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_, /**/);
|
2008-10-23 07:08:12 +00:00
|
|
|
|
Language const * oldL = buffer->params().language;
|
2004-03-30 16:19:50 +00:00
|
|
|
|
Language const * newL = languages.getLanguage(argument);
|
|
|
|
|
if (!newL || oldL == newL)
|
|
|
|
|
break;
|
|
|
|
|
|
2006-04-09 00:26:19 +00:00
|
|
|
|
if (oldL->rightToLeft() == newL->rightToLeft()
|
2008-10-23 07:08:12 +00:00
|
|
|
|
&& !buffer->isMultiLingual())
|
|
|
|
|
buffer->changeLanguage(oldL, newL);
|
2004-03-30 16:19:50 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_PARAMS_APPLY: {
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_, /**/);
|
2007-09-01 04:01:13 +00:00
|
|
|
|
|
2008-05-22 14:02:35 +00:00
|
|
|
|
DocumentClass const * const oldClass = buffer->params().documentClassPtr();
|
2007-10-18 11:51:17 +00:00
|
|
|
|
Cursor & cur = view()->cursor();
|
|
|
|
|
cur.recordUndoFullDocument();
|
2007-09-01 04:01:13 +00:00
|
|
|
|
|
2004-03-30 16:19:50 +00:00
|
|
|
|
istringstream ss(argument);
|
2008-04-02 23:06:22 +00:00
|
|
|
|
Lexer lex;
|
2004-03-30 16:19:50 +00:00
|
|
|
|
lex.setStream(ss);
|
2007-09-01 04:01:13 +00:00
|
|
|
|
int const unknown_tokens = buffer->readHeader(lex);
|
2004-03-30 16:19:50 +00:00
|
|
|
|
|
|
|
|
|
if (unknown_tokens != 0) {
|
2006-05-05 20:23:12 +00:00
|
|
|
|
lyxerr << "Warning in LFUN_BUFFER_PARAMS_APPLY!\n"
|
2007-09-01 04:01:13 +00:00
|
|
|
|
<< unknown_tokens << " unknown token"
|
|
|
|
|
<< (unknown_tokens == 1 ? "" : "s")
|
|
|
|
|
<< endl;
|
2004-03-30 16:19:50 +00:00
|
|
|
|
}
|
2007-09-01 04:01:13 +00:00
|
|
|
|
|
|
|
|
|
updateLayout(oldClass, buffer);
|
|
|
|
|
|
|
|
|
|
updateFlags = Update::Force | Update::FitCursor;
|
2008-03-04 06:56:13 +00:00
|
|
|
|
// We are most certainly here because of a change in the document
|
|
|
|
|
// It is then better to make sure that all dialogs are in sync with
|
|
|
|
|
// current document settings. LyXView::restartCursor() achieve this.
|
2007-12-08 16:36:56 +00:00
|
|
|
|
lyx_view_->restartCursor();
|
2004-03-30 16:19:50 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the backend. The ModuleList class holds a list of the available modules, which are retrieved from lyxmodules.lst, itself generated by configure.py. There are two LFUNs available: modules-clear and module-add, which do the obvious thing; you can test by typing these into the minibuffer, along with the name of one of the available modules: URL (a CharStyle), Endnote (a Custom Inset), and---with the spaces---End To Foot (View>LaTeX and look at the user preamble), which are themselves in lib/layouts. There are some others, too, that allow theorems to be added to classes like article and book.
The GUI will come next.
Issues: (i) The configure.py script could be improved. It'd be nice, for example, if it tested for the presence of the LaTeX packages a particular module needs. But this would mean re-working the LaTeX script, and I don't know how to do that. Note that at present, the packages are ignored. This will change shortly. (ii) I've used std::string in LyXModule, following what seemed to be a precedent in TextClass. If some of these should be docstrings, please let me know, and I'll change them. (iii) There is at present no distinction between LaTeX and DocBook modules. Should there be? That is: Should there be modules that are available when the document class is a LaTeX class and others that are available only when it is DocBook? Or should there just be one set of modules? Each module can of course indicate for what it is suitable in its description.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19893 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-29 17:59:49 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_LAYOUT_MODULES_CLEAR: {
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_, /**/);
|
2008-05-22 14:02:35 +00:00
|
|
|
|
DocumentClass const * const oldClass = buffer->params().documentClassPtr();
|
2007-10-18 11:51:17 +00:00
|
|
|
|
view()->cursor().recordUndoFullDocument();
|
2007-09-01 04:01:13 +00:00
|
|
|
|
buffer->params().clearLayoutModules();
|
2008-02-28 01:42:02 +00:00
|
|
|
|
buffer->params().makeDocumentClass();
|
2007-09-01 04:01:13 +00:00
|
|
|
|
updateLayout(oldClass, buffer);
|
|
|
|
|
updateFlags = Update::Force | Update::FitCursor;
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the backend. The ModuleList class holds a list of the available modules, which are retrieved from lyxmodules.lst, itself generated by configure.py. There are two LFUNs available: modules-clear and module-add, which do the obvious thing; you can test by typing these into the minibuffer, along with the name of one of the available modules: URL (a CharStyle), Endnote (a Custom Inset), and---with the spaces---End To Foot (View>LaTeX and look at the user preamble), which are themselves in lib/layouts. There are some others, too, that allow theorems to be added to classes like article and book.
The GUI will come next.
Issues: (i) The configure.py script could be improved. It'd be nice, for example, if it tested for the presence of the LaTeX packages a particular module needs. But this would mean re-working the LaTeX script, and I don't know how to do that. Note that at present, the packages are ignored. This will change shortly. (ii) I've used std::string in LyXModule, following what seemed to be a precedent in TextClass. If some of these should be docstrings, please let me know, and I'll change them. (iii) There is at present no distinction between LaTeX and DocBook modules. Should there be? That is: Should there be modules that are available when the document class is a LaTeX class and others that are available only when it is DocBook? Or should there just be one set of modules? Each module can of course indicate for what it is suitable in its description.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19893 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-29 17:59:49 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case LFUN_LAYOUT_MODULE_ADD: {
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_, /**/);
|
2008-10-20 19:48:32 +00:00
|
|
|
|
BufferParams const & params = buffer->params();
|
|
|
|
|
if (!params.moduleCanBeAdded(argument)) {
|
|
|
|
|
LYXERR0("Module `" << argument <<
|
|
|
|
|
"' cannot be added due to failed requirements or "
|
|
|
|
|
"conflicts with installed modules.");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
DocumentClass const * const oldClass = params.documentClassPtr();
|
2007-10-18 11:51:17 +00:00
|
|
|
|
view()->cursor().recordUndoFullDocument();
|
2007-09-01 04:01:13 +00:00
|
|
|
|
buffer->params().addLayoutModule(argument);
|
2008-02-28 01:42:02 +00:00
|
|
|
|
buffer->params().makeDocumentClass();
|
2007-09-01 04:01:13 +00:00
|
|
|
|
updateLayout(oldClass, buffer);
|
|
|
|
|
updateFlags = Update::Force | Update::FitCursor;
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This patch adds the backend. The ModuleList class holds a list of the available modules, which are retrieved from lyxmodules.lst, itself generated by configure.py. There are two LFUNs available: modules-clear and module-add, which do the obvious thing; you can test by typing these into the minibuffer, along with the name of one of the available modules: URL (a CharStyle), Endnote (a Custom Inset), and---with the spaces---End To Foot (View>LaTeX and look at the user preamble), which are themselves in lib/layouts. There are some others, too, that allow theorems to be added to classes like article and book.
The GUI will come next.
Issues: (i) The configure.py script could be improved. It'd be nice, for example, if it tested for the presence of the LaTeX packages a particular module needs. But this would mean re-working the LaTeX script, and I don't know how to do that. Note that at present, the packages are ignored. This will change shortly. (ii) I've used std::string in LyXModule, following what seemed to be a precedent in TextClass. If some of these should be docstrings, please let me know, and I'll change them. (iii) There is at present no distinction between LaTeX and DocBook modules. Should there be? That is: Should there be modules that are available when the document class is a LaTeX class and others that are available only when it is DocBook? Or should there just be one set of modules? Each module can of course indicate for what it is suitable in its description.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19893 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-29 17:59:49 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2004-03-30 16:19:50 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_TEXTCLASS_APPLY: {
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_, /**/);
|
2004-03-30 16:19:50 +00:00
|
|
|
|
|
2008-03-11 18:31:38 +00:00
|
|
|
|
if (!loadLayoutFile(argument, buffer->temppath()) &&
|
|
|
|
|
!loadLayoutFile(argument, buffer->filePath()))
|
2004-03-30 16:19:50 +00:00
|
|
|
|
break;
|
|
|
|
|
|
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
|
|
|
|
LayoutFile const * old_layout = buffer->params().baseClass();
|
2008-03-07 03:53:21 +00:00
|
|
|
|
LayoutFile const * new_layout = &(LayoutFileList::get()[argument]);
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This first patch does some reworking of the infrastructrue. We need to distinguish between the TextClass that a particular document is using and the layout of that document, since modules, in particular, can modify the layout. The solution adopted here is to add a TextClass pointer to BufferParams, which will hold the layout. The layout itself is then constructed from the TextClass the document is using. At present, this is completely trivial, but that will change when modules are added.
The pointer in question is a boost::shared_ptr. This is needed because CutAndPaste saves a copy of the layout with each cut or copied selection. We cannot assume the selection vanishes when the document is closed, so there are two options: (i) keep a list of all the layouts that have ever been used by any document; (ii) used some kind of smart pointer. The latter seems preferable, as the former would waste memory. More importantly, the use of a smart pointer allows modules to be modified on disk and then reloaded while LyX is running, and it will eventually allow the same for layout files.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19756 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-23 16:41:13 +00:00
|
|
|
|
|
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
|
|
|
|
if (old_layout == new_layout)
|
2004-03-30 16:19:50 +00:00
|
|
|
|
// nothing to do
|
|
|
|
|
break;
|
|
|
|
|
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This first patch does some reworking of the infrastructrue. We need to distinguish between the TextClass that a particular document is using and the layout of that document, since modules, in particular, can modify the layout. The solution adopted here is to add a TextClass pointer to BufferParams, which will hold the layout. The layout itself is then constructed from the TextClass the document is using. At present, this is completely trivial, but that will change when modules are added.
The pointer in question is a boost::shared_ptr. This is needed because CutAndPaste saves a copy of the layout with each cut or copied selection. We cannot assume the selection vanishes when the document is closed, so there are two options: (i) keep a list of all the layouts that have ever been used by any document; (ii) used some kind of smart pointer. The latter seems preferable, as the former would waste memory. More importantly, the use of a smart pointer allows modules to be modified on disk and then reloaded while LyX is running, and it will eventually allow the same for layout files.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19756 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-23 16:41:13 +00:00
|
|
|
|
//Save the old, possibly modular, layout for use in conversion.
|
2008-05-22 14:02:35 +00:00
|
|
|
|
DocumentClass const * const oldDocClass = buffer->params().documentClassPtr();
|
2007-10-18 11:51:17 +00:00
|
|
|
|
view()->cursor().recordUndoFullDocument();
|
2008-02-28 21:04:55 +00:00
|
|
|
|
buffer->params().setBaseClass(argument);
|
2008-02-28 01:42:02 +00:00
|
|
|
|
buffer->params().makeDocumentClass();
|
2008-02-28 21:04:55 +00:00
|
|
|
|
updateLayout(oldDocClass, buffer);
|
2006-10-22 11:46:36 +00:00
|
|
|
|
updateFlags = Update::Force | Update::FitCursor;
|
2004-03-30 16:19:50 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2007-09-11 16:42:22 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_LAYOUT_RELOAD: {
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_, /**/);
|
2008-05-22 14:02:35 +00:00
|
|
|
|
DocumentClass const * const oldClass = buffer->params().documentClassPtr();
|
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
|
|
|
|
LayoutFileIndex bc = buffer->params().baseClassID();
|
2008-03-07 03:53:21 +00:00
|
|
|
|
LayoutFileList::get().reset(bc);
|
2008-03-21 18:45:22 +00:00
|
|
|
|
buffer->params().setBaseClass(bc);
|
2008-02-28 01:42:02 +00:00
|
|
|
|
buffer->params().makeDocumentClass();
|
2007-09-11 16:42:22 +00:00
|
|
|
|
updateLayout(oldClass, buffer);
|
|
|
|
|
updateFlags = Update::Force | Update::FitCursor;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2004-03-30 16:19:50 +00:00
|
|
|
|
|
2004-03-31 09:44:40 +00:00
|
|
|
|
case LFUN_TEXTCLASS_LOAD:
|
2008-10-23 07:08:12 +00:00
|
|
|
|
loadLayoutFile(argument, buffer->temppath()) ||
|
|
|
|
|
loadLayoutFile(argument, buffer->filePath());
|
2004-03-30 16:19:50 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2004-03-31 16:50:59 +00:00
|
|
|
|
case LFUN_LYXRC_APPLY: {
|
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
|
|
|
|
|
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;
|
|
|
|
|
|
2009-01-14 10:41:20 +00:00
|
|
|
|
case LFUN_VC_COMMAND: {
|
|
|
|
|
string flag = cmd.getArg(0);
|
|
|
|
|
if (buffer && contains(flag, 'R') && !ensureBufferClean(view()))
|
|
|
|
|
break;
|
|
|
|
|
docstring message;
|
|
|
|
|
if (contains(flag, 'M'))
|
|
|
|
|
if (!Alert::askForText(message, _("LyX VC: Log Message")))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
string path = cmd.getArg(1);
|
|
|
|
|
if (contains(path, "$$p") && buffer)
|
|
|
|
|
path = subst(path, "$$p", buffer->filePath());
|
|
|
|
|
LYXERR(Debug::LYXVC, "Directory: " << path);
|
|
|
|
|
FileName pp(path);
|
|
|
|
|
if (!pp.isReadableDirectory()) {
|
2009-01-17 13:56:59 +00:00
|
|
|
|
lyxerr << _("Directory is not accessible.") << endl;
|
2009-01-14 10:41:20 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
support::PathChanger p(pp);
|
|
|
|
|
|
|
|
|
|
string command = cmd.getArg(2);
|
|
|
|
|
if (command.empty())
|
|
|
|
|
break;
|
|
|
|
|
if (buffer) {
|
|
|
|
|
command = subst(command, "$$i", buffer->absFileName());
|
|
|
|
|
command = subst(command, "$$p", buffer->filePath());
|
|
|
|
|
}
|
|
|
|
|
command = subst(command, "$$m", to_utf8(message));
|
|
|
|
|
LYXERR(Debug::LYXVC, "Command: " << command);
|
|
|
|
|
Systemcall one;
|
|
|
|
|
one.startscript(Systemcall::Wait, command);
|
|
|
|
|
|
|
|
|
|
if (!buffer)
|
|
|
|
|
break;
|
|
|
|
|
if (contains(flag, 'I'))
|
|
|
|
|
buffer->markDirty();
|
|
|
|
|
if (contains(flag, 'R'))
|
|
|
|
|
reloadBuffer();
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2008-03-14 16:33:16 +00:00
|
|
|
|
// Everything below is only for active lyx_view_
|
|
|
|
|
if (lyx_view_ == 0)
|
|
|
|
|
break;
|
|
|
|
|
|
2008-09-15 15:44:49 +00:00
|
|
|
|
// Start an undo group. This may be needed for
|
|
|
|
|
// some stuff like inset-apply on labels.
|
2008-10-23 06:59:31 +00:00
|
|
|
|
if (theBufferList().isLoaded(buffer))
|
|
|
|
|
buffer->undo().beginUndoGroup();
|
2008-09-15 15:44:49 +00:00
|
|
|
|
|
2007-11-26 14:36:50 +00:00
|
|
|
|
// Let the current LyXView dispatch its own actions.
|
2007-11-26 22:45:17 +00:00
|
|
|
|
if (lyx_view_->dispatch(cmd)) {
|
2008-09-15 15:44:49 +00:00
|
|
|
|
if (lyx_view_->view()) {
|
2007-11-26 14:36:50 +00:00
|
|
|
|
updateFlags = lyx_view_->view()->cursor().result().update();
|
2008-10-23 06:59:31 +00:00
|
|
|
|
if (theBufferList().isLoaded(buffer))
|
|
|
|
|
buffer->undo().endUndoGroup();
|
2008-09-15 15:44:49 +00:00
|
|
|
|
}
|
2007-11-26 14:36:50 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_->view(), /**/);
|
2008-08-15 19:24:56 +00:00
|
|
|
|
|
2007-12-21 10:42:59 +00:00
|
|
|
|
// Let the current BufferView dispatch its own actions.
|
|
|
|
|
if (view()->dispatch(cmd)) {
|
|
|
|
|
// The BufferView took care of its own updates if needed.
|
|
|
|
|
updateFlags = Update::None;
|
2008-10-23 06:59:31 +00:00
|
|
|
|
if (theBufferList().isLoaded(buffer))
|
|
|
|
|
buffer->undo().endUndoGroup();
|
2007-12-21 10:42:59 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2007-11-26 14:36:50 +00:00
|
|
|
|
|
|
|
|
|
// Let the current Cursor dispatch its own actions.
|
2008-02-22 20:45:18 +00:00
|
|
|
|
Cursor old = view()->cursor();
|
2007-12-17 18:13:02 +00:00
|
|
|
|
view()->cursor().getPos(cursorPosBeforeDispatchX_,
|
|
|
|
|
cursorPosBeforeDispatchY_);
|
2004-08-13 14:56:06 +00:00
|
|
|
|
view()->cursor().dispatch(cmd);
|
2008-02-22 20:45:18 +00:00
|
|
|
|
|
|
|
|
|
// notify insets we just left
|
|
|
|
|
if (view()->cursor() != old) {
|
|
|
|
|
old.fixIfBroken();
|
|
|
|
|
bool badcursor = notifyCursorLeaves(old, view()->cursor());
|
|
|
|
|
if (badcursor)
|
|
|
|
|
view()->cursor().fixIfBroken();
|
2007-12-21 11:22:17 +00:00
|
|
|
|
}
|
2008-02-22 20:45:18 +00:00
|
|
|
|
|
2008-10-23 06:59:31 +00:00
|
|
|
|
if (theBufferList().isLoaded(buffer))
|
|
|
|
|
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) {
|
|
|
|
|
if (cmd.action == LFUN_SELF_INSERT)
|
|
|
|
|
lyx_view_->updateCompletion(view()->cursor(), true, true);
|
|
|
|
|
else if (cmd.action == LFUN_CHAR_DELETE_BACKWARD)
|
|
|
|
|
lyx_view_->updateCompletion(view()->cursor(), false, true);
|
|
|
|
|
else
|
|
|
|
|
lyx_view_->updateCompletion(view()->cursor(), false, false);
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-22 20:45:18 +00:00
|
|
|
|
updateFlags = view()->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
|
2008-10-23 12:35:20 +00:00
|
|
|
|
if (theBufferList().isLoaded(buffer) && flag.enabled()
|
2008-10-23 06:59:31 +00:00
|
|
|
|
&& !lyxaction.funcHasFlag(action, LyXAction::NoBuffer)
|
|
|
|
|
&& !lyxaction.funcHasFlag(action, LyXAction::ReadOnly))
|
|
|
|
|
buffer->markDirty();
|
|
|
|
|
|
2007-08-14 08:53:34 +00:00
|
|
|
|
if (lyx_view_ && lyx_view_->buffer()) {
|
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.
|
2007-10-10 08:52:55 +00:00
|
|
|
|
view()->processUpdateFlags(updateFlags);
|
2006-07-13 16:37:55 +00:00
|
|
|
|
|
2008-03-10 19:08:03 +00:00
|
|
|
|
// Do we have a selection?
|
2007-07-06 17:03:45 +00:00
|
|
|
|
theSelection().haveSelection(view()->cursor().selection());
|
2008-03-10 19:08:03 +00:00
|
|
|
|
|
|
|
|
|
// update gui
|
|
|
|
|
lyx_view_->restartCursor();
|
2004-03-25 09:16:36 +00:00
|
|
|
|
}
|
2004-03-18 12:53:43 +00:00
|
|
|
|
}
|
2008-02-27 12:30:41 +00:00
|
|
|
|
if (lyx_view_) {
|
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);
|
|
|
|
|
|
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())
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->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())
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->message(dispatch_msg);
|
2002-07-18 20:15:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-07-28 18:13:51 +00:00
|
|
|
|
|
2007-01-17 14:46:20 +00:00
|
|
|
|
void LyXFunc::reloadBuffer()
|
|
|
|
|
{
|
2009-01-20 13:50:04 +00:00
|
|
|
|
FileName filename = lyx_view_->buffer()->fileName();
|
2007-12-04 23:07:14 +00:00
|
|
|
|
// The user has already confirmed that the changes, if any, should
|
2009-01-20 13:50:04 +00:00
|
|
|
|
// be discarded. So we just release the Buffer and don't call closeBuffer();
|
|
|
|
|
theBufferList().release(lyx_view_->buffer());
|
|
|
|
|
// if the lyx_view_ has been destroyed, create a new one
|
|
|
|
|
if (!lyx_view_)
|
|
|
|
|
theApp()->dispatch(FuncRequest(LFUN_WINDOW_NEW));
|
|
|
|
|
Buffer * buf = lyx_view_->loadDocument(filename);
|
2007-08-21 07:33:46 +00:00
|
|
|
|
docstring const disp_fn = makeDisplayPath(filename.absFilename());
|
|
|
|
|
docstring str;
|
2009-01-20 13:50:04 +00:00
|
|
|
|
if (buf) {
|
2007-08-21 07:33:46 +00:00
|
|
|
|
updateLabels(*buf);
|
|
|
|
|
lyx_view_->setBuffer(buf);
|
2007-11-23 11:53:10 +00:00
|
|
|
|
buf->errors("Parse");
|
2007-08-21 07:33:46 +00:00
|
|
|
|
str = bformat(_("Document %1$s reloaded."), disp_fn);
|
|
|
|
|
} else {
|
|
|
|
|
str = bformat(_("Could not reload document %1$s"), disp_fn);
|
|
|
|
|
}
|
|
|
|
|
lyx_view_->message(str);
|
2007-01-17 14:46:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-10-19 07:28:35 +00:00
|
|
|
|
// Each "lyx_view_" 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
|
|
|
|
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_, /**/);
|
2007-08-14 08:53:34 +00:00
|
|
|
|
if (!lyx_view_->buffer())
|
2006-12-21 13:58:28 +00:00
|
|
|
|
return _("Welcome to LyX!");
|
2002-07-28 18:13:51 +00:00
|
|
|
|
|
2004-02-13 07:30:59 +00:00
|
|
|
|
return view()->cursor().currentState();
|
2002-08-13 17:43:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BufferView * LyXFunc::view() const
|
|
|
|
|
{
|
2008-04-10 21:49:34 +00:00
|
|
|
|
LASSERT(lyx_view_, /**/);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
return lyx_view_->view();
|
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
|
|
|
|
|
|
|
|
|
|
2008-05-22 14:02:35 +00:00
|
|
|
|
void LyXFunc::updateLayout(DocumentClass const * const oldlayout, Buffer * buffer)
|
2007-09-01 04:01:13 +00:00
|
|
|
|
{
|
|
|
|
|
lyx_view_->message(_("Converting document to new document class..."));
|
|
|
|
|
|
|
|
|
|
StableDocIterator backcur(view()->cursor());
|
|
|
|
|
ErrorList & el = buffer->errorList("Class Switch");
|
|
|
|
|
cap::switchBetweenClasses(
|
2008-02-28 01:42:02 +00:00
|
|
|
|
oldlayout, buffer->params().documentClassPtr(),
|
2007-09-01 04:01:13 +00:00
|
|
|
|
static_cast<InsetText &>(buffer->inset()), el);
|
|
|
|
|
|
|
|
|
|
view()->setCursor(backcur.asDocIterator(&(buffer->inset())));
|
|
|
|
|
|
|
|
|
|
buffer->errors("Class Switch");
|
|
|
|
|
updateLabels(*buffer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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_ROFF_COMMAND:
|
|
|
|
|
case LyXRC::RC_PLAINTEXT_LINELEN:
|
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:
|
|
|
|
|
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:
|
|
|
|
|
case LyXRC::RC_CUSTOM_EXPORT_COMMAND:
|
|
|
|
|
case LyXRC::RC_CUSTOM_EXPORT_FORMAT:
|
|
|
|
|
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:
|
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
|
|
|
|
}
|
|
|
|
|
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:
|
2005-01-16 21:01:41 +00:00
|
|
|
|
case LyXRC::RC_INDEX_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:
|
|
|
|
|
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:
|
|
|
|
|
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
|
|
|
|
}
|
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:
|
|
|
|
|
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:
|
|
|
|
|
case LyXRC::RC_LAST:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace anon
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|