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"
|
2002-05-24 18:24:14 +00:00
|
|
|
#include "frontends/xforms/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"
|
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"
|
|
|
|
#include "minibuffer.h"
|
|
|
|
#include "vspace.h"
|
2002-05-23 12:08:47 +00:00
|
|
|
#include "frontends/LyXView.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
#include "FloatList.h"
|
|
|
|
#include "converter.h"
|
|
|
|
#include "exporter.h"
|
|
|
|
#include "importer.h"
|
2002-05-24 18:24:14 +00:00
|
|
|
#include "frontends/font_loader.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
#include "TextCache.h"
|
|
|
|
#include "lyxfind.h"
|
|
|
|
#include "undo_funcs.h"
|
|
|
|
#include "ParagraphParameters.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"
|
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
|
|
|
|
|
|
|
#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
|
|
|
|
1999-09-27 18:44:28 +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
|
|
|
|
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);
|
|
|
|
|
|
|
|
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) {}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
MiniBufferController mb_ctrl;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/* === globals =========================================================== */
|
|
|
|
|
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()),
|
|
|
|
cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get())
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2002-05-26 17:33:14 +00:00
|
|
|
meta_fake_bit = key_modifier::none;
|
1999-09-27 18:44:28 +00:00
|
|
|
lyx_dead_action = LFUN_NOACTION;
|
|
|
|
lyx_calling_dead_action = LFUN_NOACTION;
|
|
|
|
}
|
|
|
|
|
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();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
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-11-30 13:25:38 +00:00
|
|
|
if (keyseq.length() > 1) {
|
|
|
|
c = 0;
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
owner->getIntl()->getTrans()
|
|
|
|
.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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-26 17:33:14 +00:00
|
|
|
void LyXFunc::processKeySym(KeySym 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)) {
|
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
|
|
|
|
<< "["
|
2002-05-26 17:33:14 +00:00
|
|
|
<< keysym
|
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
|
|
|
|
2001-09-27 09:52:06 +00:00
|
|
|
// Can we be sure that this will work for all X Window
|
2000-08-14 15:31:16 +00:00
|
|
|
// 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;
|
|
|
|
}
|
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);
|
2000-12-17 06:09:35 +00:00
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
|
|
|
lyxerr << "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)) {
|
2002-05-26 17:33:14 +00:00
|
|
|
#if 0
|
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
|
|
|
}
|
2002-05-29 16:21:03 +00:00
|
|
|
#endif
|
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));
|
2000-12-17 06:09:35 +00:00
|
|
|
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.
|
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 << "]["
|
2001-11-30 13:25:38 +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
|
|
|
}
|
|
|
|
|
2001-11-30 13:25:38 +00:00
|
|
|
if (action == LFUN_UNKNOWN_ACTION) {
|
2001-05-17 01:23:29 +00:00
|
|
|
// It is unknown, but what if we remove all
|
|
|
|
// the modifiers? (Lgb)
|
2002-05-26 17:33:14 +00:00
|
|
|
action = keyseq.addkey(keysym, key_modifier::none);
|
2001-05-17 01:23:29 +00:00
|
|
|
|
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
|
|
|
lyxerr << "Removing modifiers...\n"
|
|
|
|
<< "Action now set to ["
|
|
|
|
<< action << "]" << endl;
|
|
|
|
}
|
2001-11-30 13:25:38 +00:00
|
|
|
if (action == LFUN_UNKNOWN_ACTION) {
|
2001-05-17 01:23:29 +00:00
|
|
|
owner->message(_("Unknown function."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action == LFUN_SELFINSERT) {
|
2001-11-30 13:25:38 +00:00
|
|
|
// This is very X dependent.
|
2001-05-29 09:50:02 +00:00
|
|
|
unsigned int c = keysym;
|
2002-01-12 20:00:47 +00:00
|
|
|
string argument;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-11-30 13:25:38 +00:00
|
|
|
c = kb_keymap::getiso(c);
|
|
|
|
|
2001-05-29 09:50:02 +00:00
|
|
|
if (c > 0)
|
|
|
|
argument = static_cast<char>(c);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-01-12 20:00:47 +00:00
|
|
|
dispatch(LFUN_SELFINSERT, argument);
|
2001-05-29 09:50:02 +00:00
|
|
|
lyxerr[Debug::KEY] << "SelfInsert arg[`"
|
|
|
|
<< argument << "']" << endl;
|
2000-08-14 15:31:16 +00:00
|
|
|
}
|
2002-01-12 20:00:47 +00:00
|
|
|
else
|
|
|
|
verboseDispatch(action, false);
|
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-01-12 20:00:47 +00:00
|
|
|
kb_action action;
|
|
|
|
string argument;
|
|
|
|
action = lyxaction.retrieveActionArg(ac, argument);
|
|
|
|
return getStatus(action, argument);
|
2001-02-26 10:32:45 +00:00
|
|
|
}
|
|
|
|
|
2002-01-12 20:00:47 +00:00
|
|
|
|
|
|
|
FuncStatus LyXFunc::getStatus(kb_action action,
|
|
|
|
string const & argument) 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-03-27 23:27:12 +00:00
|
|
|
if (action == LFUN_NOACTION) {
|
|
|
|
setStatusMessage(N_("Nothing to do"));
|
|
|
|
return flag.disabled(true);
|
|
|
|
}
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
if (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
|
|
|
|
if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
|
|
|
|
// 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() &&
|
1999-12-10 00:07:59 +00:00
|
|
|
!lyxaction.funcHasFlag(action,
|
|
|
|
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-01-20 16:07:42 +00:00
|
|
|
UpdatableInset * tli = owner->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;
|
|
|
|
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;
|
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;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2000-08-01 09:35:42 +00:00
|
|
|
case LFUN_TABULAR_FEATURE:
|
|
|
|
disable = true;
|
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)
|
|
|
|
->getStatus(argument);
|
|
|
|
} 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))
|
|
|
|
->getStatus(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;
|
|
|
|
ret = inset.getStatus(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:
|
|
|
|
disable = !owner->view()->
|
|
|
|
isSavedPosition(strToUnsignedInt(argument));
|
2001-07-19 08:52:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
2002-02-12 12:56:46 +00:00
|
|
|
case LFUN_INSET_TOGGLE: {
|
|
|
|
LyXText * lt = owner->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-03-21 17:27:08 +00:00
|
|
|
case LFUN_MATH_VALIGN:
|
2002-06-04 04:54:02 +00:00
|
|
|
if (mathcursor && mathcursor->formula()->getType() != LM_OT_SIMPLE) {
|
2001-06-27 14:10:35 +00:00
|
|
|
char align = mathcursor->valign();
|
|
|
|
if (align == '\0') {
|
|
|
|
disable = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (argument.empty()) {
|
2002-01-09 09:36:35 +00:00
|
|
|
flag.clear();
|
2001-06-27 14:10:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!contains("tcb", argument[0])) {
|
|
|
|
disable = true;
|
|
|
|
break;
|
|
|
|
}
|
2002-01-09 09:36:35 +00:00
|
|
|
flag.setOnOff(argument[0] == align);
|
2001-06-27 14:10:35 +00:00
|
|
|
} else
|
|
|
|
disable = true;
|
|
|
|
break;
|
2002-01-20 16:07:42 +00:00
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
case LFUN_MATH_HALIGN:
|
2002-06-04 04:54:02 +00:00
|
|
|
if (mathcursor && mathcursor->formula()->getType() != LM_OT_SIMPLE) {
|
2001-06-27 14:10:35 +00:00
|
|
|
char align = mathcursor->halign();
|
|
|
|
if (align == '\0') {
|
|
|
|
disable = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (argument.empty()) {
|
2002-01-09 09:36:35 +00:00
|
|
|
flag.clear();
|
2001-06-27 14:10:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!contains("lcr", argument[0])) {
|
|
|
|
disable = true;
|
|
|
|
break;
|
|
|
|
}
|
2002-01-09 09:36:35 +00:00
|
|
|
flag.setOnOff(argument[0] == align);
|
2001-06-27 14:10:35 +00:00
|
|
|
} else
|
|
|
|
disable = true;
|
|
|
|
break;
|
2002-01-20 16:07:42 +00:00
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
case LFUN_MATH_MUTATE:
|
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
|
|
|
if (argument == "inline") {
|
2002-01-09 09:36:35 +00:00
|
|
|
flag.setOnOff(type == LM_OT_SIMPLE);
|
2001-06-27 14:10:35 +00:00
|
|
|
} else if (argument == "display") {
|
2002-01-09 09:36:35 +00:00
|
|
|
flag.setOnOff(type == LM_OT_EQUATION);
|
2001-06-27 14:10:35 +00:00
|
|
|
} else if (argument == "eqnarray") {
|
2002-01-09 09:36:35 +00:00
|
|
|
flag.setOnOff(type == LM_OT_EQNARRAY);
|
2001-06-27 14:10:35 +00:00
|
|
|
} else if (argument == "align") {
|
2002-01-09 09:36:35 +00:00
|
|
|
flag.setOnOff(type == LM_OT_ALIGN);
|
2002-05-30 09:51:28 +00:00
|
|
|
} else if (argument == "none") {
|
|
|
|
flag.setOnOff(type == LM_OT_NONE);
|
2001-06-27 14:10:35 +00:00
|
|
|
} else {
|
|
|
|
disable = true;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
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:
|
|
|
|
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
|
2002-03-21 17:27:08 +00:00
|
|
|
case LFUN_MATH_ROW_INSERT:
|
|
|
|
case LFUN_MATH_ROW_DELETE:
|
|
|
|
case LFUN_MATH_COLUMN_INSERT:
|
|
|
|
case LFUN_MATH_COLUMN_DELETE:
|
2002-06-04 04:54:02 +00:00
|
|
|
disable = !mathcursor || !mathcursor->halign() ||
|
|
|
|
mathcursor->formula()->getType() == LM_OT_SIMPLE;
|
2001-07-06 12:09:32 +00:00
|
|
|
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_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;
|
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:
|
|
|
|
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-01-20 16:07:42 +00:00
|
|
|
if (code != Inset::NO_CODE && tli && !tli->insetAllowed(code)) {
|
2001-07-19 08:52:59 +00:00
|
|
|
disable = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (disable)
|
2002-01-09 09:36:35 +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
|
2001-07-19 08:52:59 +00:00
|
|
|
switch (action) {
|
2002-03-11 09:54:42 +00:00
|
|
|
case LFUN_TOOLTIPS_TOGGLE:
|
|
|
|
flag.setOnOff(owner->getDialogs()->tooltipsEnabled());
|
|
|
|
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-02-11 15:51:03 +00:00
|
|
|
if (argument == buf->fileName())
|
|
|
|
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;
|
|
|
|
switch (action) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2002-05-30 09:51:28 +00:00
|
|
|
string tc = mathcursor->getLastCode();
|
2001-12-21 13:55:24 +00:00
|
|
|
switch (action) {
|
|
|
|
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
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
// temporary dispatch method
|
2002-03-21 17:27:08 +00:00
|
|
|
void LyXFunc::miniDispatch(string const & s)
|
2001-04-17 15:15:59 +00:00
|
|
|
{
|
2002-03-21 17:27:08 +00:00
|
|
|
string s2(frontStrip(strip(s)));
|
|
|
|
|
2001-12-17 12:22:39 +00:00
|
|
|
if (!s2.empty()) {
|
2002-01-12 20:00:47 +00:00
|
|
|
verboseDispatch(s2, true);
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
2001-04-17 15:15:59 +00:00
|
|
|
}
|
|
|
|
|
2001-05-16 07:53:23 +00:00
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
void LyXFunc::verboseDispatch(string const & s, bool show_sc)
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
2002-01-13 19:19:05 +00:00
|
|
|
int action = lyxaction.LookupFunc(frontStrip(s));
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-12-17 12:22:39 +00:00
|
|
|
if (action == LFUN_UNKNOWN_ACTION) {
|
|
|
|
string const msg = string(_("Unknown function ("))
|
2002-01-13 19:19:05 +00:00
|
|
|
+ s + ")";
|
2001-12-17 12:22:39 +00:00
|
|
|
owner->message(msg);
|
|
|
|
} else {
|
2002-01-12 20:00:47 +00:00
|
|
|
verboseDispatch(action, show_sc);
|
2002-03-21 17:27:08 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
void LyXFunc::verboseDispatch(int ac, bool show_sc)
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
|
|
|
string argument;
|
|
|
|
kb_action action;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-01-12 20:00:47 +00:00
|
|
|
// get the real action and argument
|
|
|
|
action = lyxaction.retrieveActionArg(ac, argument);
|
|
|
|
|
|
|
|
verboseDispatch(action, argument, show_sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-01-14 12:56:05 +00:00
|
|
|
void LyXFunc::verboseDispatch(kb_action action,
|
|
|
|
string const & argument, bool show_sc)
|
2002-01-12 20:00:47 +00:00
|
|
|
{
|
|
|
|
string res = dispatch(action, argument);
|
|
|
|
|
|
|
|
commandshortcut.erase();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-01-12 20:00:47 +00:00
|
|
|
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);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-01-12 20:00:47 +00:00
|
|
|
int pseudoaction = action;
|
|
|
|
bool argsadded = false;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-01-12 20:00:47 +00:00
|
|
|
if (!argument.empty()) {
|
|
|
|
// the pseudoaction is useful for the bindings
|
2002-03-21 17:27:08 +00:00
|
|
|
pseudoaction =
|
2002-01-12 20:00:47 +00:00
|
|
|
lyxaction.searchActionArg(action,
|
2002-03-21 17:27:08 +00:00
|
|
|
argument);
|
2002-01-12 20:00:47 +00:00
|
|
|
|
|
|
|
if (pseudoaction == LFUN_UNKNOWN_ACTION) {
|
|
|
|
pseudoaction = action;
|
|
|
|
} else {
|
|
|
|
comname += " " + argument;
|
|
|
|
argsadded = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
string const shortcuts =
|
|
|
|
toplevel_keymap->findbinding(pseudoaction);
|
|
|
|
|
|
|
|
if (!shortcuts.empty()) {
|
|
|
|
comname += ": " + shortcuts;
|
|
|
|
} else if (!argsadded && !argument.empty()) {
|
|
|
|
comname += " " + argument;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!comname.empty()) {
|
|
|
|
comname = strip(comname);
|
|
|
|
commandshortcut = "(" + comname + ')';
|
|
|
|
}
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
}
|
2002-01-12 20:00:47 +00:00
|
|
|
|
|
|
|
if (res.empty()) {
|
|
|
|
if (!commandshortcut.empty()) {
|
|
|
|
owner->getMiniBuffer()->addSet(commandshortcut);
|
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
} else {
|
2002-01-12 20:00:47 +00:00
|
|
|
owner->getMiniBuffer()->addSet(' ' + commandshortcut);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
2002-01-12 20:00:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const LyXFunc::dispatch(kb_action action, string argument)
|
|
|
|
{
|
|
|
|
lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << action
|
|
|
|
<<"] arg[" << argument << "]" << endl;
|
|
|
|
|
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
|
|
|
|
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
|
2002-01-12 20:00:47 +00:00
|
|
|
if (getStatus(action, argument).disabled()) {
|
2001-11-09 13:44:48 +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
|
|
|
|
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) &&
|
2001-11-30 13:25:38 +00:00
|
|
|
(!keyseq.deleted())))
|
2000-06-16 15:13:25 +00:00
|
|
|
{
|
2002-04-16 14:10:39 +00:00
|
|
|
UpdatableInset * inset = owner->view()->theLockingInset();
|
|
|
|
#if 1
|
|
|
|
int inset_x;
|
|
|
|
int dummy_y;
|
|
|
|
inset->getCursorPos(owner->view(), inset_x, dummy_y);
|
|
|
|
#endif
|
2002-01-12 20:00:47 +00:00
|
|
|
if ((action == LFUN_UNKNOWN_ACTION)
|
2002-02-16 15:59:55 +00:00
|
|
|
&& 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) {
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->menuUndo();
|
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) {
|
|
|
|
owner->view()->menuRedo();
|
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-03-21 17:27:08 +00:00
|
|
|
localDispatch(owner->view(), action, argument)) ==
|
|
|
|
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) {
|
|
|
|
if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
|
|
|
|
TEXT()->cursorRight(owner->view());
|
|
|
|
moveCursorUpdate(true, false);
|
|
|
|
owner->showState();
|
|
|
|
}
|
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_RIGHT) {
|
|
|
|
if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
|
|
|
|
TEXT()->cursorRight(owner->view());
|
|
|
|
moveCursorUpdate(true, false);
|
|
|
|
owner->showState();
|
|
|
|
}
|
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(
|
|
|
|
owner->view(), TEXT()->cursor.ix() + inset_x,
|
|
|
|
TEXT()->cursor.iy() -
|
|
|
|
TEXT()->cursor.irow()->baseline() - 1);
|
|
|
|
TEXT()->cursor.x_fix(TEXT()->cursor.x());
|
|
|
|
#else
|
2001-08-16 08:52:30 +00:00
|
|
|
TEXT()->cursorUp(owner->view());
|
2002-04-16 14:10:39 +00:00
|
|
|
#endif
|
2001-08-16 08:52:30 +00:00
|
|
|
moveCursorUpdate(true, false);
|
|
|
|
owner->showState();
|
2002-03-29 15:49:45 +00:00
|
|
|
} else {
|
|
|
|
owner->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(
|
|
|
|
owner->view(), TEXT()->cursor.ix() + inset_x,
|
|
|
|
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
|
2001-08-16 08:52:30 +00:00
|
|
|
TEXT()->cursorDown(owner->view());
|
2002-04-16 14:10:39 +00:00
|
|
|
#endif
|
|
|
|
} else {
|
2001-08-16 08:52:30 +00:00
|
|
|
TEXT()->cursorRight(owner->view());
|
2002-04-16 14:10:39 +00:00
|
|
|
}
|
2001-08-16 08:52:30 +00:00
|
|
|
moveCursorUpdate(true, false);
|
|
|
|
owner->showState();
|
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:
|
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
|
|
|
}
|
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)) {
|
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
|
|
|
}
|
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())
|
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();
|
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:
|
|
|
|
{
|
|
|
|
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();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
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);
|
|
|
|
}
|
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
|
|
|
|
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()) {
|
|
|
|
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;
|
2002-03-21 17:27:08 +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
|
|
|
}
|
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:
|
2001-04-17 15:15:59 +00:00
|
|
|
{
|
2002-02-16 15:59:55 +00:00
|
|
|
vector<string> allCmds;
|
|
|
|
transform(lyxaction.func_begin(), lyxaction.func_end(),
|
|
|
|
back_inserter(allCmds), lyx::firster());
|
|
|
|
static 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;
|
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;
|
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
|
|
|
|
{
|
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.
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->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:
|
2001-07-16 15:42:57 +00:00
|
|
|
menuNew(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:
|
2001-07-16 15:42:57 +00:00
|
|
|
menuNew(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;
|
|
|
|
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;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
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;
|
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:
|
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")
|
2002-03-07 15:45:52 +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
|
2001-04-27 07:58:56 +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
|
|
|
|
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;
|
2002-03-21 17:27:08 +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;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_UNDO:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->menuUndo();
|
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:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->menuRedo();
|
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:
|
2001-03-06 10:20:33 +00:00
|
|
|
owner->getDialogs()->showSearch();
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
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_MIN:
|
2001-02-22 14:09:20 +00:00
|
|
|
changeDepth(owner->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:
|
2001-02-22 14:09:20 +00:00
|
|
|
changeDepth(owner->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:
|
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
|
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:
|
|
|
|
owner->getDialogs()->showAboutlyx();
|
2000-06-12 11:27:15 +00:00
|
|
|
break;
|
|
|
|
|
2001-10-09 15:20:10 +00:00
|
|
|
case LFUN_HELP_TEXINFO:
|
|
|
|
owner->getDialogs()->showTexinfo();
|
|
|
|
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;
|
|
|
|
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;
|
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:
|
|
|
|
{
|
2001-02-06 17:41:42 +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:
|
|
|
|
owner->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>
|
|
|
|
Buffer * tmpbuf = NewLyxFile(argument);
|
|
|
|
if (tmpbuf)
|
|
|
|
owner->view()->buffer(tmpbuf);
|
|
|
|
}
|
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:
|
2001-02-06 17:41:42 +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:
|
2001-06-15 16:18:43 +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:
|
2001-06-15 16:18:43 +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:
|
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;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
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
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
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;
|
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-03-21 17:27:08 +00:00
|
|
|
owner->view()->buffer(bufferlist.getBuffer(s));
|
2001-06-29 06:30:53 +00:00
|
|
|
} else {
|
2002-03-21 17:27:08 +00:00
|
|
|
owner->view()->buffer(bufferlist.loadLyXFile(s));
|
2001-06-29 06:30:53 +00:00
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
// Set the cursor
|
2001-02-23 16:10:03 +00:00
|
|
|
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:
|
|
|
|
{
|
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-02-16 15:59:55 +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-01-17 14:27:01 +00:00
|
|
|
if (owner->view()->theLockingInset())
|
|
|
|
owner->view()->unlockInset(owner->view()->theLockingInset());
|
|
|
|
if (par->inInset()) {
|
|
|
|
par->inInset()->edit(owner->view());
|
|
|
|
}
|
2001-02-23 16:10:03 +00:00
|
|
|
// Set the cursor
|
2002-01-17 14:27:01 +00:00
|
|
|
owner->view()->getLyXText()->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;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
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;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// --- 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:
|
|
|
|
dispatch(LFUN_SELFINSERT, "_");
|
|
|
|
break;
|
|
|
|
case LFUN_SUPERSCRIPT:
|
|
|
|
dispatch(LFUN_SELFINSERT, "^");
|
|
|
|
break;
|
|
|
|
|
2000-07-25 10:46:18 +00:00
|
|
|
case LFUN_MATH_PANEL:
|
2001-03-16 12:08:14 +00:00
|
|
|
owner->getDialogs()->showMathPanel();
|
|
|
|
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));
|
|
|
|
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
|
|
|
}
|
2001-07-16 15:42:57 +00:00
|
|
|
dispatch(LFUN_CITATION_INSERT, p.getAsString());
|
2000-12-11 09:46:09 +00:00
|
|
|
} else
|
2002-02-16 15:59:55 +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) + "...");
|
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;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_KMAP_OFF: // keymap off
|
|
|
|
owner->getIntl()->KeyMapOn(false);
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_KMAP_PRIM: // primary keymap
|
|
|
|
owner->getIntl()->KeyMapPrim();
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_KMAP_SEC: // secondary keymap
|
|
|
|
owner->getIntl()->KeyMapSec();
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_KMAP_TOGGLE: // toggle keymap
|
|
|
|
owner->getIntl()->ToggleKeyMap();
|
|
|
|
break;
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
case LFUN_SEQUENCE:
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
|
|
|
// argument contains ';'-terminated commands
|
|
|
|
while (argument.find(';') != string::npos) {
|
|
|
|
string first;
|
|
|
|
argument = split(argument, first, ';');
|
2002-01-12 20:00:47 +00:00
|
|
|
verboseDispatch(first, false);
|
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;
|
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.
|
2002-03-21 17:27:08 +00:00
|
|
|
//
|
2000-08-14 05:24:35 +00:00
|
|
|
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
|
2002-06-12 11:34:13 +00:00
|
|
|
owner->view()->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;
|
|
|
|
}
|
|
|
|
|
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)) {
|
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;
|
|
|
|
}
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2000-06-26 15:33:13 +00:00
|
|
|
lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
|
|
if (graphicsbg_changed) {
|
|
|
|
grfx::GCache & gc = grfx::GCache::get();
|
|
|
|
gc.changeDisplay(true);
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-06-26 15:33:13 +00:00
|
|
|
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;
|
|
|
|
|
2002-02-27 09:59:52 +00:00
|
|
|
case LFUN_FORKS_SHOW:
|
|
|
|
owner->getDialogs()->showForks();
|
|
|
|
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:
|
|
|
|
owner->getDialogs()->toggleTooltips();
|
|
|
|
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:
|
2001-02-23 16:10:03 +00:00
|
|
|
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
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
string const res = getMessage();
|
1999-11-22 16:19:48 +00:00
|
|
|
|
2002-01-12 20:00:47 +00:00
|
|
|
if (!res.empty())
|
|
|
|
owner->message(_(res));
|
2002-01-13 13:07:27 +00:00
|
|
|
owner->updateMenubar();
|
|
|
|
owner->updateToolbar();
|
2002-03-21 17:27:08 +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()) {
|
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;
|
2000-08-08 13:55:26 +00:00
|
|
|
string s;
|
2002-03-21 17:27:08 +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,
|
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 =
|
|
|
|
fileDlg.Select(initpath,
|
|
|
|
_("*.lyx|LyX Documents (*.lyx)"),
|
|
|
|
_("newfile"));
|
2002-03-21 17:27:08 +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;
|
|
|
|
}
|
2002-03-21 17:27:08 +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-11-26 10:19:58 +00:00
|
|
|
switch (Alert::askConfirmation(_("Document is already open:"),
|
2001-04-17 15:15:59 +00:00
|
|
|
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() &&
|
2002-03-21 17:27:08 +00:00
|
|
|
Alert::askQuestion(_("File already exists:"),
|
2001-06-27 14:10:35 +00:00
|
|
|
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));
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
ostringstream str;
|
|
|
|
str << _("Opening document") << ' '
|
|
|
|
<< disp_fn << "...";
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
owner->message(str.str().c_str());
|
|
|
|
//XFlush(fl_get_display());
|
|
|
|
owner->view()->buffer(bufferlist.loadLyXFile(s));
|
|
|
|
ostringstream str2;
|
|
|
|
str2 << _("Document") << ' '
|
|
|
|
<< disp_fn << ' ' << _("opened.");
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
owner->message(str2.str().c_str());
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
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,
|
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 =
|
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)"));
|
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
|
|
|
|
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;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
if (owner->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 =
|
|
|
|
fileDlg.Select(initpath,
|
|
|
|
"*.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");
|
|
|
|
if (fullpath.empty()) {
|
2001-11-26 10:19:58 +00:00
|
|
|
Alert::alert(_("Error"), _("Could not find file"), filename);
|
2001-08-01 10:08:53 +00:00
|
|
|
return;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-08-01 10:08:53 +00:00
|
|
|
filename = fullpath;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
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 << "...";
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-06-14 17:58:49 +00:00
|
|
|
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-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-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
|
|
|
|
2000-04-28 11:18:04 +00:00
|
|
|
if (owner->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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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)
|
|
|
|
+ " (*." + 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;
|
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:
|
2000-04-28 11:18:04 +00:00
|
|
|
owner->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-05-30 19:49:00 +00:00
|
|
|
// if the file exists already, and we didn't do
|
|
|
|
// -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()))
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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-03-21 17:27:08 +00:00
|
|
|
void LyXFunc::initMiniBuffer()
|
2001-04-17 15:15:59 +00:00
|
|
|
{
|
|
|
|
string text = _("Welcome to LyX!");
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
// When meta-fake key is pressed, show the key sequence so far + "M-".
|
|
|
|
if (wasMetaKey()) {
|
2001-11-30 13:25:38 +00:00
|
|
|
text = keyseq.print();
|
2001-04-17 15:15:59 +00:00
|
|
|
text += "M-";
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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()) {
|
2001-11-30 13:25:38 +00:00
|
|
|
text = keyseq.printOptions();
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
// Else, show the buffer state.
|
|
|
|
else if (owner->view()->available()) {
|
|
|
|
Buffer * tmpbuf = owner->buffer();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
string const nicename =
|
2001-04-17 15:15:59 +00:00
|
|
|
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 *");
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
owner->message(text);
|
|
|
|
}
|