1999-09-27 18:44:28 +00:00
|
|
|
/* This file is part of
|
1999-11-15 12:01:38 +00:00
|
|
|
* ======================================================
|
1999-10-02 16:21:10 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
#include "Lsstream.h"
|
2000-04-11 22:55:29 +00:00
|
|
|
|
2001-07-24 22:08:49 +00:00
|
|
|
#include <ctime>
|
|
|
|
#include <clocale>
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
#include <utility>
|
|
|
|
#include <algorithm>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <cctype>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
#include "support/lyxalgo.h"
|
2001-07-29 15:34:18 +00:00
|
|
|
#include "support/LAssert.h"
|
2000-07-24 13:53:19 +00:00
|
|
|
#include "version.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "kbmap.h"
|
|
|
|
#include "lyxfunc.h"
|
|
|
|
#include "bufferlist.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "BufferView.h"
|
2000-06-26 15:33:13 +00:00
|
|
|
#include "ColorHandler.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"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "insets/inseturl.h"
|
|
|
|
#include "insets/insetlatexaccent.h"
|
|
|
|
#include "insets/insettoc.h"
|
|
|
|
#include "insets/insetref.h"
|
|
|
|
#include "insets/insetparent.h"
|
1999-11-15 12:01:38 +00:00
|
|
|
#include "insets/insetindex.h"
|
|
|
|
#include "insets/insetinclude.h"
|
|
|
|
#include "insets/insetbib.h"
|
2000-06-07 08:53:40 +00:00
|
|
|
#include "insets/insetcite.h"
|
2000-02-25 12:06:15 +00:00
|
|
|
#include "insets/insettext.h"
|
|
|
|
#include "insets/insetert.h"
|
2000-06-12 11:27:15 +00:00
|
|
|
#include "insets/insetexternal.h"
|
2000-02-29 02:19:17 +00:00
|
|
|
#include "insets/insetgraphics.h"
|
2000-03-08 13:52:57 +00:00
|
|
|
#include "insets/insetfoot.h"
|
2000-06-28 13:35:52 +00:00
|
|
|
#include "insets/insetmarginal.h"
|
|
|
|
#include "insets/insetminipage.h"
|
|
|
|
#include "insets/insetfloat.h"
|
2001-07-24 22:08:49 +00:00
|
|
|
#if 0
|
2000-06-28 13:35:52 +00:00
|
|
|
#include "insets/insetlist.h"
|
2000-07-04 19:16:35 +00:00
|
|
|
#include "insets/insettheorem.h"
|
2001-07-24 22:08:49 +00:00
|
|
|
#endif
|
|
|
|
#include "insets/insettabular.h"
|
2000-07-18 17:45:27 +00:00
|
|
|
#include "insets/insetcaption.h"
|
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"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "minibuffer.h"
|
|
|
|
#include "vspace.h"
|
|
|
|
#include "LyXView.h"
|
|
|
|
#include "lyx_gui_misc.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "support/filetools.h"
|
|
|
|
#include "support/FileInfo.h"
|
1999-11-15 12:01:38 +00:00
|
|
|
#include "support/syscall.h"
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
#include "support/path.h"
|
2000-10-11 21:06:43 +00:00
|
|
|
#include "support/lyxfunctional.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
#include "debug.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lyxrc.h"
|
|
|
|
#include "lyxtext.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "trans_mgr.h"
|
1999-11-04 01:40:20 +00:00
|
|
|
#include "layout.h"
|
2000-02-10 17:53:36 +00:00
|
|
|
#include "WorkArea.h"
|
2000-04-12 14:20:08 +00:00
|
|
|
#include "bufferview_funcs.h"
|
2001-03-07 14:25:31 +00:00
|
|
|
#include "frontends/FileDialog.h"
|
2000-06-12 11:27:15 +00:00
|
|
|
#include "frontends/Dialogs.h"
|
2000-07-24 13:53:19 +00:00
|
|
|
#include "frontends/Toolbar.h"
|
|
|
|
#include "frontends/Menubar.h"
|
2000-07-15 23:51:46 +00:00
|
|
|
#include "FloatList.h"
|
2000-10-23 12:16:05 +00:00
|
|
|
#include "converter.h"
|
2000-08-30 03:40:51 +00:00
|
|
|
#include "exporter.h"
|
2000-10-23 12:16:05 +00:00
|
|
|
#include "importer.h"
|
2000-08-14 05:24:35 +00:00
|
|
|
#include "FontLoader.h"
|
|
|
|
#include "TextCache.h"
|
2001-03-06 10:20:33 +00:00
|
|
|
#include "lyxfind.h"
|
2001-07-06 15:57:54 +00:00
|
|
|
#include "undo_funcs.h"
|
2001-08-03 10:32:20 +00:00
|
|
|
#include "ParagraphParameters.h"
|
2001-08-02 18:46:53 +00:00
|
|
|
#include "figureForm.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
using std::pair;
|
2001-03-07 14:25:31 +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;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
extern BufferList bufferlist;
|
1999-11-04 01:40:20 +00:00
|
|
|
extern LyXServer * lyxserver;
|
2000-07-20 10:04:27 +00:00
|
|
|
extern int greek_kb_flag;
|
1999-09-27 18:44:28 +00:00
|
|
|
extern bool selection_possible;
|
2001-02-26 10:32:45 +00:00
|
|
|
extern void MenuSendto();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-03-07 16:18:05 +00:00
|
|
|
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-07-25 10:46:18 +00:00
|
|
|
extern void show_symbols_form(LyXFunc *);
|
2000-05-20 01:38:25 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
extern LyXAction lyxaction;
|
|
|
|
// (alkis)
|
|
|
|
extern tex_accent_struct get_accent(kb_action action);
|
|
|
|
|
2000-02-29 02:19:17 +00:00
|
|
|
extern LyXTextClass::size_type current_layout;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
extern void ShowLatexLog();
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
///
|
|
|
|
class MiniBufferController : public SigC::Object {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
MiniBufferController() {
|
|
|
|
minibuffer
|
|
|
|
.cmdReady
|
|
|
|
.connect(slot(this,
|
|
|
|
&MiniBufferController::receiveCommand));
|
|
|
|
minibuffer
|
|
|
|
.argReady
|
|
|
|
.connect(slot(this,
|
|
|
|
&MiniBufferController::receiveArg));
|
|
|
|
}
|
|
|
|
///
|
|
|
|
void receiveCmd(string const & cmd) {}
|
|
|
|
///
|
|
|
|
void receiveArg(string const & arg) {}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
MiniBufferController mb_ctrl;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/* === globals =========================================================== */
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
// Initialization of static member var
|
1999-09-27 18:44:28 +00:00
|
|
|
bool LyXFunc::show_sc = true;
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
LyXFunc::LyXFunc(LyXView * o)
|
1999-12-16 06:43:25 +00:00
|
|
|
: owner(o)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
meta_fake_bit = 0;
|
|
|
|
lyx_dead_action = LFUN_NOACTION;
|
|
|
|
lyx_calling_dead_action = LFUN_NOACTION;
|
|
|
|
setupLocalKeymap();
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
return owner->view()->text;
|
|
|
|
return owner->view()->getLyXText();
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// I changed this func slightly. I commented out the ...FinishUndo(),
|
|
|
|
// this means that all places that used to have a moveCursorUpdate, now
|
|
|
|
// have a ...FinishUndo() as the preceeding statement. I have also added
|
|
|
|
// a moveCursorUpdate to some of the functions that updated the cursor, but
|
|
|
|
// that did not show its new position.
|
|
|
|
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()) {
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT(flag)->setSelection(owner->view());
|
2001-02-22 14:09:20 +00:00
|
|
|
if (TEXT(flag)->bv_owner)
|
2001-02-14 08:38:21 +00:00
|
|
|
owner->view()->toggleToggle();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
2001-02-22 14:09:20 +00:00
|
|
|
owner->view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->showCursor();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/* ---> Everytime the cursor is moved, show the current font state. */
|
|
|
|
// should this too me moved out of this func?
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->setState();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
void LyXFunc::handleKeyFunc(kb_action action)
|
|
|
|
{
|
2001-05-16 07:53:23 +00:00
|
|
|
char c = keyseq.getiso();
|
2001-02-23 16:10:03 +00:00
|
|
|
|
2001-05-16 07:53:23 +00:00
|
|
|
if (keyseq.length != -1) c = 0;
|
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
owner->getIntl()->getTrans()
|
|
|
|
.deadkey(c, get_accent(action).accent, TEXT(false));
|
|
|
|
// Need to reset, in case the minibuffer calls these
|
|
|
|
// actions
|
|
|
|
keyseq.reset();
|
|
|
|
keyseq.length = 0;
|
|
|
|
// copied verbatim from do_accent_char
|
|
|
|
owner->view()->update(TEXT(false),
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-17 01:23:29 +00:00
|
|
|
void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
|
2000-08-14 15:31:16 +00:00
|
|
|
{
|
|
|
|
string argument;
|
|
|
|
|
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
2001-05-17 01:23:29 +00:00
|
|
|
char const * tmp = XKeysymToString(keysym);
|
2000-12-17 06:09:35 +00:00
|
|
|
string const stm = (tmp ? tmp : "");
|
2000-08-14 15:31:16 +00:00
|
|
|
lyxerr << "KeySym is "
|
|
|
|
<< stm
|
|
|
|
<< "["
|
2000-12-17 06:09:35 +00:00
|
|
|
<< keysym << "] State is ["
|
|
|
|
<< state << "]"
|
2000-08-14 15:31:16 +00:00
|
|
|
<< endl;
|
|
|
|
}
|
|
|
|
// Do nothing if we have nothing (JMarc)
|
|
|
|
if (keysym == NoSymbol) {
|
|
|
|
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
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
// Can we be sure that this will work for all X-Windows
|
|
|
|
// implementations? (Lgb)
|
|
|
|
// This code snippet makes lyx ignore some keys. Perhaps
|
|
|
|
// all of them should be explictly mentioned?
|
2000-11-04 10:00:12 +00:00
|
|
|
if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
|
2001-05-17 01:23:29 +00:00
|
|
|
|| keysym == XK_Mode_switch || keysym == 0x0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
int action = cancel_meta_seq.addkey(keysym, state
|
|
|
|
&(ShiftMask|ControlMask
|
|
|
|
|Mod1Mask));
|
2000-12-17 06:09:35 +00:00
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
|
|
|
lyxerr << "action first set to [" << action << "]" << endl;
|
|
|
|
}
|
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
// When not cancel or meta-fake, do the normal lookup.
|
|
|
|
// Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
|
|
|
|
// Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
|
2000-11-04 10:00:12 +00:00
|
|
|
if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
|
2000-12-17 06:09:35 +00:00
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
2001-04-17 15:15:59 +00:00
|
|
|
lyxerr << "meta_fake_bit is ["
|
|
|
|
<< meta_fake_bit << "]" << endl;
|
2000-12-17 06:09:35 +00:00
|
|
|
}
|
2000-08-14 15:31:16 +00:00
|
|
|
// remove Caps Lock and Mod2 as a modifiers
|
|
|
|
action = keyseq.addkey(keysym,
|
|
|
|
(state | meta_fake_bit)
|
|
|
|
&(ShiftMask|ControlMask
|
2000-12-17 06:09:35 +00:00
|
|
|
|Mod1Mask));
|
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
2001-04-17 15:15:59 +00:00
|
|
|
lyxerr << "action now set to ["
|
|
|
|
<< action << "]" << endl;
|
2000-12-17 06:09:35 +00:00
|
|
|
}
|
2000-08-14 15:31:16 +00:00
|
|
|
}
|
|
|
|
// Dont remove this unless you know what you are doing.
|
|
|
|
meta_fake_bit = 0;
|
|
|
|
|
|
|
|
if (action == 0) action = LFUN_PREFIX;
|
|
|
|
|
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
|
|
|
string buf;
|
|
|
|
keyseq.print(buf);
|
2001-05-29 09:50:02 +00:00
|
|
|
lyxerr << "Key [action="
|
2000-08-14 15:31:16 +00:00
|
|
|
<< action << "]["
|
|
|
|
<< buf << "]"
|
|
|
|
<< 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)
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
if (keyseq.length > 1 || keyseq.length < -1) {
|
2000-08-14 15:31:16 +00:00
|
|
|
string buf;
|
|
|
|
keyseq.print(buf);
|
2001-04-17 15:15:59 +00:00
|
|
|
owner->message(buf);
|
2000-08-14 15:31:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (action == -1) {
|
2001-05-17 01:23:29 +00:00
|
|
|
// It is unknown, but what if we remove all
|
|
|
|
// the modifiers? (Lgb)
|
|
|
|
action = keyseq.addkey(keysym, 0);
|
|
|
|
|
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
|
|
|
lyxerr << "Removing modifiers...\n"
|
|
|
|
<< "Action now set to ["
|
|
|
|
<< action << "]" << endl;
|
|
|
|
}
|
|
|
|
if (action == -1) {
|
|
|
|
owner->message(_("Unknown function."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action == LFUN_SELFINSERT) {
|
2001-05-29 09:50:02 +00:00
|
|
|
// This is very X dependant.
|
|
|
|
unsigned int c = keysym;
|
|
|
|
|
|
|
|
switch (c & 0x0000FF00) {
|
|
|
|
// latin 1 byte 3 = 0
|
|
|
|
case 0x00000000: break;
|
|
|
|
// latin 2 byte 3 = 1
|
|
|
|
case 0x00000100:
|
|
|
|
// latin 3 byte 3 = 2
|
|
|
|
case 0x00000200:
|
|
|
|
// latin 4 byte 3 = 3
|
|
|
|
case 0x00000300:
|
|
|
|
// latin 8 byte 3 = 18 (0x12)
|
|
|
|
case 0x00001200:
|
|
|
|
// latin 9 byte 3 = 19 (0x13)
|
|
|
|
case 0x00001300:
|
|
|
|
c &= 0x000000FF;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
c = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (c > 0)
|
|
|
|
argument = static_cast<char>(c);
|
|
|
|
lyxerr[Debug::KEY] << "SelfInsert arg[`"
|
|
|
|
<< argument << "']" << endl;
|
2000-08-14 15:31:16 +00:00
|
|
|
}
|
2000-12-18 14:21:57 +00:00
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
bool tmp_sc = show_sc;
|
|
|
|
show_sc = false;
|
2001-07-16 15:42:57 +00:00
|
|
|
dispatch(action, argument);
|
2000-08-14 15:31:16 +00:00
|
|
|
show_sc = tmp_sc;
|
|
|
|
|
2001-05-17 01:23:29 +00:00
|
|
|
//return 0;
|
2000-08-14 15:31:16 +00:00
|
|
|
}
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
func_status::value_type LyXFunc::getStatus(int ac) const
|
2001-02-26 10:32:45 +00:00
|
|
|
{
|
|
|
|
return getStatus(ac, string());
|
|
|
|
}
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
func_status::value_type LyXFunc::getStatus(int ac,
|
|
|
|
string const & not_to_use_arg) const
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
kb_action action;
|
2001-06-27 14:10:35 +00:00
|
|
|
func_status::value_type flag = func_status::OK;
|
2001-06-25 00:06:33 +00:00
|
|
|
string argument;
|
|
|
|
Buffer * buf = owner->buffer();
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
if (lyxaction.isPseudoAction(ac))
|
1999-12-10 00:07:59 +00:00
|
|
|
action = lyxaction.retrieveActionArg(ac, argument);
|
2001-02-26 10:32:45 +00:00
|
|
|
else {
|
1999-12-10 00:07:59 +00:00
|
|
|
action = static_cast<kb_action>(ac);
|
2001-02-26 10:32:45 +00:00
|
|
|
if (!not_to_use_arg.empty())
|
|
|
|
argument = not_to_use_arg; // exept here
|
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
if (action == LFUN_UNKNOWN_ACTION) {
|
|
|
|
setErrorMessage(N_("Unknown action"));
|
2001-06-27 14:10:35 +00:00
|
|
|
return func_status::Unknown;
|
2000-06-12 11:27:15 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// Check whether we need a buffer
|
|
|
|
if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
|
|
|
|
// Yes we need a buffer, do we have one?
|
|
|
|
if (buf) {
|
|
|
|
// yes
|
|
|
|
// Can we use a readonly buffer?
|
|
|
|
if (buf->isReadonly() &&
|
|
|
|
!lyxaction.funcHasFlag(action,
|
|
|
|
LyXAction::ReadOnly)) {
|
|
|
|
// no
|
|
|
|
setErrorMessage(N_("Document is read-only"));
|
2001-06-27 14:10:35 +00:00
|
|
|
flag |= func_status::Disabled;
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// no
|
|
|
|
setErrorMessage(N_("Command not allowed with"
|
|
|
|
"out any document open"));
|
2001-06-27 14:10:35 +00:00
|
|
|
flag |= func_status::Disabled;
|
2000-07-26 14:08:09 +00:00
|
|
|
return flag;
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-06 02:44:26 +00:00
|
|
|
// I would really like to avoid having this switch and rather try to
|
|
|
|
// encode this in the function itself.
|
1999-12-10 00:07:59 +00:00
|
|
|
bool disable = false;
|
|
|
|
switch (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:
|
2001-02-26 11:18:42 +00:00
|
|
|
disable = argument == "fax" &&
|
|
|
|
!Exporter::IsExportable(buf, 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;
|
|
|
|
case LFUN_SPELLCHECK:
|
2000-03-12 10:35:05 +00:00
|
|
|
disable = lyxrc.isp_command == "none";
|
1999-12-16 06:43:25 +00:00
|
|
|
break;
|
|
|
|
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;
|
|
|
|
|
2000-08-01 09:35:42 +00:00
|
|
|
case LFUN_LAYOUT_TABULAR:
|
|
|
|
disable = true;
|
2000-10-03 13:55:48 +00:00
|
|
|
if (owner->view()->theLockingInset()) {
|
2001-06-28 10:25:20 +00:00
|
|
|
disable = (owner->view()->theLockingInset()->lyxCode() != Inset::TABULAR_CODE) &&
|
|
|
|
!owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
|
2000-08-01 09:35:42 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_TABULAR_FEATURE:
|
|
|
|
disable = true;
|
2000-10-03 13:55:48 +00:00
|
|
|
if (owner->view()->theLockingInset()) {
|
2001-06-27 14:10:35 +00:00
|
|
|
func_status::value_type ret = func_status::Disabled;
|
2001-06-28 10:25:20 +00:00
|
|
|
if (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) {
|
2000-08-01 09:35:42 +00:00
|
|
|
ret = static_cast<InsetTabular *>
|
2000-10-03 13:55:48 +00:00
|
|
|
(owner->view()->theLockingInset())->
|
2000-08-01 09:35:42 +00:00
|
|
|
getStatus(argument);
|
2001-06-28 10:25:20 +00:00
|
|
|
} else if (owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
|
2000-08-01 09:35:42 +00:00
|
|
|
ret = static_cast<InsetTabular *>
|
2000-10-03 13:55:48 +00:00
|
|
|
(owner->view()->theLockingInset()->
|
2001-06-28 10:25:20 +00:00
|
|
|
getFirstLockingInsetOfType(Inset::TABULAR_CODE))->
|
2000-08-01 09:35:42 +00:00
|
|
|
getStatus(argument);
|
|
|
|
}
|
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);
|
|
|
|
func_status::value_type ret;
|
|
|
|
|
|
|
|
disable = true;
|
|
|
|
ret = inset.getStatus(argument);
|
|
|
|
if ((ret & func_status::ToggleOn) ||
|
|
|
|
(ret & func_status::ToggleOff))
|
|
|
|
flag |= func_status::ToggleOff;
|
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:
|
|
|
|
disable = !owner->view()->
|
|
|
|
isSavedPosition(strToUnsignedInt(argument));
|
2001-07-19 08:52:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_TOGGLE:
|
|
|
|
disable = (TEXT(false)->getInset() == 0);
|
|
|
|
break;
|
2001-07-06 12:09:32 +00:00
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
case LFUN_MATH_VALIGN: {
|
2001-07-06 12:09:32 +00:00
|
|
|
// I think this test can be simplified (Andre')
|
|
|
|
// mathcursor is != 0 iff we are in math mode
|
|
|
|
//Inset * tli = owner->view()->theLockingInset();
|
|
|
|
//if (tli && (tli->lyxCode() == Inset::MATH_CODE
|
|
|
|
// || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
|
|
|
|
//
|
|
|
|
if (mathcursor) {
|
2001-06-27 14:10:35 +00:00
|
|
|
char align = mathcursor->valign();
|
|
|
|
if (align == '\0') {
|
|
|
|
disable = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (argument.empty()) {
|
|
|
|
flag = func_status::OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!contains("tcb", argument[0])) {
|
|
|
|
disable = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (argument[0] == align)
|
|
|
|
flag |= func_status::ToggleOn;
|
|
|
|
else
|
|
|
|
flag |= func_status::ToggleOff;
|
|
|
|
} else
|
|
|
|
disable = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case LFUN_MATH_HALIGN: {
|
2001-07-06 12:09:32 +00:00
|
|
|
//Inset * tli = owner->view()->theLockingInset();
|
|
|
|
//if (tli && (tli->lyxCode() == Inset::MATH_CODE
|
|
|
|
// || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
|
|
|
|
if (mathcursor) {
|
2001-06-27 14:10:35 +00:00
|
|
|
char align = mathcursor->halign();
|
|
|
|
if (align == '\0') {
|
|
|
|
disable = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (argument.empty()) {
|
|
|
|
flag = func_status::OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!contains("lcr", argument[0])) {
|
|
|
|
disable = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (argument[0] == align)
|
|
|
|
flag |= func_status::ToggleOn;
|
|
|
|
else
|
|
|
|
flag |= func_status::ToggleOff;
|
|
|
|
} else
|
|
|
|
disable = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case LFUN_MATH_MUTATE: {
|
|
|
|
Inset * tli = owner->view()->theLockingInset();
|
2001-06-28 10:25:20 +00:00
|
|
|
if (tli && (tli->lyxCode() == Inset::MATH_CODE)) {
|
2001-08-01 13:28:45 +00:00
|
|
|
MathInsetTypes type = mathcursor->formula()->getType();
|
2001-06-27 14:10:35 +00:00
|
|
|
func_status::value_type box = func_status::ToggleOff;
|
|
|
|
if (argument == "inline") {
|
|
|
|
if (type == LM_OT_SIMPLE)
|
|
|
|
box = func_status::ToggleOn;
|
|
|
|
} else if (argument == "display") {
|
|
|
|
if (type == LM_OT_EQUATION)
|
|
|
|
box = func_status::ToggleOn;
|
|
|
|
} else if (argument == "eqnarray") {
|
|
|
|
if (type == LM_OT_EQNARRAY)
|
|
|
|
box = func_status::ToggleOn;
|
|
|
|
} else if (argument == "align") {
|
|
|
|
if (type == LM_OT_ALIGN)
|
|
|
|
box = func_status::ToggleOn;
|
|
|
|
} else {
|
|
|
|
box = func_status::OK;
|
|
|
|
disable = true;
|
|
|
|
}
|
|
|
|
flag |= box;
|
|
|
|
} else
|
|
|
|
disable = true;
|
|
|
|
break;
|
|
|
|
}
|
2001-07-06 12:09:32 +00:00
|
|
|
|
|
|
|
// we just need to be in math mode to enable that
|
|
|
|
case LFUN_MATH_SIZE:
|
2001-07-25 12:37:43 +00:00
|
|
|
case LFUN_MATH_SPACE:
|
2001-07-06 12:09:32 +00:00
|
|
|
case LFUN_MATH_LIMITS:
|
|
|
|
case LFUN_MATH_NONUMBER:
|
|
|
|
case LFUN_MATH_NUMBER:
|
|
|
|
disable = !mathcursor;
|
|
|
|
break;
|
|
|
|
|
|
|
|
// we need to be math mode and a math array for that
|
|
|
|
// Hack: halign produces non-zero result iff we are in a math array
|
|
|
|
case LFUN_MATH_ROW_INSERT:
|
|
|
|
case LFUN_MATH_ROW_DELETE:
|
|
|
|
case LFUN_MATH_COLUMN_INSERT:
|
|
|
|
case LFUN_MATH_COLUMN_DELETE:
|
|
|
|
disable = !mathcursor || !mathcursor->halign();
|
|
|
|
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;
|
|
|
|
switch (action) {
|
|
|
|
case LFUN_INSET_TEXT:
|
|
|
|
code = Inset::TEXT_CODE;
|
|
|
|
break;
|
|
|
|
case LFUN_INSET_ERT:
|
|
|
|
code = Inset::ERT_CODE;
|
|
|
|
break;
|
2001-07-23 09:11:14 +00:00
|
|
|
case LFUN_FIGURE:
|
2001-07-19 08:52:59 +00:00
|
|
|
case LFUN_INSET_GRAPHICS:
|
|
|
|
code = Inset::GRAPHICS_CODE;
|
|
|
|
break;
|
|
|
|
case LFUN_INSET_FOOTNOTE:
|
|
|
|
code = Inset::FOOT_CODE;
|
|
|
|
break;
|
2001-07-23 09:11:14 +00:00
|
|
|
case LFUN_DIALOG_TABULAR_INSERT:
|
2001-07-19 08:52:59 +00:00
|
|
|
case LFUN_INSET_TABULAR:
|
|
|
|
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;
|
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:
|
|
|
|
code = Inset::IGNORE_CODE;
|
|
|
|
break;
|
|
|
|
case LFUN_INSERT_LABEL:
|
|
|
|
code = Inset::LABEL_CODE;
|
|
|
|
break;
|
|
|
|
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:
|
|
|
|
case LFUN_INDEX_INSERT_LAST:
|
2001-07-23 09:11:14 +00:00
|
|
|
case LFUN_INDEX_CREATE:
|
2001-07-19 08:52:59 +00:00
|
|
|
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:
|
|
|
|
case LFUN_PROTECTEDSPACE:
|
|
|
|
code = Inset::SPECIALCHAR_CODE;
|
|
|
|
break;
|
2001-07-19 08:52:59 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (code != Inset::NO_CODE
|
|
|
|
&& owner->view()->theLockingInset()
|
|
|
|
&& !owner->view()->theLockingInset()->insetAllowed(code)) {
|
|
|
|
disable = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (disable)
|
|
|
|
flag |= func_status::Disabled;
|
|
|
|
|
2001-08-03 10:32:20 +00:00
|
|
|
// the font related functions (and a few others)
|
2001-07-19 08:52:59 +00:00
|
|
|
func_status::value_type box = func_status::ToggleOff;
|
|
|
|
LyXFont const & font =
|
|
|
|
TEXT(false)->real_current_font;
|
|
|
|
switch (action) {
|
|
|
|
case LFUN_EMPH:
|
|
|
|
if (font.emph() == LyXFont::ON)
|
|
|
|
box = func_status::ToggleOn;
|
|
|
|
break;
|
|
|
|
case LFUN_NOUN:
|
|
|
|
if (font.noun() == LyXFont::ON)
|
|
|
|
box = func_status::ToggleOn;
|
|
|
|
break;
|
|
|
|
case LFUN_BOLD:
|
|
|
|
if (font.series() == LyXFont::BOLD_SERIES)
|
|
|
|
box = func_status::ToggleOn;
|
|
|
|
break;
|
|
|
|
case LFUN_READ_ONLY_TOGGLE:
|
|
|
|
if (buf->isReadonly())
|
|
|
|
box = func_status::ToggleOn;
|
|
|
|
break;
|
2001-08-03 10:32:20 +00:00
|
|
|
case LFUN_APPENDIX:
|
|
|
|
if (TEXT(false)->cursor.par()->params().startOfAppendix())
|
|
|
|
box = func_status::ToggleOn;
|
|
|
|
break;
|
2001-07-19 08:52:59 +00:00
|
|
|
default:
|
|
|
|
box = func_status::OK;
|
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
2001-07-19 08:52:59 +00:00
|
|
|
flag |= box;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
// temporary dispatch method
|
|
|
|
void LyXFunc::miniDispatch(string const & s)
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
if (!s.empty()) {
|
2001-07-16 15:42:57 +00:00
|
|
|
dispatch(s);
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
2001-04-17 15:15:59 +00:00
|
|
|
}
|
|
|
|
|
2001-05-16 07:53:23 +00:00
|
|
|
|
2001-07-16 15:42:57 +00:00
|
|
|
string const LyXFunc::dispatch(string const & s)
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
|
|
|
// Split command string into command and argument
|
2000-09-19 11:18:35 +00:00
|
|
|
string cmd;
|
|
|
|
string line = frontStrip(s);
|
2001-06-25 00:06:33 +00:00
|
|
|
string const arg = strip(frontStrip(split(line, cmd, ' ')));
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2001-07-16 15:42:57 +00:00
|
|
|
return dispatch(lyxaction.LookupFunc(cmd), arg);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-16 15:42:57 +00:00
|
|
|
string const LyXFunc::dispatch(int ac,
|
2001-04-17 15:15:59 +00:00
|
|
|
string const & do_not_use_this_arg)
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
2000-11-04 10:00:12 +00:00
|
|
|
lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << ac
|
|
|
|
<<"] arg[" << do_not_use_this_arg << "]" << endl;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
string argument;
|
|
|
|
kb_action action;
|
|
|
|
|
|
|
|
// we have not done anything wrong yet.
|
|
|
|
errorstat = false;
|
2000-05-04 10:57:00 +00:00
|
|
|
dispatch_buffer.erase();
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// if action is a pseudo-action, we need the real action
|
|
|
|
if (lyxaction.isPseudoAction(ac)) {
|
|
|
|
string tmparg;
|
|
|
|
action = static_cast<kb_action>
|
|
|
|
(lyxaction.retrieveActionArg(ac, tmparg));
|
|
|
|
if (!tmparg.empty())
|
|
|
|
argument = tmparg;
|
|
|
|
} else {
|
|
|
|
action = static_cast<kb_action>(ac);
|
2000-09-14 17:53:12 +00:00
|
|
|
if (!do_not_use_this_arg.empty())
|
1999-12-10 00:07:59 +00:00
|
|
|
argument = do_not_use_this_arg; // except here
|
|
|
|
}
|
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
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
selection_possible = false;
|
2001-04-26 17:47:40 +00:00
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
if (owner->view()->available())
|
|
|
|
owner->view()->hideCursor();
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// We cannot use this function here
|
2001-07-24 22:08:49 +00:00
|
|
|
if (getStatus(ac, do_not_use_this_arg) & func_status::Disabled) {
|
|
|
|
lyxerr << "LyXFunc::Dispatch: "
|
|
|
|
<< lyxaction.getActionName(ac)
|
2001-08-01 10:08:53 +00:00
|
|
|
<< " [" << ac << "] is disabled at this location"
|
2001-07-24 22:08:49 +00:00
|
|
|
<< endl;
|
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
|
|
|
|
2000-10-03 13:55:48 +00:00
|
|
|
if (owner->view()->available() && owner->view()->theLockingInset()) {
|
2000-04-19 14:42:19 +00:00
|
|
|
UpdatableInset::RESULT result;
|
2000-06-16 15:13:25 +00:00
|
|
|
if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
|
|
|
|
(keyseq.length >= -1)))
|
|
|
|
{
|
|
|
|
if ((action==LFUN_UNKNOWN_ACTION) && argument.empty()){
|
1999-12-10 00:07:59 +00:00
|
|
|
argument = keyseq.getiso();
|
|
|
|
}
|
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) {
|
|
|
|
#ifdef RETHINK_THIS_FOR_NOW_WE_LEAVE_ALL_UNLOCKED
|
2000-09-29 18:44:07 +00:00
|
|
|
int slx;
|
|
|
|
int sly;
|
1999-12-10 00:07:59 +00:00
|
|
|
UpdatableInset * inset =
|
2001-07-06 15:57:54 +00:00
|
|
|
owner->view()->theLockingInset()->getLockingInset();
|
|
|
|
int inset_id = inset->id();
|
2001-06-28 10:25:20 +00:00
|
|
|
inset->getCursorPos(owner->view(), slx, sly);
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->unlockInset(inset);
|
2001-07-06 15:57:54 +00:00
|
|
|
#else
|
|
|
|
owner->view()->unlockInset(owner->view()->theLockingInset());
|
|
|
|
#endif
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->menuUndo();
|
2001-07-06 15:57:54 +00:00
|
|
|
#ifdef RETHINK_THIS_FOR_NOW_WE_LEAVE_ALL_UNLOCKED
|
|
|
|
#if 0
|
2001-02-22 14:09:20 +00:00
|
|
|
if (TEXT()->cursor.par()->
|
2001-06-25 00:06:33 +00:00
|
|
|
isInset(TEXT()->cursor.pos())) {
|
2000-03-31 10:35:53 +00:00
|
|
|
inset = static_cast<UpdatableInset*>(
|
2001-02-22 14:09:20 +00:00
|
|
|
TEXT()->cursor.par()->
|
2001-06-25 00:06:33 +00:00
|
|
|
getInset(TEXT()->
|
2000-06-08 23:16:16 +00:00
|
|
|
cursor.pos()));
|
2000-03-31 10:35:53 +00:00
|
|
|
} else {
|
|
|
|
inset = 0;
|
|
|
|
}
|
2001-07-06 15:57:54 +00:00
|
|
|
#else
|
|
|
|
inset = static_cast<UpdatableInset *>(owner->view()->buffer()->getInsetFromID(inset_id));
|
|
|
|
#endif
|
2000-02-25 12:06:15 +00:00
|
|
|
if (inset)
|
2001-06-28 10:25:20 +00:00
|
|
|
inset->edit(owner->view(),slx,sly,0);
|
2001-07-06 15:57:54 +00:00
|
|
|
#endif
|
1999-12-10 00:07:59 +00:00
|
|
|
return string();
|
2000-02-25 12:06:15 +00:00
|
|
|
} else if (action == LFUN_REDO) {
|
2000-09-29 18:44:07 +00:00
|
|
|
int slx;
|
|
|
|
int sly;
|
2000-02-25 12:06:15 +00:00
|
|
|
UpdatableInset * inset = owner->view()->
|
2000-10-03 13:55:48 +00:00
|
|
|
theLockingInset();
|
2001-06-28 10:25:20 +00:00
|
|
|
inset->getCursorPos(owner->view(), slx, sly);
|
2000-02-25 12:06:15 +00:00
|
|
|
owner->view()->unlockInset(inset);
|
|
|
|
owner->view()->menuRedo();
|
|
|
|
inset = static_cast<UpdatableInset*>(
|
2001-02-22 14:09:20 +00:00
|
|
|
TEXT()->cursor.par()->
|
2001-06-25 00:06:33 +00:00
|
|
|
getInset(TEXT()->
|
2000-06-08 23:16:16 +00:00
|
|
|
cursor.pos()));
|
2000-02-25 12:06:15 +00:00
|
|
|
if (inset)
|
2001-06-28 10:25:20 +00:00
|
|
|
inset->edit(owner->view(),slx,sly,0);
|
2000-02-25 12:06:15 +00:00
|
|
|
return string();
|
2000-10-03 13:55:48 +00:00
|
|
|
} else if (((result=owner->view()->theLockingInset()->
|
2001-08-16 08:52:30 +00:00
|
|
|
localDispatch(owner->view(), action, argument)) ==
|
|
|
|
UpdatableInset::DISPATCHED) ||
|
|
|
|
(result == UpdatableInset::DISPATCHED_NOUPDATE))
|
2000-02-25 12:06:15 +00:00
|
|
|
return string();
|
2001-08-16 08:52:30 +00:00
|
|
|
else if (result == UpdatableInset::FINISHED) {
|
|
|
|
if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
|
|
|
|
TEXT()->cursorRight(owner->view());
|
|
|
|
moveCursorUpdate(true, false);
|
|
|
|
owner->showState();
|
|
|
|
}
|
|
|
|
return string();
|
|
|
|
} else if (result == UpdatableInset::FINISHED_RIGHT) {
|
|
|
|
if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
|
|
|
|
TEXT()->cursorRight(owner->view());
|
|
|
|
moveCursorUpdate(true, false);
|
|
|
|
owner->showState();
|
|
|
|
}
|
|
|
|
return string();
|
|
|
|
} else if (result == UpdatableInset::FINISHED_UP) {
|
|
|
|
if (TEXT()->cursor.row()->previous()) {
|
|
|
|
TEXT()->cursorUp(owner->view());
|
|
|
|
moveCursorUpdate(true, false);
|
|
|
|
owner->showState();
|
|
|
|
}
|
|
|
|
return string();
|
|
|
|
} else if (result == UpdatableInset::FINISHED_DOWN) {
|
|
|
|
if (TEXT()->cursor.row()->next())
|
|
|
|
TEXT()->cursorDown(owner->view());
|
|
|
|
else
|
|
|
|
TEXT()->cursorRight(owner->view());
|
|
|
|
moveCursorUpdate(true, false);
|
|
|
|
owner->showState();
|
|
|
|
return string();
|
|
|
|
} else {
|
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:
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT()->cursorRight(owner->view());
|
2000-04-03 11:36:35 +00:00
|
|
|
owner->view()->setState();
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
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)) {
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT()->cursorRight(owner->view());
|
2001-02-22 14:09:20 +00:00
|
|
|
moveCursorUpdate(true, false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
2000-04-03 11:36:35 +00:00
|
|
|
}
|
|
|
|
return string();
|
|
|
|
case LFUN_LEFT:
|
2001-02-22 14:09:20 +00:00
|
|
|
if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT()->cursorRight(owner->view());
|
2001-02-22 14:09:20 +00:00
|
|
|
moveCursorUpdate(true, false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
2000-04-03 11:36:35 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
return string();
|
2000-04-19 14:42:19 +00:00
|
|
|
case LFUN_DOWN:
|
2001-06-01 15:10:26 +00:00
|
|
|
if (TEXT()->cursor.row()->next())
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT()->cursorDown(owner->view());
|
2001-06-01 15:10:26 +00:00
|
|
|
else
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT()->cursorRight(owner->view());
|
2001-02-22 14:09:20 +00:00
|
|
|
moveCursorUpdate(true, false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
2000-04-19 14:42:19 +00:00
|
|
|
return string();
|
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) {
|
2001-05-18 07:37:14 +00:00
|
|
|
|
|
|
|
case LFUN_ESCAPE:
|
|
|
|
{
|
|
|
|
if (!owner->view()->available()) break;
|
|
|
|
|
|
|
|
// this function should be used always [asierra060396]
|
|
|
|
UpdatableInset * tli =
|
|
|
|
owner->view()->theLockingInset();
|
|
|
|
if (tli) {
|
2001-06-28 10:25:20 +00:00
|
|
|
UpdatableInset * lock = tli->getLockingInset();
|
2001-05-18 07:37:14 +00:00
|
|
|
|
|
|
|
if (tli == lock) {
|
|
|
|
owner->view()->unlockInset(tli);
|
2001-06-25 00:06:33 +00:00
|
|
|
TEXT()->cursorRight(owner->view());
|
2001-05-18 07:37:14 +00:00
|
|
|
moveCursorUpdate(true, false);
|
|
|
|
owner->showState();
|
|
|
|
} else {
|
2001-06-28 10:25:20 +00:00
|
|
|
tli->unlockInsetInInset(owner->view(),
|
2001-05-18 07:37:14 +00:00
|
|
|
lock,
|
|
|
|
true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// --- Misc -------------------------------------------
|
|
|
|
case LFUN_WORDFINDFORWARD :
|
|
|
|
case LFUN_WORDFINDBACKWARD : {
|
|
|
|
static string last_search;
|
|
|
|
string searched_string;
|
|
|
|
|
|
|
|
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()) {
|
|
|
|
LyXFind(owner->view(), searched_string, fw);
|
2001-01-17 17:33:22 +00:00
|
|
|
}
|
2001-07-20 14:18:48 +00:00
|
|
|
// owner->view()->showCursor();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
2001-02-23 16:10:03 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_PREFIX:
|
|
|
|
{
|
2001-06-01 15:10:26 +00:00
|
|
|
if (owner->view()->available() && !owner->view()->theLockingInset()) {
|
2001-02-22 14:09:20 +00:00
|
|
|
owner->view()->update(TEXT(),
|
2001-02-14 08:38:21 +00:00
|
|
|
BufferView::SELECT|BufferView::FITCUR);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
1999-12-16 06:43:25 +00:00
|
|
|
string buf;
|
|
|
|
keyseq.print(buf, true);
|
2001-04-17 15:15:59 +00:00
|
|
|
owner->message(buf);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// --- Misc -------------------------------------------
|
|
|
|
case LFUN_EXEC_COMMAND:
|
2001-04-17 15:15:59 +00:00
|
|
|
{
|
2001-04-18 10:20:17 +00:00
|
|
|
std::vector<string> allCmds;
|
|
|
|
std::transform(lyxaction.func_begin(), lyxaction.func_end(),
|
|
|
|
std::back_inserter(allCmds), lyx::firster());
|
|
|
|
static std::vector<string> hist;
|
2001-04-24 15:25:26 +00:00
|
|
|
owner->getMiniBuffer()->getString(MiniBuffer::spaces,
|
2001-04-17 15:15:59 +00:00
|
|
|
allCmds, hist);
|
|
|
|
}
|
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
case LFUN_CANCEL: // RVDK_PATCH_5
|
|
|
|
keyseq.reset();
|
|
|
|
meta_fake_bit = 0;
|
2000-11-04 10:00:12 +00:00
|
|
|
if (owner->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
|
|
|
|
{
|
|
|
|
meta_fake_bit = Mod1Mask;
|
1999-12-16 06:43:25 +00:00
|
|
|
string buf;
|
|
|
|
keyseq.print(buf, true);
|
1999-12-10 00:07:59 +00:00
|
|
|
setMessage(buf); // RVDK_PATCH_5
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_READ_ONLY_TOGGLE:
|
|
|
|
if (owner->buffer()->lyxvc.inUse()) {
|
|
|
|
owner->buffer()->lyxvc.toggleReadOnly();
|
|
|
|
} else {
|
|
|
|
owner->buffer()->setReadonly(
|
|
|
|
!owner->buffer()->isReadonly());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_CENTER: // this is center and redraw.
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->center();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
// --- Menus -----------------------------------------------
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_MENUNEW:
|
2001-07-16 15:42:57 +00:00
|
|
|
menuNew(false);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MENUNEWTMPLT:
|
2001-07-16 15:42:57 +00:00
|
|
|
menuNew(true);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_CLOSEBUFFER:
|
2001-07-16 15:42:57 +00:00
|
|
|
closeBuffer();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
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;
|
|
|
|
s1 << _("Saving document") << ' '
|
|
|
|
<< MakeDisplayPath(owner->buffer()->fileName() + "...");
|
|
|
|
owner->message(s1.str().c_str());
|
2000-11-14 02:01:57 +00:00
|
|
|
MenuWrite(owner->view(), owner->buffer());
|
2001-03-07 14:25:31 +00:00
|
|
|
} else
|
|
|
|
WriteAs(owner->view(), owner->buffer());
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
case LFUN_WRITEAS:
|
|
|
|
WriteAs(owner->view(), owner->buffer(), argument);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MENURELOAD:
|
|
|
|
reloadBuffer();
|
|
|
|
break;
|
|
|
|
|
2000-08-30 03:40:51 +00:00
|
|
|
case LFUN_UPDATE:
|
|
|
|
Exporter::Export(owner->buffer(), argument, true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_PREVIEW:
|
|
|
|
Exporter::Preview(owner->buffer(), argument);
|
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
case LFUN_BUILDPROG:
|
2000-10-23 12:16:05 +00:00
|
|
|
Exporter::Export(owner->buffer(), "program", true);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_RUNCHKTEX:
|
|
|
|
MenuRunChktex(owner->buffer());
|
|
|
|
break;
|
2000-08-30 03:40:51 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_MENUPRINT:
|
2000-06-12 11:27:15 +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")
|
|
|
|
MenuSendto();
|
|
|
|
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;
|
|
|
|
|
|
|
|
case LFUN_QUIT:
|
|
|
|
QuitLyX();
|
|
|
|
break;
|
|
|
|
|
|
|
|
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
|
2000-11-04 10:00:12 +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
|
2001-04-27 07:58:56 +00:00
|
|
|
owner->getDialogs()->createTOC(p.getAsString());
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2000-05-20 21:37:05 +00:00
|
|
|
}
|
2000-08-01 17:33:32 +00:00
|
|
|
|
2000-08-25 13:37:24 +00:00
|
|
|
case LFUN_DIALOG_TABULAR_INSERT:
|
2000-07-11 15:08:54 +00:00
|
|
|
owner->getDialogs()->showTabularCreate();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_FIGURE:
|
2000-02-04 09:38:32 +00:00
|
|
|
Figure();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2000-02-29 02:19:17 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_AUTOSAVE:
|
2000-04-11 22:55:29 +00:00
|
|
|
AutoSave(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_UNDO:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->menuUndo();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_REDO:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->menuRedo();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MENUSEARCH:
|
2001-03-06 10:20:33 +00:00
|
|
|
owner->getDialogs()->showSearch();
|
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
case LFUN_REMOVEERRORS:
|
2000-01-08 21:02:58 +00:00
|
|
|
if (owner->view()->removeAutoInsets()) {
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->redraw();
|
2001-08-02 14:55:06 +00:00
|
|
|
owner->view()->fitCursor();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DEPTH:
|
2001-02-22 14:09:20 +00:00
|
|
|
changeDepth(owner->view(), TEXT(false), 0);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DEPTH_MIN:
|
2001-02-22 14:09:20 +00:00
|
|
|
changeDepth(owner->view(), TEXT(false), -1);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DEPTH_PLUS:
|
2001-02-22 14:09:20 +00:00
|
|
|
changeDepth(owner->view(), TEXT(false), 1);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_FREE:
|
2001-02-26 15:17:19 +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:
|
2000-02-04 09:38:32 +00:00
|
|
|
Reconfigure(owner->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")
|
|
|
|
owner->view()->allFloats(1,0);
|
|
|
|
else if (argument == "closefoot")
|
|
|
|
owner->view()->allFloats(0,0);
|
|
|
|
else if (argument == "openfig")
|
|
|
|
owner->view()->allFloats(1,1);
|
|
|
|
else if (argument == "closefig")
|
|
|
|
owner->view()->allFloats(0,1);
|
|
|
|
break;
|
|
|
|
#else
|
2001-04-17 00:19:49 +00:00
|
|
|
#ifdef WITH_WARNINGS
|
2000-11-03 15:22:04 +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:
|
|
|
|
owner->getDialogs()->showAboutlyx();
|
2000-06-12 11:27:15 +00:00
|
|
|
break;
|
|
|
|
|
2001-07-13 14:03:48 +00:00
|
|
|
case LFUN_HELP_COPYRIGHT:
|
2000-07-24 13:53:19 +00:00
|
|
|
case LFUN_HELP_CREDITS:
|
2001-07-13 14:03:48 +00:00
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
case LFUN_HELP_OPEN:
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
str << _("Opening help file") << ' '
|
|
|
|
<< MakeDisplayPath(fname) << "...";
|
|
|
|
owner->message(str.str().c_str());
|
2001-07-03 15:19:04 +00:00
|
|
|
owner->view()->buffer(bufferlist.loadLyXFile(fname, false));
|
|
|
|
owner->allowInput();
|
2000-07-24 13:53:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-07-13 14:03:48 +00:00
|
|
|
case LFUN_HELP_VERSION:
|
2000-10-11 21:06:43 +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;
|
|
|
|
|
|
|
|
case LFUN_VC_CHECKIN:
|
|
|
|
{
|
|
|
|
if (owner->buffer()->lyxvc.inUse()
|
|
|
|
&& !owner->buffer()->isReadonly())
|
|
|
|
owner->buffer()->lyxvc.checkIn();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_VC_CHECKOUT:
|
|
|
|
{
|
|
|
|
if (owner->buffer()->lyxvc.inUse()
|
|
|
|
&& owner->buffer()->isReadonly())
|
|
|
|
owner->buffer()->lyxvc.checkOut();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_VC_REVERT:
|
|
|
|
{
|
|
|
|
owner->buffer()->lyxvc.revert();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_VC_UNDO:
|
|
|
|
{
|
|
|
|
owner->buffer()->lyxvc.undoLast();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_VC_HISTORY:
|
|
|
|
{
|
2001-02-06 17:41:42 +00:00
|
|
|
owner->getDialogs()->showVCLogFile();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- buffers ----------------------------------------
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
case LFUN_SWITCHBUFFER:
|
|
|
|
owner->view()->buffer(bufferlist.getBuffer(argument));
|
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_FILE_NEW:
|
|
|
|
{
|
|
|
|
// servercmd: argument must be <file>:<template>
|
|
|
|
Buffer * tmpbuf = NewLyxFile(argument);
|
|
|
|
if (tmpbuf)
|
|
|
|
owner->view()->buffer(tmpbuf);
|
|
|
|
}
|
1999-12-16 06:43:25 +00:00
|
|
|
break;
|
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:
|
2001-02-06 17:41:42 +00:00
|
|
|
owner->getDialogs()->showLogFile();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LAYOUTNO:
|
|
|
|
{
|
2001-06-27 14:10:35 +00:00
|
|
|
lyxerr[Debug::INFO] << "LFUN_LAYOUTNO: (arg) " << argument << endl;
|
1999-12-10 00:07:59 +00:00
|
|
|
int sel = strToInt(argument);
|
2001-06-27 14:10:35 +00:00
|
|
|
lyxerr[Debug::INFO] << "LFUN_LAYOUTNO: (sel) "<< sel << endl;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// Should this give a setMessage instead?
|
|
|
|
if (sel == 0)
|
|
|
|
return string(); // illegal argument
|
|
|
|
|
2000-01-24 18:34:46 +00:00
|
|
|
--sel; // sel 1..., but layout 0...
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// Pretend we got the name instead.
|
2001-07-16 15:42:57 +00:00
|
|
|
dispatch(int(LFUN_LAYOUT),
|
2000-04-19 01:42:55 +00:00
|
|
|
textclasslist.NameOfLayout(owner->view()
|
|
|
|
->buffer()->params.textclass,
|
2000-09-19 11:18:35 +00:00
|
|
|
sel));
|
1999-12-10 00:07:59 +00:00
|
|
|
return string();
|
|
|
|
}
|
|
|
|
|
|
|
|
case LFUN_LAYOUT_DOCUMENT:
|
2001-06-15 16:18:43 +00:00
|
|
|
owner->getDialogs()->showDocument();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LAYOUT_PARAGRAPH:
|
2001-06-15 16:18:43 +00:00
|
|
|
owner->getDialogs()->showParagraph();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LAYOUT_CHARACTER:
|
2001-06-15 16:18:43 +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:
|
2000-10-03 13:55:48 +00:00
|
|
|
if (owner->view()->theLockingInset()) {
|
2001-06-28 10:25:20 +00:00
|
|
|
if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
|
2000-08-01 09:35:42 +00:00
|
|
|
InsetTabular * inset = static_cast<InsetTabular *>
|
2000-10-03 13:55:48 +00:00
|
|
|
(owner->view()->theLockingInset());
|
2001-06-28 10:25:20 +00:00
|
|
|
inset->openLayoutDialog(owner->view());
|
2000-10-03 13:55:48 +00:00
|
|
|
} else if (owner->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 *>(
|
2001-06-28 10:25:20 +00:00
|
|
|
owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
|
|
|
|
inset->openLayoutDialog(owner->view());
|
2000-08-01 09:35:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_LAYOUT_PREAMBLE:
|
2001-02-20 13:34:05 +00:00
|
|
|
owner->getDialogs()->showPreamble();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LAYOUT_SAVE_DEFAULT:
|
2000-11-14 02:01:57 +00:00
|
|
|
MenuLayoutSave(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DROP_LAYOUTS_CHOICE:
|
2000-07-24 13:53:19 +00:00
|
|
|
owner->getToolbar()->openLayoutList();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MENU_OPEN_BY_NAME:
|
2000-07-24 13:53:19 +00:00
|
|
|
owner->getMenubar()->openByName(argument);
|
1999-12-10 00:07:59 +00:00
|
|
|
break; // RVDK_PATCH_5
|
|
|
|
|
|
|
|
case LFUN_SPELLCHECK:
|
2000-03-12 10:35:05 +00:00
|
|
|
if (lyxrc.isp_command != "none")
|
2001-07-13 11:50:39 +00:00
|
|
|
owner->getDialogs()->showSpellchecker();
|
|
|
|
break;
|
1999-12-10 00:07:59 +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;
|
|
|
|
|
|
|
|
case LFUN_NOTIFY:
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
2001-02-23 16:10:03 +00:00
|
|
|
string buf;
|
|
|
|
keyseq.print(buf);
|
|
|
|
dispatch_buffer = buf;
|
|
|
|
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)) {
|
2001-02-23 16:10:03 +00:00
|
|
|
owner->view()->buffer(bufferlist.getBuffer(s));
|
2001-06-29 06:30:53 +00:00
|
|
|
} else {
|
2001-02-23 16:10:03 +00:00
|
|
|
owner->view()->buffer(bufferlist.loadLyXFile(s));
|
2001-06-29 06:30:53 +00:00
|
|
|
}
|
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
// Set the cursor
|
|
|
|
owner->view()->setCursorFromRow(row);
|
|
|
|
|
|
|
|
// Recenter screen
|
|
|
|
owner->view()->center();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
case LFUN_GOTO_PARAGRAPH:
|
|
|
|
{
|
2001-06-29 11:54:39 +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! ["
|
|
|
|
<< id << "]" << std::endl;
|
2001-03-30 19:24:28 +00:00
|
|
|
break;
|
2001-08-05 22:12:27 +00:00
|
|
|
} else {
|
|
|
|
lyxerr << "Paragraph " << par->id()
|
|
|
|
<< " found." << endl;
|
2001-06-29 06:30:53 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
// Set the cursor
|
2001-08-05 22:12:27 +00:00
|
|
|
owner->view()->text->setCursor(owner->view(), par, 0);
|
2001-02-23 16:10:03 +00:00
|
|
|
owner->view()->setState();
|
2000-08-31 11:51:59 +00:00
|
|
|
owner->showState();
|
|
|
|
|
|
|
|
// Recenter screen
|
|
|
|
owner->view()->center();
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
|
|
|
|
// --- toolbar ----------------------------------
|
|
|
|
case LFUN_PUSH_TOOLBAR:
|
|
|
|
{
|
|
|
|
int nth = strToInt(argument);
|
|
|
|
if (nth <= 0) {
|
|
|
|
setErrorMessage(N_("Push-toolbar needs argument > 0"));
|
|
|
|
} else {
|
|
|
|
owner->getToolbar()->push(nth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_ADD_TO_TOOLBAR:
|
|
|
|
{
|
2000-07-24 13:53:19 +00:00
|
|
|
if (lyxerr.debugging(Debug::GUI)) {
|
1999-12-10 00:07:59 +00:00
|
|
|
lyxerr << "LFUN_ADD_TO_TOOLBAR:"
|
|
|
|
"argument = `" << argument << '\'' << endl;
|
|
|
|
}
|
|
|
|
string tmp(argument);
|
|
|
|
//lyxerr <<string("Argument: ") + argument);
|
|
|
|
//lyxerr <<string("Tmp : ") + tmp);
|
|
|
|
if (tmp.empty()) {
|
|
|
|
setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
|
|
|
|
} else {
|
|
|
|
owner->getToolbar()->add(argument, false);
|
|
|
|
owner->getToolbar()->set();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
|
|
|
|
case LFUN_MATH_PANEL:
|
2001-03-16 12:08:14 +00:00
|
|
|
owner->getDialogs()->showMathPanel();
|
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2000-08-03 12:56:25 +00:00
|
|
|
case LFUN_CITATION_CREATE:
|
2000-07-07 07:46:37 +00:00
|
|
|
{
|
2000-08-03 12:56:25 +00:00
|
|
|
InsetCommandParams p( "cite" );
|
2000-08-01 17:33:32 +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, "|")) {
|
|
|
|
p.setContents( token(argument, '|', 0) );
|
|
|
|
p.setOptions( token(argument, '|', 1) );
|
|
|
|
} else {
|
|
|
|
p.setContents( argument );
|
|
|
|
}
|
2001-07-16 15:42:57 +00:00
|
|
|
dispatch(LFUN_CITATION_INSERT, p.getAsString());
|
2000-12-11 09:46:09 +00:00
|
|
|
} else
|
|
|
|
owner->getDialogs()->createCitation( p.getAsString() );
|
2000-07-07 07:46:37 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_CHILDOPEN:
|
|
|
|
{
|
2000-11-14 02:01:57 +00:00
|
|
|
string const filename =
|
1999-12-10 00:07:59 +00:00
|
|
|
MakeAbsPath(argument,
|
|
|
|
OnlyPath(owner->buffer()->fileName()));
|
|
|
|
setMessage(N_("Opening child document ") +
|
|
|
|
MakeDisplayPath(filename) + "...");
|
2001-01-28 18:31:36 +00:00
|
|
|
owner->view()->savePosition(0);
|
1999-12-10 00:07:59 +00:00
|
|
|
if (bufferlist.exists(filename))
|
1999-12-16 06:43:25 +00:00
|
|
|
owner->view()->buffer(bufferlist.getBuffer(filename));
|
1999-12-10 00:07:59 +00:00
|
|
|
else
|
1999-12-16 06:43:25 +00:00
|
|
|
owner->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;
|
|
|
|
|
|
|
|
case LFUN_KMAP_OFF: // keymap off
|
|
|
|
owner->getIntl()->KeyMapOn(false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_KMAP_PRIM: // primary keymap
|
|
|
|
owner->getIntl()->KeyMapPrim();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_KMAP_SEC: // secondary keymap
|
|
|
|
owner->getIntl()->KeyMapSec();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_KMAP_TOGGLE: // toggle keymap
|
|
|
|
owner->getIntl()->ToggleKeyMap();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_SEQUENCE:
|
|
|
|
{
|
|
|
|
// argument contains ';'-terminated commands
|
|
|
|
while (argument.find(';') != string::npos) {
|
|
|
|
string first;
|
|
|
|
argument = split(argument, first, ';');
|
2001-07-16 15:42:57 +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:
|
|
|
|
owner->getDialogs()->showPreferences();
|
|
|
|
break;
|
|
|
|
|
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();
|
|
|
|
fontloader.update();
|
|
|
|
// 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
|
|
|
|
owner->resize();
|
2000-08-14 05:24:35 +00:00
|
|
|
// We also need to empty the textcache so that
|
|
|
|
// the buffer will be formatted correctly after
|
|
|
|
// a zoom change.
|
|
|
|
textcache.clear();
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lcolor.setColor(lyx_name, x11_name)) {
|
2000-11-14 02:01:57 +00:00
|
|
|
static string const err1 (N_("Set-color \""));
|
|
|
|
static string const err2 (
|
|
|
|
N_("\" failed - color is undefined "
|
|
|
|
"or may not be redefined"));
|
|
|
|
setErrorMessage(_(err1) + lyx_name + _(err2));
|
2000-06-26 15:33:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
|
|
|
|
owner->view()->redraw();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
case LFUN_MESSAGE:
|
|
|
|
owner->message(argument);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MESSAGE_PUSH:
|
|
|
|
owner->messagePush(argument);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MESSAGE_POP:
|
|
|
|
owner->messagePop();
|
|
|
|
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
|
|
|
|
if (!owner->view()->Dispatch(action, argument))
|
2001-05-16 07:53:23 +00:00
|
|
|
lyxerr << "A truly unknown func ["
|
2001-07-11 12:10:46 +00:00
|
|
|
<< lyxaction.getActionName(action) << "]!"
|
|
|
|
<< endl;
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
} // end of switch
|
2001-02-23 16:10:03 +00:00
|
|
|
|
|
|
|
exit_with_message:
|
1999-11-22 16:19:48 +00:00
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
commandshortcut.erase();
|
|
|
|
|
|
|
|
if (lyxrc.display_shortcuts && show_sc) {
|
|
|
|
if (action != LFUN_SELFINSERT) {
|
|
|
|
// Put name of command and list of shortcuts
|
|
|
|
// for it in minibuffer
|
|
|
|
string comname = lyxaction.getActionName(action);
|
|
|
|
|
|
|
|
int pseudoaction = action;
|
|
|
|
bool argsadded = false;
|
|
|
|
|
|
|
|
if (!argument.empty()) {
|
|
|
|
// If we have the command with argument,
|
|
|
|
// this is better
|
|
|
|
pseudoaction =
|
|
|
|
lyxaction.searchActionArg(action,
|
|
|
|
argument);
|
|
|
|
|
|
|
|
if (pseudoaction == -1) {
|
|
|
|
pseudoaction = action;
|
|
|
|
} else {
|
|
|
|
comname += " " + argument;
|
|
|
|
argsadded = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
string const shortcuts =
|
|
|
|
toplevel_keymap->findbinding(pseudoaction);
|
|
|
|
|
|
|
|
if (!shortcuts.empty()) {
|
|
|
|
comname += ": " + shortcuts;
|
|
|
|
} else if (!argsadded) {
|
|
|
|
comname += " " + argument;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!comname.empty()) {
|
|
|
|
comname = strip(comname);
|
|
|
|
commandshortcut = "(" + comname + ')';
|
|
|
|
|
|
|
|
// Here we could even add a small pause,
|
|
|
|
// to annoy the user and make him learn
|
|
|
|
// the shortcuts.
|
|
|
|
// No! That will just annoy, not teach
|
|
|
|
// anything. The user will read the messages
|
|
|
|
// if they are interested. (Asger)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
string const res = getMessage();
|
1999-11-22 16:19:48 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
if (res.empty()) {
|
|
|
|
if (!commandshortcut.empty()) {
|
2001-04-17 15:15:59 +00:00
|
|
|
owner->getMiniBuffer()->addSet(commandshortcut);
|
1999-12-03 13:51:01 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
} else {
|
2001-04-17 15:15:59 +00:00
|
|
|
string const msg(_(res) + ' ' + commandshortcut);
|
|
|
|
owner->message(msg);
|
1999-11-22 16:19:48 +00:00
|
|
|
}
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
return res;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-22 16:19:48 +00:00
|
|
|
|
1999-09-27 18:44:28 +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
|
|
|
|
|
|
|
|
2001-07-16 15:42:57 +00:00
|
|
|
void LyXFunc::menuNew(bool fromTemplate)
|
1999-12-16 06:43:25 +00:00
|
|
|
{
|
2000-10-11 21:06:43 +00:00
|
|
|
string initpath = lyxrc.document_path;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
if (owner->view()->available()) {
|
2000-11-14 02:01:57 +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;
|
2000-08-08 13:55:26 +00:00
|
|
|
string s;
|
2000-11-14 02:01:57 +00:00
|
|
|
|
2000-08-08 11:08:07 +00:00
|
|
|
if (lyxrc.new_ask_filename) {
|
2001-03-07 14:25:31 +00:00
|
|
|
FileDialog fileDlg(owner, _("Enter filename for new document"),
|
2001-04-17 15:15:59 +00:00
|
|
|
LFUN_SELECT_FILE_SYNC,
|
|
|
|
make_pair(string(_("Documents")),
|
|
|
|
string(lyxrc.document_path)),
|
|
|
|
make_pair(string(_("Templates")),
|
|
|
|
string(lyxrc.template_path)));
|
|
|
|
|
|
|
|
FileDialog::Result result =
|
|
|
|
fileDlg.Select(initpath,
|
|
|
|
_("*.lyx|LyX Documents (*.lyx)"),
|
|
|
|
_("newfile"));
|
1999-12-16 06:43:25 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
if (result.second.empty()) {
|
2001-04-24 17:33:01 +00:00
|
|
|
owner->message(_("Canceled."));
|
2001-06-27 14:10:35 +00:00
|
|
|
lyxerr[Debug::INFO] << "New Document Cancelled." << endl;
|
2000-08-08 11:08:07 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-07-26 13:43:16 +00:00
|
|
|
|
2000-08-08 11:08:07 +00:00
|
|
|
// get absolute path of file and make sure the filename ends
|
|
|
|
// with .lyx
|
2001-03-07 14:25:31 +00:00
|
|
|
s = MakeAbsPath(result.second);
|
2000-08-08 11:08:07 +00:00
|
|
|
if (!IsLyXFilename(s))
|
|
|
|
s += ".lyx";
|
|
|
|
|
|
|
|
// Check if the document already is open
|
|
|
|
if (bufferlist.exists(s)) {
|
2001-04-17 15:15:59 +00:00
|
|
|
switch (AskConfirmation(_("Document is already open:"),
|
|
|
|
MakeDisplayPath(s, 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
|
|
|
{
|
|
|
|
case 1: // Yes: close the document
|
|
|
|
if (!bufferlist.close(bufferlist.getBuffer(s)))
|
|
|
|
// If close is canceled, we cancel here too.
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case 2: // No: switch to the open document
|
|
|
|
owner->view()->buffer(bufferlist.getBuffer(s));
|
|
|
|
return;
|
|
|
|
case 3: // Cancel: Do nothing
|
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
|
|
|
}
|
2000-08-08 11:08:07 +00:00
|
|
|
}
|
|
|
|
// Check whether the file already exists
|
2001-06-27 14:10:35 +00:00
|
|
|
FileInfo fi(s);
|
|
|
|
if (fi.readable() &&
|
|
|
|
AskQuestion(_("File already exists:"),
|
|
|
|
MakeDisplayPath(s, 50),
|
|
|
|
_("Do you want to open the document?"))) {
|
2000-08-08 11:08:07 +00:00
|
|
|
// loads document
|
2001-06-27 14:10:35 +00:00
|
|
|
string const disp_fn(MakeDisplayPath(s));
|
|
|
|
|
|
|
|
ostringstream str;
|
|
|
|
str << _("Opening document") << ' '
|
|
|
|
<< disp_fn << "...";
|
|
|
|
|
|
|
|
owner->message(str.str().c_str());
|
|
|
|
//XFlush(fl_get_display());
|
|
|
|
owner->view()->buffer(bufferlist.loadLyXFile(s));
|
|
|
|
ostringstream str2;
|
|
|
|
str2 << _("Document") << ' '
|
|
|
|
<< disp_fn << ' ' << _("opened.");
|
|
|
|
|
|
|
|
owner->message(str2.str().c_str());
|
|
|
|
|
|
|
|
return;
|
2000-08-08 11:08:07 +00:00
|
|
|
}
|
|
|
|
} else {
|
2000-10-02 16:44:47 +00:00
|
|
|
s = AddName(lyxrc.document_path,
|
|
|
|
"newfile" + tostr(++newfile_number) + ".lyx");
|
1999-12-16 06:43:25 +00:00
|
|
|
FileInfo fi(s);
|
2000-08-08 11:08:07 +00:00
|
|
|
while (bufferlist.exists(s) || fi.readable()) {
|
|
|
|
++newfile_number;
|
2000-10-02 16:44:47 +00:00
|
|
|
s = AddName(lyxrc.document_path,
|
|
|
|
"newfile" + tostr(newfile_number) +
|
|
|
|
".lyx");
|
2000-08-08 11:08:07 +00:00
|
|
|
fi.newFile(s);
|
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,
|
2001-04-17 15:15:59 +00:00
|
|
|
make_pair(string(_("Documents")),
|
|
|
|
string(lyxrc.document_path)),
|
|
|
|
make_pair(string(_("Templates")),
|
|
|
|
string(lyxrc.template_path)));
|
|
|
|
|
|
|
|
FileDialog::Result result =
|
2001-06-25 00:06:33 +00:00
|
|
|
fileDlg.Select(lyxrc.template_path,
|
2001-04-17 15:15:59 +00:00
|
|
|
_("*.lyx|LyX Documents (*.lyx)"));
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
return;
|
|
|
|
|
|
|
|
string const fname = result.second;
|
|
|
|
|
|
|
|
if (fname.empty())
|
|
|
|
return;
|
2000-10-26 17:31:11 +00:00
|
|
|
templname = fname;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-12-16 06:43:25 +00:00
|
|
|
|
|
|
|
// find a free buffer
|
2001-06-27 14:10:35 +00:00
|
|
|
lyxerr[Debug::INFO] << "Find a free buffer." << endl;
|
1999-12-16 06:43:25 +00:00
|
|
|
owner->view()->buffer(bufferlist.newFile(s, templname));
|
|
|
|
}
|
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;
|
1999-12-16 06:43:25 +00:00
|
|
|
|
|
|
|
if (owner->view()->available()) {
|
2000-11-14 02:01:57 +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;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
if (fname.empty()) {
|
|
|
|
FileDialog fileDlg(owner, _("Select document to open"),
|
|
|
|
LFUN_FILE_OPEN,
|
2001-04-17 15:15:59 +00:00
|
|
|
make_pair(string(_("Documents")),
|
|
|
|
string(lyxrc.document_path)),
|
|
|
|
make_pair(string(_("Examples")),
|
|
|
|
string(AddPath(system_lyxdir, "examples"))));
|
|
|
|
|
|
|
|
FileDialog::Result result =
|
|
|
|
fileDlg.Select(initpath,
|
|
|
|
"*.lyx|LyX Documents (*.lyx)");
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
return;
|
|
|
|
|
|
|
|
filename = result.second;
|
|
|
|
|
|
|
|
// 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");
|
|
|
|
if (fullpath.empty()) {
|
|
|
|
WriteAlert(_("Error"), _("Could not find file"), filename);
|
|
|
|
return;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-08-01 10:08:53 +00:00
|
|
|
filename = fullpath;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// loads document
|
2001-06-14 17:58:49 +00:00
|
|
|
string const disp_fn(MakeDisplayPath(filename));
|
|
|
|
|
|
|
|
ostringstream str;
|
|
|
|
str << _("Opening document") << ' ' << disp_fn << "...";
|
|
|
|
|
|
|
|
owner->message(str.str().c_str());
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
Buffer * openbuf = bufferlist.loadLyXFile(filename);
|
|
|
|
if (openbuf) {
|
1999-11-22 16:19:48 +00:00
|
|
|
owner->view()->buffer(openbuf);
|
2001-06-14 17:58:49 +00:00
|
|
|
ostringstream str;
|
|
|
|
str << _("Document") << ' ' << disp_fn << ' ' << _("opened.");
|
|
|
|
owner->message(str.str().c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
} else {
|
2001-06-14 17:58:49 +00:00
|
|
|
ostringstream str;
|
2001-08-16 10:19:59 +00:00
|
|
|
str << _("Could not open document") << ' ' << disp_fn;
|
2001-06-14 17:58:49 +00:00
|
|
|
owner->message(str.str().c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
|
2000-04-28 11:18:04 +00:00
|
|
|
// checks for running without gui are missing.
|
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, ' ');
|
2001-06-27 14:10:35 +00:00
|
|
|
lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
|
|
|
|
<< " file: " << filename << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-04-28 11:18:04 +00:00
|
|
|
if (filename.empty()) { // need user interaction
|
|
|
|
string initpath = lyxrc.document_path;
|
|
|
|
|
|
|
|
if (owner->view()->available()) {
|
2000-11-14 02:01:57 +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;
|
|
|
|
}
|
|
|
|
|
2001-07-30 11:56:00 +00:00
|
|
|
string const text = _("Select ") + formats.prettyName(format)
|
2000-10-23 12:16:05 +00:00
|
|
|
+ _(" file to import");
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
FileDialog fileDlg(owner, text,
|
|
|
|
LFUN_IMPORT,
|
2001-04-17 15:15:59 +00:00
|
|
|
make_pair(string(_("Documents")),
|
|
|
|
string(lyxrc.document_path)),
|
|
|
|
make_pair(string(_("Examples")),
|
|
|
|
string(AddPath(system_lyxdir, "examples"))));
|
2001-03-07 14:25:31 +00:00
|
|
|
|
2001-07-30 11:56:00 +00:00
|
|
|
string const extension = "*." + formats.extension(format)
|
|
|
|
+ "| " + formats.prettyName(format)
|
|
|
|
+ " (*." + formats.extension(format) + ")";
|
2001-03-07 14:25:31 +00:00
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
FileDialog::Result result = fileDlg.Select(initpath,
|
|
|
|
extension);
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
return;
|
|
|
|
|
|
|
|
filename = result.second;
|
1999-09-27 18:44:28 +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
|
|
|
}
|
|
|
|
|
2000-04-28 11:18:04 +00:00
|
|
|
// still no filename? abort
|
|
|
|
if (filename.empty())
|
|
|
|
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
|
2000-04-28 11:18:04 +00:00
|
|
|
if (bufferlist.exists(lyxfile)) {
|
2000-11-04 10:00:12 +00:00
|
|
|
switch (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
|
|
|
{
|
|
|
|
case 1: // Yes: close the document
|
2000-04-28 11:18:04 +00:00
|
|
|
if (!bufferlist.close(bufferlist.getBuffer(lyxfile)))
|
1999-09-27 18:44:28 +00:00
|
|
|
// If close is canceled, we cancel here too.
|
1999-12-16 06:43:25 +00:00
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case 2: // No: switch to the open document
|
2000-04-28 11:18:04 +00:00
|
|
|
owner->view()->buffer(bufferlist.getBuffer(lyxfile));
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
1999-12-16 06:43:25 +00:00
|
|
|
case 3: // Cancel: Do nothing
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// Check if a LyX document by the same root exists in filesystem
|
2000-11-14 02:01:57 +00:00
|
|
|
FileInfo const f(lyxfile, true);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (f.exist() && !AskQuestion(_("A document by the name"),
|
2000-04-28 11:18:04 +00:00
|
|
|
MakeDisplayPath(lyxfile),
|
1999-09-27 18:44:28 +00:00
|
|
|
_("already exists. Overwrite?"))) {
|
2001-04-24 17:33:01 +00:00
|
|
|
owner->message(_("Canceled"));
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-04-28 11:18:04 +00:00
|
|
|
// filename should be valid now
|
2001-04-17 15:15:59 +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()))
|
1999-11-22 16:19:48 +00:00
|
|
|
owner->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
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->getDialogs()->hideBufferDependent();
|
2000-11-14 02:01:57 +00:00
|
|
|
} else {
|
1999-11-22 16:19:48 +00:00
|
|
|
owner->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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
void LyXFunc::setMessage(string const & m)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
dispatch_buffer = m;
|
|
|
|
}
|
2001-04-17 15:15:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
void LyXFunc::initMiniBuffer()
|
|
|
|
{
|
|
|
|
string text = _("Welcome to LyX!");
|
|
|
|
|
|
|
|
// When meta-fake key is pressed, show the key sequence so far + "M-".
|
|
|
|
if (wasMetaKey()) {
|
|
|
|
keyseqStr();
|
|
|
|
text += "M-";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Else, when a non-complete key sequence is pressed,
|
|
|
|
// show the available options.
|
|
|
|
else if (keyseqUncomplete())
|
|
|
|
text = keyseqOptions();
|
|
|
|
|
|
|
|
// Else, show the buffer state.
|
|
|
|
else if (owner->view()->available()) {
|
|
|
|
Buffer * tmpbuf = owner->buffer();
|
|
|
|
|
|
|
|
string const nicename =
|
|
|
|
MakeDisplayPath(tmpbuf->fileName());
|
|
|
|
// Should we do this instead? (kindo like emacs)
|
|
|
|
// leaves more room for other information
|
|
|
|
text = "LyX: ";
|
|
|
|
text += nicename;
|
|
|
|
if (tmpbuf->lyxvc.inUse()) {
|
|
|
|
text += " [";
|
2001-08-19 19:53:54 +00:00
|
|
|
text += tmpbuf->lyxvc.versionString();
|
2001-04-17 15:15:59 +00:00
|
|
|
text += ' ';
|
|
|
|
text += tmpbuf->lyxvc.locker();
|
|
|
|
if (tmpbuf->isReadonly())
|
|
|
|
text += " (RO)";
|
|
|
|
text += ']';
|
|
|
|
} else if (tmpbuf->isReadonly())
|
|
|
|
text += " [RO]";
|
|
|
|
if (!tmpbuf->isLyxClean())
|
|
|
|
text += _(" (Changed)");
|
|
|
|
} else {
|
|
|
|
if (text != _("Welcome to LyX!")) // this is a hack
|
|
|
|
text = _("* No document open *");
|
|
|
|
}
|
|
|
|
|
|
|
|
owner->message(text);
|
|
|
|
}
|
|
|
|
|