2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file lyxfunc.C
|
|
|
|
|
* 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
|
|
|
|
|
2001-12-10 20:06:59 +00:00
|
|
|
|
#include "lyxfunc.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
|
2003-09-09 17:00:19 +00:00
|
|
|
|
#include "BranchList.h"
|
2003-05-23 13:54:09 +00:00
|
|
|
|
#include "buffer.h"
|
2003-06-20 12:46:28 +00:00
|
|
|
|
#include "buffer_funcs.h"
|
2006-09-29 22:06:28 +00:00
|
|
|
|
#include "bufferlist.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
|
#include "bufferparams.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "BufferView.h"
|
2006-12-29 23:54:48 +00:00
|
|
|
|
#include "bufferview_funcs.h"
|
2003-09-17 16:44:51 +00:00
|
|
|
|
#include "cursor.h"
|
2004-03-30 16:19:50 +00:00
|
|
|
|
#include "CutAndPaste.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
#include "debug.h"
|
2003-10-29 10:47:21 +00:00
|
|
|
|
#include "dispatchresult.h"
|
2003-01-05 22:38:42 +00:00
|
|
|
|
#include "encoding.h"
|
2004-03-30 16:19:50 +00:00
|
|
|
|
#include "errorlist.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
#include "exporter.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "format.h"
|
|
|
|
|
#include "funcrequest.h"
|
2006-10-12 14:10:13 +00:00
|
|
|
|
#include "FuncStatus.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "gettext.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
#include "importer.h"
|
2004-03-30 12:36:33 +00:00
|
|
|
|
#include "insetiterator.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "intl.h"
|
|
|
|
|
#include "kbmap.h"
|
2004-03-30 16:19:50 +00:00
|
|
|
|
#include "language.h"
|
2003-09-16 10:30:59 +00:00
|
|
|
|
#include "LColor.h"
|
2006-04-05 22:56:18 +00:00
|
|
|
|
#include "session.h"
|
|
|
|
|
#include "lyx_main.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "lyx_cb.h"
|
|
|
|
|
#include "LyXAction.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
#include "lyxfind.h"
|
2004-03-30 16:19:50 +00:00
|
|
|
|
#include "lyxlex.h"
|
2003-09-06 23:36:02 +00:00
|
|
|
|
#include "lyxrc.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "lyxrow.h"
|
2006-09-29 22:06:28 +00:00
|
|
|
|
#include "lyxserver.h"
|
2004-03-30 16:19:50 +00:00
|
|
|
|
#include "lyxtextclasslist.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
|
#include "lyxvc.h"
|
2003-09-06 17:23:08 +00:00
|
|
|
|
#include "paragraph.h"
|
2004-03-28 22:00:22 +00:00
|
|
|
|
#include "pariterator.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
#include "ParagraphParameters.h"
|
2003-10-14 13:01:49 +00:00
|
|
|
|
#include "undo.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"
|
|
|
|
|
#include "insets/InsetNote.h"
|
|
|
|
|
#include "insets/InsetTabular.h"
|
|
|
|
|
#include "insets/InsetVSpace.h"
|
|
|
|
|
#include "insets/InsetWrap.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
|
2006-09-22 12:34:13 +00:00
|
|
|
|
#include "frontends/Application.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "frontends/Alert.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
#include "frontends/Dialogs.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "frontends/FileDialog.h"
|
2006-10-03 16:17:32 +00:00
|
|
|
|
#include "frontends/FontLoader.h"
|
2006-10-23 16:29:24 +00:00
|
|
|
|
#include "frontends/Gui.h"
|
2003-09-06 20:08:10 +00:00
|
|
|
|
#include "frontends/LyXKeySym.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "frontends/LyXView.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
#include "frontends/Menubar.h"
|
2004-04-29 09:54:59 +00:00
|
|
|
|
#include "frontends/Toolbars.h"
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
2005-02-15 13:45:41 +00:00
|
|
|
|
#include "support/environment.h"
|
2004-11-25 11:08:32 +00:00
|
|
|
|
#include "support/filefilterlist.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "support/filetools.h"
|
2002-02-27 09:59:52 +00:00
|
|
|
|
#include "support/forkedcontr.h"
|
2005-01-31 10:42:26 +00:00
|
|
|
|
#include "support/fs_extras.h"
|
2004-03-28 14:12:33 +00:00
|
|
|
|
#include "support/lstrings.h"
|
1999-11-15 12:01:38 +00:00
|
|
|
|
#include "support/path.h"
|
2005-01-10 19:17:43 +00:00
|
|
|
|
#include "support/package.h"
|
2004-03-27 23:11:46 +00:00
|
|
|
|
#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
|
|
|
|
|
2005-03-07 11:03:45 +00:00
|
|
|
|
#include <boost/current_function.hpp>
|
2005-01-31 10:42:26 +00:00
|
|
|
|
#include <boost/filesystem/operations.hpp>
|
|
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
|
#include <sstream>
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using bv_funcs::freefont2string;
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
using support::absolutePath;
|
|
|
|
|
using support::addName;
|
|
|
|
|
using support::addPath;
|
|
|
|
|
using support::bformat;
|
|
|
|
|
using support::changeExtension;
|
|
|
|
|
using support::contains;
|
|
|
|
|
using support::FileFilterList;
|
2006-11-26 21:30:39 +00:00
|
|
|
|
using support::FileName;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
using support::fileSearch;
|
|
|
|
|
using support::ForkedcallsController;
|
|
|
|
|
using support::i18nLibFileSearch;
|
|
|
|
|
using support::isDirWriteable;
|
|
|
|
|
using support::isFileReadable;
|
|
|
|
|
using support::isStrInt;
|
|
|
|
|
using support::makeAbsPath;
|
|
|
|
|
using support::makeDisplayPath;
|
|
|
|
|
using support::package;
|
|
|
|
|
using support::quoteName;
|
|
|
|
|
using support::rtrim;
|
|
|
|
|
using support::split;
|
|
|
|
|
using support::subst;
|
|
|
|
|
using support::Systemcall;
|
|
|
|
|
using support::token;
|
|
|
|
|
using support::trim;
|
|
|
|
|
using support::prefixIs;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
|
using std::endl;
|
2003-09-08 00:33:41 +00:00
|
|
|
|
using std::make_pair;
|
2003-12-05 13:37:23 +00:00
|
|
|
|
using std::pair;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-09-05 18:02:24 +00:00
|
|
|
|
using std::istringstream;
|
view-source feature, from Bo Peng <ben.bob@gmail.com>
* src/buffer.h buffer.C - getSourceCode()
* src/lyxfunc.C - open view-source dialog
* src/text3.C - change LFUN_MOUSE_RELEASE
* src/output_linuxdoc.C, src/output_docbook.C, src/output_latex.C
- intercept output
* src/outputparams.h, outputparams.C - add par_begin, par_end, dryrun
* src/insets/insetgraphics.C - add dryrun mode of file conversion
* lib/ui/stdmenus.ui - add view-source menu item under view
* Add view-source dialog, add
src/frontends/qt2/QViewSourceDialog.h, QViewSource.C, QViewSource.h, QViewSourceDialog.C
src/frontends/qt2/ui/QViewSourceDialogBase.ui
src/frontends/controllers/ControlViewSource.h ControlViewSource.C
modify
src/frontends/qt2/Makefile.dialogs, Makefile.am, Dialogs.C,
src/frontends/controllers/Makefile.am, po.POTFILES.in
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13610 a592a061-630c-0410-9148-cb99ea01b6c8
2006-04-09 02:48:54 +00:00
|
|
|
|
using std::ostringstream;
|
2003-09-08 00:33:41 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace Alert = frontend::Alert;
|
2005-01-31 10:42:26 +00:00
|
|
|
|
namespace fs = boost::filesystem;
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
bool getLocalStatus(LCursor cursor,
|
2005-01-05 20:21:27 +00:00
|
|
|
|
FuncRequest const & cmd, FuncStatus & status)
|
|
|
|
|
{
|
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)
|
|
|
|
|
//LCursor safe = *this;
|
|
|
|
|
bool res = false;
|
2005-02-08 13:18:05 +00:00
|
|
|
|
for ( ; cursor.depth(); cursor.pop()) {
|
2005-01-05 20:21:27 +00:00
|
|
|
|
//lyxerr << "\nLCursor::getStatus: cmd: " << cmd << endl << *this << endl;
|
2005-03-07 11:03:45 +00:00
|
|
|
|
BOOST_ASSERT(cursor.idx() <= cursor.lastidx());
|
|
|
|
|
BOOST_ASSERT(cursor.pit() <= cursor.lastpit());
|
|
|
|
|
BOOST_ASSERT(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
|
|
|
|
}
|
|
|
|
|
|
2006-10-19 07:20:32 +00:00
|
|
|
|
LyXFunc::LyXFunc()
|
2006-10-19 07:28:35 +00:00
|
|
|
|
: lyx_view_(0),
|
2003-01-05 22:38:42 +00:00
|
|
|
|
encoded_last_key(0),
|
2002-10-21 16:21:56 +00:00
|
|
|
|
meta_fake_bit(key_modifier::none)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
|
2006-10-19 07:20:32 +00:00
|
|
|
|
void LyXFunc::initKeySequences(kb_keymap * kb)
|
|
|
|
|
{
|
|
|
|
|
keyseq.reset(new kb_sequence(kb, kb));
|
|
|
|
|
cancel_meta_seq.reset(new kb_sequence(kb, kb));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-12 14:58:57 +00:00
|
|
|
|
void LyXFunc::setLyXView(LyXView * lv)
|
|
|
|
|
{
|
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
|
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
|
void LyXFunc::handleKeyFunc(kb_action action)
|
|
|
|
|
{
|
2006-10-22 10:15:23 +00:00
|
|
|
|
char_type c = encoded_last_key;
|
2001-02-23 16:10:03 +00:00
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
|
if (keyseq->length())
|
2001-11-30 13:25:38 +00:00
|
|
|
|
c = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
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
|
2006-10-19 07:20:32 +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();
|
2003-08-04 09:06:35 +00:00
|
|
|
|
view()->update();
|
2001-02-23 16:10:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-01-11 16:01:10 +00:00
|
|
|
|
void LyXFunc::gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer)
|
|
|
|
|
{
|
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
|
|
|
|
if (!LyX::ref().session().bookmarks().isValid(idx))
|
|
|
|
|
return;
|
|
|
|
|
BookmarksSection::Bookmark const & bm = LyX::ref().session().bookmarks().bookmark(idx);
|
|
|
|
|
BOOST_ASSERT(!bm.filename.empty());
|
|
|
|
|
string const file = bm.filename.absFilename();
|
|
|
|
|
// if the file is not opened, open it.
|
|
|
|
|
if (!theBufferList().exists(file)) {
|
|
|
|
|
if (openFile)
|
|
|
|
|
dispatch(FuncRequest(LFUN_FILE_OPEN, file));
|
|
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// open may fail, so we need to test it again
|
|
|
|
|
if (theBufferList().exists(file)) {
|
|
|
|
|
// if the current buffer is not that one, switch to it.
|
|
|
|
|
if (lyx_view_->buffer()->fileName() != file) {
|
|
|
|
|
if (switchToBuffer)
|
|
|
|
|
dispatch(FuncRequest(LFUN_BUFFER_SWITCH, file));
|
|
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// moveToPosition use par_id, and par_pit and return new par_id.
|
|
|
|
|
pit_type new_pit;
|
2007-04-16 19:01:32 +00:00
|
|
|
|
pos_type new_pos;
|
2007-01-11 16:01:10 +00:00
|
|
|
|
int new_id;
|
2007-04-16 19:01:32 +00:00
|
|
|
|
boost::tie(new_pit, new_pos, new_id) = view()->moveToPosition(bm.bottom_pit, bm.bottom_pos, bm.top_id, bm.top_pos);
|
|
|
|
|
// if bottom_pit, bottom_pos or top_id has been changed, update bookmark
|
2007-01-11 16:01:10 +00:00
|
|
|
|
// see http://bugzilla.lyx.org/show_bug.cgi?id=3092
|
2007-04-16 19:01:32 +00:00
|
|
|
|
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-01-11 16:01:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-01-26 10:13:15 +00:00
|
|
|
|
void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
|
2000-08-14 15:31:16 +00:00
|
|
|
|
{
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::KEY) << "KeySym is " << keysym->getSymbolName() << endl;
|
2002-11-04 02:12:42 +00:00
|
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
|
// Do nothing if we have nothing (JMarc)
|
2002-08-07 08:11:41 +00:00
|
|
|
|
if (!keysym->isOK()) {
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::KEY) << "Empty kbd action (probably composing)"
|
2000-08-14 15:31:16 +00:00
|
|
|
|
<< endl;
|
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
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
if (keysym->isModifier()) {
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::KEY) << "isModifier true" << endl;
|
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();
|
2006-08-13 22:54:59 +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?
|
|
|
|
|
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
|
2006-10-19 07:20:32 +00:00
|
|
|
|
cancel_meta_seq->reset();
|
2000-08-14 15:31:16 +00:00
|
|
|
|
|
2006-10-19 07:20:32 +00:00
|
|
|
|
FuncRequest func = cancel_meta_seq->addkey(keysym, state);
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::KEY) << BOOST_CURRENT_FUNCTION
|
2005-02-08 02:06:39 +00:00
|
|
|
|
<< " action first set to [" << func.action << ']'
|
|
|
|
|
<< endl;
|
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.
|
2002-05-26 17:33:14 +00:00
|
|
|
|
// Mostly, meta_fake_bit = key_modifier::none. 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
|
2006-10-19 07:20:32 +00:00
|
|
|
|
func = keyseq->addkey(keysym, (state | meta_fake_bit));
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::KEY) << BOOST_CURRENT_FUNCTION
|
2005-02-08 02:06:39 +00:00
|
|
|
|
<< "action now set to ["
|
|
|
|
|
<< func.action << ']' << endl;
|
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.
|
2002-05-26 17:33:14 +00:00
|
|
|
|
meta_fake_bit = key_modifier::none;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2005-02-08 02:06:39 +00:00
|
|
|
|
// Can this happen now ?
|
2003-09-21 23:00:47 +00:00
|
|
|
|
if (func.action == LFUN_NOACTION) {
|
2006-05-05 20:23:12 +00:00
|
|
|
|
func = FuncRequest(LFUN_COMMAND_PREFIX);
|
2001-11-30 13:25:38 +00:00
|
|
|
|
}
|
2000-08-14 15:31:16 +00:00
|
|
|
|
|
2007-04-01 14:51:13 +00:00
|
|
|
|
LYXERR(Debug::KEY) << BOOST_CURRENT_FUNCTION
|
|
|
|
|
<< " Key [action="
|
|
|
|
|
<< func.action << "]["
|
|
|
|
|
<< to_utf8(keyseq->print(false)) << ']'
|
|
|
|
|
<< endl;
|
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)
|
|
|
|
|
|
2006-10-19 07:20:32 +00:00
|
|
|
|
if (keyseq->length() > 1) {
|
2007-01-04 17:10:24 +00:00
|
|
|
|
lyx_view_->message(keyseq->print(true));
|
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
|
2003-09-21 23:00:47 +00:00
|
|
|
|
if (func.action == LFUN_UNKNOWN_ACTION &&
|
|
|
|
|
state == key_modifier::shift) {
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::KEY) << "Trying without shift" << endl;
|
2006-10-19 07:20:32 +00:00
|
|
|
|
func = keyseq->addkey(keysym, key_modifier::none);
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::KEY) << "Action now " << func.action << endl;
|
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
|
2006-10-19 07:20:32 +00:00
|
|
|
|
if (keysym->isText() && keyseq->length() == 1) {
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::KEY) << "isText() is true, inserting." << endl;
|
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-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::KEY) << "Unknown, !isText() - giving up" << endl;
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->message(_("Unknown function."));
|
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-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::KEY)
|
2006-10-21 00:16:43 +00:00
|
|
|
|
<< "SelfInsert arg[`" << to_utf8(arg) << "']" << endl;
|
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);
|
2002-06-18 17:22:17 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
}
|
2000-08-14 15:31:16 +00:00
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
|
2004-02-13 07:30:59 +00:00
|
|
|
|
FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
1999-12-10 00:07:59 +00:00
|
|
|
|
{
|
2004-03-18 13:57:20 +00:00
|
|
|
|
//lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl;
|
2002-01-09 09:36:35 +00:00
|
|
|
|
FuncStatus flag;
|
2006-10-23 16:29:24 +00:00
|
|
|
|
|
2004-02-06 16:14:06 +00:00
|
|
|
|
LCursor & cur = view()->cursor();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2004-11-16 10:46:23 +00:00
|
|
|
|
/* In LyX/Mac, when a dialog is open, the menus of the
|
|
|
|
|
application can still be accessed without giving focus to
|
|
|
|
|
the main window. In this case, we want to disable the menu
|
|
|
|
|
entries that are buffer-related.
|
2005-09-21 13:18:15 +00:00
|
|
|
|
|
|
|
|
|
Note that this code is not perfect, as bug 1941 attests:
|
|
|
|
|
http://bugzilla.lyx.org/show_bug.cgi?id=1941#c4
|
2004-11-16 10:46:23 +00:00
|
|
|
|
*/
|
2006-11-26 15:46:02 +00:00
|
|
|
|
Buffer * buf = lyx_view_? lyx_view_->buffer() : 0;
|
|
|
|
|
if (lyx_view_ && cmd.origin == FuncRequest::MENU && !lyx_view_->hasFocus())
|
2004-11-16 10:46:23 +00:00
|
|
|
|
buf = 0;
|
|
|
|
|
|
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")));
|
2004-03-18 13:57:20 +00:00
|
|
|
|
flag.enabled(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);
|
2004-03-18 13:57:20 +00:00
|
|
|
|
flag.enabled(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")));
|
2004-03-23 11:22:11 +00:00
|
|
|
|
flag.enabled(false);
|
|
|
|
|
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) {
|
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?)
|
2006-10-21 00:16:43 +00:00
|
|
|
|
if (to_utf8(cmd.argument()) == buf->fileName())
|
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"
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|| Exporter::isExportable(*buf, 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:
|
2006-04-09 00:26:19 +00:00
|
|
|
|
enable = Exporter::isExportable(*buf, "program");
|
2000-07-31 12:51:19 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2000-08-01 09:35:42 +00:00
|
|
|
|
case LFUN_LAYOUT_TABULAR:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
enable = cur.innerInsetOfType(InsetBase::TABULAR_CODE);
|
2003-04-03 01:26:02 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2002-01-20 23:17:17 +00:00
|
|
|
|
case LFUN_LAYOUT:
|
2004-02-06 16:14:06 +00:00
|
|
|
|
case LFUN_LAYOUT_PARAGRAPH:
|
2005-11-17 08:41:56 +00:00
|
|
|
|
enable = !cur.inset().forceDefaultParagraphs(cur.idx());
|
2000-08-01 09:35:42 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
case LFUN_VC_REGISTER:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
enable = !buf->lyxvc().inUse();
|
2000-07-24 13:53:19 +00:00
|
|
|
|
break;
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_VC_CHECK_IN:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
enable = buf->lyxvc().inUse() && !buf->isReadonly();
|
2000-07-24 13:53:19 +00:00
|
|
|
|
break;
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_VC_CHECK_OUT:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
enable = buf->lyxvc().inUse() && buf->isReadonly();
|
2000-07-24 13:53:19 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_VC_REVERT:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_VC_UNDO_LAST:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
enable = buf->lyxvc().inUse();
|
2000-07-24 13:53:19 +00:00
|
|
|
|
break;
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_RELOAD:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
enable = !buf->isUnnamed() && !buf->isClean();
|
2003-02-17 18:40:04 +00:00
|
|
|
|
break;
|
2003-10-29 12:18:08 +00:00
|
|
|
|
|
2003-04-26 19:01:33 +00:00
|
|
|
|
case LFUN_INSET_SETTINGS: {
|
2004-03-18 13:57:20 +00:00
|
|
|
|
enable = false;
|
2005-02-08 13:18:05 +00:00
|
|
|
|
if (!cur)
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
2005-07-15 22:10:25 +00:00
|
|
|
|
InsetBase::Code code = cur.inset().lyxCode();
|
2003-04-26 19:01:33 +00:00
|
|
|
|
switch (code) {
|
2004-11-25 19:13:07 +00:00
|
|
|
|
case InsetBase::TABULAR_CODE:
|
2006-09-01 15:41:38 +00:00
|
|
|
|
enable = cmd.argument() == "tabular";
|
2003-04-26 19:01:33 +00:00
|
|
|
|
break;
|
2004-11-25 19:13:07 +00:00
|
|
|
|
case InsetBase::ERT_CODE:
|
2006-09-01 15:41:38 +00:00
|
|
|
|
enable = cmd.argument() == "ert";
|
2003-04-26 19:01:33 +00:00
|
|
|
|
break;
|
2004-11-25 19:13:07 +00:00
|
|
|
|
case InsetBase::FLOAT_CODE:
|
2006-09-01 15:41:38 +00:00
|
|
|
|
enable = cmd.argument() == "float";
|
2003-04-26 19:01:33 +00:00
|
|
|
|
break;
|
2004-11-25 19:13:07 +00:00
|
|
|
|
case InsetBase::WRAP_CODE:
|
2006-09-01 15:41:38 +00:00
|
|
|
|
enable = cmd.argument() == "wrap";
|
2003-04-26 19:01:33 +00:00
|
|
|
|
break;
|
2004-11-25 19:13:07 +00:00
|
|
|
|
case InsetBase::NOTE_CODE:
|
2006-09-01 15:41:38 +00:00
|
|
|
|
enable = cmd.argument() == "note";
|
2003-07-15 23:52:05 +00:00
|
|
|
|
break;
|
2004-11-25 19:13:07 +00:00
|
|
|
|
case InsetBase::BRANCH_CODE:
|
2006-09-01 15:41:38 +00:00
|
|
|
|
enable = cmd.argument() == "branch";
|
2003-08-17 11:28:23 +00:00
|
|
|
|
break;
|
2004-11-25 19:13:07 +00:00
|
|
|
|
case InsetBase::BOX_CODE:
|
2006-09-01 15:41:38 +00:00
|
|
|
|
enable = cmd.argument() == "box";
|
2003-10-07 07:42:15 +00:00
|
|
|
|
break;
|
2003-04-26 19:01:33 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-13 09:43:58 +00:00
|
|
|
|
case LFUN_INSET_APPLY: {
|
|
|
|
|
string const name = cmd.getArg(0);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
InsetBase * inset = lyx_view_->getDialogs().getOpenInset(name);
|
2005-04-13 09:43:58 +00:00
|
|
|
|
if (inset) {
|
2006-09-01 15:41:38 +00:00
|
|
|
|
FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
|
2005-04-13 09:43:58 +00:00
|
|
|
|
FuncStatus fs;
|
2007-01-04 14:32:37 +00:00
|
|
|
|
if (!inset->getStatus(cur, fr, fs)) {
|
|
|
|
|
// Every inset is supposed to handle this
|
|
|
|
|
BOOST_ASSERT(false);
|
|
|
|
|
}
|
2005-04-13 09:43:58 +00:00
|
|
|
|
flag |= fs;
|
|
|
|
|
} else {
|
2006-09-01 15:41:38 +00:00
|
|
|
|
FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
|
2005-04-13 09:43:58 +00:00
|
|
|
|
flag |= getStatus(fr);
|
|
|
|
|
}
|
|
|
|
|
enable = flag.enabled();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
|
case LFUN_DIALOG_SHOW: {
|
2004-02-13 07:30:59 +00:00
|
|
|
|
string const name = cmd.getArg(0);
|
2004-03-18 12:53:43 +00:00
|
|
|
|
if (!buf)
|
2004-03-18 13:57:20 +00:00
|
|
|
|
enable = name == "aboutlyx"
|
2007-04-23 09:35:28 +00:00
|
|
|
|
|| name == "file" //FIXME: should be removed.
|
2004-03-31 18:51:11 +00:00
|
|
|
|
|| name == "prefs"
|
2004-03-18 13:57:20 +00:00
|
|
|
|
|| name == "texinfo";
|
2004-03-18 12:53:43 +00:00
|
|
|
|
else if (name == "print")
|
2006-04-09 00:26:19 +00:00
|
|
|
|
enable = Exporter::isExportable(*buf, "dvi")
|
2004-03-18 13:57:20 +00:00
|
|
|
|
&& lyxrc.print_command != "none";
|
2007-04-19 21:42:42 +00:00
|
|
|
|
else if (name == "character")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
enable = cur.inset().lyxCode() != InsetBase::ERT_CODE;
|
2004-03-18 12:53:43 +00:00
|
|
|
|
else if (name == "latexlog")
|
2006-11-26 21:30:39 +00:00
|
|
|
|
enable = isFileReadable(FileName(buf->getLogName().second));
|
2005-05-05 21:08:18 +00:00
|
|
|
|
else if (name == "spellchecker")
|
2007-04-23 09:35:28 +00:00
|
|
|
|
#if defined (USE_ASPELL) || defined (USE_ISPELL) || defined (USE_PSPELL)
|
|
|
|
|
enable = !buf->isReadonly();
|
|
|
|
|
#else
|
2005-05-05 21:08:18 +00:00
|
|
|
|
enable = false;
|
|
|
|
|
#endif
|
|
|
|
|
else if (name == "vclog")
|
|
|
|
|
enable = buf->lyxvc().inUse();
|
2003-06-19 16:49:45 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-03 17:24:40 +00:00
|
|
|
|
case LFUN_DIALOG_SHOW_NEW_INSET:
|
2007-02-01 14:43:13 +00:00
|
|
|
|
enable = cur.inset().lyxCode() != InsetBase::ERT_CODE;
|
|
|
|
|
if (cur.inset().lyxCode() == InsetBase::CAPTION_CODE) {
|
|
|
|
|
FuncStatus flag;
|
|
|
|
|
if (cur.inset().getStatus(cur, cmd, flag))
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
2005-02-03 17:24:40 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2004-04-05 18:34:36 +00:00
|
|
|
|
case LFUN_DIALOG_UPDATE: {
|
|
|
|
|
string const name = cmd.getArg(0);
|
|
|
|
|
if (!buf)
|
|
|
|
|
enable = name == "prefs";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_WRITE: {
|
2006-04-05 23:56:29 +00:00
|
|
|
|
enable = view()->buffer()->isUnnamed()
|
2006-03-23 13:52:32 +00:00
|
|
|
|
|| !view()->buffer()->isClean();
|
2006-03-16 13:12:40 +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()));
|
|
|
|
|
enable = LyX::ref().session().bookmarks().isValid(num);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case LFUN_BOOKMARK_CLEAR:
|
|
|
|
|
enable = LyX::ref().session().bookmarks().size() > 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_TOOLBAR_TOGGLE_STATE: {
|
2007-04-19 19:43:15 +00:00
|
|
|
|
ToolbarInfo::Flags flags = lyx_view_->getToolbarState(to_utf8(cmd.argument()));
|
|
|
|
|
if (!(flags & ToolbarInfo::AUTO))
|
|
|
|
|
flag.setOnOff(flags & ToolbarInfo::ON);
|
2007-01-22 14:43:45 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2006-11-02 18:59:33 +00:00
|
|
|
|
|
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);
|
2004-05-04 14:12:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_NEW:
|
2006-05-08 18:09:19 +00:00
|
|
|
|
case LFUN_BUFFER_NEW_TEMPLATE:
|
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_WRITE_AS:
|
|
|
|
|
case LFUN_BUFFER_UPDATE:
|
|
|
|
|
case LFUN_BUFFER_VIEW:
|
|
|
|
|
case LFUN_BUFFER_IMPORT:
|
|
|
|
|
case LFUN_TOC_VIEW:
|
|
|
|
|
case LFUN_BUFFER_AUTO_SAVE:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
case LFUN_RECONFIGURE:
|
|
|
|
|
case LFUN_HELP_OPEN:
|
|
|
|
|
case LFUN_FILE_NEW:
|
|
|
|
|
case LFUN_FILE_OPEN:
|
|
|
|
|
case LFUN_DROP_LAYOUTS_CHOICE:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_MENU_OPEN:
|
|
|
|
|
case LFUN_SERVER_GET_NAME:
|
|
|
|
|
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:
|
|
|
|
|
case LFUN_TOGGLE_CURSOR_FOLLOWS_SCROLLBAR:
|
|
|
|
|
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_SCREEN_FONT_UPDATE:
|
|
|
|
|
case LFUN_SET_COLOR:
|
|
|
|
|
case LFUN_MESSAGE:
|
|
|
|
|
case LFUN_EXTERNAL_EDIT:
|
2004-04-13 10:36:09 +00:00
|
|
|
|
case LFUN_GRAPHICS_EDIT:
|
2004-03-30 12:36:33 +00:00
|
|
|
|
case LFUN_ALL_INSETS_TOGGLE:
|
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:
|
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:
|
2006-10-21 09:45:11 +00:00
|
|
|
|
case LFUN_WINDOW_NEW:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
case LFUN_WINDOW_CLOSE:
|
2007-01-22 14:43:45 +00:00
|
|
|
|
case LFUN_LYX_QUIT:
|
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:
|
2006-10-21 00:16:43 +00:00
|
|
|
|
if (!getLocalStatus(cur, 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)
|
|
|
|
|
flag.enabled(false);
|
|
|
|
|
|
|
|
|
|
// 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")));
|
2004-03-23 11:22:11 +00:00
|
|
|
|
flag.enabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-07 10:37:05 +00:00
|
|
|
|
// Are we in a DELETED change-tracking region?
|
2006-10-06 18:53:35 +00:00
|
|
|
|
if (buf && lookupChangeType(cur, 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.")));
|
2005-09-07 10:37:05 +00:00
|
|
|
|
flag.enabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
Buffer & buf = *bv->buffer();
|
|
|
|
|
if (buf.isClean())
|
|
|
|
|
return true;
|
|
|
|
|
|
2006-09-11 08:54:10 +00:00
|
|
|
|
docstring const file = makeDisplayPath(buf.fileName(), 30);
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
void loadTextclass(string const & name)
|
|
|
|
|
{
|
2006-10-21 00:16:43 +00:00
|
|
|
|
std::pair<bool, textclass_type> const tc_pair =
|
2006-04-09 00:26:19 +00:00
|
|
|
|
textclasslist.numberOfClass(name);
|
2004-03-31 09:44:40 +00:00
|
|
|
|
|
|
|
|
|
if (!tc_pair.first) {
|
|
|
|
|
lyxerr << "Document class \"" << name
|
|
|
|
|
<< "\" does not exist."
|
|
|
|
|
<< std::endl;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
textclass_type const tc = tc_pair.second;
|
2004-03-31 09:44:40 +00:00
|
|
|
|
|
|
|
|
|
if (!textclasslist[tc].load()) {
|
2006-09-11 08:54:10 +00:00
|
|
|
|
docstring s = bformat(_("The document could not be converted\n"
|
|
|
|
|
"into the document class %1$s."),
|
2006-10-21 00:16:43 +00:00
|
|
|
|
from_utf8(textclasslist[tc].name()));
|
2006-09-11 08:54:10 +00:00
|
|
|
|
Alert::error(_("Could not change class"), s);
|
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());
|
2004-03-18 12:53:43 +00:00
|
|
|
|
kb_action const action = cmd.action;
|
2003-09-21 23:00:47 +00:00
|
|
|
|
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::ACTION) << endl << "LyXFunc::dispatch: cmd: " << cmd << endl;
|
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-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::ACTION) << "LyXFunc::dispatch: "
|
2002-01-12 20:00:47 +00:00
|
|
|
|
<< lyxaction.getActionName(action)
|
|
|
|
|
<< " [" << action << "] is disabled at this location"
|
2001-07-24 22:08:49 +00:00
|
|
|
|
<< endl;
|
2004-11-25 09:15:26 +00:00
|
|
|
|
setErrorMessage(flag.message());
|
2003-11-13 13:43:44 +00:00
|
|
|
|
} else {
|
|
|
|
|
switch (action) {
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_WORD_FIND_FORWARD:
|
|
|
|
|
case LFUN_WORD_FIND_BACKWARD: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(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:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2007-01-04 17:10:24 +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
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_COMMAND_EXECUTE:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->getToolbars().display("minibuffer", true);
|
|
|
|
|
lyx_view_->focus_command_buffer();
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
case LFUN_CANCEL:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && lyx_view_->view());
|
2006-10-19 07:20:32 +00:00
|
|
|
|
keyseq->reset();
|
2003-11-13 13:43:44 +00:00
|
|
|
|
meta_fake_bit = key_modifier::none;
|
2006-09-16 14:00:13 +00:00
|
|
|
|
if (view()->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:
|
2003-11-13 13:43:44 +00:00
|
|
|
|
meta_fake_bit = key_modifier::alt;
|
2007-01-04 17:10:24 +00:00
|
|
|
|
setMessage(keyseq->print(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_TOGGLE_READ_ONLY:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && lyx_view_->view() && lyx_view_->buffer());
|
2006-10-19 07:28:35 +00:00
|
|
|
|
if (lyx_view_->buffer()->lyxvc().inUse())
|
|
|
|
|
lyx_view_->buffer()->lyxvc().toggleReadOnly();
|
2003-11-13 13:43:44 +00:00
|
|
|
|
else
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->buffer()->setReadonly(
|
|
|
|
|
!lyx_view_->buffer()->isReadonly());
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
// --- Menus -----------------------------------------------
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_NEW:
|
2003-11-13 13:43:44 +00:00
|
|
|
|
menuNew(argument, false);
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-08 18:09:19 +00:00
|
|
|
|
case LFUN_BUFFER_NEW_TEMPLATE:
|
2003-11-13 13:43:44 +00:00
|
|
|
|
menuNew(argument, true);
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_CLOSE:
|
2003-11-13 13:43:44 +00:00
|
|
|
|
closeBuffer();
|
2006-10-23 11:34:43 +00:00
|
|
|
|
view()->update();
|
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_WRITE:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
|
2006-10-19 07:28:35 +00:00
|
|
|
|
if (!lyx_view_->buffer()->isUnnamed()) {
|
2006-09-11 08:54:10 +00:00
|
|
|
|
docstring const str = bformat(_("Saving document %1$s..."),
|
2006-10-19 07:28:35 +00:00
|
|
|
|
makeDisplayPath(lyx_view_->buffer()->fileName()));
|
|
|
|
|
lyx_view_->message(str);
|
|
|
|
|
menuWrite(lyx_view_->buffer());
|
|
|
|
|
lyx_view_->message(str + _(" done."));
|
2007-01-29 20:04:10 +00:00
|
|
|
|
} else {
|
|
|
|
|
writeAs(lyx_view_->buffer());
|
|
|
|
|
}
|
2006-10-22 11:46:36 +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_WRITE_AS:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
|
2006-10-19 07:28:35 +00:00
|
|
|
|
writeAs(lyx_view_->buffer(), argument);
|
2006-10-22 11:46:36 +00:00
|
|
|
|
updateFlags = Update::None;
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2003-03-29 07:44:44 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_RELOAD: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
|
2006-09-11 08:54:10 +00:00
|
|
|
|
docstring const file = makeDisplayPath(view()->buffer()->fileName(), 20);
|
|
|
|
|
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?"),
|
|
|
|
|
text, 0, 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:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
|
2006-10-19 07:28:35 +00:00
|
|
|
|
Exporter::Export(lyx_view_->buffer(), 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:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
|
2006-10-19 07:28:35 +00:00
|
|
|
|
Exporter::preview(lyx_view_->buffer(), argument);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2002-03-19 03:56:23 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUILD_PROGRAM:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
|
2006-10-19 07:28:35 +00:00
|
|
|
|
Exporter::Export(lyx_view_->buffer(), "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:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->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:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
|
2003-11-13 13:43:44 +00:00
|
|
|
|
if (argument == "custom")
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->getDialogs().show("sendto");
|
2003-11-13 13:43:44 +00:00
|
|
|
|
else {
|
2006-10-19 07:28:35 +00:00
|
|
|
|
Exporter::Export(lyx_view_->buffer(), 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: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && 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!"
|
|
|
|
|
<< std::endl;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-19 07:28:35 +00:00
|
|
|
|
Buffer * buffer = lyx_view_->buffer();
|
2004-03-27 23:11:46 +00:00
|
|
|
|
|
|
|
|
|
// The name of the file created by the conversion process
|
|
|
|
|
string filename;
|
|
|
|
|
|
|
|
|
|
// Output to filename
|
|
|
|
|
if (format->name() == "lyx") {
|
|
|
|
|
string const latexname =
|
|
|
|
|
buffer->getLatexName(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 {
|
2006-08-13 16:16:43 +00:00
|
|
|
|
Exporter::Export(buffer, 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: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
|
2004-03-28 14:12:33 +00:00
|
|
|
|
string target;
|
|
|
|
|
string target_name;
|
|
|
|
|
string command = split(split(argument, target, ' '),
|
|
|
|
|
target_name, ' ');
|
|
|
|
|
|
|
|
|
|
if (target.empty()
|
|
|
|
|
|| target_name.empty()
|
|
|
|
|
|| command.empty()) {
|
|
|
|
|
lyxerr << "Unable to parse \""
|
|
|
|
|
<< argument << '"' << std::endl;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (target != "printer" && target != "file") {
|
|
|
|
|
lyxerr << "Unrecognized target \""
|
|
|
|
|
<< target << '"' << std::endl;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-19 07:28:35 +00:00
|
|
|
|
Buffer * buffer = lyx_view_->buffer();
|
2004-03-28 14:12:33 +00:00
|
|
|
|
|
|
|
|
|
if (!Exporter::Export(buffer, "dvi", true)) {
|
|
|
|
|
showPrintError(buffer->fileName());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Push directory path.
|
2007-04-06 18:03:29 +00:00
|
|
|
|
string const path(buffer->temppath());
|
|
|
|
|
// Prevent the compiler from optimizing away p
|
|
|
|
|
FileName pp(path);
|
|
|
|
|
support::Path 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 =
|
2006-04-08 22:31:11 +00:00
|
|
|
|
changeExtension(buffer->getLatexName(true),
|
2004-03-28 14:12:33 +00:00
|
|
|
|
"dvi");
|
|
|
|
|
|
|
|
|
|
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");
|
2004-03-28 14:12:33 +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 =
|
|
|
|
|
lyxrc.print_spool_command +' ';
|
|
|
|
|
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
|
|
|
|
|
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-02-01 12:55:57 +00:00
|
|
|
|
FileName const filename(makeAbsPath(target_name, path));
|
|
|
|
|
if (fs::exists(filename.toFilesystemEncoding())) {
|
|
|
|
|
docstring text = bformat(
|
|
|
|
|
_("The file %1$s already exists.\n\n"
|
|
|
|
|
"Do you want to over-write that file?"),
|
|
|
|
|
makeDisplayPath(filename.absFilename()));
|
|
|
|
|
if (Alert::prompt(_("Over-write file?"),
|
2007-02-01 17:30:35 +00:00
|
|
|
|
text, 0, 1, _("&Over-write"), _("&Cancel")) != 0)
|
2007-02-01 12:55:57 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2004-03-28 14:12:33 +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
|
|
|
|
+ ' '
|
2006-04-08 22:31:11 +00:00
|
|
|
|
+ quoteName(dviname);
|
2004-03-28 14:12:33 +00:00
|
|
|
|
res = one.startscript(Systemcall::DontWait,
|
|
|
|
|
command);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (res != 0)
|
|
|
|
|
showPrintError(buffer->fileName());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_IMPORT:
|
2003-11-13 13:43:44 +00:00
|
|
|
|
doImport(argument);
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_LYX_QUIT:
|
2006-12-12 01:39:50 +00:00
|
|
|
|
// quitting is triggered by the gui code
|
|
|
|
|
// (leaving the event loop).
|
2007-01-22 14:43:45 +00:00
|
|
|
|
lyx_view_->message(from_utf8(N_("Exiting.")));
|
2006-12-12 01:39:50 +00:00
|
|
|
|
if (theBufferList().quitWriteAll())
|
|
|
|
|
theApp()->gui().closeAllViews();
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2000-08-01 17:33:32 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_TOC_VIEW: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
InsetCommandParams p("tableofcontents");
|
|
|
|
|
string const data = InsetCommandMailer::params2string("toc", p);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->getDialogs().show("toc", data, 0);
|
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_AUTO_SAVE:
|
2006-04-09 00:26:19 +00:00
|
|
|
|
autoSave(view());
|
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:
|
2006-11-01 13:14:21 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
|
|
|
|
reconfigure(*lyx_view_);
|
2000-07-24 13:53:19 +00:00
|
|
|
|
break;
|
2003-11-13 13:43:44 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_HELP_OPEN: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
string const arg = argument;
|
|
|
|
|
if (arg.empty()) {
|
2007-02-14 19:11:09 +00:00
|
|
|
|
setErrorMessage(from_ascii(N_("Missing argument")));
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2006-12-02 16:07:15 +00:00
|
|
|
|
FileName const fname = i18nLibFileSearch("doc", 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())));
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->loadLyXFile(fname, false);
|
2000-07-24 13:53:19 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
// --- version control -------------------------------
|
|
|
|
|
case LFUN_VC_REGISTER:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
|
2003-11-13 13:43:44 +00:00
|
|
|
|
if (!ensureBufferClean(view()))
|
|
|
|
|
break;
|
2006-10-19 07:28:35 +00:00
|
|
|
|
if (!lyx_view_->buffer()->lyxvc().inUse()) {
|
|
|
|
|
lyx_view_->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:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
|
2003-11-13 13:43:44 +00:00
|
|
|
|
if (!ensureBufferClean(view()))
|
|
|
|
|
break;
|
2006-10-19 07:28:35 +00:00
|
|
|
|
if (lyx_view_->buffer()->lyxvc().inUse()
|
|
|
|
|
&& !lyx_view_->buffer()->isReadonly()) {
|
|
|
|
|
lyx_view_->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:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
|
2003-11-13 13:43:44 +00:00
|
|
|
|
if (!ensureBufferClean(view()))
|
|
|
|
|
break;
|
2006-10-19 07:28:35 +00:00
|
|
|
|
if (lyx_view_->buffer()->lyxvc().inUse()
|
|
|
|
|
&& lyx_view_->buffer()->isReadonly()) {
|
|
|
|
|
lyx_view_->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:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->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:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->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
|
|
|
|
// --- buffers ----------------------------------------
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_SWITCH:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->setBuffer(theBufferList().getBuffer(argument));
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2000-07-24 13:53:19 +00:00
|
|
|
|
|
2006-05-08 18:09:19 +00:00
|
|
|
|
case LFUN_BUFFER_NEXT:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->setBuffer(theBufferList().next(view()->buffer()));
|
2004-10-22 10:24:55 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_PREVIOUS:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->setBuffer(theBufferList().previous(view()->buffer()));
|
2004-10-22 10:24:55 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
case LFUN_FILE_NEW:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2006-04-09 00:26:19 +00:00
|
|
|
|
newFile(view(), argument);
|
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_FILE_OPEN:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
open(argument);
|
|
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
case LFUN_DROP_LAYOUTS_CHOICE:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->getToolbars().openLayoutList();
|
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_MENU_OPEN:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2006-10-21 00:16:43 +00:00
|
|
|
|
lyx_view_->getMenubar().openByName(from_utf8(argument));
|
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 ----------------------------
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_SERVER_GET_NAME:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
|
2006-10-21 00:16:43 +00:00
|
|
|
|
setMessage(from_utf8(lyx_view_->buffer()->fileName()));
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::INFO) << "FNAME["
|
2006-10-19 07:28:35 +00:00
|
|
|
|
<< lyx_view_->buffer()->fileName()
|
2003-11-13 13:43:44 +00:00
|
|
|
|
<< "] " << endl;
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_SERVER_NOTIFY:
|
2007-01-04 17:10:24 +00:00
|
|
|
|
dispatch_buffer = keyseq->print(false);
|
2006-10-21 00:16:43 +00:00
|
|
|
|
theLyXServer().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: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
string file_name;
|
|
|
|
|
int row;
|
|
|
|
|
istringstream is(argument);
|
|
|
|
|
is >> file_name >> row;
|
2007-04-06 13:09:54 +00:00
|
|
|
|
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
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->setBuffer(theBufferList().getBufferFromTmp(file_name));
|
2003-10-14 11:35:50 +00:00
|
|
|
|
} 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
|
2006-12-02 16:07:15 +00:00
|
|
|
|
if (theBufferList().exists(s.absFilename())) {
|
|
|
|
|
lyx_view_->setBuffer(theBufferList().getBuffer(s.absFilename()));
|
2003-11-13 13:43:44 +00:00
|
|
|
|
} else {
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->loadLyXFile(s);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
}
|
2003-10-14 11:35:50 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
view()->setCursorFromRow(row);
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
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
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
case LFUN_DIALOG_SHOW: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2004-01-30 11:41:12 +00:00
|
|
|
|
string const name = cmd.getArg(0);
|
2006-10-21 00:16:43 +00:00
|
|
|
|
string data = trim(to_utf8(cmd.argument()).substr(name.size()));
|
2003-11-13 13:43:44 +00:00
|
|
|
|
|
|
|
|
|
if (name == "character") {
|
|
|
|
|
data = freefont2string();
|
|
|
|
|
if (!data.empty())
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->getDialogs().show("character", data);
|
2006-04-10 16:27:59 +00:00
|
|
|
|
} else if (name == "latexlog") {
|
2003-12-05 13:37:23 +00:00
|
|
|
|
pair<Buffer::LogType, string> const logfile =
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->buffer()->getLogName();
|
2003-12-05 13:37:23 +00:00
|
|
|
|
switch (logfile.first) {
|
|
|
|
|
case Buffer::latexlog:
|
|
|
|
|
data = "latex ";
|
|
|
|
|
break;
|
|
|
|
|
case Buffer::buildlog:
|
|
|
|
|
data = "literate ";
|
|
|
|
|
break;
|
|
|
|
|
}
|
2006-08-12 10:39:12 +00:00
|
|
|
|
data += LyXLex::quoteString(logfile.second);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->getDialogs().show("log", data);
|
2006-04-10 16:27:59 +00:00
|
|
|
|
} else if (name == "vclog") {
|
2003-12-05 13:37:23 +00:00
|
|
|
|
string const data = "vc " +
|
2006-10-19 07:28:35 +00:00
|
|
|
|
LyXLex::quoteString(lyx_view_->buffer()->lyxvc().getLogFile());
|
|
|
|
|
lyx_view_->getDialogs().show("log", data);
|
2006-04-10 16:27:59 +00:00
|
|
|
|
} else
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->getDialogs().show(name, data);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2003-02-25 14:51:38 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
case LFUN_DIALOG_SHOW_NEW_INSET: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2004-01-30 11:41:12 +00:00
|
|
|
|
string const name = cmd.getArg(0);
|
2006-10-21 00:16:43 +00:00
|
|
|
|
string data = trim(to_utf8(cmd.argument()).substr(name.size()));
|
2003-11-13 13:43:44 +00:00
|
|
|
|
if (name == "bibitem" ||
|
2003-12-10 22:10:38 +00:00
|
|
|
|
name == "bibtex" ||
|
|
|
|
|
name == "index" ||
|
|
|
|
|
name == "label" ||
|
2006-11-04 17:55:36 +00:00
|
|
|
|
name == "nomenclature" ||
|
2003-12-10 22:10:38 +00:00
|
|
|
|
name == "ref" ||
|
|
|
|
|
name == "toc" ||
|
|
|
|
|
name == "url") {
|
2003-11-13 13:43:44 +00:00
|
|
|
|
InsetCommandParams p(name);
|
|
|
|
|
data = InsetCommandMailer::params2string(name, p);
|
2005-08-02 22:31:56 +00:00
|
|
|
|
} else if (name == "include") {
|
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";
|
2005-08-02 22:31:56 +00:00
|
|
|
|
InsetCommandParams p(data);
|
|
|
|
|
data = InsetIncludeMailer::params2string(p);
|
2003-12-10 22:10:38 +00:00
|
|
|
|
} else if (name == "box") {
|
|
|
|
|
// \c data == "Boxed" || "Frameless" etc
|
|
|
|
|
InsetBoxParams p(data);
|
|
|
|
|
data = InsetBoxMailer::params2string(p);
|
|
|
|
|
} else if (name == "branch") {
|
|
|
|
|
InsetBranchParams p;
|
|
|
|
|
data = InsetBranchMailer::params2string(p);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
} else if (name == "citation") {
|
|
|
|
|
InsetCommandParams p("cite");
|
|
|
|
|
data = InsetCommandMailer::params2string(name, p);
|
2003-12-10 22:10:38 +00:00
|
|
|
|
} else if (name == "ert") {
|
|
|
|
|
data = InsetERTMailer::params2string(InsetCollapsable::Open);
|
|
|
|
|
} else if (name == "external") {
|
|
|
|
|
InsetExternalParams p;
|
2006-10-19 07:28:35 +00:00
|
|
|
|
Buffer const & buffer = *lyx_view_->buffer();
|
2003-12-10 22:10:38 +00:00
|
|
|
|
data = InsetExternalMailer::params2string(p, buffer);
|
|
|
|
|
} else if (name == "float") {
|
|
|
|
|
InsetFloatParams p;
|
|
|
|
|
data = InsetFloatMailer::params2string(p);
|
|
|
|
|
} else if (name == "graphics") {
|
|
|
|
|
InsetGraphicsParams p;
|
2006-10-19 07:28:35 +00:00
|
|
|
|
Buffer const & buffer = *lyx_view_->buffer();
|
2003-12-10 22:10:38 +00:00
|
|
|
|
data = InsetGraphicsMailer::params2string(p, buffer);
|
|
|
|
|
} else if (name == "note") {
|
|
|
|
|
InsetNoteParams p;
|
|
|
|
|
data = InsetNoteMailer::params2string(p);
|
2003-11-28 15:53:34 +00:00
|
|
|
|
} else if (name == "vspace") {
|
|
|
|
|
VSpace space;
|
|
|
|
|
data = InsetVSpaceMailer::params2string(space);
|
2003-12-10 22:10:38 +00:00
|
|
|
|
} else if (name == "wrap") {
|
|
|
|
|
InsetWrapParams p;
|
|
|
|
|
data = InsetWrapMailer::params2string(p);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
}
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->getDialogs().show(name, data, 0);
|
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_DIALOG_UPDATE: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
string const & name = argument;
|
|
|
|
|
// Can only update a dialog connected to an existing inset
|
2006-10-19 07:28:35 +00:00
|
|
|
|
InsetBase * inset = lyx_view_->getDialogs().getOpenInset(name);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
if (inset) {
|
2006-09-01 15:41:38 +00:00
|
|
|
|
FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument());
|
2004-01-20 14:25:24 +00:00
|
|
|
|
inset->dispatch(view()->cursor(), fr);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
} else if (name == "paragraph") {
|
|
|
|
|
dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
|
2004-04-05 18:34:36 +00:00
|
|
|
|
} else if (name == "prefs") {
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->getDialogs().update(name, string());
|
2003-11-13 13:43:44 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
case LFUN_DIALOG_HIDE:
|
|
|
|
|
Dialogs::hide(argument, 0);
|
|
|
|
|
break;
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
case LFUN_DIALOG_DISCONNECT_INSET:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->getDialogs().disconnect(argument);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
2006-04-05 23:56:29 +00:00
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_CITATION_INSERT: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(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-04-05 13:49:01 +00:00
|
|
|
|
InsetCommandParams icp("cite");
|
|
|
|
|
icp["key"] = from_utf8(arg);
|
|
|
|
|
if (!opt1.empty())
|
|
|
|
|
icp["before"] = from_utf8(opt1);
|
|
|
|
|
string icstr = InsetCommandMailer::params2string("citation", icp);
|
|
|
|
|
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: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2006-12-27 10:56:11 +00:00
|
|
|
|
FileName const filename =
|
2006-10-19 07:28:35 +00:00
|
|
|
|
makeAbsPath(argument, lyx_view_->buffer()->filePath());
|
2007-02-14 19:11:09 +00:00
|
|
|
|
setMessage(bformat(_("Opening child document %1$s..."),
|
|
|
|
|
makeDisplayPath(filename.absFilename())));
|
2006-11-01 15:55:17 +00:00
|
|
|
|
view()->saveBookmark(false);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
string const parentfilename = lyx_view_->buffer()->fileName();
|
2006-12-27 10:56:11 +00:00
|
|
|
|
if (theBufferList().exists(filename.absFilename()))
|
|
|
|
|
lyx_view_->setBuffer(theBufferList().getBuffer(filename.absFilename()));
|
2003-11-13 13:43:44 +00:00
|
|
|
|
else
|
2006-12-27 10:56:11 +00:00
|
|
|
|
lyx_view_->loadLyXFile(filename);
|
2003-11-24 20:48:21 +00:00
|
|
|
|
// 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.
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->buffer()->setParentName(parentfilename);
|
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_TOGGLE_CURSOR_FOLLOWS_SCROLLBAR:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(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:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_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:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_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:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_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:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_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;
|
2004-03-18 12:53:43 +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;
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
break;
|
2004-05-04 14:12:50 +00:00
|
|
|
|
}
|
2000-08-14 05:24:35 +00:00
|
|
|
|
|
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-04-06 13:09:54 +00:00
|
|
|
|
package().user_support().absFilename()),
|
2006-11-29 21:47:37 +00:00
|
|
|
|
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_SCREEN_FONT_UPDATE:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
// handle the screen font changes.
|
2006-10-11 17:24:46 +00:00
|
|
|
|
theFontLoader().update();
|
2007-01-15 15:51:45 +00:00
|
|
|
|
/// FIXME: only the current view will be updated. the Gui
|
|
|
|
|
/// class is able to furnish the list of views.
|
|
|
|
|
updateFlags = Update::Force;
|
2000-06-26 15:33:13 +00:00
|
|
|
|
break;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
case LFUN_SET_COLOR: {
|
|
|
|
|
string lyx_name;
|
|
|
|
|
string const x11_name = split(argument, lyx_name, ' ');
|
|
|
|
|
if (lyx_name.empty() || x11_name.empty()) {
|
2007-02-14 19:11:09 +00:00
|
|
|
|
setErrorMessage(from_ascii(N_(
|
|
|
|
|
"Syntax: set-color <lyx_name>"
|
|
|
|
|
" <x11_name>")));
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool const graphicsbg_changed =
|
|
|
|
|
(lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
|
|
|
|
|
x11_name != lcolor.getX11Name(LColor::graphicsbg));
|
|
|
|
|
|
2004-03-25 15:51:21 +00:00
|
|
|
|
if (!lcolor.setColor(lyx_name, x11_name)) {
|
2003-11-13 13:43:44 +00:00
|
|
|
|
setErrorMessage(
|
2006-09-11 08:54:10 +00:00
|
|
|
|
bformat(_("Set-color \"%1$s\" failed "
|
2006-09-09 15:27:44 +00:00
|
|
|
|
"- color is undefined or "
|
2006-09-11 08:54:10 +00:00
|
|
|
|
"may not be redefined"),
|
2006-10-21 00:16:43 +00:00
|
|
|
|
from_utf8(lyx_name)));
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-30 00:04:51 +00:00
|
|
|
|
theApp()->updateColor(lcolor.getFromLyXName(lyx_name));
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
if (graphicsbg_changed) {
|
2002-06-25 15:59:10 +00:00
|
|
|
|
#ifdef WITH_WARNINGS
|
|
|
|
|
#warning FIXME!! The graphics cache no longer has a changeDisplay method.
|
|
|
|
|
#endif
|
|
|
|
|
#if 0
|
2006-10-21 00:16:43 +00:00
|
|
|
|
graphics::GCache::get().changeDisplay(true);
|
2002-06-25 15:59:10 +00:00
|
|
|
|
#endif
|
2003-11-13 13:43:44 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-11-13 13:43:44 +00:00
|
|
|
|
case LFUN_MESSAGE:
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(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
|
|
|
|
|
2004-03-18 12:53:43 +00:00
|
|
|
|
case LFUN_EXTERNAL_EDIT: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2004-03-18 12:53:43 +00:00
|
|
|
|
FuncRequest fr(action, argument);
|
|
|
|
|
InsetExternal().dispatch(view()->cursor(), fr);
|
2003-11-13 13:43:44 +00:00
|
|
|
|
break;
|
2004-03-18 12:53:43 +00:00
|
|
|
|
}
|
2003-06-11 11:01:34 +00:00
|
|
|
|
|
2004-04-13 10:36:09 +00:00
|
|
|
|
case LFUN_GRAPHICS_EDIT: {
|
|
|
|
|
FuncRequest fr(action, argument);
|
|
|
|
|
InsetGraphics().dispatch(view()->cursor(), fr);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-13 09:43:58 +00:00
|
|
|
|
case LFUN_INSET_APPLY: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2005-04-13 09:43:58 +00:00
|
|
|
|
string const name = cmd.getArg(0);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
InsetBase * inset = lyx_view_->getDialogs().getOpenInset(name);
|
2005-04-13 09:43:58 +00:00
|
|
|
|
if (inset) {
|
|
|
|
|
FuncRequest fr(LFUN_INSET_MODIFY, argument);
|
|
|
|
|
inset->dispatch(view()->cursor(), fr);
|
|
|
|
|
} else {
|
|
|
|
|
FuncRequest fr(LFUN_INSET_INSERT, argument);
|
|
|
|
|
dispatch(fr);
|
|
|
|
|
}
|
2005-05-06 12:15:36 +00:00
|
|
|
|
// ideally, the update flag should be set by the insets,
|
|
|
|
|
// but this is not possible currently
|
2006-10-22 11:46:36 +00:00
|
|
|
|
updateFlags = Update::Force | Update::FitCursor;
|
2005-04-13 09:43:58 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-30 12:36:33 +00:00
|
|
|
|
case LFUN_ALL_INSETS_TOGGLE: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2004-03-30 12:36:33 +00:00
|
|
|
|
string action;
|
|
|
|
|
string const name = split(argument, action, ' ');
|
|
|
|
|
InsetBase::Code const inset_code =
|
|
|
|
|
InsetBase::translate(name);
|
|
|
|
|
|
|
|
|
|
LCursor & cur = view()->cursor();
|
|
|
|
|
FuncRequest fr(LFUN_INSET_TOGGLE, action);
|
|
|
|
|
|
2006-10-19 07:28:35 +00:00
|
|
|
|
InsetBase & inset = lyx_view_->buffer()->inset();
|
2004-03-30 12:36:33 +00:00
|
|
|
|
InsetIterator it = inset_iterator_begin(inset);
|
|
|
|
|
InsetIterator const end = inset_iterator_end(inset);
|
|
|
|
|
for (; it != end; ++it) {
|
2007-04-09 09:31:56 +00:00
|
|
|
|
if (!it->asInsetMath()
|
|
|
|
|
&& (inset_code == InsetBase::NO_CODE
|
|
|
|
|
|| inset_code == it->lyxCode())) {
|
2005-10-24 09:42:20 +00:00
|
|
|
|
LCursor tmpcur = cur;
|
|
|
|
|
tmpcur.pushLeft(*it);
|
|
|
|
|
it->dispatch(tmpcur, fr);
|
|
|
|
|
}
|
2004-03-30 12:36:33 +00:00
|
|
|
|
}
|
2006-10-22 11:46:36 +00:00
|
|
|
|
updateFlags = Update::Force | Update::FitCursor;
|
2004-03-30 12:36:33 +00:00
|
|
|
|
break;
|
2004-03-25 09:16:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BUFFER_LANGUAGE: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
Buffer & buffer = *lyx_view_->buffer();
|
2004-03-30 16:19:50 +00:00
|
|
|
|
Language const * oldL = buffer.params().language;
|
|
|
|
|
Language const * newL = languages.getLanguage(argument);
|
|
|
|
|
if (!newL || oldL == newL)
|
|
|
|
|
break;
|
|
|
|
|
|
2006-04-09 00:26:19 +00:00
|
|
|
|
if (oldL->rightToLeft() == newL->rightToLeft()
|
2004-03-30 16:19:50 +00:00
|
|
|
|
&& !buffer.isMultiLingual())
|
|
|
|
|
buffer.changeLanguage(oldL, newL);
|
|
|
|
|
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);
|
|
|
|
|
LyXLex lex(0,0);
|
|
|
|
|
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
|
|
|
|
|
2006-11-30 16:59:50 +00:00
|
|
|
|
if (defaults.writeFile(FileName(defaults.fileName())))
|
2007-02-14 19:11:09 +00:00
|
|
|
|
setMessage(bformat(_("Document defaults saved in %1$s"),
|
|
|
|
|
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: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2004-05-17 08:52:21 +00:00
|
|
|
|
biblio::CiteEngine const engine =
|
2007-03-25 01:12:38 +00:00
|
|
|
|
lyx_view_->buffer()->params().getEngine();
|
2004-05-17 08:52:21 +00:00
|
|
|
|
|
2004-03-30 16:19:50 +00:00
|
|
|
|
istringstream ss(argument);
|
|
|
|
|
LyXLex lex(0,0);
|
|
|
|
|
lex.setStream(ss);
|
|
|
|
|
int const unknown_tokens =
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->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"
|
2004-03-30 16:19:50 +00:00
|
|
|
|
<< unknown_tokens << " unknown token"
|
|
|
|
|
<< (unknown_tokens == 1 ? "" : "s")
|
|
|
|
|
<< endl;
|
|
|
|
|
}
|
2007-03-25 01:12:38 +00:00
|
|
|
|
if (engine == lyx_view_->buffer()->params().getEngine())
|
2004-05-17 08:52:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
LCursor & cur = view()->cursor();
|
|
|
|
|
FuncRequest fr(LFUN_INSET_REFRESH);
|
|
|
|
|
|
2006-10-19 07:28:35 +00:00
|
|
|
|
InsetBase & inset = lyx_view_->buffer()->inset();
|
2004-05-17 08:52:21 +00:00
|
|
|
|
InsetIterator it = inset_iterator_begin(inset);
|
|
|
|
|
InsetIterator const end = inset_iterator_end(inset);
|
|
|
|
|
for (; it != end; ++it)
|
|
|
|
|
if (it->lyxCode() == InsetBase::CITE_CODE)
|
|
|
|
|
it->dispatch(cur, fr);
|
2004-03-30 16:19:50 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case LFUN_TEXTCLASS_APPLY: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
Buffer * buffer = lyx_view_->buffer();
|
2004-03-30 16:19:50 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
textclass_type const old_class =
|
2004-03-30 16:19:50 +00:00
|
|
|
|
buffer->params().textclass;
|
|
|
|
|
|
2004-03-31 09:44:40 +00:00
|
|
|
|
loadTextclass(argument);
|
2004-03-30 16:19:50 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
std::pair<bool, textclass_type> const tc_pair =
|
2006-04-09 00:26:19 +00:00
|
|
|
|
textclasslist.numberOfClass(argument);
|
2004-03-30 16:19:50 +00:00
|
|
|
|
|
|
|
|
|
if (!tc_pair.first)
|
|
|
|
|
break;
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
textclass_type const new_class = tc_pair.second;
|
2004-03-30 16:19:50 +00:00
|
|
|
|
if (old_class == new_class)
|
|
|
|
|
// nothing to do
|
|
|
|
|
break;
|
|
|
|
|
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->message(_("Converting document to new document class..."));
|
2005-09-19 09:55:49 +00:00
|
|
|
|
recordUndoFullDocument(view());
|
|
|
|
|
buffer->params().textclass = new_class;
|
2005-07-15 17:45:36 +00:00
|
|
|
|
StableDocIterator backcur(view()->cursor());
|
2006-08-13 16:16:43 +00:00
|
|
|
|
ErrorList & el = buffer->errorList("Class Switch");
|
2006-10-21 00:16:43 +00:00
|
|
|
|
cap::switchBetweenClasses(
|
2004-03-30 16:19:50 +00:00
|
|
|
|
old_class, new_class,
|
2006-05-21 17:33:03 +00:00
|
|
|
|
static_cast<InsetText &>(buffer->inset()), el);
|
2004-03-30 16:19:50 +00:00
|
|
|
|
|
2005-07-15 17:45:36 +00:00
|
|
|
|
view()->setCursor(backcur.asDocIterator(&(buffer->inset())));
|
2006-08-13 16:16:43 +00:00
|
|
|
|
|
|
|
|
|
buffer->errors("Class Switch");
|
2006-04-16 14:19:25 +00:00
|
|
|
|
updateLabels(*buffer);
|
2006-10-22 11:46:36 +00:00
|
|
|
|
updateFlags = Update::Force | Update::FitCursor;
|
2004-03-30 16:19:50 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-31 09:44:40 +00:00
|
|
|
|
case LFUN_TEXTCLASS_LOAD:
|
|
|
|
|
loadTextclass(argument);
|
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
|
|
|
|
|
|
|
|
|
/// 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
|
|
|
|
|
2006-10-21 09:45:11 +00:00
|
|
|
|
case LFUN_WINDOW_NEW:
|
|
|
|
|
LyX::ref().newLyXView();
|
2006-10-23 16:29:24 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_WINDOW_CLOSE:
|
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2006-11-30 08:42:29 +00:00
|
|
|
|
BOOST_ASSERT(theApp());
|
2007-01-11 16:01:10 +00:00
|
|
|
|
// update bookmark pit of the current buffer before window close
|
|
|
|
|
for (size_t i = 0; i < LyX::ref().session().bookmarks().size(); ++i)
|
|
|
|
|
gotoBookmark(i+1, false, false);
|
2006-12-12 01:39:50 +00:00
|
|
|
|
// ask the user for saving changes or cancel quit
|
|
|
|
|
if (!theBufferList().quitWriteAll())
|
|
|
|
|
break;
|
2006-10-23 16:29:24 +00:00
|
|
|
|
lyx_view_->close();
|
|
|
|
|
return;
|
2006-10-21 09:45:11 +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);
|
2006-11-01 15:55:17 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_BOOKMARK_CLEAR:
|
|
|
|
|
LyX::ref().session().bookmarks().clear();
|
|
|
|
|
break;
|
|
|
|
|
|
2006-11-02 16:01:36 +00:00
|
|
|
|
case LFUN_TOOLBAR_TOGGLE_STATE:
|
|
|
|
|
lyx_view_->toggleToolbarState(argument);
|
|
|
|
|
break;
|
|
|
|
|
|
2004-03-18 12:53:43 +00:00
|
|
|
|
default: {
|
2006-10-23 16:29:24 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
2004-08-13 14:56:06 +00:00
|
|
|
|
view()->cursor().dispatch(cmd);
|
2006-10-22 11:46:36 +00:00
|
|
|
|
updateFlags = view()->cursor().result().update();
|
2005-07-14 17:30:24 +00:00
|
|
|
|
if (!view()->cursor().result().dispatched())
|
2007-01-24 23:10:03 +00:00
|
|
|
|
updateFlags = view()->dispatch(cmd);
|
2004-01-15 17:34:44 +00:00
|
|
|
|
break;
|
2003-11-10 09:06:48 +00:00
|
|
|
|
}
|
2004-03-18 12:53:43 +00:00
|
|
|
|
}
|
2001-02-23 16:10:03 +00:00
|
|
|
|
|
2006-10-23 16:29:24 +00:00
|
|
|
|
if (lyx_view_ && 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.
|
|
|
|
|
if (view()->update(updateFlags)) {
|
2006-11-21 09:04:54 +00:00
|
|
|
|
// Buffer::changed() signals that a repaint is needed.
|
|
|
|
|
// The frontend (WorkArea) knows which area to repaint
|
|
|
|
|
// thanks to the ViewMetricsInfo updated above.
|
2006-11-20 14:42:18 +00:00
|
|
|
|
view()->buffer()->changed();
|
2006-12-07 11:46:27 +00:00
|
|
|
|
}
|
2004-11-30 01:59:49 +00:00
|
|
|
|
|
2006-10-22 17:21:00 +00:00
|
|
|
|
lyx_view_->updateStatusBar();
|
2006-07-13 16:37:55 +00:00
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
// if we executed a mutating lfun, mark the buffer as dirty
|
2005-12-23 12:19:56 +00:00
|
|
|
|
if (flag.enabled()
|
2007-01-29 20:06:08 +00:00
|
|
|
|
&& !lyxaction.funcHasFlag(action, LyXAction::NoBuffer)
|
|
|
|
|
&& !lyxaction.funcHasFlag(action, LyXAction::ReadOnly))
|
2004-03-25 09:16:36 +00:00
|
|
|
|
view()->buffer()->markDirty();
|
2003-03-19 18:43:56 +00:00
|
|
|
|
|
2006-08-23 08:27:51 +00:00
|
|
|
|
if (view()->cursor().inTexted()) {
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->updateLayoutChoice();
|
2006-08-23 08:27:51 +00:00
|
|
|
|
}
|
2004-03-25 09:16:36 +00:00
|
|
|
|
}
|
2004-03-18 12:53:43 +00:00
|
|
|
|
}
|
2006-11-09 14:56:57 +00:00
|
|
|
|
if (!quitting) {
|
|
|
|
|
lyx_view_->updateMenubar();
|
|
|
|
|
lyx_view_->updateToolbars();
|
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-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::ACTION) << "dispatch msg is " << to_utf8(msg) << endl;
|
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
|
|
|
|
|
2006-12-22 09:23:10 +00:00
|
|
|
|
docstring const shortcuts = theTopLevelKeymap().printbindings(cmd);
|
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-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::ACTION) << "verbose dispatch msg "
|
2006-10-21 00:16:43 +00:00
|
|
|
|
<< to_utf8(dispatch_msg) << endl;
|
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
|
|
|
|
|
2002-07-11 15:13:21 +00:00
|
|
|
|
void LyXFunc::menuNew(string const & name, bool fromTemplate)
|
1999-12-16 06:43:25 +00:00
|
|
|
|
{
|
2006-12-02 16:07:15 +00:00
|
|
|
|
// FIXME: initpath is not used. What to do?
|
2000-10-11 21:06:43 +00:00
|
|
|
|
string initpath = lyxrc.document_path;
|
2002-07-11 15:13:21 +00:00
|
|
|
|
string filename(name);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-09-16 14:00:13 +00:00
|
|
|
|
if (view()->buffer()) {
|
2006-10-19 07:28:35 +00:00
|
|
|
|
string const trypath = lyx_view_->buffer()->filePath();
|
1999-12-16 06:43:25 +00:00
|
|
|
|
// If directory is writeable, use this as default.
|
2006-12-27 10:56:11 +00:00
|
|
|
|
if (isDirWriteable(FileName(trypath)))
|
1999-12-16 06:43:25 +00:00
|
|
|
|
initpath = trypath;
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-06-04 23:57:32 +00:00
|
|
|
|
static int newfile_number;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-07-11 15:13:21 +00:00
|
|
|
|
if (filename.empty()) {
|
2006-04-08 22:31:11 +00:00
|
|
|
|
filename = addName(lyxrc.document_path,
|
2005-01-06 15:40:49 +00:00
|
|
|
|
"newfile" + convert<string>(++newfile_number) + ".lyx");
|
2006-12-05 12:57:01 +00:00
|
|
|
|
while (theBufferList().exists(filename) ||
|
|
|
|
|
fs::is_readable(FileName(filename).toFilesystemEncoding())) {
|
2000-08-08 11:08:07 +00:00
|
|
|
|
++newfile_number;
|
2006-04-08 22:31:11 +00:00
|
|
|
|
filename = addName(lyxrc.document_path,
|
2005-01-06 15:40:49 +00:00
|
|
|
|
"newfile" + convert<string>(newfile_number) +
|
2000-10-02 16:44:47 +00:00
|
|
|
|
".lyx");
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
1999-12-16 06:43:25 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
|
// The template stuff
|
|
|
|
|
string templname;
|
|
|
|
|
if (fromTemplate) {
|
2006-10-09 16:33:20 +00:00
|
|
|
|
FileDialog fileDlg(_("Select template file"),
|
2001-03-07 14:25:31 +00:00
|
|
|
|
LFUN_SELECT_FILE_SYNC,
|
2006-10-21 00:16:43 +00:00
|
|
|
|
make_pair(_("Documents|#o#O"), from_utf8(lyxrc.document_path)),
|
|
|
|
|
make_pair(_("Templates|#T#t"), from_utf8(lyxrc.template_path)));
|
2001-04-17 15:15:59 +00:00
|
|
|
|
|
|
|
|
|
FileDialog::Result result =
|
2006-10-21 00:16:43 +00:00
|
|
|
|
fileDlg.open(from_utf8(lyxrc.template_path),
|
2006-10-09 16:33:20 +00:00
|
|
|
|
FileFilterList(_("LyX Documents (*.lyx)")),
|
|
|
|
|
docstring());
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
|
return;
|
2003-11-13 13:43:44 +00:00
|
|
|
|
if (result.second.empty())
|
2001-03-07 14:25:31 +00:00
|
|
|
|
return;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
templname = to_utf8(result.second);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-07-17 15:13:49 +00:00
|
|
|
|
Buffer * const b = newFile(filename, templname, !name.empty());
|
2007-03-12 11:30:48 +00:00
|
|
|
|
if (b) {
|
|
|
|
|
updateLabels(*b);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->setBuffer(b);
|
2007-03-12 11:30:48 +00:00
|
|
|
|
}
|
1999-12-16 06:43:25 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2001-07-16 15:42:57 +00:00
|
|
|
|
void LyXFunc::open(string const & fname)
|
1999-12-16 06:43:25 +00:00
|
|
|
|
{
|
2000-03-12 10:35:05 +00:00
|
|
|
|
string initpath = lyxrc.document_path;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-09-16 14:00:13 +00:00
|
|
|
|
if (view()->buffer()) {
|
2006-10-19 07:28:35 +00:00
|
|
|
|
string const trypath = lyx_view_->buffer()->filePath();
|
1999-12-16 06:43:25 +00:00
|
|
|
|
// If directory is writeable, use this as default.
|
2006-12-27 10:56:11 +00:00
|
|
|
|
if (isDirWriteable(FileName(trypath)))
|
1999-12-16 06:43:25 +00:00
|
|
|
|
initpath = trypath;
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
|
string filename;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
|
if (fname.empty()) {
|
2006-10-09 16:33:20 +00:00
|
|
|
|
FileDialog fileDlg(_("Select document to open"),
|
2001-03-07 14:25:31 +00:00
|
|
|
|
LFUN_FILE_OPEN,
|
2006-10-21 00:16:43 +00:00
|
|
|
|
make_pair(_("Documents|#o#O"), from_utf8(lyxrc.document_path)),
|
2007-04-06 13:09:54 +00:00
|
|
|
|
make_pair(_("Examples|#E#e"), from_utf8(addPath(package().system_support().absFilename(), "examples"))));
|
2001-04-17 15:15:59 +00:00
|
|
|
|
|
|
|
|
|
FileDialog::Result result =
|
2006-10-21 00:16:43 +00:00
|
|
|
|
fileDlg.open(from_utf8(initpath),
|
2006-10-09 16:33:20 +00:00
|
|
|
|
FileFilterList(_("LyX Documents (*.lyx)")),
|
|
|
|
|
docstring());
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
|
return;
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
filename = to_utf8(result.second);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
|
// check selected filename
|
|
|
|
|
if (filename.empty()) {
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->message(_("Canceled."));
|
2001-03-07 14:25:31 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
filename = fname;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
|
// get absolute path of file and add ".lyx" to the filename if
|
|
|
|
|
// necessary
|
2006-11-30 16:59:50 +00:00
|
|
|
|
FileName const fullname = fileSearch(string(), filename, "lyx");
|
2006-12-02 16:07:15 +00:00
|
|
|
|
if (!fullname.empty())
|
|
|
|
|
filename = fullname.absFilename();
|
2001-06-14 17:58:49 +00:00
|
|
|
|
|
2002-08-01 22:26:30 +00:00
|
|
|
|
// if the file doesn't exist, let the user create one
|
2006-11-30 16:59:50 +00:00
|
|
|
|
if (!fs::exists(fullname.toFilesystemEncoding())) {
|
2006-07-13 16:37:55 +00:00
|
|
|
|
// the user specifically chose this name. Believe him.
|
2006-07-17 15:13:49 +00:00
|
|
|
|
Buffer * const b = newFile(filename, string(), true);
|
|
|
|
|
if (b)
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->setBuffer(b);
|
2002-08-01 22:26:30 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-02 16:07:15 +00:00
|
|
|
|
docstring const disp_fn = makeDisplayPath(filename);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->message(bformat(_("Opening document %1$s..."), disp_fn));
|
2001-06-14 17:58:49 +00:00
|
|
|
|
|
2006-09-11 08:54:10 +00:00
|
|
|
|
docstring str2;
|
2006-12-02 16:07:15 +00:00
|
|
|
|
if (lyx_view_->loadLyXFile(fullname)) {
|
2006-09-11 08:54:10 +00:00
|
|
|
|
str2 = bformat(_("Document %1$s opened."), disp_fn);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
} else {
|
2006-09-11 08:54:10 +00:00
|
|
|
|
str2 = bformat(_("Could not open document %1$s"), disp_fn);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->message(str2);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
|
|
2000-10-23 12:16:05 +00:00
|
|
|
|
void LyXFunc::doImport(string const & argument)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2000-10-23 12:16:05 +00:00
|
|
|
|
string format;
|
|
|
|
|
string filename = split(argument, format, ' ');
|
2002-05-30 19:49:00 +00:00
|
|
|
|
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::INFO) << "LyXFunc::doImport: " << format
|
2001-06-27 14:10:35 +00:00
|
|
|
|
<< " file: " << filename << endl;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
2002-05-30 19:49:00 +00:00
|
|
|
|
// need user interaction
|
|
|
|
|
if (filename.empty()) {
|
2000-04-28 11:18:04 +00:00
|
|
|
|
string initpath = lyxrc.document_path;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-09-16 14:00:13 +00:00
|
|
|
|
if (view()->buffer()) {
|
2006-10-19 07:28:35 +00:00
|
|
|
|
string const trypath = lyx_view_->buffer()->filePath();
|
2000-04-28 11:18:04 +00:00
|
|
|
|
// If directory is writeable, use this as default.
|
2006-12-27 10:56:11 +00:00
|
|
|
|
if (isDirWriteable(FileName(trypath)))
|
2000-04-28 11:18:04 +00:00
|
|
|
|
initpath = trypath;
|
|
|
|
|
}
|
|
|
|
|
|
2006-09-11 08:54:10 +00:00
|
|
|
|
docstring const text = bformat(_("Select %1$s file to import"),
|
2003-05-13 09:48:57 +00:00
|
|
|
|
formats.prettyName(format));
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
2006-10-09 16:33:20 +00:00
|
|
|
|
FileDialog fileDlg(text,
|
2006-05-05 20:23:12 +00:00
|
|
|
|
LFUN_BUFFER_IMPORT,
|
2006-10-21 00:16:43 +00:00
|
|
|
|
make_pair(_("Documents|#o#O"), from_utf8(lyxrc.document_path)),
|
2006-10-09 16:33:20 +00:00
|
|
|
|
make_pair(_("Examples|#E#e"),
|
2007-04-06 13:09:54 +00:00
|
|
|
|
from_utf8(addPath(package().system_support().absFilename(), "examples"))));
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-10-09 16:33:20 +00:00
|
|
|
|
docstring filter = formats.prettyName(format);
|
|
|
|
|
filter += " (*.";
|
|
|
|
|
// FIXME UNICODE
|
2006-10-21 00:16:43 +00:00
|
|
|
|
filter += from_utf8(formats.extension(format));
|
2006-10-09 16:33:20 +00:00
|
|
|
|
filter += ')';
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
2004-01-08 10:59:51 +00:00
|
|
|
|
FileDialog::Result result =
|
2006-10-21 00:16:43 +00:00
|
|
|
|
fileDlg.open(from_utf8(initpath),
|
2004-01-08 10:59:51 +00:00
|
|
|
|
FileFilterList(filter),
|
2006-10-09 16:33:20 +00:00
|
|
|
|
docstring());
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
|
return;
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
filename = to_utf8(result.second);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2000-04-28 11:18:04 +00:00
|
|
|
|
// check selected filename
|
2001-04-17 15:15:59 +00:00
|
|
|
|
if (filename.empty())
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->message(_("Canceled."));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
if (filename.empty())
|
2000-04-28 11:18:04 +00:00
|
|
|
|
return;
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// get absolute path of file
|
2006-12-02 16:07:15 +00:00
|
|
|
|
FileName const fullname(makeAbsPath(filename));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-12-02 16:07:15 +00:00
|
|
|
|
FileName const lyxfile(changeExtension(fullname.absFilename(), ".lyx"));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// Check if the document already is open
|
2006-12-02 16:07:15 +00:00
|
|
|
|
if (use_gui && theBufferList().exists(lyxfile.absFilename())) {
|
|
|
|
|
if (!theBufferList().close(theBufferList().getBuffer(lyxfile.absFilename()), true)) {
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->message(_("Canceled."));
|
2003-03-29 07:09:13 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
|
// if the file exists already, and we didn't do
|
2002-05-30 19:49:00 +00:00
|
|
|
|
// -i lyx thefile.lyx, warn
|
2006-12-02 16:07:15 +00:00
|
|
|
|
if (fs::exists(lyxfile.toFilesystemEncoding()) && fullname != lyxfile) {
|
|
|
|
|
docstring const file = makeDisplayPath(lyxfile.absFilename(), 30);
|
2003-03-29 07:09:13 +00:00
|
|
|
|
|
2006-09-11 08:54:10 +00:00
|
|
|
|
docstring text = bformat(_("The document %1$s already exists.\n\n"
|
|
|
|
|
"Do you want to over-write that document?"), file);
|
|
|
|
|
int const ret = Alert::prompt(_("Over-write document?"),
|
|
|
|
|
text, 0, 1, _("&Over-write"), _("&Cancel"));
|
2003-03-29 07:09:13 +00:00
|
|
|
|
|
|
|
|
|
if (ret == 1) {
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->message(_("Canceled."));
|
2002-05-30 19:49:00 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-08-13 16:16:43 +00:00
|
|
|
|
ErrorList errorList;
|
2006-12-02 16:07:15 +00:00
|
|
|
|
Importer::Import(lyx_view_, fullname, format, errorList);
|
2006-08-13 16:16:43 +00:00
|
|
|
|
// FIXME (Abdel 12/08/06): Is there a need to display the error list here?
|
2000-03-20 18:55:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-07-16 15:42:57 +00:00
|
|
|
|
void LyXFunc::closeBuffer()
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2007-01-11 16:01:10 +00:00
|
|
|
|
// goto bookmark to update bookmark pit.
|
|
|
|
|
for (size_t i = 0; i < LyX::ref().session().bookmarks().size(); ++i)
|
|
|
|
|
gotoBookmark(i+1, false, false);
|
2006-10-19 07:28:35 +00:00
|
|
|
|
if (theBufferList().close(lyx_view_->buffer(), true) && !quitting) {
|
2006-10-11 17:24:46 +00:00
|
|
|
|
if (theBufferList().empty()) {
|
2003-07-25 17:11:25 +00:00
|
|
|
|
// need this otherwise SEGV may occur while
|
2003-07-11 12:21:31 +00:00
|
|
|
|
// trying to set variables that don't exist
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// since there's no current buffer
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->getDialogs().hideBufferDependent();
|
2000-11-14 02:01:57 +00:00
|
|
|
|
} else {
|
2006-10-19 07:28:35 +00:00
|
|
|
|
lyx_view_->setBuffer(theBufferList().first());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-01-17 14:46:20 +00:00
|
|
|
|
void LyXFunc::reloadBuffer()
|
|
|
|
|
{
|
|
|
|
|
FileName filename(lyx_view_->buffer()->fileName());
|
|
|
|
|
closeBuffer();
|
|
|
|
|
lyx_view_->loadLyXFile(filename);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
2006-12-21 13:58:28 +00:00
|
|
|
|
docstring const 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-01-04 17:10:24 +00:00
|
|
|
|
return keyseq->print(true) + "M-";
|
2001-04-17 15:15:59 +00:00
|
|
|
|
|
|
|
|
|
// Else, when a non-complete key sequence is pressed,
|
|
|
|
|
// show the available options.
|
2006-10-19 07:20:32 +00:00
|
|
|
|
if (keyseq->length() > 0 && !keyseq->deleted())
|
2007-01-04 17:10:24 +00:00
|
|
|
|
return keyseq->printOptions(true);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-09-16 14:00:13 +00:00
|
|
|
|
if (!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
|
|
|
|
|
{
|
2006-10-19 07:28:35 +00:00
|
|
|
|
BOOST_ASSERT(lyx_view_);
|
|
|
|
|
return lyx_view_->view();
|
2001-04-17 15:15:59 +00:00
|
|
|
|
}
|
2003-07-28 22:34:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool LyXFunc::wasMetaKey() const
|
|
|
|
|
{
|
|
|
|
|
return (meta_fake_bit != key_modifier::none);
|
|
|
|
|
}
|
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:
|
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:
|
|
|
|
|
case LyXRC::RC_DEFAULT_PAPERSIZE:
|
|
|
|
|
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) {
|
2006-12-05 12:57:01 +00:00
|
|
|
|
string const encoded = FileName(
|
|
|
|
|
lyxrc_new.document_path).toFilesystemEncoding();
|
|
|
|
|
if (fs::exists(encoded) && fs::is_directory(encoded))
|
2007-04-06 13:09:54 +00:00
|
|
|
|
support::package().document_dir() = FileName(lyxrc.document_path);
|
2005-01-16 21:01:41 +00:00
|
|
|
|
}
|
|
|
|
|
case LyXRC::RC_ESC_CHARS:
|
|
|
|
|
case LyXRC::RC_FONT_ENCODING:
|
|
|
|
|
case LyXRC::RC_FORMAT:
|
|
|
|
|
case LyXRC::RC_INDEX_COMMAND:
|
|
|
|
|
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:
|
|
|
|
|
case LyXRC::RC_MAKE_BACKUP:
|
|
|
|
|
case LyXRC::RC_MARK_FOREIGN_LANGUAGE:
|
|
|
|
|
case LyXRC::RC_NUMLASTFILES:
|
|
|
|
|
case LyXRC::RC_PATH_PREFIX:
|
|
|
|
|
if (lyxrc_orig.path_prefix != lyxrc_new.path_prefix) {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
support::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:
|
2006-04-05 22:56:18 +00:00
|
|
|
|
case LyXRC::RC_SCREEN_GEOMETRY_HEIGHT:
|
|
|
|
|
case LyXRC::RC_SCREEN_GEOMETRY_WIDTH:
|
|
|
|
|
case LyXRC::RC_SCREEN_GEOMETRY_XYSAVED:
|
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:
|
|
|
|
|
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) {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
support::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:
|
|
|
|
|
case LyXRC::RC_USE_SPELL_LIB:
|
|
|
|
|
case LyXRC::RC_VIEWDVI_PAPEROPTION:
|
|
|
|
|
case LyXRC::RC_VIEWER:
|
|
|
|
|
case LyXRC::RC_LAST:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace anon
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|