1999-09-27 18:44:28 +00:00
|
|
|
/* This file is part of
|
2002-03-21 17:27:08 +00:00
|
|
|
* ======================================================
|
|
|
|
*
|
1999-10-02 16:21:10 +00:00
|
|
|
* LyX, The Document Processor
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
1999-10-02 16:21:10 +00:00
|
|
|
* Copyright 1995 Matthias Ettrich
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 1995-2001 The LyX Team.
|
1999-10-02 16:21:10 +00:00
|
|
|
*
|
1999-11-15 12:01:38 +00:00
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
2000-04-11 22:55:29 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2001-12-10 20:06:59 +00:00
|
|
|
#include "lyxfunc.h"
|
2000-07-24 13:53:19 +00:00
|
|
|
#include "version.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "kbmap.h"
|
2001-11-26 16:42:04 +00:00
|
|
|
#include "lyxrow.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "bufferlist.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "BufferView.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lyxserver.h"
|
|
|
|
#include "intl.h"
|
|
|
|
#include "lyx_main.h"
|
|
|
|
#include "lyx_cb.h"
|
1999-11-22 16:19:48 +00:00
|
|
|
#include "LyXAction.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
#include "debug.h"
|
|
|
|
#include "lyxrc.h"
|
|
|
|
#include "lyxtext.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "Lsstream.h"
|
|
|
|
#include "trans_mgr.h"
|
|
|
|
#include "layout.h"
|
|
|
|
#include "bufferview_funcs.h"
|
2002-05-23 12:08:47 +00:00
|
|
|
#include "frontends/LyXView.h"
|
2002-07-12 02:27:42 +00:00
|
|
|
#include "frontends/lyx_gui.h"
|
|
|
|
#include "vspace.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
#include "FloatList.h"
|
|
|
|
#include "converter.h"
|
|
|
|
#include "exporter.h"
|
|
|
|
#include "importer.h"
|
|
|
|
#include "TextCache.h"
|
|
|
|
#include "lyxfind.h"
|
|
|
|
#include "undo_funcs.h"
|
|
|
|
#include "ParagraphParameters.h"
|
|
|
|
|
2002-09-09 17:32:53 +00:00
|
|
|
#include "insets/insetcommand.h"
|
2001-07-24 22:08:49 +00:00
|
|
|
#include "insets/insettabular.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "mathed/formulamacro.h"
|
2001-06-27 14:10:35 +00:00
|
|
|
#include "mathed/math_cursor.h"
|
|
|
|
#include "mathed/math_inset.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
|
|
|
#include "frontends/FileDialog.h"
|
|
|
|
#include "frontends/Dialogs.h"
|
|
|
|
#include "frontends/Toolbar.h"
|
|
|
|
#include "frontends/Menubar.h"
|
|
|
|
#include "frontends/Alert.h"
|
|
|
|
|
2002-02-27 09:59:52 +00:00
|
|
|
#include "graphics/GraphicsCache.h"
|
|
|
|
|
2001-12-10 20:06:59 +00:00
|
|
|
#include "support/lyxalgo.h"
|
|
|
|
#include "support/LAssert.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "support/filetools.h"
|
|
|
|
#include "support/FileInfo.h"
|
2002-02-27 09:59:52 +00:00
|
|
|
#include "support/forkedcontr.h"
|
1999-11-15 12:01:38 +00:00
|
|
|
#include "support/lstrings.h"
|
|
|
|
#include "support/path.h"
|
2000-10-11 21:06:43 +00:00
|
|
|
#include "support/lyxfunctional.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
2002-11-21 18:33:09 +00:00
|
|
|
#include "BoostFormat.h"
|
|
|
|
|
2001-12-10 20:06:59 +00:00
|
|
|
#include <ctime>
|
|
|
|
#include <clocale>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cctype>
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
#include <utility>
|
|
|
|
#include <algorithm>
|
2001-12-10 20:06:59 +00:00
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
using std::pair;
|
2002-03-21 17:27:08 +00:00
|
|
|
using std::make_pair;
|
2000-03-28 02:18:55 +00:00
|
|
|
using std::endl;
|
2000-10-12 15:17:42 +00:00
|
|
|
using std::find_if;
|
2002-02-16 15:59:55 +00:00
|
|
|
using std::vector;
|
|
|
|
using std::transform;
|
|
|
|
using std::back_inserter;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
extern BufferList bufferlist;
|
1999-11-04 01:40:20 +00:00
|
|
|
extern LyXServer * lyxserver;
|
1999-09-27 18:44:28 +00:00
|
|
|
extern bool selection_possible;
|
|
|
|
|
2001-03-07 16:18:05 +00:00
|
|
|
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// (alkis)
|
|
|
|
extern tex_accent_struct get_accent(kb_action action);
|
|
|
|
|
|
|
|
extern void ShowLatexLog();
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
LyXFunc::LyXFunc(LyXView * o)
|
2001-11-30 13:25:38 +00:00
|
|
|
: owner(o),
|
|
|
|
keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
|
2002-10-21 16:21:56 +00:00
|
|
|
cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get()),
|
|
|
|
meta_fake_bit(key_modifier::none)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
2001-02-22 14:09:20 +00:00
|
|
|
inline
|
2001-04-17 15:15:59 +00:00
|
|
|
LyXText * LyXFunc::TEXT(bool flag = true) const
|
2001-02-22 14:09:20 +00:00
|
|
|
{
|
|
|
|
if (flag)
|
2002-08-13 17:43:40 +00:00
|
|
|
return view()->text;
|
|
|
|
return view()->getLyXText();
|
2001-02-22 14:09:20 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
inline
|
2001-02-22 14:09:20 +00:00
|
|
|
void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-05-31 02:23:46 +00:00
|
|
|
if (selecting || TEXT(flag)->selection.mark()) {
|
2002-08-13 17:43:40 +00:00
|
|
|
TEXT(flag)->setSelection(view());
|
2001-02-22 14:09:20 +00:00
|
|
|
if (TEXT(flag)->bv_owner)
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->toggleToggle();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
|
|
|
|
view()->showCursor();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->switchKeyMap();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
void LyXFunc::handleKeyFunc(kb_action action)
|
|
|
|
{
|
2002-06-18 15:44:30 +00:00
|
|
|
char c = keyseq.getLastKeyEncoded();
|
2001-02-23 16:10:03 +00:00
|
|
|
|
2001-11-30 13:25:38 +00:00
|
|
|
if (keyseq.length() > 1) {
|
|
|
|
c = 0;
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getIntl().getTransManager()
|
2001-02-23 16:10:03 +00:00
|
|
|
.deadkey(c, get_accent(action).accent, TEXT(false));
|
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
|
2001-11-30 13:25:38 +00:00
|
|
|
keyseq.clear();
|
2001-02-23 16:10:03 +00:00
|
|
|
// copied verbatim from do_accent_char
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->update(TEXT(false),
|
2001-02-23 16:10:03 +00:00
|
|
|
BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
2001-05-31 02:23:46 +00:00
|
|
|
TEXT(false)->selection.cursor = TEXT(false)->cursor;
|
2001-02-23 16:10:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
void LyXFunc::processKeySym(LyXKeySymPtr keysym,
|
|
|
|
key_modifier::state state)
|
2000-08-14 15:31:16 +00:00
|
|
|
{
|
|
|
|
string argument;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
|
|
|
lyxerr << "KeySym is "
|
2002-06-18 15:44:30 +00:00
|
|
|
<< keysym->getSymbolName()
|
2000-08-14 15:31:16 +00:00
|
|
|
<< 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()) {
|
2000-08-14 15:31:16 +00:00
|
|
|
lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
|
|
|
|
<< 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()) {
|
2002-12-12 13:46:06 +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
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
// Do a one-deep top-level lookup for
|
|
|
|
// cancel and meta-fake keys. RVDK_PATCH_5
|
|
|
|
cancel_meta_seq.reset();
|
|
|
|
|
2002-05-26 17:33:14 +00:00
|
|
|
int action = cancel_meta_seq.addkey(keysym, state);
|
2002-11-27 10:30:28 +00:00
|
|
|
lyxerr[Debug::KEY] << "action first set to [" << 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.
|
2000-11-04 10:00:12 +00:00
|
|
|
if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
|
2000-08-14 15:31:16 +00:00
|
|
|
// remove Caps Lock and Mod2 as a modifiers
|
2002-05-26 17:33:14 +00:00
|
|
|
action = keyseq.addkey(keysym, (state | meta_fake_bit));
|
2002-08-06 00:54:20 +00:00
|
|
|
lyxerr[Debug::KEY] << "action now set to ["
|
2002-11-27 10:30:28 +00:00
|
|
|
<< 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
|
|
|
|
|
|
|
// can this happen now ?
|
2001-11-30 13:25:38 +00:00
|
|
|
if (action == LFUN_NOACTION) {
|
|
|
|
action = LFUN_PREFIX;
|
|
|
|
}
|
2000-08-14 15:31:16 +00:00
|
|
|
|
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
2001-05-29 09:50:02 +00:00
|
|
|
lyxerr << "Key [action="
|
2000-08-14 15:31:16 +00:00
|
|
|
<< action << "]["
|
2002-11-27 10:30:28 +00:00
|
|
|
<< keyseq.print() << ']'
|
2000-08-14 15:31:16 +00:00
|
|
|
<< endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
// already here we know if it any point in going further
|
|
|
|
// why not return already here if action == -1 and
|
|
|
|
// num_bytes == 0? (Lgb)
|
|
|
|
|
2002-03-01 14:13:01 +00:00
|
|
|
if (keyseq.length() > 1) {
|
2001-11-30 13:25:38 +00:00
|
|
|
owner->message(keyseq.print());
|
2000-08-14 15:31:16 +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
|
|
|
|
if (action == LFUN_UNKNOWN_ACTION && state == key_modifier::shift) {
|
|
|
|
lyxerr[Debug::KEY] << "Trying without shift" << endl;
|
2002-05-26 17:33:14 +00:00
|
|
|
action = keyseq.addkey(keysym, key_modifier::none);
|
2002-12-12 13:46:06 +00:00
|
|
|
lyxerr[Debug::KEY] << "Action now " << action << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action == LFUN_UNKNOWN_ACTION) {
|
|
|
|
// Hmm, we didn't match any of the keysequences. See
|
|
|
|
// if it's normal insertable text not already covered
|
|
|
|
// by a binding
|
|
|
|
if (keysym->isText() && keyseq.length() == 1) {
|
|
|
|
lyxerr[Debug::KEY] << "isText() is true, inserting." << endl;
|
|
|
|
action = LFUN_SELFINSERT;
|
|
|
|
} else {
|
|
|
|
lyxerr[Debug::KEY] << "Unknown, !isText() - giving up" << endl;
|
2001-05-17 01:23:29 +00:00
|
|
|
owner->message(_("Unknown function."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action == LFUN_SELFINSERT) {
|
2002-06-18 15:44:30 +00:00
|
|
|
char c = keysym->getISOEncoded();
|
2002-01-12 20:00:47 +00:00
|
|
|
string argument;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-12-12 13:46:06 +00:00
|
|
|
// FIXME: why ...
|
2002-06-18 15:44:30 +00:00
|
|
|
if (c != 0)
|
|
|
|
argument = c;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
dispatch(FuncRequest(view(), LFUN_SELFINSERT, argument));
|
2001-05-29 09:50:02 +00:00
|
|
|
lyxerr[Debug::KEY] << "SelfInsert arg[`"
|
|
|
|
<< argument << "']" << endl;
|
2002-06-18 17:22:17 +00:00
|
|
|
} else {
|
2002-07-18 20:15:29 +00:00
|
|
|
dispatch(action);
|
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
|
|
|
|
2002-01-09 09:36:35 +00:00
|
|
|
FuncStatus LyXFunc::getStatus(int ac) const
|
2001-02-26 10:32:45 +00:00
|
|
|
{
|
2002-08-14 10:16:05 +00:00
|
|
|
return getStatus(lyxaction.retrieveActionArg(ac));
|
2001-02-26 10:32:45 +00:00
|
|
|
}
|
|
|
|
|
2002-01-12 20:00:47 +00:00
|
|
|
|
2002-08-07 08:11:41 +00:00
|
|
|
FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
2002-01-09 09:36:35 +00:00
|
|
|
FuncStatus flag;
|
2001-06-25 00:06:33 +00:00
|
|
|
Buffer * buf = owner->buffer();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-08-07 08:11:41 +00:00
|
|
|
if (ev.action == LFUN_NOACTION) {
|
2002-03-27 23:27:12 +00:00
|
|
|
setStatusMessage(N_("Nothing to do"));
|
|
|
|
return flag.disabled(true);
|
|
|
|
}
|
|
|
|
|
2002-08-07 08:11:41 +00:00
|
|
|
if (ev.action == LFUN_UNKNOWN_ACTION) {
|
2002-01-13 13:07:27 +00:00
|
|
|
setStatusMessage(N_("Unknown action"));
|
2002-01-09 09:36:35 +00:00
|
|
|
return flag.unknown(true);
|
2000-06-12 11:27:15 +00:00
|
|
|
}
|
2002-02-06 15:12:40 +00:00
|
|
|
|
|
|
|
// the default error message if we disable the command
|
|
|
|
setStatusMessage(N_("Command disabled"));
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// Check whether we need a buffer
|
2002-08-07 08:11:41 +00:00
|
|
|
if (!lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer)) {
|
1999-12-10 00:07:59 +00:00
|
|
|
// Yes we need a buffer, do we have one?
|
|
|
|
if (buf) {
|
|
|
|
// yes
|
|
|
|
// Can we use a readonly buffer?
|
2002-03-21 17:27:08 +00:00
|
|
|
if (buf->isReadonly() &&
|
2002-08-07 08:11:41 +00:00
|
|
|
!lyxaction.funcHasFlag(ev.action,
|
1999-12-10 00:07:59 +00:00
|
|
|
LyXAction::ReadOnly)) {
|
|
|
|
// no
|
2002-01-13 13:07:27 +00:00
|
|
|
setStatusMessage(N_("Document is read-only"));
|
2002-01-09 09:36:35 +00:00
|
|
|
flag.disabled(true);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// no
|
2002-01-13 13:07:27 +00:00
|
|
|
setStatusMessage(N_("Command not allowed with"
|
1999-12-10 00:07:59 +00:00
|
|
|
"out any document open"));
|
2002-01-09 09:36:35 +00:00
|
|
|
return flag.disabled(true);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
UpdatableInset * tli = view()->theLockingInset();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-01-06 02:44:26 +00:00
|
|
|
// I would really like to avoid having this switch and rather try to
|
|
|
|
// encode this in the function itself.
|
2002-03-21 17:27:08 +00:00
|
|
|
bool disable = false;
|
2002-08-07 08:11:41 +00:00
|
|
|
switch (ev.action) {
|
1999-12-16 06:43:25 +00:00
|
|
|
case LFUN_MENUPRINT:
|
2000-10-02 16:44:47 +00:00
|
|
|
disable = !Exporter::IsExportable(buf, "dvi")
|
|
|
|
|| lyxrc.print_command == "none";
|
1999-12-16 06:43:25 +00:00
|
|
|
break;
|
2000-11-06 11:20:22 +00:00
|
|
|
case LFUN_EXPORT:
|
2002-08-07 08:11:41 +00:00
|
|
|
disable = ev.argument == "fax" &&
|
|
|
|
!Exporter::IsExportable(buf, ev.argument);
|
2000-11-06 11:20:22 +00:00
|
|
|
break;
|
1999-12-16 06:43:25 +00:00
|
|
|
case LFUN_UNDO:
|
|
|
|
disable = buf->undostack.empty();
|
|
|
|
break;
|
|
|
|
case LFUN_REDO:
|
|
|
|
disable = buf->redostack.empty();
|
|
|
|
break;
|
2002-08-24 22:02:30 +00:00
|
|
|
case LFUN_CUT:
|
|
|
|
case LFUN_COPY:
|
2002-09-16 12:52:58 +00:00
|
|
|
if (tli && tli->lyxCode() == Inset::TABULAR_CODE) {
|
|
|
|
InsetTabular * t(static_cast<InsetTabular*>(tli));
|
|
|
|
if (t->hasSelection()) {
|
|
|
|
disable = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-08-26 09:01:18 +00:00
|
|
|
disable = !mathcursor && !view()->getLyXText()->selection.set();
|
2002-08-24 22:02:30 +00:00
|
|
|
break;
|
2001-10-11 10:29:41 +00:00
|
|
|
#ifndef HAVE_LIBAIKSAURUS
|
|
|
|
case LFUN_THESAURUS_ENTRY:
|
|
|
|
disable = true;
|
|
|
|
break;
|
|
|
|
#endif
|
1999-12-16 06:43:25 +00:00
|
|
|
case LFUN_RUNCHKTEX:
|
2000-03-12 10:35:05 +00:00
|
|
|
disable = lyxrc.chktex_command == "none";
|
1999-12-16 06:43:25 +00:00
|
|
|
break;
|
2000-07-25 10:46:18 +00:00
|
|
|
case LFUN_BUILDPROG:
|
2000-10-23 12:16:05 +00:00
|
|
|
disable = !Exporter::IsExportable(buf, "program");
|
2000-07-31 12:51:19 +00:00
|
|
|
break;
|
|
|
|
|
2002-07-30 22:58:54 +00:00
|
|
|
case LFUN_LAYOUT_CHARACTER:
|
|
|
|
disable = tli && tli->lyxCode() == Inset::ERT_CODE;
|
|
|
|
break;
|
|
|
|
|
2000-08-01 09:35:42 +00:00
|
|
|
case LFUN_LAYOUT_TABULAR:
|
2002-01-20 16:07:42 +00:00
|
|
|
disable = !tli
|
|
|
|
|| (tli->lyxCode() != Inset::TABULAR_CODE
|
|
|
|
&& !tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
|
2000-08-01 09:35:42 +00:00
|
|
|
break;
|
|
|
|
|
2002-01-20 23:17:17 +00:00
|
|
|
case LFUN_LAYOUT:
|
2002-01-20 16:07:42 +00:00
|
|
|
case LFUN_LAYOUT_PARAGRAPH: {
|
|
|
|
Inset * inset = TEXT(false)->cursor.par()->inInset();
|
|
|
|
disable = inset && inset->forceDefaultParagraphs(inset);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-08-23 09:05:32 +00:00
|
|
|
case LFUN_INSET_OPTARG:
|
|
|
|
disable = (TEXT(false)->cursor.par()->layout()->optionalargs == 0);
|
|
|
|
break;
|
|
|
|
|
2000-08-01 09:35:42 +00:00
|
|
|
case LFUN_TABULAR_FEATURE:
|
2002-08-21 13:47:52 +00:00
|
|
|
if (mathcursor) {
|
|
|
|
#if 0
|
|
|
|
// FIXME: check temporarily disabled
|
|
|
|
// valign code
|
|
|
|
char align = mathcursor->valign();
|
|
|
|
if (align == '\0') {
|
|
|
|
disable = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ev.argument.empty()) {
|
|
|
|
flag.clear();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!contains("tcb", ev.argument[0])) {
|
|
|
|
disable = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
flag.setOnOff(ev.argument[0] == align);
|
|
|
|
} else
|
|
|
|
disable = true;
|
|
|
|
|
|
|
|
char align = mathcursor->halign();
|
|
|
|
if (align == '\0') {
|
|
|
|
disable = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ev.argument.empty()) {
|
|
|
|
flag.clear();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!contains("lcr", ev.argument[0])) {
|
|
|
|
disable = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
flag.setOnOff(ev.argument[0] == align);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
disable = !mathcursor->halign();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-01-20 16:07:42 +00:00
|
|
|
if (tli) {
|
2002-01-09 09:36:35 +00:00
|
|
|
FuncStatus ret;
|
2002-01-12 20:00:47 +00:00
|
|
|
//ret.disabled(true);
|
2002-01-20 16:07:42 +00:00
|
|
|
if (tli->lyxCode() == Inset::TABULAR_CODE) {
|
|
|
|
ret = static_cast<InsetTabular *>(tli)
|
2002-08-07 08:11:41 +00:00
|
|
|
->getStatus(ev.argument);
|
2002-01-20 16:07:42 +00:00
|
|
|
} else if (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
|
2000-08-01 09:35:42 +00:00
|
|
|
ret = static_cast<InsetTabular *>
|
2002-01-20 16:07:42 +00:00
|
|
|
(tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE))
|
2002-08-07 08:11:41 +00:00
|
|
|
->getStatus(ev.argument);
|
2000-08-01 09:35:42 +00:00
|
|
|
}
|
2000-08-18 15:32:42 +00:00
|
|
|
flag |= ret;
|
2000-08-25 13:37:24 +00:00
|
|
|
disable = false;
|
2000-08-18 15:32:42 +00:00
|
|
|
} else {
|
2001-06-27 14:10:35 +00:00
|
|
|
static InsetTabular inset(*owner->buffer(), 1, 1);
|
2002-01-09 09:36:35 +00:00
|
|
|
FuncStatus ret;
|
2001-06-27 14:10:35 +00:00
|
|
|
|
|
|
|
disable = true;
|
2002-08-07 08:11:41 +00:00
|
|
|
ret = inset.getStatus(ev.argument);
|
2002-01-20 16:07:42 +00:00
|
|
|
if (ret.onoff(true) || ret.onoff(false))
|
|
|
|
flag.setOnOff(false);
|
2000-08-01 09:35:42 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
case LFUN_VC_REGISTER:
|
|
|
|
disable = buf->lyxvc.inUse();
|
|
|
|
break;
|
|
|
|
case LFUN_VC_CHECKIN:
|
|
|
|
disable = !buf->lyxvc.inUse() || buf->isReadonly();
|
|
|
|
break;
|
|
|
|
case LFUN_VC_CHECKOUT:
|
|
|
|
disable = !buf->lyxvc.inUse() || !buf->isReadonly();
|
|
|
|
break;
|
|
|
|
case LFUN_VC_REVERT:
|
|
|
|
case LFUN_VC_UNDO:
|
|
|
|
case LFUN_VC_HISTORY:
|
|
|
|
disable = !buf->lyxvc.inUse();
|
|
|
|
break;
|
2001-01-28 18:31:36 +00:00
|
|
|
case LFUN_BOOKMARK_GOTO:
|
2002-08-13 17:43:40 +00:00
|
|
|
disable = !view()->
|
2002-08-07 08:11:41 +00:00
|
|
|
isSavedPosition(strToUnsignedInt(ev.argument));
|
2001-07-19 08:52:59 +00:00
|
|
|
break;
|
2002-02-12 12:56:46 +00:00
|
|
|
case LFUN_INSET_TOGGLE: {
|
2002-08-13 17:43:40 +00:00
|
|
|
LyXText * lt = view()->getLyXText();
|
2002-03-21 17:27:08 +00:00
|
|
|
disable = !(isEditableInset(lt->getInset())
|
|
|
|
|| (lt->inset_owner
|
2002-02-12 12:56:46 +00:00
|
|
|
&& lt->inset_owner->owner()
|
2002-03-21 17:27:08 +00:00
|
|
|
&& lt->inset_owner->owner()->isOpen()));
|
2001-07-19 08:52:59 +00:00
|
|
|
break;
|
2002-02-12 12:56:46 +00:00
|
|
|
}
|
2002-07-30 12:14:43 +00:00
|
|
|
case LFUN_LATEX_LOG:
|
|
|
|
disable = !IsFileReadable(buf->getLogName().second);
|
|
|
|
break;
|
2002-01-20 16:07:42 +00:00
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
case LFUN_MATH_MUTATE:
|
2002-08-15 14:33:14 +00:00
|
|
|
if (mathcursor)
|
|
|
|
//flag.setOnOff(mathcursor->formula()->hullType() == ev.argument);
|
|
|
|
flag.setOnOff(false);
|
2002-07-03 10:36:44 +00:00
|
|
|
else
|
2001-06-27 14:10:35 +00:00
|
|
|
disable = true;
|
|
|
|
break;
|
2001-07-06 12:09:32 +00:00
|
|
|
|
|
|
|
// we just need to be in math mode to enable that
|
2002-03-21 17:27:08 +00:00
|
|
|
case LFUN_MATH_SIZE:
|
2001-07-25 12:37:43 +00:00
|
|
|
case LFUN_MATH_SPACE:
|
2002-03-21 17:27:08 +00:00
|
|
|
case LFUN_MATH_LIMITS:
|
|
|
|
case LFUN_MATH_NONUMBER:
|
2001-07-06 12:09:32 +00:00
|
|
|
case LFUN_MATH_NUMBER:
|
2002-08-14 13:22:05 +00:00
|
|
|
case LFUN_MATH_EXTERN:
|
2001-07-06 12:09:32 +00:00
|
|
|
disable = !mathcursor;
|
|
|
|
break;
|
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
default:
|
|
|
|
break;
|
2001-07-19 08:52:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// the functions which insert insets
|
|
|
|
Inset::Code code = Inset::NO_CODE;
|
2002-08-07 08:11:41 +00:00
|
|
|
switch (ev.action) {
|
2001-07-19 08:52:59 +00:00
|
|
|
case LFUN_INSET_ERT:
|
2002-03-21 17:27:08 +00:00
|
|
|
code = Inset::ERT_CODE;
|
2001-07-19 08:52:59 +00:00
|
|
|
break;
|
|
|
|
case LFUN_INSET_GRAPHICS:
|
|
|
|
code = Inset::GRAPHICS_CODE;
|
|
|
|
break;
|
|
|
|
case LFUN_INSET_FOOTNOTE:
|
|
|
|
code = Inset::FOOT_CODE;
|
|
|
|
break;
|
2002-08-04 23:11:50 +00:00
|
|
|
case LFUN_TABULAR_INSERT:
|
2001-07-19 08:52:59 +00:00
|
|
|
code = Inset::TABULAR_CODE;
|
|
|
|
break;
|
|
|
|
case LFUN_INSET_EXTERNAL:
|
|
|
|
code = Inset::EXTERNAL_CODE;
|
|
|
|
break;
|
|
|
|
case LFUN_INSET_MARGINAL:
|
|
|
|
code = Inset::MARGIN_CODE;
|
|
|
|
break;
|
|
|
|
case LFUN_INSET_MINIPAGE:
|
|
|
|
code = Inset::MINIPAGE_CODE;
|
|
|
|
break;
|
|
|
|
case LFUN_INSET_FLOAT:
|
|
|
|
case LFUN_INSET_WIDE_FLOAT:
|
|
|
|
code = Inset::FLOAT_CODE;
|
|
|
|
break;
|
2002-09-10 10:18:58 +00:00
|
|
|
case LFUN_INSET_WRAP:
|
2002-09-11 06:00:15 +00:00
|
|
|
code = Inset::WRAP_CODE;
|
2002-09-10 10:18:58 +00:00
|
|
|
break;
|
2001-07-23 09:11:14 +00:00
|
|
|
case LFUN_FLOAT_LIST:
|
|
|
|
code = Inset::FLOAT_LIST_CODE;
|
|
|
|
break;
|
2001-07-19 08:52:59 +00:00
|
|
|
#if 0
|
|
|
|
case LFUN_INSET_LIST:
|
|
|
|
code = Inset::LIST_CODE;
|
|
|
|
break;
|
|
|
|
case LFUN_INSET_THEOREM:
|
|
|
|
code = Inset::THEOREM_CODE;
|
|
|
|
break;
|
2001-07-24 22:08:49 +00:00
|
|
|
#endif
|
2001-07-19 08:52:59 +00:00
|
|
|
case LFUN_INSET_CAPTION:
|
|
|
|
code = Inset::CAPTION_CODE;
|
|
|
|
break;
|
|
|
|
case LFUN_INSERT_NOTE:
|
2002-08-04 23:11:50 +00:00
|
|
|
code = Inset::NOTE_CODE;
|
2001-07-19 08:52:59 +00:00
|
|
|
break;
|
|
|
|
case LFUN_INSERT_LABEL:
|
|
|
|
code = Inset::LABEL_CODE;
|
|
|
|
break;
|
2002-08-23 09:05:32 +00:00
|
|
|
case LFUN_INSET_OPTARG:
|
|
|
|
code = Inset::OPTARG_CODE;
|
|
|
|
break;
|
2001-07-19 08:52:59 +00:00
|
|
|
case LFUN_REF_INSERT:
|
|
|
|
code = Inset::REF_CODE;
|
|
|
|
break;
|
2001-07-23 09:11:14 +00:00
|
|
|
case LFUN_CITATION_CREATE:
|
2001-07-19 08:52:59 +00:00
|
|
|
case LFUN_CITATION_INSERT:
|
|
|
|
code = Inset::CITE_CODE;
|
|
|
|
break;
|
|
|
|
case LFUN_INSERT_BIBTEX:
|
|
|
|
code = Inset::BIBTEX_CODE;
|
|
|
|
break;
|
|
|
|
case LFUN_INDEX_INSERT:
|
|
|
|
code = Inset::INDEX_CODE;
|
|
|
|
break;
|
2001-07-23 09:11:14 +00:00
|
|
|
case LFUN_INDEX_PRINT:
|
|
|
|
code = Inset::INDEX_PRINT_CODE;
|
|
|
|
break;
|
2001-07-19 08:52:59 +00:00
|
|
|
case LFUN_CHILD_INSERT:
|
2001-07-23 09:11:14 +00:00
|
|
|
code = Inset::INCLUDE_CODE;
|
2001-07-19 08:52:59 +00:00
|
|
|
break;
|
|
|
|
case LFUN_TOC_INSERT:
|
|
|
|
code = Inset::TOC_CODE;
|
|
|
|
break;
|
|
|
|
case LFUN_PARENTINSERT:
|
|
|
|
code = Inset::PARENT_CODE;
|
|
|
|
break;
|
2001-07-23 09:11:14 +00:00
|
|
|
case LFUN_HTMLURL:
|
|
|
|
case LFUN_URL:
|
2001-07-19 08:52:59 +00:00
|
|
|
case LFUN_INSERT_URL:
|
|
|
|
code = Inset::URL_CODE;
|
|
|
|
break;
|
2001-07-23 09:11:14 +00:00
|
|
|
case LFUN_QUOTE:
|
|
|
|
// always allow this, since we will inset a raw quote
|
|
|
|
// if an inset is not allowed.
|
|
|
|
break;
|
|
|
|
case LFUN_HYPHENATION:
|
|
|
|
case LFUN_LIGATURE_BREAK:
|
|
|
|
case LFUN_HFILL:
|
|
|
|
case LFUN_MENU_SEPARATOR:
|
|
|
|
case LFUN_LDOTS:
|
|
|
|
case LFUN_END_OF_SENTENCE:
|
|
|
|
code = Inset::SPECIALCHAR_CODE;
|
|
|
|
break;
|
2002-04-22 22:31:49 +00:00
|
|
|
case LFUN_PROTECTEDSPACE:
|
|
|
|
// slight hack: we know this is allowed in math mode
|
|
|
|
if (!mathcursor)
|
|
|
|
code = Inset::SPECIALCHAR_CODE;
|
|
|
|
break;
|
2001-07-19 08:52:59 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2002-08-23 09:05:32 +00:00
|
|
|
if (code != Inset::NO_CODE && tli && !tli->insetAllowed(code))
|
2001-07-19 08:52:59 +00:00
|
|
|
disable = true;
|
|
|
|
|
|
|
|
if (disable)
|
2002-07-21 15:51:07 +00:00
|
|
|
flag.disabled(true);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-12-21 13:55:24 +00:00
|
|
|
// A few general toggles
|
2002-08-07 08:11:41 +00:00
|
|
|
switch (ev.action) {
|
2002-03-11 09:54:42 +00:00
|
|
|
case LFUN_TOOLTIPS_TOGGLE:
|
2002-08-13 14:40:38 +00:00
|
|
|
flag.setOnOff(owner->getDialogs().tooltipsEnabled());
|
2002-03-11 09:54:42 +00:00
|
|
|
break;
|
|
|
|
|
2001-07-19 08:52:59 +00:00
|
|
|
case LFUN_READ_ONLY_TOGGLE:
|
2002-01-09 09:36:35 +00:00
|
|
|
flag.setOnOff(buf->isReadonly());
|
2001-07-19 08:52:59 +00:00
|
|
|
break;
|
2001-08-03 10:32:20 +00:00
|
|
|
case LFUN_APPENDIX:
|
2002-01-09 09:36:35 +00:00
|
|
|
flag.setOnOff(TEXT(false)->cursor.par()->params().startOfAppendix());
|
2001-08-03 10:32:20 +00:00
|
|
|
break;
|
2002-02-11 15:51:03 +00:00
|
|
|
case LFUN_SWITCHBUFFER:
|
|
|
|
// toggle on the current buffer, but do not toggle off
|
2002-03-21 17:27:08 +00:00
|
|
|
// the other ones (is that a good idea?)
|
2002-08-07 08:11:41 +00:00
|
|
|
if (ev.argument == buf->fileName())
|
2002-02-11 15:51:03 +00:00
|
|
|
flag.setOnOff(true);
|
|
|
|
break;
|
2001-07-19 08:52:59 +00:00
|
|
|
default:
|
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
|
2001-12-21 13:55:24 +00:00
|
|
|
// the font related toggles
|
|
|
|
if (!mathcursor) {
|
|
|
|
LyXFont const & font = TEXT(false)->real_current_font;
|
2002-08-07 08:11:41 +00:00
|
|
|
switch (ev.action) {
|
2001-12-21 13:55:24 +00:00
|
|
|
case LFUN_EMPH:
|
2002-01-09 09:36:35 +00:00
|
|
|
flag.setOnOff(font.emph() == LyXFont::ON);
|
2001-12-21 13:55:24 +00:00
|
|
|
break;
|
|
|
|
case LFUN_NOUN:
|
2002-01-09 09:36:35 +00:00
|
|
|
flag.setOnOff(font.noun() == LyXFont::ON);
|
2001-12-21 13:55:24 +00:00
|
|
|
break;
|
|
|
|
case LFUN_BOLD:
|
2002-01-09 09:36:35 +00:00
|
|
|
flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
|
2001-12-21 13:55:24 +00:00
|
|
|
break;
|
|
|
|
case LFUN_SANS:
|
2002-01-09 09:36:35 +00:00
|
|
|
flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
|
2001-12-21 13:55:24 +00:00
|
|
|
break;
|
|
|
|
case LFUN_ROMAN:
|
2002-01-09 09:36:35 +00:00
|
|
|
flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
|
2001-12-21 13:55:24 +00:00
|
|
|
break;
|
|
|
|
case LFUN_CODE:
|
2002-01-09 09:36:35 +00:00
|
|
|
flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
|
2001-12-21 13:55:24 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2002-07-18 20:15:29 +00:00
|
|
|
} else {
|
2002-05-30 09:51:28 +00:00
|
|
|
string tc = mathcursor->getLastCode();
|
2002-08-07 08:11:41 +00:00
|
|
|
switch (ev.action) {
|
2001-12-21 13:55:24 +00:00
|
|
|
case LFUN_BOLD:
|
2002-05-30 09:51:28 +00:00
|
|
|
flag.setOnOff(tc == "mathbf");
|
2001-12-21 13:55:24 +00:00
|
|
|
break;
|
|
|
|
case LFUN_SANS:
|
2002-05-30 09:51:28 +00:00
|
|
|
flag.setOnOff(tc == "mathsf");
|
2001-12-21 13:55:24 +00:00
|
|
|
break;
|
|
|
|
case LFUN_EMPH:
|
2002-05-30 09:51:28 +00:00
|
|
|
flag.setOnOff(tc == "mathcal");
|
2001-12-21 13:55:24 +00:00
|
|
|
break;
|
|
|
|
case LFUN_ROMAN:
|
2002-05-30 09:51:28 +00:00
|
|
|
flag.setOnOff(tc == "mathrm");
|
2001-12-21 13:55:24 +00:00
|
|
|
break;
|
|
|
|
case LFUN_CODE:
|
2002-05-30 09:51:28 +00:00
|
|
|
flag.setOnOff(tc == "mathtt");
|
2001-12-21 13:55:24 +00:00
|
|
|
break;
|
|
|
|
case LFUN_NOUN:
|
2002-05-30 09:51:28 +00:00
|
|
|
flag.setOnOff(tc == "mathbb");
|
2001-12-21 13:55:24 +00:00
|
|
|
break;
|
|
|
|
case LFUN_DEFAULT:
|
2002-05-30 09:51:28 +00:00
|
|
|
flag.setOnOff(tc == "mathnormal");
|
2001-12-21 13:55:24 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-07-21 15:51:07 +00:00
|
|
|
// this one is difficult to get right. As a half-baked
|
|
|
|
// solution, we consider only the first action of the sequence
|
2002-08-07 08:11:41 +00:00
|
|
|
if (ev.action == LFUN_SEQUENCE) {
|
2002-07-21 15:51:07 +00:00
|
|
|
// argument contains ';'-terminated commands
|
2002-08-07 08:11:41 +00:00
|
|
|
flag = getStatus(lyxaction.LookupFunc(token(ev.argument, ';', 0)));
|
2002-07-21 15:51:07 +00:00
|
|
|
}
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-18 20:15:29 +00:00
|
|
|
void LyXFunc::dispatch(string const & s, bool verbose)
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
2002-07-21 15:51:07 +00:00
|
|
|
int const action = lyxaction.LookupFunc(s);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-12-17 12:22:39 +00:00
|
|
|
if (action == LFUN_UNKNOWN_ACTION) {
|
2002-11-27 10:30:28 +00:00
|
|
|
#if USE_BOOST_FORMAT
|
|
|
|
boost::format fmt(_("Unknown function (%1$s)"));
|
|
|
|
fmt % s;
|
|
|
|
owner->message(fmt.str());
|
|
|
|
#else
|
2001-12-17 12:22:39 +00:00
|
|
|
string const msg = string(_("Unknown function ("))
|
2002-11-27 10:30:28 +00:00
|
|
|
+ s + ')';
|
2001-12-17 12:22:39 +00:00
|
|
|
owner->message(msg);
|
2002-11-27 10:30:28 +00:00
|
|
|
#endif
|
2002-07-18 20:15:29 +00:00
|
|
|
return;
|
2002-03-21 17:27:08 +00:00
|
|
|
}
|
2002-07-18 20:15:29 +00:00
|
|
|
|
|
|
|
dispatch(action, verbose);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-18 20:15:29 +00:00
|
|
|
void LyXFunc::dispatch(int ac, bool verbose)
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
2002-08-14 10:16:05 +00:00
|
|
|
dispatch(lyxaction.retrieveActionArg(ac), verbose);
|
2002-01-12 20:00:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-08-07 08:11:41 +00:00
|
|
|
void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
|
2002-01-12 20:00:47 +00:00
|
|
|
{
|
2002-08-07 08:11:41 +00:00
|
|
|
lyxerr[Debug::ACTION] << "LyXFunc::dispatch: action[" << ev.action
|
2002-11-27 10:30:28 +00:00
|
|
|
<<"] arg[" << ev.argument << ']' << 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();
|
2001-06-29 06:30:53 +00:00
|
|
|
|
|
|
|
#ifdef NEW_DISPATCHER
|
|
|
|
// We try do call the most specific dispatcher first:
|
|
|
|
// 1. the lockinginset's dispatch
|
|
|
|
// 2. the bufferview's dispatch
|
|
|
|
// 3. the lyxview's dispatch
|
|
|
|
#endif
|
2002-01-12 20:00:47 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
selection_possible = false;
|
2002-01-12 20:00:47 +00:00
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
if (view()->available())
|
|
|
|
view()->hideCursor();
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2002-08-07 08:11:41 +00:00
|
|
|
string argument = ev.argument;
|
|
|
|
kb_action action = ev.action;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// We cannot use this function here
|
2002-08-07 08:11:41 +00:00
|
|
|
if (getStatus(ev).disabled()) {
|
2002-07-20 20:47:54 +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;
|
2002-01-13 13:07:27 +00:00
|
|
|
setErrorMessage(getStatusMessage());
|
1999-12-10 00:07:59 +00:00
|
|
|
goto exit_with_message;
|
2001-07-24 22:08:49 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
if (view()->available() && view()->theLockingInset()) {
|
2002-08-19 10:11:13 +00:00
|
|
|
Inset::RESULT result;
|
2000-06-16 15:13:25 +00:00
|
|
|
if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
|
2001-11-30 13:25:38 +00:00
|
|
|
(!keyseq.deleted())))
|
2000-06-16 15:13:25 +00:00
|
|
|
{
|
2002-08-13 17:43:40 +00:00
|
|
|
UpdatableInset * inset = view()->theLockingInset();
|
2002-04-16 14:10:39 +00:00
|
|
|
#if 1
|
|
|
|
int inset_x;
|
|
|
|
int dummy_y;
|
2002-08-13 17:43:40 +00:00
|
|
|
inset->getCursorPos(view(), inset_x, dummy_y);
|
2002-04-16 14:10:39 +00:00
|
|
|
#endif
|
2002-01-12 20:00:47 +00:00
|
|
|
if ((action == LFUN_UNKNOWN_ACTION)
|
2002-02-16 15:59:55 +00:00
|
|
|
&& argument.empty()) {
|
2002-06-18 15:44:30 +00:00
|
|
|
argument = keyseq.getLastKeyEncoded();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
2001-06-27 14:10:35 +00:00
|
|
|
// Undo/Redo is a bit tricky for insets.
|
2001-07-06 15:57:54 +00:00
|
|
|
if (action == LFUN_UNDO) {
|
2002-10-21 16:21:56 +00:00
|
|
|
view()->undo();
|
2002-01-13 13:07:27 +00:00
|
|
|
goto exit_with_message;
|
2000-02-25 12:06:15 +00:00
|
|
|
} else if (action == LFUN_REDO) {
|
2002-10-21 16:21:56 +00:00
|
|
|
view()->redo();
|
2002-01-13 13:07:27 +00:00
|
|
|
goto exit_with_message;
|
2002-04-16 14:10:39 +00:00
|
|
|
} else if (((result=inset->
|
2002-02-07 16:43:54 +00:00
|
|
|
// Hand-over to inset's own dispatch:
|
2002-08-13 17:43:40 +00:00
|
|
|
localDispatch(FuncRequest(view(), action, argument))) ==
|
2002-03-21 17:27:08 +00:00
|
|
|
UpdatableInset::DISPATCHED) ||
|
|
|
|
(result == UpdatableInset::DISPATCHED_NOUPDATE))
|
2002-01-13 13:07:27 +00:00
|
|
|
goto exit_with_message;
|
2002-02-07 16:43:54 +00:00
|
|
|
// If UNDISPATCHED, just soldier on
|
2001-08-16 08:52:30 +00:00
|
|
|
else if (result == UpdatableInset::FINISHED) {
|
2002-07-13 14:56:42 +00:00
|
|
|
goto exit_with_message;
|
|
|
|
// We do not need special RTL handling here:
|
|
|
|
// FINISHED means that the cursor should be
|
|
|
|
// one position after the inset.
|
2001-08-16 08:52:30 +00:00
|
|
|
} else if (result == UpdatableInset::FINISHED_RIGHT) {
|
2002-08-13 17:43:40 +00:00
|
|
|
TEXT()->cursorRight(view());
|
2002-07-13 14:56:42 +00:00
|
|
|
moveCursorUpdate(true, false);
|
2002-07-17 04:13:41 +00:00
|
|
|
owner->view_state_changed();
|
2002-01-13 13:07:27 +00:00
|
|
|
goto exit_with_message;
|
2001-08-16 08:52:30 +00:00
|
|
|
} else if (result == UpdatableInset::FINISHED_UP) {
|
2002-04-16 14:10:39 +00:00
|
|
|
if (TEXT()->cursor.irow()->previous()) {
|
|
|
|
#if 1
|
|
|
|
TEXT()->setCursorFromCoordinates(
|
2002-08-13 17:43:40 +00:00
|
|
|
view(), TEXT()->cursor.ix() + inset_x,
|
2002-04-16 14:10:39 +00:00
|
|
|
TEXT()->cursor.iy() -
|
|
|
|
TEXT()->cursor.irow()->baseline() - 1);
|
|
|
|
TEXT()->cursor.x_fix(TEXT()->cursor.x());
|
|
|
|
#else
|
2002-08-13 17:43:40 +00:00
|
|
|
TEXT()->cursorUp(view());
|
2002-04-16 14:10:39 +00:00
|
|
|
#endif
|
2001-08-16 08:52:30 +00:00
|
|
|
moveCursorUpdate(true, false);
|
2002-07-17 04:13:41 +00:00
|
|
|
owner->view_state_changed();
|
2002-03-29 15:49:45 +00:00
|
|
|
} else {
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR);
|
2001-08-16 08:52:30 +00:00
|
|
|
}
|
2002-01-13 13:07:27 +00:00
|
|
|
goto exit_with_message;
|
2001-08-16 08:52:30 +00:00
|
|
|
} else if (result == UpdatableInset::FINISHED_DOWN) {
|
2002-04-16 14:10:39 +00:00
|
|
|
if (TEXT()->cursor.irow()->next()) {
|
|
|
|
#if 1
|
|
|
|
TEXT()->setCursorFromCoordinates(
|
2002-08-13 17:43:40 +00:00
|
|
|
view(), TEXT()->cursor.ix() + inset_x,
|
2002-04-16 14:10:39 +00:00
|
|
|
TEXT()->cursor.iy() -
|
|
|
|
TEXT()->cursor.irow()->baseline() +
|
|
|
|
TEXT()->cursor.irow()->height() + 1);
|
|
|
|
TEXT()->cursor.x_fix(TEXT()->cursor.x());
|
2002-04-22 16:31:14 +00:00
|
|
|
#else
|
2002-08-13 17:43:40 +00:00
|
|
|
TEXT()->cursorDown(view());
|
2002-04-16 14:10:39 +00:00
|
|
|
#endif
|
|
|
|
} else {
|
2002-08-13 17:43:40 +00:00
|
|
|
TEXT()->cursorRight(view());
|
2002-04-16 14:10:39 +00:00
|
|
|
}
|
2001-08-16 08:52:30 +00:00
|
|
|
moveCursorUpdate(true, false);
|
2002-07-17 04:13:41 +00:00
|
|
|
owner->view_state_changed();
|
2002-01-13 13:07:27 +00:00
|
|
|
goto exit_with_message;
|
2002-04-17 08:34:59 +00:00
|
|
|
}
|
|
|
|
#warning I am not sure this is still right, please have a look! (Jug 20020417)
|
|
|
|
else { // result == UNDISPATCHED
|
2001-01-08 16:14:09 +00:00
|
|
|
//setMessage(N_("Text mode"));
|
2000-11-04 10:00:12 +00:00
|
|
|
switch (action) {
|
2000-04-03 11:36:35 +00:00
|
|
|
case LFUN_UNKNOWN_ACTION:
|
|
|
|
case LFUN_BREAKPARAGRAPH:
|
|
|
|
case LFUN_BREAKLINE:
|
2002-08-13 17:43:40 +00:00
|
|
|
TEXT()->cursorRight(view());
|
|
|
|
view()->switchKeyMap();
|
2002-07-17 04:13:41 +00:00
|
|
|
owner->view_state_changed();
|
2000-04-03 11:36:35 +00:00
|
|
|
break;
|
|
|
|
case LFUN_RIGHT:
|
2001-02-22 14:09:20 +00:00
|
|
|
if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
|
2002-08-13 17:43:40 +00:00
|
|
|
TEXT()->cursorRight(view());
|
2001-02-22 14:09:20 +00:00
|
|
|
moveCursorUpdate(true, false);
|
2002-07-17 04:13:41 +00:00
|
|
|
owner->view_state_changed();
|
2000-04-03 11:36:35 +00:00
|
|
|
}
|
2002-01-13 13:07:27 +00:00
|
|
|
goto exit_with_message;
|
2002-03-21 17:27:08 +00:00
|
|
|
case LFUN_LEFT:
|
2001-02-22 14:09:20 +00:00
|
|
|
if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
|
2002-08-13 17:43:40 +00:00
|
|
|
TEXT()->cursorRight(view());
|
2001-02-22 14:09:20 +00:00
|
|
|
moveCursorUpdate(true, false);
|
2002-07-17 04:13:41 +00:00
|
|
|
owner->view_state_changed();
|
2000-04-03 11:36:35 +00:00
|
|
|
}
|
2002-01-13 13:07:27 +00:00
|
|
|
goto exit_with_message;
|
2000-04-19 14:42:19 +00:00
|
|
|
case LFUN_DOWN:
|
2001-06-01 15:10:26 +00:00
|
|
|
if (TEXT()->cursor.row()->next())
|
2002-08-13 17:43:40 +00:00
|
|
|
TEXT()->cursorDown(view());
|
2001-06-01 15:10:26 +00:00
|
|
|
else
|
2002-08-13 17:43:40 +00:00
|
|
|
TEXT()->cursorRight(view());
|
2001-02-22 14:09:20 +00:00
|
|
|
moveCursorUpdate(true, false);
|
2002-07-17 04:13:41 +00:00
|
|
|
owner->view_state_changed();
|
2002-01-13 13:07:27 +00:00
|
|
|
goto exit_with_message;
|
2000-04-03 11:36:35 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
switch (action) {
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2001-05-18 07:37:14 +00:00
|
|
|
case LFUN_ESCAPE:
|
|
|
|
{
|
2002-08-13 17:43:40 +00:00
|
|
|
if (!view()->available()) break;
|
2001-05-18 07:37:14 +00:00
|
|
|
// this function should be used always [asierra060396]
|
|
|
|
UpdatableInset * tli =
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->theLockingInset();
|
2001-05-18 07:37:14 +00:00
|
|
|
if (tli) {
|
2001-06-28 10:25:20 +00:00
|
|
|
UpdatableInset * lock = tli->getLockingInset();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-05-18 07:37:14 +00:00
|
|
|
if (tli == lock) {
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->unlockInset(tli);
|
|
|
|
TEXT()->cursorRight(view());
|
2001-05-18 07:37:14 +00:00
|
|
|
moveCursorUpdate(true, false);
|
2002-07-17 04:13:41 +00:00
|
|
|
owner->view_state_changed();
|
2001-05-18 07:37:14 +00:00
|
|
|
} else {
|
2002-08-13 17:43:40 +00:00
|
|
|
tli->unlockInsetInInset(view(),
|
2001-05-18 07:37:14 +00:00
|
|
|
lock,
|
|
|
|
true);
|
|
|
|
}
|
2002-01-04 16:03:53 +00:00
|
|
|
finishUndo();
|
2002-04-19 10:51:06 +00:00
|
|
|
// Tell the paragraph dialog that we changed paragraph
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().updateParagraph();
|
2001-05-18 07:37:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// --- Misc -------------------------------------------
|
2002-03-21 17:27:08 +00:00
|
|
|
case LFUN_WORDFINDFORWARD :
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_WORDFINDBACKWARD : {
|
|
|
|
static string last_search;
|
|
|
|
string searched_string;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
if (!argument.empty()) {
|
|
|
|
last_search = argument;
|
|
|
|
searched_string = argument;
|
|
|
|
} else {
|
|
|
|
searched_string = last_search;
|
|
|
|
}
|
2001-07-20 14:18:48 +00:00
|
|
|
bool fw = (action == LFUN_WORDFINDBACKWARD);
|
|
|
|
if (!searched_string.empty()) {
|
2002-08-13 17:43:40 +00:00
|
|
|
lyxfind::LyXFind(view(), searched_string, fw);
|
2001-01-17 17:33:22 +00:00
|
|
|
}
|
2002-08-13 17:43:40 +00:00
|
|
|
// view()->showCursor();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_PREFIX:
|
|
|
|
{
|
2002-08-13 17:43:40 +00:00
|
|
|
if (view()->available() && !view()->theLockingInset()) {
|
|
|
|
view()->update(TEXT(),
|
2001-02-14 08:38:21 +00:00
|
|
|
BufferView::SELECT|BufferView::FITCUR);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
2002-03-01 14:13:01 +00:00
|
|
|
owner->message(keyseq.printOptions());
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// --- Misc -------------------------------------------
|
|
|
|
case LFUN_EXEC_COMMAND:
|
2002-07-19 20:56:31 +00:00
|
|
|
owner->focus_command_buffer();
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_CANCEL: // RVDK_PATCH_5
|
|
|
|
keyseq.reset();
|
2002-05-26 17:33:14 +00:00
|
|
|
meta_fake_bit = key_modifier::none;
|
2002-08-13 17:43:40 +00:00
|
|
|
if (view()->available())
|
1999-12-10 00:07:59 +00:00
|
|
|
// cancel any selection
|
2001-07-16 15:42:57 +00:00
|
|
|
dispatch(LFUN_MARK_OFF);
|
1999-12-10 00:07:59 +00:00
|
|
|
setMessage(N_("Cancel"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_META_FAKE: // RVDK_PATCH_5
|
|
|
|
{
|
2002-05-26 17:33:14 +00:00
|
|
|
meta_fake_bit = key_modifier::alt;
|
2001-11-30 13:25:38 +00:00
|
|
|
setMessage(keyseq.print());
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
case LFUN_READ_ONLY_TOGGLE:
|
|
|
|
if (owner->buffer()->lyxvc.inUse()) {
|
|
|
|
owner->buffer()->lyxvc.toggleReadOnly();
|
|
|
|
} else {
|
|
|
|
owner->buffer()->setReadonly(
|
|
|
|
!owner->buffer()->isReadonly());
|
|
|
|
}
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_CENTER: // this is center and redraw.
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->center();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
// --- Menus -----------------------------------------------
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_MENUNEW:
|
2002-07-11 15:13:21 +00:00
|
|
|
menuNew(argument, false);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_MENUNEWTMPLT:
|
2002-07-11 15:13:21 +00:00
|
|
|
menuNew(argument, true);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_CLOSEBUFFER:
|
2001-07-16 15:42:57 +00:00
|
|
|
closeBuffer();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_MENUWRITE:
|
2000-07-26 13:43:16 +00:00
|
|
|
if (!owner->buffer()->isUnnamed()) {
|
2001-06-14 17:58:49 +00:00
|
|
|
ostringstream s1;
|
2002-11-24 15:20:31 +00:00
|
|
|
#if USE_BOOST_FORMAT
|
2002-11-21 18:33:09 +00:00
|
|
|
s1 << boost::format(_("Saving document %1$s..."))
|
|
|
|
% MakeDisplayPath(owner->buffer()->fileName());
|
2002-11-24 15:20:31 +00:00
|
|
|
#else
|
|
|
|
s1 << _("Saving document ")
|
|
|
|
<< MakeDisplayPath(owner->buffer()->fileName())
|
|
|
|
<< _("...");
|
|
|
|
#endif
|
2002-11-04 02:12:42 +00:00
|
|
|
owner->message(STRCONV(s1.str()));
|
2002-08-13 17:43:40 +00:00
|
|
|
MenuWrite(view(), owner->buffer());
|
2002-07-20 20:47:54 +00:00
|
|
|
s1 << _(" done.");
|
2002-11-04 02:12:42 +00:00
|
|
|
owner->message(STRCONV(s1.str()));
|
2001-03-07 14:25:31 +00:00
|
|
|
} else
|
2002-08-13 17:43:40 +00:00
|
|
|
WriteAs(view(), owner->buffer());
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
case LFUN_WRITEAS:
|
2002-08-13 17:43:40 +00:00
|
|
|
WriteAs(view(), owner->buffer(), argument);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_MENURELOAD:
|
|
|
|
reloadBuffer();
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-08-30 03:40:51 +00:00
|
|
|
case LFUN_UPDATE:
|
|
|
|
Exporter::Export(owner->buffer(), argument, true);
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-08-30 03:40:51 +00:00
|
|
|
case LFUN_PREVIEW:
|
|
|
|
Exporter::Preview(owner->buffer(), argument);
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-03-19 13:48:02 +00:00
|
|
|
case LFUN_BUILDPROG:
|
2000-10-23 12:16:05 +00:00
|
|
|
Exporter::Export(owner->buffer(), "program", true);
|
2002-03-19 03:56:23 +00:00
|
|
|
break;
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
case LFUN_RUNCHKTEX:
|
1999-12-10 00:07:59 +00:00
|
|
|
MenuRunChktex(owner->buffer());
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_MENUPRINT:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().showPrint();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_EXPORT:
|
2001-02-26 10:32:45 +00:00
|
|
|
if (argument == "custom")
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().showSendto();
|
2001-02-26 10:32:45 +00:00
|
|
|
else
|
|
|
|
Exporter::Export(owner->buffer(), argument, false);
|
1999-12-15 17:42:22 +00:00
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
case LFUN_IMPORT:
|
2000-04-28 11:18:04 +00:00
|
|
|
doImport(argument);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_QUIT:
|
|
|
|
QuitLyX();
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_TOCVIEW:
|
2001-05-04 10:36:36 +00:00
|
|
|
#if 0
|
2000-05-20 21:37:05 +00:00
|
|
|
case LFUN_LOFVIEW:
|
|
|
|
case LFUN_LOTVIEW:
|
|
|
|
case LFUN_LOAVIEW:
|
2001-05-04 10:36:36 +00:00
|
|
|
#endif
|
2000-05-20 21:37:05 +00:00
|
|
|
{
|
2000-08-01 17:33:32 +00:00
|
|
|
InsetCommandParams p;
|
2001-05-04 10:36:36 +00:00
|
|
|
|
|
|
|
#if 0
|
2001-04-27 07:58:56 +00:00
|
|
|
if (action == LFUN_TOCVIEW)
|
2001-05-04 10:36:36 +00:00
|
|
|
#endif
|
2001-04-27 07:58:56 +00:00
|
|
|
p.setCmdName("tableofcontents");
|
2001-05-04 10:36:36 +00:00
|
|
|
#if 0
|
2002-02-16 15:59:55 +00:00
|
|
|
else if (action == LFUN_LOAVIEW)
|
2001-04-27 07:58:56 +00:00
|
|
|
p.setCmdName("listof{algorithm}{List of Algorithms}");
|
|
|
|
else if (action == LFUN_LOFVIEW)
|
|
|
|
p.setCmdName("listoffigures");
|
2000-08-01 17:33:32 +00:00
|
|
|
else
|
2001-04-27 07:58:56 +00:00
|
|
|
p.setCmdName("listoftables");
|
2001-05-04 10:36:36 +00:00
|
|
|
#endif
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().createTOC(p.getAsString());
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
}
|
2000-08-01 17:33:32 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_AUTOSAVE:
|
2002-08-13 17:43:40 +00:00
|
|
|
AutoSave(view());
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_UNDO:
|
2002-10-21 16:21:56 +00:00
|
|
|
view()->undo();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_REDO:
|
2002-10-21 16:21:56 +00:00
|
|
|
view()->redo();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_MENUSEARCH:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().showSearch();
|
2001-03-06 10:20:33 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_REMOVEERRORS:
|
2002-08-13 17:43:40 +00:00
|
|
|
if (view()->removeAutoInsets()) {
|
2002-06-21 02:22:13 +00:00
|
|
|
#warning repaint() or update() or nothing ?
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->repaint();
|
|
|
|
view()->fitCursor();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DEPTH_MIN:
|
2002-08-13 17:43:40 +00:00
|
|
|
changeDepth(view(), TEXT(false), -1);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_DEPTH_PLUS:
|
2002-08-13 17:43:40 +00:00
|
|
|
changeDepth(view(), TEXT(false), 1);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_FREE:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().setUserFreeFont();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2001-06-27 14:10:35 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_RECONFIGURE:
|
2002-08-13 17:43:40 +00:00
|
|
|
Reconfigure(view());
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
2001-05-03 14:31:33 +00:00
|
|
|
#if 0
|
2000-11-03 15:22:04 +00:00
|
|
|
case LFUN_FLOATSOPERATE:
|
|
|
|
if (argument == "openfoot")
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->allFloats(1,0);
|
2000-11-03 15:22:04 +00:00
|
|
|
else if (argument == "closefoot")
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->allFloats(0,0);
|
2000-11-03 15:22:04 +00:00
|
|
|
else if (argument == "openfig")
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->allFloats(1,1);
|
2000-11-03 15:22:04 +00:00
|
|
|
else if (argument == "closefig")
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->allFloats(0,1);
|
2000-11-03 15:22:04 +00:00
|
|
|
break;
|
|
|
|
#else
|
2001-04-17 00:19:49 +00:00
|
|
|
#ifdef WITH_WARNINGS
|
2001-09-09 22:02:19 +00:00
|
|
|
//#warning Find another implementation here (or another lyxfunc)!
|
2001-04-17 00:19:49 +00:00
|
|
|
#endif
|
2000-07-19 17:16:27 +00:00
|
|
|
#endif
|
2001-07-13 14:03:48 +00:00
|
|
|
case LFUN_HELP_ABOUTLYX:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().showAboutlyx();
|
2000-06-12 11:27:15 +00:00
|
|
|
break;
|
|
|
|
|
2001-10-09 15:20:10 +00:00
|
|
|
case LFUN_HELP_TEXINFO:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().showTexinfo();
|
2001-10-09 15:20:10 +00:00
|
|
|
break;
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
case LFUN_HELP_OPEN:
|
2001-04-17 15:15:59 +00:00
|
|
|
{
|
|
|
|
string const arg = argument;
|
2000-07-24 13:53:19 +00:00
|
|
|
if (arg.empty()) {
|
|
|
|
setErrorMessage(N_("Missing argument"));
|
|
|
|
break;
|
|
|
|
}
|
2001-07-03 15:19:04 +00:00
|
|
|
owner->prohibitInput();
|
2001-04-17 15:15:59 +00:00
|
|
|
string const fname = i18nLibFileSearch("doc", arg, "lyx");
|
2000-07-24 13:53:19 +00:00
|
|
|
if (fname.empty()) {
|
|
|
|
lyxerr << "LyX: unable to find documentation file `"
|
|
|
|
<< arg << "'. Bad installation?" << endl;
|
2001-07-03 15:19:04 +00:00
|
|
|
owner->allowInput();
|
2000-07-24 13:53:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-06-14 17:58:49 +00:00
|
|
|
ostringstream str;
|
2002-11-24 15:20:31 +00:00
|
|
|
#if USE_BOOST_FORMAT
|
2002-11-21 18:33:09 +00:00
|
|
|
str << boost::format(_("Opening help file %1$s..."))
|
|
|
|
% MakeDisplayPath(fname);
|
2002-11-24 15:20:31 +00:00
|
|
|
#else
|
|
|
|
str << _("Opening help file ")
|
|
|
|
<< MakeDisplayPath(fname) << _("...");
|
|
|
|
#endif
|
2002-11-04 02:12:42 +00:00
|
|
|
owner->message(STRCONV(str.str()));
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->buffer(bufferlist.loadLyXFile(fname, false));
|
2001-07-03 15:19:04 +00:00
|
|
|
owner->allowInput();
|
2000-07-24 13:53:19 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
}
|
2000-07-24 13:53:19 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// --- version control -------------------------------
|
|
|
|
case LFUN_VC_REGISTER:
|
|
|
|
{
|
|
|
|
if (!owner->buffer()->lyxvc.inUse())
|
|
|
|
owner->buffer()->lyxvc.registrer();
|
|
|
|
}
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_VC_CHECKIN:
|
|
|
|
{
|
|
|
|
if (owner->buffer()->lyxvc.inUse()
|
|
|
|
&& !owner->buffer()->isReadonly())
|
|
|
|
owner->buffer()->lyxvc.checkIn();
|
|
|
|
}
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_VC_CHECKOUT:
|
|
|
|
{
|
|
|
|
if (owner->buffer()->lyxvc.inUse()
|
|
|
|
&& owner->buffer()->isReadonly())
|
|
|
|
owner->buffer()->lyxvc.checkOut();
|
|
|
|
}
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_VC_REVERT:
|
|
|
|
{
|
|
|
|
owner->buffer()->lyxvc.revert();
|
|
|
|
}
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_VC_UNDO:
|
|
|
|
{
|
|
|
|
owner->buffer()->lyxvc.undoLast();
|
|
|
|
}
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_VC_HISTORY:
|
|
|
|
{
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().showVCLogFile();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// --- buffers ----------------------------------------
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
case LFUN_SWITCHBUFFER:
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->buffer(bufferlist.getBuffer(argument));
|
2000-07-24 13:53:19 +00:00
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_FILE_NEW:
|
|
|
|
{
|
|
|
|
// servercmd: argument must be <file>:<template>
|
2002-08-04 23:11:50 +00:00
|
|
|
Buffer * tmpbuf = NewFile(argument);
|
1999-12-10 00:07:59 +00:00
|
|
|
if (tmpbuf)
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->buffer(tmpbuf);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
1999-12-16 06:43:25 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_FILE_OPEN:
|
2001-07-16 15:42:57 +00:00
|
|
|
open(argument);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LATEX_LOG:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().showLogFile();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_LAYOUT_DOCUMENT:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().showDocument();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_LAYOUT_PARAGRAPH:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().showParagraph();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_LAYOUT_CHARACTER:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().showCharacter();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2000-09-23 04:57:18 +00:00
|
|
|
|
2000-08-01 09:35:42 +00:00
|
|
|
case LFUN_LAYOUT_TABULAR:
|
2002-08-13 17:43:40 +00:00
|
|
|
if (view()->theLockingInset()) {
|
|
|
|
if (view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
|
2000-08-01 09:35:42 +00:00
|
|
|
InsetTabular * inset = static_cast<InsetTabular *>
|
2002-08-13 17:43:40 +00:00
|
|
|
(view()->theLockingInset());
|
|
|
|
inset->openLayoutDialog(view());
|
|
|
|
} else if (view()->theLockingInset()->
|
2001-06-28 10:25:20 +00:00
|
|
|
getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
|
2000-08-01 09:35:42 +00:00
|
|
|
InsetTabular * inset = static_cast<InsetTabular *>(
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
|
|
|
|
inset->openLayoutDialog(view());
|
2000-08-01 09:35:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_LAYOUT_PREAMBLE:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().showPreamble();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_DROP_LAYOUTS_CHOICE:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getToolbar().openLayoutList();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MENU_OPEN_BY_NAME:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getMenubar().openByName(argument);
|
1999-12-10 00:07:59 +00:00
|
|
|
break; // RVDK_PATCH_5
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_SPELLCHECK:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().showSpellchecker();
|
2001-07-13 11:50:39 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
// --- lyxserver commands ----------------------------
|
|
|
|
|
|
|
|
|
|
|
|
case LFUN_GETNAME:
|
|
|
|
setMessage(owner->buffer()->fileName());
|
2001-06-27 14:10:35 +00:00
|
|
|
lyxerr[Debug::INFO] << "FNAME["
|
2001-02-23 16:10:03 +00:00
|
|
|
<< owner->buffer()->fileName()
|
|
|
|
<< "] " << endl;
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
case LFUN_NOTIFY:
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
2001-11-30 13:25:38 +00:00
|
|
|
dispatch_buffer = keyseq.print();
|
2001-02-23 16:10:03 +00:00
|
|
|
lyxserver->notifyClient(dispatch_buffer);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
2001-02-23 16:10:03 +00:00
|
|
|
|
|
|
|
case LFUN_GOTOFILEROW:
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
2001-06-29 06:30:53 +00:00
|
|
|
string file_name;
|
|
|
|
int row;
|
2001-06-29 11:54:39 +00:00
|
|
|
istringstream istr(argument.c_str());
|
2001-06-29 06:35:47 +00:00
|
|
|
istr >> file_name >> row;
|
2001-02-23 16:10:03 +00:00
|
|
|
// Must replace extension of the file to be .lyx and get full path
|
2001-06-29 06:30:53 +00:00
|
|
|
string const s(ChangeExtension(file_name, ".lyx"));
|
2001-02-23 16:10:03 +00:00
|
|
|
|
|
|
|
// Either change buffer or load the file
|
2001-06-29 06:30:53 +00:00
|
|
|
if (bufferlist.exists(s)) {
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->buffer(bufferlist.getBuffer(s));
|
2001-06-29 06:30:53 +00:00
|
|
|
} else {
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->buffer(bufferlist.loadLyXFile(s));
|
2001-06-29 06:30:53 +00:00
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->setCursorFromRow(row);
|
2001-02-23 16:10:03 +00:00
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->center();
|
2002-07-28 18:13:51 +00:00
|
|
|
// see BufferView_pimpl::center()
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->updateScrollbar();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
case LFUN_GOTO_PARAGRAPH:
|
|
|
|
{
|
2002-01-17 14:27:01 +00:00
|
|
|
istringstream istr(argument.c_str());
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
int id;
|
|
|
|
istr >> id;
|
2001-07-09 09:16:00 +00:00
|
|
|
Paragraph * par = owner->buffer()->getParFromID(id);
|
2001-06-29 06:30:53 +00:00
|
|
|
if (par == 0) {
|
|
|
|
lyxerr[Debug::INFO] << "No matching paragraph found! ["
|
2002-11-27 10:30:28 +00:00
|
|
|
<< id << ']' << endl;
|
2001-03-30 19:24:28 +00:00
|
|
|
break;
|
2001-08-05 22:12:27 +00:00
|
|
|
} else {
|
2002-03-27 10:27:59 +00:00
|
|
|
lyxerr[Debug::INFO] << "Paragraph " << par->id()
|
|
|
|
<< " found." << endl;
|
2001-06-29 06:30:53 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
if (view()->theLockingInset())
|
|
|
|
view()->unlockInset(view()->theLockingInset());
|
2002-01-17 14:27:01 +00:00
|
|
|
if (par->inInset()) {
|
2002-08-13 17:43:40 +00:00
|
|
|
par->inInset()->edit(view());
|
2002-01-17 14:27:01 +00:00
|
|
|
}
|
2001-02-23 16:10:03 +00:00
|
|
|
// Set the cursor
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->getLyXText()->setCursor(view(), par, 0);
|
|
|
|
view()->switchKeyMap();
|
2002-07-17 04:13:41 +00:00
|
|
|
owner->view_state_changed();
|
2000-08-31 11:51:59 +00:00
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->center();
|
2002-07-28 18:13:51 +00:00
|
|
|
// see BufferView_pimpl::center()
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->updateScrollbar();
|
2000-08-31 11:51:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_APROPOS:
|
|
|
|
case LFUN_GETTIP:
|
|
|
|
{
|
2000-09-26 13:54:57 +00:00
|
|
|
int const qa = lyxaction.LookupFunc(argument);
|
1999-12-13 00:05:34 +00:00
|
|
|
setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// --- insert characters ----------------------------------------
|
2000-02-04 09:38:32 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// --- Mathed stuff. If we are here, there is no locked inset yet.
|
2001-04-25 15:43:57 +00:00
|
|
|
case LFUN_MATH_EXTERN:
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_MATH_NUMBER:
|
2001-06-25 00:06:33 +00:00
|
|
|
case LFUN_MATH_NONUMBER:
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_MATH_LIMITS:
|
|
|
|
{
|
|
|
|
setErrorMessage(N_("This is only allowed in math mode!"));
|
2000-07-25 10:46:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-01-03 16:16:39 +00:00
|
|
|
// passthrough hat and underscore outside mathed:
|
|
|
|
case LFUN_SUBSCRIPT:
|
2002-08-13 17:43:40 +00:00
|
|
|
dispatch(FuncRequest(view(), LFUN_SELFINSERT, "_"));
|
2002-01-03 16:16:39 +00:00
|
|
|
break;
|
|
|
|
case LFUN_SUPERSCRIPT:
|
2002-08-13 17:43:40 +00:00
|
|
|
dispatch(FuncRequest(view(), LFUN_SELFINSERT, "^"));
|
2002-01-03 16:16:39 +00:00
|
|
|
break;
|
|
|
|
|
2000-07-25 10:46:18 +00:00
|
|
|
case LFUN_MATH_PANEL:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().showMathPanel();
|
2001-03-16 12:08:14 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-08-03 12:56:25 +00:00
|
|
|
case LFUN_CITATION_CREATE:
|
2000-07-07 07:46:37 +00:00
|
|
|
{
|
2002-02-16 15:59:55 +00:00
|
|
|
InsetCommandParams p("cite");
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-12-11 09:46:09 +00:00
|
|
|
if (!argument.empty()) {
|
|
|
|
// This should be set at source, ie when typing
|
|
|
|
// "citation-insert foo" in the minibuffer.
|
|
|
|
// Question: would pybibliographer also need to be
|
|
|
|
// changed. Suspect so. Leave as-is therefore.
|
|
|
|
if (contains(argument, "|")) {
|
2002-02-16 15:59:55 +00:00
|
|
|
p.setContents(token(argument, '|', 0));
|
2002-08-11 16:27:10 +00:00
|
|
|
p.setOptions(token(argument, '|', 1));
|
2000-12-11 09:46:09 +00:00
|
|
|
} else {
|
2002-02-16 15:59:55 +00:00
|
|
|
p.setContents(argument);
|
2000-12-11 09:46:09 +00:00
|
|
|
}
|
2002-08-13 17:43:40 +00:00
|
|
|
dispatch(FuncRequest(view(), LFUN_CITATION_INSERT, p.getAsString()));
|
2000-12-11 09:46:09 +00:00
|
|
|
} else
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().createCitation(p.getAsString());
|
2000-07-07 07:46:37 +00:00
|
|
|
}
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_CHILDOPEN:
|
|
|
|
{
|
2000-11-14 02:01:57 +00:00
|
|
|
string const filename =
|
2002-03-21 17:27:08 +00:00
|
|
|
MakeAbsPath(argument,
|
2002-01-14 23:31:23 +00:00
|
|
|
owner->buffer()->filePath());
|
1999-12-10 00:07:59 +00:00
|
|
|
setMessage(N_("Opening child document ") +
|
|
|
|
MakeDisplayPath(filename) + "...");
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->savePosition(0);
|
1999-12-10 00:07:59 +00:00
|
|
|
if (bufferlist.exists(filename))
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->buffer(bufferlist.getBuffer(filename));
|
1999-12-10 00:07:59 +00:00
|
|
|
else
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->buffer(bufferlist.loadLyXFile(filename));
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_TOGGLECURSORFOLLOW:
|
2000-10-10 14:17:33 +00:00
|
|
|
lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-09-06 01:41:01 +00:00
|
|
|
case LFUN_KMAP_OFF:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getIntl().KeyMapOn(false);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-09-06 01:41:01 +00:00
|
|
|
case LFUN_KMAP_PRIM:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getIntl().KeyMapPrim();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-09-06 01:41:01 +00:00
|
|
|
case LFUN_KMAP_SEC:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getIntl().KeyMapSec();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-09-06 01:41:01 +00:00
|
|
|
case LFUN_KMAP_TOGGLE:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getIntl().ToggleKeyMap();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
case LFUN_SEQUENCE:
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
|
|
|
// argument contains ';'-terminated commands
|
2002-07-10 15:34:30 +00:00
|
|
|
while (!argument.empty()) {
|
1999-12-10 00:07:59 +00:00
|
|
|
string first;
|
|
|
|
argument = split(argument, first, ';');
|
2002-07-18 20:15:29 +00:00
|
|
|
dispatch(first);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-07-28 04:59:45 +00:00
|
|
|
case LFUN_DIALOG_PREFERENCES:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().showPreferences();
|
2000-07-28 04:59:45 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_SAVEPREFERENCES:
|
|
|
|
{
|
|
|
|
Path p(user_lyxdir);
|
2000-03-12 10:35:05 +00:00
|
|
|
lyxrc.write("preferences");
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2000-08-14 05:24:35 +00:00
|
|
|
case LFUN_SCREEN_FONT_UPDATE:
|
|
|
|
{
|
|
|
|
// handle the screen font changes.
|
|
|
|
lyxrc.set_font_norm_type();
|
2002-07-12 03:05:13 +00:00
|
|
|
lyx_gui::update_fonts();
|
2002-08-07 14:15:06 +00:00
|
|
|
// We also need to empty the textcache so that
|
|
|
|
// the buffer will be formatted correctly after
|
|
|
|
// a zoom change.
|
|
|
|
textcache.clear();
|
2000-08-14 05:24:35 +00:00
|
|
|
// Of course we should only do the resize and the textcache.clear
|
|
|
|
// if values really changed...but not very important right now. (Lgb)
|
2001-06-25 00:06:33 +00:00
|
|
|
// All visible buffers will need resize
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->resize();
|
|
|
|
view()->repaint();
|
2000-08-14 05:24:35 +00:00
|
|
|
}
|
2000-10-02 06:11:02 +00:00
|
|
|
break;
|
2000-08-14 05:24:35 +00:00
|
|
|
|
2000-06-26 15:33:13 +00:00
|
|
|
case LFUN_SET_COLOR:
|
|
|
|
{
|
2000-11-14 02:01:57 +00:00
|
|
|
string lyx_name;
|
|
|
|
string const x11_name = split(argument, lyx_name, ' ');
|
2000-06-26 15:33:13 +00:00
|
|
|
if (lyx_name.empty() || x11_name.empty()) {
|
|
|
|
setErrorMessage(N_("Syntax: set-color <lyx_name>"
|
|
|
|
" <x11_name>"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-02-27 09:59:52 +00:00
|
|
|
bool const graphicsbg_changed =
|
|
|
|
(lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
|
|
|
|
x11_name != lcolor.getX11Name(LColor::graphicsbg));
|
|
|
|
|
2000-06-26 15:33:13 +00:00
|
|
|
if (!lcolor.setColor(lyx_name, x11_name)) {
|
2002-11-24 15:20:31 +00:00
|
|
|
#if USE_BOOST_FORMAT
|
|
|
|
setErrorMessage(
|
|
|
|
boost::io::str(
|
|
|
|
boost::format(
|
|
|
|
_("Set-color \"%1$s\" failed "
|
|
|
|
"- color is undefined or "
|
|
|
|
"may not be redefined"))
|
|
|
|
% lyx_name));
|
|
|
|
#else
|
|
|
|
setErrorMessage(_("Set-color ") + lyx_name
|
|
|
|
+ _(" failed - color is undefined"
|
|
|
|
" or may not be redefined"));
|
|
|
|
#endif
|
2002-11-21 18:33:09 +00:00
|
|
|
|
2000-06-26 15:33:13 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2002-07-12 02:27:42 +00:00
|
|
|
lyx_gui::update_color(lcolor.getFromLyXName(lyx_name));
|
2002-02-27 09:59:52 +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
|
2002-02-27 09:59:52 +00:00
|
|
|
grfx::GCache & gc = grfx::GCache::get();
|
|
|
|
gc.changeDisplay(true);
|
2002-06-25 15:59:10 +00:00
|
|
|
#endif
|
2002-02-27 09:59:52 +00:00
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->repaint();
|
2000-06-26 15:33:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
case LFUN_MESSAGE:
|
|
|
|
owner->message(argument);
|
|
|
|
break;
|
|
|
|
|
2002-02-27 09:59:52 +00:00
|
|
|
case LFUN_FORKS_SHOW:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().showForks();
|
2002-02-27 09:59:52 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_FORKS_KILL:
|
|
|
|
{
|
|
|
|
if (!isStrInt(argument))
|
|
|
|
break;
|
|
|
|
|
|
|
|
pid_t const pid = strToInt(argument);
|
|
|
|
ForkedcallsController & fcc = ForkedcallsController::get();
|
|
|
|
fcc.kill(pid);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-03-11 09:54:42 +00:00
|
|
|
case LFUN_TOOLTIPS_TOGGLE:
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().toggleTooltips();
|
2002-03-11 09:54:42 +00:00
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
default:
|
2001-02-23 16:10:03 +00:00
|
|
|
// Then if it was none of the above
|
2002-02-07 16:43:54 +00:00
|
|
|
// Trying the BufferView::pimpl dispatch:
|
2002-08-13 17:43:40 +00:00
|
|
|
if (!view()->dispatch(ev))
|
2001-05-16 07:53:23 +00:00
|
|
|
lyxerr << "A truly unknown func ["
|
2002-08-07 08:11:41 +00:00
|
|
|
<< lyxaction.getActionName(ev.action) << "]!"
|
2001-07-11 12:10:46 +00:00
|
|
|
<< endl;
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
} // end of switch
|
2001-02-23 16:10:03 +00:00
|
|
|
|
|
|
|
exit_with_message:
|
2002-08-07 08:11:41 +00:00
|
|
|
sendDispatchMessage(getMessage(), ev, verbose);
|
2002-07-18 20:15:29 +00:00
|
|
|
}
|
1999-11-22 16:19:48 +00:00
|
|
|
|
|
|
|
|
2002-08-07 08:11:41 +00:00
|
|
|
void LyXFunc::sendDispatchMessage(string const & msg, FuncRequest const & ev, bool verbose)
|
2002-07-18 20:15:29 +00:00
|
|
|
{
|
2002-01-13 13:07:27 +00:00
|
|
|
owner->updateMenubar();
|
|
|
|
owner->updateToolbar();
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2002-08-07 08:11:41 +00:00
|
|
|
if (ev.action == LFUN_SELFINSERT || !verbose) {
|
2002-07-18 20:15:29 +00:00
|
|
|
lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl;
|
|
|
|
if (!msg.empty())
|
|
|
|
owner->message(msg);
|
|
|
|
return;
|
|
|
|
}
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2002-08-07 08:11:41 +00:00
|
|
|
string 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
|
|
|
|
2002-08-07 08:11:41 +00:00
|
|
|
string comname = lyxaction.getActionName(ev.action);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-08-07 08:11:41 +00:00
|
|
|
int pseudoaction = ev.action;
|
2002-07-18 20:15:29 +00:00
|
|
|
bool argsadded = false;
|
|
|
|
|
2002-08-07 08:11:41 +00:00
|
|
|
if (!ev.argument.empty()) {
|
2002-07-18 20:15:29 +00:00
|
|
|
// the pseudoaction is useful for the bindings
|
2002-08-07 08:11:41 +00:00
|
|
|
pseudoaction = lyxaction.searchActionArg(ev.action, ev.argument);
|
2002-07-18 20:15:29 +00:00
|
|
|
|
|
|
|
if (pseudoaction == LFUN_UNKNOWN_ACTION) {
|
2002-08-07 08:11:41 +00:00
|
|
|
pseudoaction = ev.action;
|
2002-07-18 20:15:29 +00:00
|
|
|
} else {
|
2002-11-27 10:30:28 +00:00
|
|
|
comname += ' ' + ev.argument;
|
2002-07-18 20:15:29 +00:00
|
|
|
argsadded = true;
|
|
|
|
}
|
|
|
|
}
|
1999-11-22 16:19:48 +00:00
|
|
|
|
2002-07-18 20:15:29 +00:00
|
|
|
string const shortcuts = toplevel_keymap->findbinding(pseudoaction);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-07-18 20:15:29 +00:00
|
|
|
if (!shortcuts.empty()) {
|
|
|
|
comname += ": " + shortcuts;
|
2002-08-07 08:11:41 +00:00
|
|
|
} else if (!argsadded && !ev.argument.empty()) {
|
2002-11-27 10:30:28 +00:00
|
|
|
comname += ' ' + ev.argument;
|
2002-07-18 20:15:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!comname.empty()) {
|
2002-07-28 22:50:13 +00:00
|
|
|
comname = rtrim(comname);
|
2002-11-27 10:30:28 +00:00
|
|
|
dispatch_msg += '(' + comname + ')';
|
2002-07-18 20:15:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lyxerr[Debug::ACTION] << "verbose dispatch msg " << dispatch_msg << endl;
|
|
|
|
if (!dispatch_msg.empty())
|
|
|
|
owner->message(dispatch_msg);
|
|
|
|
}
|
|
|
|
|
2002-07-28 18:13:51 +00:00
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
void LyXFunc::setupLocalKeymap()
|
|
|
|
{
|
2001-03-07 16:18:05 +00:00
|
|
|
keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
|
|
|
|
cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
|
1999-12-16 06:43:25 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +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
|
|
|
{
|
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
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
if (view()->available()) {
|
2002-01-14 23:31:23 +00:00
|
|
|
string const trypath = owner->buffer()->filePath();
|
1999-12-16 06:43:25 +00:00
|
|
|
// If directory is writeable, use this as default.
|
2001-08-01 10:08:53 +00:00
|
|
|
if (IsDirWriteable(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()) {
|
|
|
|
filename = AddName(lyxrc.document_path,
|
2000-10-02 16:44:47 +00:00
|
|
|
"newfile" + tostr(++newfile_number) + ".lyx");
|
2002-07-11 15:13:21 +00:00
|
|
|
FileInfo fi(filename);
|
|
|
|
while (bufferlist.exists(filename) || fi.readable()) {
|
2000-08-08 11:08:07 +00:00
|
|
|
++newfile_number;
|
2002-07-11 15:13:21 +00:00
|
|
|
filename = AddName(lyxrc.document_path,
|
2000-10-02 16:44:47 +00:00
|
|
|
"newfile" + tostr(newfile_number) +
|
|
|
|
".lyx");
|
2002-07-11 15:13:21 +00:00
|
|
|
fi.newFile(filename);
|
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) {
|
2001-03-07 14:25:31 +00:00
|
|
|
FileDialog fileDlg(owner, _("Select template file"),
|
|
|
|
LFUN_SELECT_FILE_SYNC,
|
2002-01-13 15:01:25 +00:00
|
|
|
make_pair(string(_("Documents|#o#O")),
|
2001-04-17 15:15:59 +00:00
|
|
|
string(lyxrc.document_path)),
|
2002-01-13 15:01:25 +00:00
|
|
|
make_pair(string(_("Templates|#T#t")),
|
2001-04-17 15:15:59 +00:00
|
|
|
string(lyxrc.template_path)));
|
|
|
|
|
|
|
|
FileDialog::Result result =
|
2002-11-17 08:32:09 +00:00
|
|
|
fileDlg.open(lyxrc.template_path,
|
2001-04-17 15:15:59 +00:00
|
|
|
_("*.lyx|LyX Documents (*.lyx)"));
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
return;
|
|
|
|
|
|
|
|
string const fname = result.second;
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
if (fname.empty())
|
2001-03-07 14:25:31 +00:00
|
|
|
return;
|
2002-03-21 17:27:08 +00:00
|
|
|
templname = fname;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->buffer(bufferlist.newFile(filename, templname, !name.empty()));
|
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
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
if (view()->available()) {
|
2002-01-14 23:31:23 +00:00
|
|
|
string const trypath = owner->buffer()->filePath();
|
1999-12-16 06:43:25 +00:00
|
|
|
// If directory is writeable, use this as default.
|
2001-08-01 10:08:53 +00:00
|
|
|
if (IsDirWriteable(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()) {
|
|
|
|
FileDialog fileDlg(owner, _("Select document to open"),
|
|
|
|
LFUN_FILE_OPEN,
|
2002-01-13 15:01:25 +00:00
|
|
|
make_pair(string(_("Documents|#o#O")),
|
2001-04-17 15:15:59 +00:00
|
|
|
string(lyxrc.document_path)),
|
2002-01-13 15:01:25 +00:00
|
|
|
make_pair(string(_("Examples|#E#e")),
|
2001-04-17 15:15:59 +00:00
|
|
|
string(AddPath(system_lyxdir, "examples"))));
|
|
|
|
|
|
|
|
FileDialog::Result result =
|
2002-11-17 08:32:09 +00:00
|
|
|
fileDlg.open(initpath,
|
2001-04-17 15:15:59 +00:00
|
|
|
"*.lyx|LyX Documents (*.lyx)");
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
return;
|
|
|
|
|
|
|
|
filename = result.second;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
// check selected filename
|
|
|
|
if (filename.empty()) {
|
2001-04-24 17:33:01 +00:00
|
|
|
owner->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
|
2001-08-01 10:08:53 +00:00
|
|
|
string const fullpath = FileSearch(string(), filename, "lyx");
|
2002-08-01 22:26:30 +00:00
|
|
|
if (!fullpath.empty()) {
|
|
|
|
filename = fullpath;
|
2001-08-01 10:08:53 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-06-14 17:58:49 +00:00
|
|
|
string const disp_fn(MakeDisplayPath(filename));
|
|
|
|
|
2002-08-01 22:26:30 +00:00
|
|
|
// if the file doesn't exist, let the user create one
|
|
|
|
FileInfo const f(filename, true);
|
|
|
|
if (!f.exist()) {
|
2002-08-10 15:21:07 +00:00
|
|
|
if (!Alert::askQuestion(_("No such file"), disp_fn,
|
2002-08-01 22:26:30 +00:00
|
|
|
_("Start a new document with this filename ?"))) {
|
|
|
|
owner->message(_("Canceled"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// the user specifically chose this name. Believe them.
|
|
|
|
Buffer * buffer = bufferlist.newFile(filename, "", true);
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->buffer(buffer);
|
2002-08-01 22:26:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-06-14 17:58:49 +00:00
|
|
|
ostringstream str;
|
2002-11-24 15:20:31 +00:00
|
|
|
#if USE_BOOST_FORMAT
|
2002-11-21 18:33:09 +00:00
|
|
|
str << boost::format(_("Opening document %1$s...")) % disp_fn;
|
2002-11-24 15:20:31 +00:00
|
|
|
#else
|
|
|
|
str << _("Opening document ") << disp_fn << _("...");
|
|
|
|
#endif
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-11-04 02:12:42 +00:00
|
|
|
owner->message(STRCONV(str.str()));
|
2001-06-14 17:58:49 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
Buffer * openbuf = bufferlist.loadLyXFile(filename);
|
2002-11-04 02:12:42 +00:00
|
|
|
ostringstream str2;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (openbuf) {
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->buffer(openbuf);
|
2002-11-24 15:20:31 +00:00
|
|
|
#if USE_BOOST_FORMAT
|
2002-11-21 18:33:09 +00:00
|
|
|
str2 << boost::format(_("Document %1$s opened.")) % disp_fn;
|
2002-11-24 15:20:31 +00:00
|
|
|
#else
|
|
|
|
str2 << _("Document ") << disp_fn << _(" opened.");
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
} else {
|
2002-11-24 15:20:31 +00:00
|
|
|
#if USE_BOOST_FORMAT
|
|
|
|
str2 << boost::format(_("Could not open document %1$s"))
|
|
|
|
% disp_fn;
|
|
|
|
#else
|
|
|
|
str2 << _("Could not open document ") << disp_fn;
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2002-11-04 02:12:42 +00:00
|
|
|
owner->message(STRCONV(str2.str()));
|
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
|
|
|
|
2002-03-21 17:27:08 +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
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
if (view()->available()) {
|
2002-01-14 23:31:23 +00:00
|
|
|
string const trypath = owner->buffer()->filePath();
|
2000-04-28 11:18:04 +00:00
|
|
|
// If directory is writeable, use this as default.
|
2001-08-01 10:08:53 +00:00
|
|
|
if (IsDirWriteable(trypath))
|
2000-04-28 11:18:04 +00:00
|
|
|
initpath = trypath;
|
|
|
|
}
|
|
|
|
|
2002-11-24 15:20:31 +00:00
|
|
|
#if USE_BOOST_FORMAT
|
|
|
|
boost::format fmt(_("Select %1$s file to import"));
|
|
|
|
fmt % formats.prettyName(format);
|
|
|
|
string const text = fmt.str();
|
|
|
|
#else
|
|
|
|
string const text = _("Select ") + formats.prettyName(format)
|
|
|
|
+ _(" file to import");;
|
|
|
|
#endif
|
2001-03-07 14:25:31 +00:00
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
FileDialog fileDlg(owner, text,
|
2001-03-07 14:25:31 +00:00
|
|
|
LFUN_IMPORT,
|
2002-01-13 15:01:25 +00:00
|
|
|
make_pair(string(_("Documents|#o#O")),
|
2001-04-17 15:15:59 +00:00
|
|
|
string(lyxrc.document_path)),
|
2002-01-13 15:01:25 +00:00
|
|
|
make_pair(string(_("Examples|#E#e")),
|
2001-04-17 15:15:59 +00:00
|
|
|
string(AddPath(system_lyxdir, "examples"))));
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-07-30 11:56:00 +00:00
|
|
|
string const extension = "*." + formats.extension(format)
|
|
|
|
+ "| " + formats.prettyName(format)
|
2002-11-27 10:30:28 +00:00
|
|
|
+ " (*." + formats.extension(format) + ')';
|
2001-03-07 14:25:31 +00:00
|
|
|
|
2002-11-17 08:32:09 +00:00
|
|
|
FileDialog::Result result = fileDlg.open(initpath,
|
2001-04-17 15:15:59 +00:00
|
|
|
extension);
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
return;
|
|
|
|
|
|
|
|
filename = 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())
|
2001-04-24 17:33:01 +00:00
|
|
|
owner->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
|
|
|
|
filename = MakeAbsPath(filename);
|
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
string const lyxfile = ChangeExtension(filename, ".lyx");
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Check if the document already is open
|
2002-05-30 19:49:00 +00:00
|
|
|
if (lyxrc.use_gui && bufferlist.exists(lyxfile)) {
|
2002-03-21 17:27:08 +00:00
|
|
|
switch (Alert::askConfirmation(_("Document is already open:"),
|
2001-04-17 15:15:59 +00:00
|
|
|
MakeDisplayPath(lyxfile, 50),
|
|
|
|
_("Do you want to close that document now?\n"
|
|
|
|
"('No' will just switch to the open version)")))
|
1999-12-16 06:43:25 +00:00
|
|
|
{
|
2002-05-30 19:49:00 +00:00
|
|
|
case 1:
|
1999-09-27 18:44:28 +00:00
|
|
|
// If close is canceled, we cancel here too.
|
2002-05-30 19:49:00 +00:00
|
|
|
if (!bufferlist.close(bufferlist.getBuffer(lyxfile)))
|
1999-12-16 06:43:25 +00:00
|
|
|
return;
|
|
|
|
break;
|
2002-05-30 19:49:00 +00:00
|
|
|
case 2:
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->buffer(bufferlist.getBuffer(lyxfile));
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
2002-05-30 19:49:00 +00:00
|
|
|
case 3:
|
2001-04-24 17:33:01 +00:00
|
|
|
owner->message(_("Canceled."));
|
1999-12-16 06:43:25 +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
|
|
|
|
if (FileInfo(lyxfile, true).exist() && filename != lyxfile) {
|
|
|
|
if (!Alert::askQuestion(_("A document by the name"),
|
|
|
|
MakeDisplayPath(lyxfile), _("already exists. Overwrite?"))) {
|
|
|
|
owner->message(_("Canceled"));
|
|
|
|
return;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-10-23 12:16:05 +00:00
|
|
|
Importer::Import(owner, filename, format);
|
2000-03-20 18:55:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void LyXFunc::reloadBuffer()
|
|
|
|
{
|
2000-11-14 02:01:57 +00:00
|
|
|
string const fn = owner->buffer()->fileName();
|
1999-11-09 23:52:04 +00:00
|
|
|
if (bufferlist.close(owner->buffer()))
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->buffer(bufferlist.loadLyXFile(fn));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-16 15:42:57 +00:00
|
|
|
void LyXFunc::closeBuffer()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-09 23:52:04 +00:00
|
|
|
if (bufferlist.close(owner->buffer()) && !quitting) {
|
1999-11-05 06:02:34 +00:00
|
|
|
if (bufferlist.empty()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
// need this otherwise SEGV may occur while trying to
|
|
|
|
// set variables that don't exist
|
|
|
|
// since there's no current buffer
|
2002-08-13 14:40:38 +00:00
|
|
|
owner->getDialogs().hideBufferDependent();
|
2000-11-14 02:01:57 +00:00
|
|
|
} else {
|
2002-08-13 17:43:40 +00:00
|
|
|
view()->buffer(bufferlist.first());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Each "owner" should have it's own message method. lyxview and
|
|
|
|
// the minibuffer would use the minibuffer, but lyxserver would
|
|
|
|
// send an ERROR signal to its client. Alejandro 970603
|
|
|
|
// This func is bit problematic when it comes to NLS, to make the
|
|
|
|
// lyx servers client be language indepenent we must not translate
|
|
|
|
// strings sent to this func.
|
1999-11-22 16:19:48 +00:00
|
|
|
void LyXFunc::setErrorMessage(string const & m) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
dispatch_buffer = m;
|
|
|
|
errorstat = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
void LyXFunc::setMessage(string const & m) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
dispatch_buffer = m;
|
|
|
|
}
|
2001-04-17 15:15:59 +00:00
|
|
|
|
|
|
|
|
2002-01-13 13:07:27 +00:00
|
|
|
void LyXFunc::setStatusMessage(string const & m) const
|
|
|
|
{
|
|
|
|
status_buffer = m;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-18 20:15:29 +00:00
|
|
|
string const LyXFunc::view_status_message()
|
2001-04-17 15:15:59 +00:00
|
|
|
{
|
|
|
|
// When meta-fake key is pressed, show the key sequence so far + "M-".
|
|
|
|
if (wasMetaKey()) {
|
2002-07-18 20:15:29 +00:00
|
|
|
return keyseq.print() + "M-";
|
2001-04-17 15:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Else, when a non-complete key sequence is pressed,
|
|
|
|
// show the available options.
|
2001-12-03 13:17:04 +00:00
|
|
|
if (keyseq.length() > 0 && !keyseq.deleted()) {
|
2002-07-18 20:15:29 +00:00
|
|
|
return keyseq.printOptions();
|
2001-04-17 15:15:59 +00:00
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
if (!view()->available())
|
2002-07-18 20:15:29 +00:00
|
|
|
return _("Welcome to LyX!");
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
return currentState(view());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BufferView * LyXFunc::view() const
|
|
|
|
{
|
2002-08-14 10:16:05 +00:00
|
|
|
lyx::Assert(owner);
|
2002-08-13 17:43:40 +00:00
|
|
|
return owner->view().get();
|
2001-04-17 15:15:59 +00:00
|
|
|
}
|