1999-09-27 18:44:28 +00:00
|
|
|
/* This file is part of
|
1999-11-15 12:01:38 +00:00
|
|
|
* ======================================================
|
1999-10-02 16:21:10 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 1995-2001 The LyX Team.
|
1999-10-02 16:21:10 +00:00
|
|
|
*
|
1999-11-15 12:01:38 +00:00
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
2000-04-11 22:55:29 +00:00
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
#include "Lsstream.h"
|
2000-04-11 22:55:29 +00:00
|
|
|
|
2000-02-01 11:32:33 +00:00
|
|
|
#include <time.h>
|
|
|
|
#include <locale.h>
|
2001-03-07 14:25:31 +00:00
|
|
|
#include <utility>
|
|
|
|
#include <algorithm>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <cctype>
|
|
|
|
#include <cstring>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
#include "support/lyxalgo.h"
|
2000-07-24 13:53:19 +00:00
|
|
|
#include "version.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "kbmap.h"
|
|
|
|
#include "lyxfunc.h"
|
|
|
|
#include "bufferlist.h"
|
2000-06-26 15:33:13 +00:00
|
|
|
#include "ColorHandler.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lyxserver.h"
|
2001-03-28 14:51:25 +00:00
|
|
|
#include "figure_form.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "intl.h"
|
|
|
|
#include "lyx_main.h"
|
|
|
|
#include "lyx_cb.h"
|
1999-11-22 16:19:48 +00:00
|
|
|
#include "LyXAction.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "insets/inseturl.h"
|
|
|
|
#include "insets/insetlatexaccent.h"
|
|
|
|
#include "insets/insettoc.h"
|
|
|
|
#include "insets/insetref.h"
|
|
|
|
#include "insets/insetparent.h"
|
1999-11-15 12:01:38 +00:00
|
|
|
#include "insets/insetindex.h"
|
|
|
|
#include "insets/insetinclude.h"
|
|
|
|
#include "insets/insetbib.h"
|
2000-06-07 08:53:40 +00:00
|
|
|
#include "insets/insetcite.h"
|
2000-02-25 12:06:15 +00:00
|
|
|
#include "insets/insettext.h"
|
|
|
|
#include "insets/insetert.h"
|
2000-06-12 11:27:15 +00:00
|
|
|
#include "insets/insetexternal.h"
|
2000-02-29 02:19:17 +00:00
|
|
|
#include "insets/insetgraphics.h"
|
2000-03-08 13:52:57 +00:00
|
|
|
#include "insets/insetfoot.h"
|
2000-06-28 13:35:52 +00:00
|
|
|
#include "insets/insetmarginal.h"
|
|
|
|
#include "insets/insetminipage.h"
|
|
|
|
#include "insets/insetfloat.h"
|
|
|
|
#include "insets/insetlist.h"
|
2000-04-19 14:42:19 +00:00
|
|
|
#include "insets/insettabular.h"
|
2000-07-04 19:16:35 +00:00
|
|
|
#include "insets/insettheorem.h"
|
2000-07-18 17:45:27 +00:00
|
|
|
#include "insets/insetcaption.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "mathed/formulamacro.h"
|
|
|
|
#include "spellchecker.h" // RVDK_PATCH_5
|
|
|
|
#include "minibuffer.h"
|
|
|
|
#include "vspace.h"
|
|
|
|
#include "LyXView.h"
|
|
|
|
#include "lyx_gui_misc.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "support/filetools.h"
|
|
|
|
#include "support/FileInfo.h"
|
1999-11-15 12:01:38 +00:00
|
|
|
#include "support/syscall.h"
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
#include "support/path.h"
|
2000-10-11 21:06:43 +00:00
|
|
|
#include "support/lyxfunctional.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
#include "debug.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lyxrc.h"
|
|
|
|
#include "lyxtext.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "trans_mgr.h"
|
1999-11-04 01:40:20 +00:00
|
|
|
#include "layout.h"
|
2000-02-10 17:53:36 +00:00
|
|
|
#include "WorkArea.h"
|
2000-04-12 14:20:08 +00:00
|
|
|
#include "bufferview_funcs.h"
|
2001-03-07 14:25:31 +00:00
|
|
|
#include "frontends/FileDialog.h"
|
2000-06-12 11:27:15 +00:00
|
|
|
#include "frontends/Dialogs.h"
|
2000-07-24 13:53:19 +00:00
|
|
|
#include "frontends/Toolbar.h"
|
|
|
|
#include "frontends/Menubar.h"
|
2000-07-15 23:51:46 +00:00
|
|
|
#include "FloatList.h"
|
2000-10-23 12:16:05 +00:00
|
|
|
#include "converter.h"
|
2000-08-30 03:40:51 +00:00
|
|
|
#include "exporter.h"
|
2000-10-23 12:16:05 +00:00
|
|
|
#include "importer.h"
|
2000-08-14 05:24:35 +00:00
|
|
|
#include "FontLoader.h"
|
|
|
|
#include "TextCache.h"
|
2001-03-06 10:20:33 +00:00
|
|
|
#include "lyxfind.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
using std::pair;
|
2001-03-07 14:25:31 +00:00
|
|
|
using std::make_pair;
|
2000-03-28 02:18:55 +00:00
|
|
|
using std::endl;
|
2000-10-12 15:17:42 +00:00
|
|
|
using std::find_if;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
extern BufferList bufferlist;
|
1999-11-04 01:40:20 +00:00
|
|
|
extern LyXServer * lyxserver;
|
2000-07-20 10:04:27 +00:00
|
|
|
extern int greek_kb_flag;
|
1999-09-27 18:44:28 +00:00
|
|
|
extern bool selection_possible;
|
2001-02-26 10:32:45 +00:00
|
|
|
extern void MenuSendto();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-03-07 16:18:05 +00:00
|
|
|
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-07-25 10:46:18 +00:00
|
|
|
extern void show_symbols_form(LyXFunc *);
|
2000-05-20 01:38:25 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
extern LyXAction lyxaction;
|
|
|
|
// (alkis)
|
|
|
|
extern tex_accent_struct get_accent(kb_action action);
|
|
|
|
|
2000-02-29 02:19:17 +00:00
|
|
|
extern LyXTextClass::size_type current_layout;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
extern void ShowLatexLog();
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
///
|
|
|
|
class MiniBufferController : public SigC::Object {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
MiniBufferController() {
|
|
|
|
minibuffer
|
|
|
|
.cmdReady
|
|
|
|
.connect(slot(this,
|
|
|
|
&MiniBufferController::receiveCommand));
|
|
|
|
minibuffer
|
|
|
|
.argReady
|
|
|
|
.connect(slot(this,
|
|
|
|
&MiniBufferController::receiveArg));
|
|
|
|
}
|
|
|
|
///
|
|
|
|
void receiveCmd(string const & cmd) {}
|
|
|
|
///
|
|
|
|
void receiveArg(string const & arg) {}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
MiniBufferController mb_ctrl;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/* === globals =========================================================== */
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
// Initialization of static member var
|
1999-09-27 18:44:28 +00:00
|
|
|
bool LyXFunc::show_sc = true;
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
LyXFunc::LyXFunc(LyXView * o)
|
1999-12-16 06:43:25 +00:00
|
|
|
: owner(o)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
meta_fake_bit = 0;
|
|
|
|
lyx_dead_action = LFUN_NOACTION;
|
|
|
|
lyx_calling_dead_action = LFUN_NOACTION;
|
|
|
|
setupLocalKeymap();
|
|
|
|
}
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
2001-02-22 14:09:20 +00:00
|
|
|
inline
|
2001-04-17 15:15:59 +00:00
|
|
|
LyXText * LyXFunc::TEXT(bool flag = true) const
|
2001-02-22 14:09:20 +00:00
|
|
|
{
|
|
|
|
if (flag)
|
|
|
|
return owner->view()->text;
|
|
|
|
return owner->view()->getLyXText();
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// I changed this func slightly. I commented out the ...FinishUndo(),
|
|
|
|
// this means that all places that used to have a moveCursorUpdate, now
|
|
|
|
// have a ...FinishUndo() as the preceeding statement. I have also added
|
|
|
|
// a moveCursorUpdate to some of the functions that updated the cursor, but
|
|
|
|
// that did not show its new position.
|
|
|
|
inline
|
2001-02-22 14:09:20 +00:00
|
|
|
void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-02-22 14:09:20 +00:00
|
|
|
if (selecting || TEXT(flag)->mark_set) {
|
|
|
|
TEXT(flag)->SetSelection(owner->view());
|
|
|
|
if (TEXT(flag)->bv_owner)
|
2001-02-14 08:38:21 +00:00
|
|
|
owner->view()->toggleToggle();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
2001-02-22 14:09:20 +00:00
|
|
|
owner->view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->showCursor();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/* ---> Everytime the cursor is moved, show the current font state. */
|
|
|
|
// should this too me moved out of this func?
|
2000-07-20 11:39:14 +00:00
|
|
|
//owner->showState();
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->setState();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
void LyXFunc::handleKeyFunc(kb_action action)
|
|
|
|
{
|
2001-05-16 07:53:23 +00:00
|
|
|
char c = keyseq.getiso();
|
2001-02-23 16:10:03 +00:00
|
|
|
|
2001-05-16 07:53:23 +00:00
|
|
|
if (keyseq.length != -1) c = 0;
|
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
owner->getIntl()->getTrans()
|
|
|
|
.deadkey(c, get_accent(action).accent, TEXT(false));
|
|
|
|
// Need to reset, in case the minibuffer calls these
|
|
|
|
// actions
|
|
|
|
keyseq.reset();
|
|
|
|
keyseq.length = 0;
|
|
|
|
// copied verbatim from do_accent_char
|
|
|
|
owner->view()->update(TEXT(false),
|
|
|
|
BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
|
|
|
TEXT(false)->sel_cursor = TEXT(false)->cursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-17 01:23:29 +00:00
|
|
|
void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
|
2000-08-14 15:31:16 +00:00
|
|
|
{
|
|
|
|
string argument;
|
|
|
|
|
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
2001-05-17 01:23:29 +00:00
|
|
|
char const * tmp = XKeysymToString(keysym);
|
2000-12-17 06:09:35 +00:00
|
|
|
string const stm = (tmp ? tmp : "");
|
2000-08-14 15:31:16 +00:00
|
|
|
lyxerr << "KeySym is "
|
|
|
|
<< stm
|
|
|
|
<< "["
|
2000-12-17 06:09:35 +00:00
|
|
|
<< keysym << "] State is ["
|
|
|
|
<< state << "]"
|
2000-08-14 15:31:16 +00:00
|
|
|
<< endl;
|
|
|
|
}
|
|
|
|
// Do nothing if we have nothing (JMarc)
|
|
|
|
if (keysym == NoSymbol) {
|
|
|
|
lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
|
|
|
|
<< endl;
|
|
|
|
//return 0;
|
2001-05-17 01:23:29 +00:00
|
|
|
//return FL_PREEMPT;
|
|
|
|
return;
|
2000-08-14 15:31:16 +00:00
|
|
|
}
|
2000-10-12 01:18:11 +00:00
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
// Can we be sure that this will work for all X-Windows
|
|
|
|
// implementations? (Lgb)
|
|
|
|
// This code snippet makes lyx ignore some keys. Perhaps
|
|
|
|
// all of them should be explictly mentioned?
|
2000-11-04 10:00:12 +00:00
|
|
|
if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
|
2001-05-17 01:23:29 +00:00
|
|
|
|| keysym == XK_Mode_switch || keysym == 0x0) {
|
|
|
|
//return 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
// Do a one-deep top-level lookup for
|
|
|
|
// cancel and meta-fake keys. RVDK_PATCH_5
|
|
|
|
cancel_meta_seq.reset();
|
|
|
|
|
|
|
|
int action = cancel_meta_seq.addkey(keysym, state
|
|
|
|
&(ShiftMask|ControlMask
|
|
|
|
|Mod1Mask));
|
2000-12-17 06:09:35 +00:00
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
|
|
|
lyxerr << "action first set to [" << action << "]" << endl;
|
|
|
|
}
|
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
// When not cancel or meta-fake, do the normal lookup.
|
|
|
|
// Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
|
|
|
|
// Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
|
2000-11-04 10:00:12 +00:00
|
|
|
if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
|
2000-12-17 06:09:35 +00:00
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
2001-04-17 15:15:59 +00:00
|
|
|
lyxerr << "meta_fake_bit is ["
|
|
|
|
<< meta_fake_bit << "]" << endl;
|
2000-12-17 06:09:35 +00:00
|
|
|
}
|
2000-08-14 15:31:16 +00:00
|
|
|
// remove Caps Lock and Mod2 as a modifiers
|
|
|
|
action = keyseq.addkey(keysym,
|
|
|
|
(state | meta_fake_bit)
|
|
|
|
&(ShiftMask|ControlMask
|
2000-12-17 06:09:35 +00:00
|
|
|
|Mod1Mask));
|
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
2001-04-17 15:15:59 +00:00
|
|
|
lyxerr << "action now set to ["
|
|
|
|
<< action << "]" << endl;
|
2000-12-17 06:09:35 +00:00
|
|
|
}
|
2000-08-14 15:31:16 +00:00
|
|
|
}
|
|
|
|
// Dont remove this unless you know what you are doing.
|
|
|
|
meta_fake_bit = 0;
|
|
|
|
|
|
|
|
if (action == 0) action = LFUN_PREFIX;
|
|
|
|
|
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
|
|
|
string buf;
|
|
|
|
keyseq.print(buf);
|
2001-05-29 09:50:02 +00:00
|
|
|
lyxerr << "Key [action="
|
2000-08-14 15:31:16 +00:00
|
|
|
<< action << "]["
|
|
|
|
<< buf << "]"
|
|
|
|
<< endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
// already here we know if it any point in going further
|
|
|
|
// why not return already here if action == -1 and
|
|
|
|
// num_bytes == 0? (Lgb)
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
if (keyseq.length > 1 || keyseq.length < -1) {
|
2000-08-14 15:31:16 +00:00
|
|
|
string buf;
|
|
|
|
keyseq.print(buf);
|
2001-04-17 15:15:59 +00:00
|
|
|
owner->message(buf);
|
2000-08-14 15:31:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (action == -1) {
|
2001-05-17 01:23:29 +00:00
|
|
|
// It is unknown, but what if we remove all
|
|
|
|
// the modifiers? (Lgb)
|
|
|
|
action = keyseq.addkey(keysym, 0);
|
|
|
|
|
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
|
|
|
lyxerr << "Removing modifiers...\n"
|
|
|
|
<< "Action now set to ["
|
|
|
|
<< action << "]" << endl;
|
|
|
|
}
|
|
|
|
if (action == -1) {
|
|
|
|
owner->message(_("Unknown function."));
|
|
|
|
//return 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action == LFUN_SELFINSERT) {
|
2001-05-29 09:50:02 +00:00
|
|
|
// This is very X dependant.
|
|
|
|
unsigned int c = keysym;
|
|
|
|
|
|
|
|
switch (c & 0x0000FF00) {
|
|
|
|
// latin 1 byte 3 = 0
|
|
|
|
case 0x00000000: break;
|
|
|
|
// latin 2 byte 3 = 1
|
|
|
|
case 0x00000100:
|
|
|
|
// latin 3 byte 3 = 2
|
|
|
|
case 0x00000200:
|
|
|
|
// latin 4 byte 3 = 3
|
|
|
|
case 0x00000300:
|
|
|
|
// latin 8 byte 3 = 18 (0x12)
|
|
|
|
case 0x00001200:
|
|
|
|
// latin 9 byte 3 = 19 (0x13)
|
|
|
|
case 0x00001300:
|
|
|
|
c &= 0x000000FF;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
c = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (c > 0)
|
|
|
|
argument = static_cast<char>(c);
|
|
|
|
lyxerr[Debug::KEY] << "SelfInsert arg[`"
|
|
|
|
<< argument << "']" << endl;
|
2000-08-14 15:31:16 +00:00
|
|
|
}
|
2000-12-18 14:21:57 +00:00
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
bool tmp_sc = show_sc;
|
|
|
|
show_sc = false;
|
2000-09-19 11:18:35 +00:00
|
|
|
Dispatch(action, argument);
|
2000-08-14 15:31:16 +00:00
|
|
|
show_sc = tmp_sc;
|
|
|
|
|
2001-05-17 01:23:29 +00:00
|
|
|
//return 0;
|
2000-08-14 15:31:16 +00:00
|
|
|
}
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
LyXFunc::func_status LyXFunc::getStatus(int ac) const
|
2001-02-26 10:32:45 +00:00
|
|
|
{
|
|
|
|
return getStatus(ac, string());
|
|
|
|
}
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
|
|
|
|
LyXFunc::func_status LyXFunc::getStatus(int ac,
|
|
|
|
string const & not_to_use_arg) const
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
|
|
|
kb_action action;
|
|
|
|
func_status flag = LyXFunc::OK;
|
|
|
|
string argument;
|
|
|
|
Buffer * buf = owner->buffer();
|
|
|
|
|
|
|
|
if (lyxaction.isPseudoAction(ac))
|
|
|
|
action = lyxaction.retrieveActionArg(ac, argument);
|
2001-02-26 10:32:45 +00:00
|
|
|
else {
|
1999-12-10 00:07:59 +00:00
|
|
|
action = static_cast<kb_action>(ac);
|
2001-02-26 10:32:45 +00:00
|
|
|
if (!not_to_use_arg.empty())
|
|
|
|
argument = not_to_use_arg; // exept here
|
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
if (action == LFUN_UNKNOWN_ACTION) {
|
|
|
|
setErrorMessage(N_("Unknown action"));
|
|
|
|
return LyXFunc::Unknown;
|
2000-06-12 11:27:15 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// Check whether we need a buffer
|
|
|
|
if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
|
|
|
|
// Yes we need a buffer, do we have one?
|
|
|
|
if (buf) {
|
|
|
|
// yes
|
|
|
|
// Can we use a readonly buffer?
|
|
|
|
if (buf->isReadonly() &&
|
|
|
|
!lyxaction.funcHasFlag(action,
|
|
|
|
LyXAction::ReadOnly)) {
|
|
|
|
// no
|
|
|
|
setErrorMessage(N_("Document is read-only"));
|
2000-01-06 02:44:26 +00:00
|
|
|
flag |= LyXFunc::Disabled;
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// no
|
|
|
|
setErrorMessage(N_("Command not allowed with"
|
|
|
|
"out any document open"));
|
2000-01-06 02:44:26 +00:00
|
|
|
flag |= LyXFunc::Disabled;
|
2000-07-26 14:08:09 +00:00
|
|
|
return flag;
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-06 02:44:26 +00:00
|
|
|
// I would really like to avoid having this switch and rather try to
|
|
|
|
// encode this in the function itself.
|
1999-12-10 00:07:59 +00:00
|
|
|
bool disable = false;
|
|
|
|
switch (action) {
|
1999-12-16 06:43:25 +00:00
|
|
|
case LFUN_MENUPRINT:
|
2000-10-02 16:44:47 +00:00
|
|
|
disable = !Exporter::IsExportable(buf, "dvi")
|
|
|
|
|| lyxrc.print_command == "none";
|
1999-12-16 06:43:25 +00:00
|
|
|
break;
|
2000-11-06 11:20:22 +00:00
|
|
|
case LFUN_EXPORT:
|
2001-02-26 11:18:42 +00:00
|
|
|
disable = argument == "fax" &&
|
|
|
|
!Exporter::IsExportable(buf, argument);
|
2000-11-06 11:20:22 +00:00
|
|
|
break;
|
1999-12-16 06:43:25 +00:00
|
|
|
case LFUN_UNDO:
|
|
|
|
disable = buf->undostack.empty();
|
|
|
|
break;
|
|
|
|
case LFUN_REDO:
|
|
|
|
disable = buf->redostack.empty();
|
|
|
|
break;
|
|
|
|
case LFUN_SPELLCHECK:
|
2000-03-12 10:35:05 +00:00
|
|
|
disable = lyxrc.isp_command == "none";
|
1999-12-16 06:43:25 +00:00
|
|
|
break;
|
|
|
|
case LFUN_RUNCHKTEX:
|
2000-03-12 10:35:05 +00:00
|
|
|
disable = lyxrc.chktex_command == "none";
|
1999-12-16 06:43:25 +00:00
|
|
|
break;
|
2000-07-25 10:46:18 +00:00
|
|
|
case LFUN_BUILDPROG:
|
2000-10-23 12:16:05 +00:00
|
|
|
disable = !Exporter::IsExportable(buf, "program");
|
2000-07-31 12:51:19 +00:00
|
|
|
break;
|
|
|
|
|
2000-12-07 13:36:39 +00:00
|
|
|
case LFUN_INSERTFOOTNOTE:
|
|
|
|
// Disable insertion of floats in a tabular.
|
|
|
|
disable = false;
|
|
|
|
if (owner->view()->theLockingInset()) {
|
|
|
|
disable = (owner->view()->theLockingInset()->LyxCode() == Inset::TABULAR_CODE) ||
|
|
|
|
owner->view()->theLockingInset()->GetFirstLockingInsetOfType(Inset::TABULAR_CODE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-08-01 09:35:42 +00:00
|
|
|
case LFUN_LAYOUT_TABULAR:
|
|
|
|
disable = true;
|
2000-10-03 13:55:48 +00:00
|
|
|
if (owner->view()->theLockingInset()) {
|
|
|
|
disable = (owner->view()->theLockingInset()->LyxCode() != Inset::TABULAR_CODE) &&
|
|
|
|
!owner->view()->theLockingInset()->GetFirstLockingInsetOfType(Inset::TABULAR_CODE);
|
2000-08-01 09:35:42 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_TABULAR_FEATURE:
|
|
|
|
disable = true;
|
2000-10-03 13:55:48 +00:00
|
|
|
if (owner->view()->theLockingInset()) {
|
2000-08-18 15:32:42 +00:00
|
|
|
func_status ret = LyXFunc::Disabled;
|
2000-10-03 13:55:48 +00:00
|
|
|
if (owner->view()->theLockingInset()->LyxCode() == Inset::TABULAR_CODE) {
|
2000-08-01 09:35:42 +00:00
|
|
|
ret = static_cast<InsetTabular *>
|
2000-10-03 13:55:48 +00:00
|
|
|
(owner->view()->theLockingInset())->
|
2000-08-01 09:35:42 +00:00
|
|
|
getStatus(argument);
|
2000-10-03 13:55:48 +00:00
|
|
|
} else if (owner->view()->theLockingInset()->GetFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
|
2000-08-01 09:35:42 +00:00
|
|
|
ret = static_cast<InsetTabular *>
|
2000-10-03 13:55:48 +00:00
|
|
|
(owner->view()->theLockingInset()->
|
2000-08-01 09:35:42 +00:00
|
|
|
GetFirstLockingInsetOfType(Inset::TABULAR_CODE))->
|
|
|
|
getStatus(argument);
|
|
|
|
}
|
2000-08-18 15:32:42 +00:00
|
|
|
flag |= ret;
|
2000-08-25 13:37:24 +00:00
|
|
|
disable = false;
|
2000-08-18 15:32:42 +00:00
|
|
|
} else {
|
2000-10-10 11:50:43 +00:00
|
|
|
static InsetTabular inset(*owner->buffer(), 1, 1);
|
2000-08-18 15:32:42 +00:00
|
|
|
func_status ret;
|
|
|
|
|
|
|
|
disable = true;
|
|
|
|
ret = inset.getStatus(argument);
|
|
|
|
if ((ret & LyXFunc::ToggleOn) ||
|
|
|
|
(ret & LyXFunc::ToggleOff))
|
|
|
|
flag |= LyXFunc::ToggleOff;
|
2000-08-01 09:35:42 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
case LFUN_VC_REGISTER:
|
|
|
|
disable = buf->lyxvc.inUse();
|
|
|
|
break;
|
|
|
|
case LFUN_VC_CHECKIN:
|
|
|
|
disable = !buf->lyxvc.inUse() || buf->isReadonly();
|
|
|
|
break;
|
|
|
|
case LFUN_VC_CHECKOUT:
|
|
|
|
disable = !buf->lyxvc.inUse() || !buf->isReadonly();
|
|
|
|
break;
|
|
|
|
case LFUN_VC_REVERT:
|
|
|
|
case LFUN_VC_UNDO:
|
|
|
|
case LFUN_VC_HISTORY:
|
|
|
|
disable = !buf->lyxvc.inUse();
|
|
|
|
break;
|
2001-01-28 18:31:36 +00:00
|
|
|
case LFUN_BOOKMARK_GOTO:
|
|
|
|
disable = !owner->view()->
|
|
|
|
isSavedPosition(strToUnsignedInt(argument));
|
1999-12-16 06:43:25 +00:00
|
|
|
default:
|
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
if (disable)
|
|
|
|
flag |= LyXFunc::Disabled;
|
|
|
|
|
|
|
|
if (buf) {
|
|
|
|
func_status box = LyXFunc::ToggleOff;
|
2000-12-17 06:09:35 +00:00
|
|
|
LyXFont const & font =
|
2001-02-22 14:09:20 +00:00
|
|
|
TEXT(false)->real_current_font;
|
1999-12-10 00:07:59 +00:00
|
|
|
switch (action) {
|
|
|
|
case LFUN_EMPH:
|
|
|
|
if (font.emph() == LyXFont::ON)
|
|
|
|
box = LyXFunc::ToggleOn;
|
|
|
|
break;
|
|
|
|
case LFUN_NOUN:
|
|
|
|
if (font.noun() == LyXFont::ON)
|
|
|
|
box = LyXFunc::ToggleOn;
|
|
|
|
break;
|
|
|
|
case LFUN_BOLD:
|
|
|
|
if (font.series() == LyXFont::BOLD_SERIES)
|
|
|
|
box = LyXFunc::ToggleOn;
|
|
|
|
break;
|
|
|
|
case LFUN_TEX:
|
|
|
|
if (font.latex() == LyXFont::ON)
|
|
|
|
box = LyXFunc::ToggleOn;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
box = LyXFunc::OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
flag |= box;
|
|
|
|
}
|
|
|
|
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
// temporary dispatch method
|
|
|
|
void LyXFunc::miniDispatch(string const & s)
|
|
|
|
{
|
|
|
|
Dispatch(s);
|
|
|
|
}
|
|
|
|
|
2001-05-16 07:53:23 +00:00
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
string const LyXFunc::Dispatch(string const & s)
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
|
|
|
// Split command string into command and argument
|
2000-09-19 11:18:35 +00:00
|
|
|
string cmd;
|
|
|
|
string line = frontStrip(s);
|
1999-12-10 00:07:59 +00:00
|
|
|
string arg = strip(frontStrip(split(line, cmd, ' ')));
|
|
|
|
|
2000-09-26 13:54:57 +00:00
|
|
|
return Dispatch(lyxaction.LookupFunc(cmd), arg);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
string const LyXFunc::Dispatch(int ac,
|
2001-04-17 15:15:59 +00:00
|
|
|
string const & do_not_use_this_arg)
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
2000-11-04 10:00:12 +00:00
|
|
|
lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << ac
|
|
|
|
<<"] arg[" << do_not_use_this_arg << "]" << endl;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
string argument;
|
|
|
|
kb_action action;
|
|
|
|
|
|
|
|
// we have not done anything wrong yet.
|
|
|
|
errorstat = false;
|
2000-05-04 10:57:00 +00:00
|
|
|
dispatch_buffer.erase();
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// if action is a pseudo-action, we need the real action
|
|
|
|
if (lyxaction.isPseudoAction(ac)) {
|
|
|
|
string tmparg;
|
|
|
|
action = static_cast<kb_action>
|
|
|
|
(lyxaction.retrieveActionArg(ac, tmparg));
|
|
|
|
if (!tmparg.empty())
|
|
|
|
argument = tmparg;
|
|
|
|
} else {
|
|
|
|
action = static_cast<kb_action>(ac);
|
2000-09-14 17:53:12 +00:00
|
|
|
if (!do_not_use_this_arg.empty())
|
1999-12-10 00:07:59 +00:00
|
|
|
argument = do_not_use_this_arg; // except here
|
|
|
|
}
|
|
|
|
|
|
|
|
selection_possible = false;
|
2001-04-26 17:47:40 +00:00
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
if (owner->view()->available())
|
|
|
|
owner->view()->hideCursor();
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// We cannot use this function here
|
2001-02-26 10:32:45 +00:00
|
|
|
if (getStatus(ac, do_not_use_this_arg) & Disabled)
|
1999-12-10 00:07:59 +00:00
|
|
|
goto exit_with_message;
|
|
|
|
|
2000-05-04 10:57:00 +00:00
|
|
|
commandshortcut.erase();
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2000-03-12 10:35:05 +00:00
|
|
|
if (lyxrc.display_shortcuts && show_sc) {
|
1999-12-10 00:07:59 +00:00
|
|
|
if (action != LFUN_SELFINSERT) {
|
|
|
|
// Put name of command and list of shortcuts
|
|
|
|
// for it in minibuffer
|
|
|
|
string comname = lyxaction.getActionName(action);
|
|
|
|
|
|
|
|
int pseudoaction = action;
|
|
|
|
bool argsadded = false;
|
|
|
|
|
|
|
|
if (!argument.empty()) {
|
|
|
|
// If we have the command with argument,
|
|
|
|
// this is better
|
|
|
|
pseudoaction =
|
|
|
|
lyxaction.searchActionArg(action,
|
2000-09-26 13:54:57 +00:00
|
|
|
argument);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
if (pseudoaction == -1) {
|
|
|
|
pseudoaction = action;
|
|
|
|
} else {
|
|
|
|
comname += " " + argument;
|
|
|
|
argsadded = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-17 06:09:35 +00:00
|
|
|
string const shortcuts =
|
|
|
|
toplevel_keymap->findbinding(pseudoaction);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
if (!shortcuts.empty()) {
|
|
|
|
comname += ": " + shortcuts;
|
|
|
|
} else if (!argsadded) {
|
|
|
|
comname += " " + argument;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!comname.empty()) {
|
|
|
|
comname = strip(comname);
|
|
|
|
commandshortcut = "(" + comname + ')';
|
2001-04-17 15:15:59 +00:00
|
|
|
owner->message(commandshortcut);
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// Here we could even add a small pause,
|
|
|
|
// to annoy the user and make him learn
|
|
|
|
// the shortcuts.
|
|
|
|
// No! That will just annoy, not teach
|
|
|
|
// anything. The user will read the messages
|
|
|
|
// if they are interested. (Asger)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-10-03 13:55:48 +00:00
|
|
|
if (owner->view()->available() && owner->view()->theLockingInset()) {
|
2000-04-19 14:42:19 +00:00
|
|
|
UpdatableInset::RESULT result;
|
2000-06-16 15:13:25 +00:00
|
|
|
if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
|
|
|
|
(keyseq.length >= -1)))
|
|
|
|
{
|
|
|
|
if ((action==LFUN_UNKNOWN_ACTION) && argument.empty()){
|
1999-12-10 00:07:59 +00:00
|
|
|
argument = keyseq.getiso();
|
|
|
|
}
|
|
|
|
// Undo/Redo pre 0.13 is a bit tricky for insets.
|
|
|
|
if (action == LFUN_UNDO) {
|
2000-09-29 18:44:07 +00:00
|
|
|
int slx;
|
|
|
|
int sly;
|
1999-12-10 00:07:59 +00:00
|
|
|
UpdatableInset * inset =
|
2000-10-03 13:55:48 +00:00
|
|
|
owner->view()->theLockingInset();
|
2000-06-21 15:07:57 +00:00
|
|
|
inset->GetCursorPos(owner->view(), slx, sly);
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->unlockInset(inset);
|
|
|
|
owner->view()->menuUndo();
|
2001-02-22 14:09:20 +00:00
|
|
|
if (TEXT()->cursor.par()->
|
|
|
|
IsInset(TEXT()->cursor.pos())) {
|
2000-03-31 10:35:53 +00:00
|
|
|
inset = static_cast<UpdatableInset*>(
|
2001-02-22 14:09:20 +00:00
|
|
|
TEXT()->cursor.par()->
|
|
|
|
GetInset(TEXT()->
|
2000-06-08 23:16:16 +00:00
|
|
|
cursor.pos()));
|
2000-03-31 10:35:53 +00:00
|
|
|
} else {
|
|
|
|
inset = 0;
|
|
|
|
}
|
2000-02-25 12:06:15 +00:00
|
|
|
if (inset)
|
|
|
|
inset->Edit(owner->view(),slx,sly,0);
|
1999-12-10 00:07:59 +00:00
|
|
|
return string();
|
2000-02-25 12:06:15 +00:00
|
|
|
} else if (action == LFUN_REDO) {
|
2000-09-29 18:44:07 +00:00
|
|
|
int slx;
|
|
|
|
int sly;
|
2000-02-25 12:06:15 +00:00
|
|
|
UpdatableInset * inset = owner->view()->
|
2000-10-03 13:55:48 +00:00
|
|
|
theLockingInset();
|
2000-06-21 15:07:57 +00:00
|
|
|
inset->GetCursorPos(owner->view(), slx, sly);
|
2000-02-25 12:06:15 +00:00
|
|
|
owner->view()->unlockInset(inset);
|
|
|
|
owner->view()->menuRedo();
|
|
|
|
inset = static_cast<UpdatableInset*>(
|
2001-02-22 14:09:20 +00:00
|
|
|
TEXT()->cursor.par()->
|
|
|
|
GetInset(TEXT()->
|
2000-06-08 23:16:16 +00:00
|
|
|
cursor.pos()));
|
2000-02-25 12:06:15 +00:00
|
|
|
if (inset)
|
|
|
|
inset->Edit(owner->view(),slx,sly,0);
|
|
|
|
return string();
|
2000-10-03 13:55:48 +00:00
|
|
|
} else if (((result=owner->view()->theLockingInset()->
|
2000-02-25 13:35:38 +00:00
|
|
|
LocalDispatch(owner->view(), action,
|
2000-04-19 14:42:19 +00:00
|
|
|
argument)) ==
|
|
|
|
UpdatableInset::DISPATCHED) ||
|
|
|
|
(result == UpdatableInset::DISPATCHED_NOUPDATE))
|
2000-02-25 12:06:15 +00:00
|
|
|
return string();
|
|
|
|
else {
|
2001-01-08 16:14:09 +00:00
|
|
|
//setMessage(N_("Text mode"));
|
2000-11-04 10:00:12 +00:00
|
|
|
switch (action) {
|
2000-04-03 11:36:35 +00:00
|
|
|
case LFUN_UNKNOWN_ACTION:
|
|
|
|
case LFUN_BREAKPARAGRAPH:
|
|
|
|
case LFUN_BREAKLINE:
|
2001-02-22 14:09:20 +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)) {
|
|
|
|
TEXT()->CursorRight(owner->view());
|
|
|
|
moveCursorUpdate(true, false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
2000-04-03 11:36:35 +00:00
|
|
|
}
|
|
|
|
return string();
|
|
|
|
case LFUN_LEFT:
|
2001-02-22 14:09:20 +00:00
|
|
|
if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
|
|
|
|
TEXT()->CursorRight(owner->view());
|
|
|
|
moveCursorUpdate(true, false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
2000-04-03 11:36:35 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
return string();
|
2000-04-19 14:42:19 +00:00
|
|
|
case LFUN_DOWN:
|
2001-02-22 14:09:20 +00:00
|
|
|
TEXT()->CursorDown(owner->view());
|
|
|
|
moveCursorUpdate(true, false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
2000-04-19 14:42:19 +00:00
|
|
|
return string();
|
2000-04-03 11:36:35 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-24 15:25:26 +00:00
|
|
|
lyx::Assert(action != LFUN_SELECT_FILE_SYNC);
|
2001-03-07 14:25:31 +00:00
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
switch (action) {
|
2001-05-18 07:37:14 +00:00
|
|
|
|
|
|
|
case LFUN_ESCAPE:
|
|
|
|
{
|
|
|
|
if (!owner->view()->available()) break;
|
|
|
|
|
|
|
|
// this function should be used always [asierra060396]
|
|
|
|
UpdatableInset * tli =
|
|
|
|
owner->view()->theLockingInset();
|
|
|
|
if (tli) {
|
|
|
|
UpdatableInset * lock = tli->GetLockingInset();
|
|
|
|
|
|
|
|
if (tli == lock) {
|
|
|
|
owner->view()->unlockInset(tli);
|
|
|
|
TEXT()->CursorRight(owner->view());
|
|
|
|
moveCursorUpdate(true, false);
|
|
|
|
owner->showState();
|
|
|
|
} else {
|
|
|
|
tli->UnlockInsetInInset(owner->view(),
|
|
|
|
lock,
|
|
|
|
true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// --- Misc -------------------------------------------
|
|
|
|
case LFUN_WORDFINDFORWARD :
|
|
|
|
case LFUN_WORDFINDBACKWARD : {
|
|
|
|
static string last_search;
|
|
|
|
string searched_string;
|
|
|
|
|
|
|
|
if (!argument.empty()) {
|
|
|
|
last_search = argument;
|
|
|
|
searched_string = argument;
|
|
|
|
} else {
|
|
|
|
searched_string = last_search;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!searched_string.empty() &&
|
|
|
|
((action == LFUN_WORDFINDBACKWARD) ?
|
2001-03-06 10:20:33 +00:00
|
|
|
SearchBackward(owner->view(), searched_string) :
|
|
|
|
SearchForward(owner->view(), searched_string))) {
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// ??? What is that ???
|
2001-02-22 14:09:20 +00:00
|
|
|
owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// ??? Needed ???
|
|
|
|
// clear the selection (if there is any)
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->toggleSelection();
|
2001-02-22 14:09:20 +00:00
|
|
|
TEXT()->ClearSelection(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// Move cursor so that successive C-s 's will not stand in place.
|
2000-11-04 10:00:12 +00:00
|
|
|
if (action == LFUN_WORDFINDFORWARD )
|
2001-02-22 14:09:20 +00:00
|
|
|
TEXT()->CursorRightOneWord(owner->view());
|
|
|
|
TEXT()->FinishUndo();
|
|
|
|
moveCursorUpdate(true, false);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// ??? Needed ???
|
|
|
|
// set the new selection
|
|
|
|
// SetSelectionOverLenChars(owner->view()->currentBuffer()->text, iLenSelected);
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->toggleSelection(false);
|
2001-01-17 17:33:22 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// REMOVED : if (owner->view()->getWorkArea()->focus)
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->showCursor();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
2001-02-23 16:10:03 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_PREFIX:
|
|
|
|
{
|
2000-02-17 19:59:08 +00:00
|
|
|
if (owner->view()->available()) {
|
2001-02-22 14:09:20 +00:00
|
|
|
owner->view()->update(TEXT(),
|
2001-02-14 08:38:21 +00:00
|
|
|
BufferView::SELECT|BufferView::FITCUR);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
1999-12-16 06:43:25 +00:00
|
|
|
string buf;
|
|
|
|
keyseq.print(buf, true);
|
2001-04-17 15:15:59 +00:00
|
|
|
owner->message(buf);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// --- Misc -------------------------------------------
|
|
|
|
case LFUN_EXEC_COMMAND:
|
2001-04-17 15:15:59 +00:00
|
|
|
{
|
2001-04-18 10:20:17 +00:00
|
|
|
std::vector<string> allCmds;
|
|
|
|
std::transform(lyxaction.func_begin(), lyxaction.func_end(),
|
|
|
|
std::back_inserter(allCmds), lyx::firster());
|
|
|
|
static std::vector<string> hist;
|
2001-04-24 15:25:26 +00:00
|
|
|
owner->getMiniBuffer()->getString(MiniBuffer::spaces,
|
2001-04-17 15:15:59 +00:00
|
|
|
allCmds, hist);
|
|
|
|
}
|
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
case LFUN_CANCEL: // RVDK_PATCH_5
|
|
|
|
keyseq.reset();
|
|
|
|
meta_fake_bit = 0;
|
2000-11-04 10:00:12 +00:00
|
|
|
if (owner->view()->available())
|
1999-12-10 00:07:59 +00:00
|
|
|
// cancel any selection
|
2000-09-20 16:15:27 +00:00
|
|
|
Dispatch(LFUN_MARK_OFF);
|
1999-12-10 00:07:59 +00:00
|
|
|
setMessage(N_("Cancel"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_META_FAKE: // RVDK_PATCH_5
|
|
|
|
{
|
|
|
|
meta_fake_bit = Mod1Mask;
|
1999-12-16 06:43:25 +00:00
|
|
|
string buf;
|
|
|
|
keyseq.print(buf, true);
|
1999-12-10 00:07:59 +00:00
|
|
|
setMessage(buf); // RVDK_PATCH_5
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_READ_ONLY_TOGGLE:
|
|
|
|
if (owner->buffer()->lyxvc.inUse()) {
|
|
|
|
owner->buffer()->lyxvc.toggleReadOnly();
|
|
|
|
} else {
|
|
|
|
owner->buffer()->setReadonly(
|
|
|
|
!owner->buffer()->isReadonly());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_CENTER: // this is center and redraw.
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->center();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
// --- Menus -----------------------------------------------
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_MENUNEW:
|
|
|
|
MenuNew(false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MENUNEWTMPLT:
|
|
|
|
MenuNew(true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_CLOSEBUFFER:
|
|
|
|
CloseBuffer();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MENUWRITE:
|
2000-07-26 13:43:16 +00:00
|
|
|
if (!owner->buffer()->isUnnamed()) {
|
2001-04-17 15:15:59 +00:00
|
|
|
string const s1 = _("Saving document") + ' '
|
|
|
|
+ MakeDisplayPath(owner->buffer()->fileName()
|
|
|
|
+ "...");
|
|
|
|
|
|
|
|
owner->message(s1);
|
2000-11-14 02:01:57 +00:00
|
|
|
MenuWrite(owner->view(), owner->buffer());
|
2001-03-07 14:25:31 +00:00
|
|
|
} else
|
|
|
|
WriteAs(owner->view(), owner->buffer());
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
case LFUN_WRITEAS:
|
|
|
|
WriteAs(owner->view(), owner->buffer(), argument);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MENURELOAD:
|
|
|
|
reloadBuffer();
|
|
|
|
break;
|
|
|
|
|
2000-08-30 03:40:51 +00:00
|
|
|
case LFUN_UPDATE:
|
|
|
|
Exporter::Export(owner->buffer(), argument, true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_PREVIEW:
|
|
|
|
Exporter::Preview(owner->buffer(), argument);
|
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
case LFUN_BUILDPROG:
|
2000-10-23 12:16:05 +00:00
|
|
|
Exporter::Export(owner->buffer(), "program", true);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_RUNCHKTEX:
|
|
|
|
MenuRunChktex(owner->buffer());
|
|
|
|
break;
|
2000-08-30 03:40:51 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_MENUPRINT:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->getDialogs()->showPrint();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_EXPORT:
|
2001-02-26 10:32:45 +00:00
|
|
|
if (argument == "custom")
|
|
|
|
MenuSendto();
|
|
|
|
else
|
|
|
|
Exporter::Export(owner->buffer(), argument, false);
|
1999-12-15 17:42:22 +00:00
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
case LFUN_IMPORT:
|
2000-04-28 11:18:04 +00:00
|
|
|
doImport(argument);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_QUIT:
|
|
|
|
QuitLyX();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_TOCVIEW:
|
2001-05-04 10:36:36 +00:00
|
|
|
#if 0
|
2000-05-20 21:37:05 +00:00
|
|
|
case LFUN_LOFVIEW:
|
|
|
|
case LFUN_LOTVIEW:
|
|
|
|
case LFUN_LOAVIEW:
|
2001-05-04 10:36:36 +00:00
|
|
|
#endif
|
2000-05-20 21:37:05 +00:00
|
|
|
{
|
2000-08-01 17:33:32 +00:00
|
|
|
InsetCommandParams p;
|
2001-05-04 10:36:36 +00:00
|
|
|
|
|
|
|
#if 0
|
2001-04-27 07:58:56 +00:00
|
|
|
if (action == LFUN_TOCVIEW)
|
2001-05-04 10:36:36 +00:00
|
|
|
#endif
|
2001-04-27 07:58:56 +00:00
|
|
|
p.setCmdName("tableofcontents");
|
2001-05-04 10:36:36 +00:00
|
|
|
#if 0
|
2000-11-04 10:00:12 +00:00
|
|
|
else if (action == LFUN_LOAVIEW )
|
2001-04-27 07:58:56 +00:00
|
|
|
p.setCmdName("listof{algorithm}{List of Algorithms}");
|
|
|
|
else if (action == LFUN_LOFVIEW)
|
|
|
|
p.setCmdName("listoffigures");
|
2000-08-01 17:33:32 +00:00
|
|
|
else
|
2001-04-27 07:58:56 +00:00
|
|
|
p.setCmdName("listoftables");
|
2001-05-04 10:36:36 +00:00
|
|
|
#endif
|
2001-04-27 07:58:56 +00:00
|
|
|
owner->getDialogs()->createTOC(p.getAsString());
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2000-05-20 21:37:05 +00:00
|
|
|
}
|
2000-08-01 17:33:32 +00:00
|
|
|
|
2000-08-25 13:37:24 +00:00
|
|
|
case LFUN_DIALOG_TABULAR_INSERT:
|
2000-07-11 15:08:54 +00:00
|
|
|
owner->getDialogs()->showTabularCreate();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_FIGURE:
|
2000-02-04 09:38:32 +00:00
|
|
|
Figure();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2000-02-29 02:19:17 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_AUTOSAVE:
|
2000-04-11 22:55:29 +00:00
|
|
|
AutoSave(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_UNDO:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->menuUndo();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_REDO:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->menuRedo();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MENUSEARCH:
|
2001-03-06 10:20:33 +00:00
|
|
|
owner->getDialogs()->showSearch();
|
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
case LFUN_REMOVEERRORS:
|
2000-01-08 21:02:58 +00:00
|
|
|
if (owner->view()->removeAutoInsets()) {
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->redraw();
|
2001-02-22 14:09:20 +00:00
|
|
|
owner->view()->fitCursor(TEXT());
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DEPTH:
|
2001-02-22 14:09:20 +00:00
|
|
|
changeDepth(owner->view(), TEXT(false), 0);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DEPTH_MIN:
|
2001-02-22 14:09:20 +00:00
|
|
|
changeDepth(owner->view(), TEXT(false), -1);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DEPTH_PLUS:
|
2001-02-22 14:09:20 +00:00
|
|
|
changeDepth(owner->view(), TEXT(false), 1);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_FREE:
|
2001-02-26 15:17:19 +00:00
|
|
|
owner->getDialogs()->setUserFreeFont();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_TEX:
|
2000-04-11 22:55:29 +00:00
|
|
|
Tex(owner->view());
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->setState();
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2001-05-03 14:31:33 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_RECONFIGURE:
|
2000-02-04 09:38:32 +00:00
|
|
|
Reconfigure(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
2001-05-03 14:31:33 +00:00
|
|
|
#if 0
|
2000-11-03 15:22:04 +00:00
|
|
|
case LFUN_FLOATSOPERATE:
|
|
|
|
if (argument == "openfoot")
|
|
|
|
owner->view()->allFloats(1,0);
|
|
|
|
else if (argument == "closefoot")
|
|
|
|
owner->view()->allFloats(0,0);
|
|
|
|
else if (argument == "openfig")
|
|
|
|
owner->view()->allFloats(1,1);
|
|
|
|
else if (argument == "closefig")
|
|
|
|
owner->view()->allFloats(0,1);
|
|
|
|
break;
|
|
|
|
#else
|
2001-04-17 00:19:49 +00:00
|
|
|
#ifdef WITH_WARNINGS
|
2000-11-03 15:22:04 +00:00
|
|
|
#warning Find another implementation here (or another lyxfunc)!
|
2001-04-17 00:19:49 +00:00
|
|
|
#endif
|
2000-07-19 17:16:27 +00:00
|
|
|
#endif
|
2000-06-12 11:27:15 +00:00
|
|
|
case LFUN_HELP_COPYRIGHT:
|
|
|
|
owner->getDialogs()->showCopyright();
|
|
|
|
break;
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
case LFUN_HELP_CREDITS:
|
|
|
|
owner->getDialogs()->showCredits();
|
|
|
|
break;
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
case LFUN_HELP_OPEN:
|
|
|
|
{
|
|
|
|
string const arg = argument;
|
2000-07-24 13:53:19 +00:00
|
|
|
if (arg.empty()) {
|
|
|
|
setErrorMessage(N_("Missing argument"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ProhibitInput(owner->view());
|
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;
|
|
|
|
AllowInput(owner->view());
|
|
|
|
break;
|
|
|
|
}
|
2001-04-17 15:15:59 +00:00
|
|
|
string const str = _("Opening help file") + ' '
|
|
|
|
+ MakeDisplayPath(fname) + "...";
|
|
|
|
|
|
|
|
owner->message(str);
|
2000-07-24 13:53:19 +00:00
|
|
|
owner->view()->buffer(bufferlist.loadLyXFile(fname,false));
|
|
|
|
AllowInput(owner->view());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-10-11 21:06:43 +00:00
|
|
|
case LFUN_HELP_VERSION: {
|
2000-07-24 13:53:19 +00:00
|
|
|
ProhibitInput(owner->view());
|
2000-10-11 21:06:43 +00:00
|
|
|
string msg(_("LyX Version "));
|
|
|
|
msg += LYX_VERSION;
|
|
|
|
msg += " of ";
|
|
|
|
msg += LYX_RELEASE;
|
|
|
|
fl_show_message(msg.c_str(),
|
2000-07-24 13:53:19 +00:00
|
|
|
(_("Library directory: ")
|
|
|
|
+ MakeDisplayPath(system_lyxdir)).c_str(),
|
|
|
|
(_("User directory: ")
|
|
|
|
+ MakeDisplayPath(user_lyxdir)).c_str());
|
|
|
|
AllowInput(owner->view());
|
|
|
|
break;
|
2000-10-11 21:06:43 +00:00
|
|
|
}
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// --- version control -------------------------------
|
|
|
|
case LFUN_VC_REGISTER:
|
|
|
|
{
|
|
|
|
if (!owner->buffer()->lyxvc.inUse())
|
|
|
|
owner->buffer()->lyxvc.registrer();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_VC_CHECKIN:
|
|
|
|
{
|
|
|
|
if (owner->buffer()->lyxvc.inUse()
|
|
|
|
&& !owner->buffer()->isReadonly())
|
|
|
|
owner->buffer()->lyxvc.checkIn();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_VC_CHECKOUT:
|
|
|
|
{
|
|
|
|
if (owner->buffer()->lyxvc.inUse()
|
|
|
|
&& owner->buffer()->isReadonly())
|
|
|
|
owner->buffer()->lyxvc.checkOut();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_VC_REVERT:
|
|
|
|
{
|
|
|
|
owner->buffer()->lyxvc.revert();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_VC_UNDO:
|
|
|
|
{
|
|
|
|
owner->buffer()->lyxvc.undoLast();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_VC_HISTORY:
|
|
|
|
{
|
2001-02-06 17:41:42 +00:00
|
|
|
owner->getDialogs()->showVCLogFile();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- buffers ----------------------------------------
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
case LFUN_SWITCHBUFFER:
|
|
|
|
owner->view()->buffer(bufferlist.getBuffer(argument));
|
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_FILE_NEW:
|
|
|
|
{
|
|
|
|
// servercmd: argument must be <file>:<template>
|
|
|
|
Buffer * tmpbuf = NewLyxFile(argument);
|
|
|
|
if (tmpbuf)
|
|
|
|
owner->view()->buffer(tmpbuf);
|
|
|
|
}
|
1999-12-16 06:43:25 +00:00
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
case LFUN_FILE_OPEN:
|
2001-03-07 14:25:31 +00:00
|
|
|
Open(argument);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LATEX_LOG:
|
2001-02-06 17:41:42 +00:00
|
|
|
owner->getDialogs()->showLogFile();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LAYOUTNO:
|
|
|
|
{
|
|
|
|
lyxerr.debug() << "LFUN_LAYOUTNO: (arg) " << argument << endl;
|
|
|
|
int sel = strToInt(argument);
|
|
|
|
lyxerr.debug() << "LFUN_LAYOUTNO: (sel) "<< sel << endl;
|
|
|
|
|
|
|
|
// Should this give a setMessage instead?
|
|
|
|
if (sel == 0)
|
|
|
|
return string(); // illegal argument
|
|
|
|
|
2000-01-24 18:34:46 +00:00
|
|
|
--sel; // sel 1..., but layout 0...
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// Pretend we got the name instead.
|
|
|
|
Dispatch(int(LFUN_LAYOUT),
|
2000-04-19 01:42:55 +00:00
|
|
|
textclasslist.NameOfLayout(owner->view()
|
|
|
|
->buffer()->params.textclass,
|
2000-09-19 11:18:35 +00:00
|
|
|
sel));
|
1999-12-10 00:07:59 +00:00
|
|
|
return string();
|
|
|
|
}
|
|
|
|
|
|
|
|
case LFUN_LAYOUT_DOCUMENT:
|
2000-08-11 14:42:20 +00:00
|
|
|
owner->getDialogs()->showLayoutDocument();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LAYOUT_PARAGRAPH:
|
2000-09-25 15:59:27 +00:00
|
|
|
owner->getDialogs()->showLayoutParagraph();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LAYOUT_CHARACTER:
|
2001-02-26 15:17:19 +00:00
|
|
|
owner->getDialogs()->showLayoutCharacter();
|
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()) {
|
|
|
|
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());
|
2000-08-01 09:35:42 +00:00
|
|
|
inset->OpenLayoutDialog(owner->view());
|
2000-10-03 13:55:48 +00:00
|
|
|
} else if (owner->view()->theLockingInset()->
|
2000-08-01 09:35:42 +00:00
|
|
|
GetFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
|
|
|
|
InsetTabular * inset = static_cast<InsetTabular *>(
|
2000-10-03 13:55:48 +00:00
|
|
|
owner->view()->theLockingInset()->GetFirstLockingInsetOfType(Inset::TABULAR_CODE));
|
2000-08-01 09:35:42 +00:00
|
|
|
inset->OpenLayoutDialog(owner->view());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_LAYOUT_PREAMBLE:
|
2001-02-20 13:34:05 +00:00
|
|
|
owner->getDialogs()->showPreamble();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LAYOUT_SAVE_DEFAULT:
|
2000-11-14 02:01:57 +00:00
|
|
|
MenuLayoutSave(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DROP_LAYOUTS_CHOICE:
|
2000-07-24 13:53:19 +00:00
|
|
|
owner->getToolbar()->openLayoutList();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MENU_OPEN_BY_NAME:
|
2000-07-24 13:53:19 +00:00
|
|
|
owner->getMenubar()->openByName(argument);
|
1999-12-10 00:07:59 +00:00
|
|
|
break; // RVDK_PATCH_5
|
|
|
|
|
|
|
|
case LFUN_SPELLCHECK:
|
2000-03-12 10:35:05 +00:00
|
|
|
if (lyxrc.isp_command != "none")
|
2000-02-22 00:36:17 +00:00
|
|
|
ShowSpellChecker(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
break; // RVDK_PATCH_5
|
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
// --- lyxserver commands ----------------------------
|
|
|
|
|
|
|
|
|
|
|
|
case LFUN_GETNAME:
|
|
|
|
setMessage(owner->buffer()->fileName());
|
|
|
|
lyxerr.debug() << "FNAME["
|
|
|
|
<< owner->buffer()->fileName()
|
|
|
|
<< "] " << endl;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_NOTIFY:
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
2001-02-23 16:10:03 +00:00
|
|
|
string buf;
|
|
|
|
keyseq.print(buf);
|
|
|
|
dispatch_buffer = buf;
|
|
|
|
lyxserver->notifyClient(dispatch_buffer);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
2001-02-23 16:10:03 +00:00
|
|
|
|
|
|
|
case LFUN_GOTOFILEROW:
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
2001-02-23 16:10:03 +00:00
|
|
|
char file_name[100];
|
|
|
|
int row;
|
|
|
|
::sscanf(argument.c_str(), " %s %d", file_name, &row);
|
2000-02-10 17:53:36 +00:00
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
// Must replace extension of the file to be .lyx and get full path
|
|
|
|
string s = ChangeExtension(string(file_name), ".lyx");
|
|
|
|
|
|
|
|
// Either change buffer or load the file
|
|
|
|
if (bufferlist.exists(s))
|
|
|
|
owner->view()->buffer(bufferlist.getBuffer(s));
|
|
|
|
else
|
|
|
|
owner->view()->buffer(bufferlist.loadLyXFile(s));
|
|
|
|
|
|
|
|
// Set the cursor
|
|
|
|
owner->view()->setCursorFromRow(row);
|
|
|
|
|
|
|
|
// Recenter screen
|
|
|
|
owner->view()->center();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
case LFUN_GOTO_PARAGRAPH:
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
LyXParagraph * par = TEXT()->GetParFromID(id);
|
2001-03-30 19:24:28 +00:00
|
|
|
if (par == 0)
|
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2001-02-23 16:10:03 +00:00
|
|
|
// Set the cursor
|
|
|
|
TEXT()->SetCursor(owner->view(), par, 0);
|
|
|
|
owner->view()->setState();
|
2000-08-31 11:51:59 +00:00
|
|
|
owner->showState();
|
|
|
|
|
|
|
|
// Recenter screen
|
|
|
|
owner->view()->center();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_APROPOS:
|
|
|
|
case LFUN_GETTIP:
|
|
|
|
{
|
2000-09-26 13:54:57 +00:00
|
|
|
int const qa = lyxaction.LookupFunc(argument);
|
1999-12-13 00:05:34 +00:00
|
|
|
setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// --- toolbar ----------------------------------
|
|
|
|
case LFUN_PUSH_TOOLBAR:
|
|
|
|
{
|
|
|
|
int nth = strToInt(argument);
|
|
|
|
if (nth <= 0) {
|
|
|
|
setErrorMessage(N_("Push-toolbar needs argument > 0"));
|
|
|
|
} else {
|
|
|
|
owner->getToolbar()->push(nth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_ADD_TO_TOOLBAR:
|
|
|
|
{
|
2000-07-24 13:53:19 +00:00
|
|
|
if (lyxerr.debugging(Debug::GUI)) {
|
1999-12-10 00:07:59 +00:00
|
|
|
lyxerr << "LFUN_ADD_TO_TOOLBAR:"
|
|
|
|
"argument = `" << argument << '\'' << endl;
|
|
|
|
}
|
|
|
|
string tmp(argument);
|
|
|
|
//lyxerr <<string("Argument: ") + argument);
|
|
|
|
//lyxerr <<string("Tmp : ") + tmp);
|
|
|
|
if (tmp.empty()) {
|
|
|
|
setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
|
|
|
|
} else {
|
|
|
|
owner->getToolbar()->add(argument, false);
|
|
|
|
owner->getToolbar()->set();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// --- insert characters ----------------------------------------
|
2000-02-04 09:38:32 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// --- Mathed stuff. If we are here, there is no locked inset yet.
|
|
|
|
|
|
|
|
// Greek mode
|
|
|
|
case LFUN_GREEK:
|
|
|
|
{
|
|
|
|
if (!greek_kb_flag) {
|
|
|
|
greek_kb_flag = 1;
|
|
|
|
setMessage(N_("Math greek mode on"));
|
|
|
|
} else
|
|
|
|
greek_kb_flag = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Greek keyboard
|
|
|
|
case LFUN_GREEK_TOGGLE:
|
|
|
|
{
|
1999-12-16 06:43:25 +00:00
|
|
|
greek_kb_flag = greek_kb_flag ? 0 : 2;
|
1999-12-10 00:07:59 +00:00
|
|
|
if (greek_kb_flag) {
|
|
|
|
setMessage(N_("Math greek keyboard on"));
|
|
|
|
} else {
|
|
|
|
setMessage(N_("Math greek keyboard off"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2001-04-25 15:43:57 +00:00
|
|
|
case LFUN_MATH_EXTERN:
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_MATH_NUMBER:
|
|
|
|
case LFUN_MATH_LIMITS:
|
|
|
|
{
|
|
|
|
setErrorMessage(N_("This is only allowed in math mode!"));
|
2000-07-25 10:46:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MATH_PANEL:
|
2001-03-16 12:08:14 +00:00
|
|
|
owner->getDialogs()->showMathPanel();
|
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2000-08-03 12:56:25 +00:00
|
|
|
case LFUN_CITATION_CREATE:
|
2000-07-07 07:46:37 +00:00
|
|
|
{
|
2000-08-03 12:56:25 +00:00
|
|
|
InsetCommandParams p( "cite" );
|
2000-08-01 17:33:32 +00:00
|
|
|
|
2000-12-11 09:46:09 +00:00
|
|
|
if (!argument.empty()) {
|
|
|
|
// This should be set at source, ie when typing
|
|
|
|
// "citation-insert foo" in the minibuffer.
|
|
|
|
// Question: would pybibliographer also need to be
|
|
|
|
// changed. Suspect so. Leave as-is therefore.
|
|
|
|
if (contains(argument, "|")) {
|
|
|
|
p.setContents( token(argument, '|', 0) );
|
|
|
|
p.setOptions( token(argument, '|', 1) );
|
|
|
|
} else {
|
|
|
|
p.setContents( argument );
|
|
|
|
}
|
|
|
|
Dispatch(LFUN_CITATION_INSERT, p.getAsString());
|
|
|
|
} else
|
|
|
|
owner->getDialogs()->createCitation( p.getAsString() );
|
2000-07-07 07:46:37 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_CHILDOPEN:
|
|
|
|
{
|
2000-11-14 02:01:57 +00:00
|
|
|
string const filename =
|
1999-12-10 00:07:59 +00:00
|
|
|
MakeAbsPath(argument,
|
|
|
|
OnlyPath(owner->buffer()->fileName()));
|
|
|
|
setMessage(N_("Opening child document ") +
|
|
|
|
MakeDisplayPath(filename) + "...");
|
2001-01-28 18:31:36 +00:00
|
|
|
owner->view()->savePosition(0);
|
1999-12-10 00:07:59 +00:00
|
|
|
if (bufferlist.exists(filename))
|
1999-12-16 06:43:25 +00:00
|
|
|
owner->view()->buffer(bufferlist.getBuffer(filename));
|
1999-12-10 00:07:59 +00:00
|
|
|
else
|
1999-12-16 06:43:25 +00:00
|
|
|
owner->view()->buffer(bufferlist.loadLyXFile(filename));
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_TOGGLECURSORFOLLOW:
|
2000-10-10 14:17:33 +00:00
|
|
|
lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_KMAP_OFF: // keymap off
|
|
|
|
owner->getIntl()->KeyMapOn(false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_KMAP_PRIM: // primary keymap
|
|
|
|
owner->getIntl()->KeyMapPrim();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_KMAP_SEC: // secondary keymap
|
|
|
|
owner->getIntl()->KeyMapSec();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_KMAP_TOGGLE: // toggle keymap
|
|
|
|
owner->getIntl()->ToggleKeyMap();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_SEQUENCE:
|
|
|
|
{
|
|
|
|
// argument contains ';'-terminated commands
|
|
|
|
while (argument.find(';') != string::npos) {
|
|
|
|
string first;
|
|
|
|
argument = split(argument, first, ';');
|
|
|
|
Dispatch(first);
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-07-28 04:59:45 +00:00
|
|
|
case LFUN_DIALOG_PREFERENCES:
|
|
|
|
owner->getDialogs()->showPreferences();
|
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_SAVEPREFERENCES:
|
|
|
|
{
|
|
|
|
Path p(user_lyxdir);
|
2000-03-12 10:35:05 +00:00
|
|
|
lyxrc.write("preferences");
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2000-08-14 05:24:35 +00:00
|
|
|
case LFUN_SCREEN_FONT_UPDATE:
|
|
|
|
{
|
|
|
|
// handle the screen font changes.
|
|
|
|
//
|
|
|
|
lyxrc.set_font_norm_type();
|
|
|
|
fontloader.update();
|
|
|
|
// Of course we should only do the resize and the textcache.clear
|
|
|
|
// if values really changed...but not very important right now. (Lgb)
|
|
|
|
// All buffers will need resize
|
|
|
|
bufferlist.resize();
|
|
|
|
// We also need to empty the textcache so that
|
|
|
|
// the buffer will be formatted correctly after
|
|
|
|
// a zoom change.
|
|
|
|
textcache.clear();
|
|
|
|
}
|
2000-10-02 06:11:02 +00:00
|
|
|
break;
|
2000-08-14 05:24:35 +00:00
|
|
|
|
2000-06-26 15:33:13 +00:00
|
|
|
case LFUN_SET_COLOR:
|
|
|
|
{
|
2000-11-14 02:01:57 +00:00
|
|
|
string lyx_name;
|
|
|
|
string const x11_name = split(argument, lyx_name, ' ');
|
2000-06-26 15:33:13 +00:00
|
|
|
if (lyx_name.empty() || x11_name.empty()) {
|
|
|
|
setErrorMessage(N_("Syntax: set-color <lyx_name>"
|
|
|
|
" <x11_name>"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lcolor.setColor(lyx_name, x11_name)) {
|
2000-11-14 02:01:57 +00:00
|
|
|
static string const err1 (N_("Set-color \""));
|
|
|
|
static string const err2 (
|
|
|
|
N_("\" failed - color is undefined "
|
|
|
|
"or may not be redefined"));
|
|
|
|
setErrorMessage(_(err1) + lyx_name + _(err2));
|
2000-06-26 15:33:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
|
|
|
|
owner->view()->redraw();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
case LFUN_MESSAGE:
|
|
|
|
owner->message(argument);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MESSAGE_PUSH:
|
|
|
|
owner->messagePush(argument);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MESSAGE_POP:
|
|
|
|
owner->messagePop();
|
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
default:
|
2001-02-23 16:10:03 +00:00
|
|
|
// Then if it was none of the above
|
|
|
|
if (!owner->view()->Dispatch(action, argument))
|
2001-05-16 07:53:23 +00:00
|
|
|
lyxerr << "A truly unknown func ["
|
|
|
|
<< 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
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
if (res.empty()) {
|
|
|
|
if (!commandshortcut.empty()) {
|
2001-04-17 15:15:59 +00:00
|
|
|
owner->getMiniBuffer()->addSet(commandshortcut);
|
1999-12-03 13:51:01 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
} else {
|
2001-04-17 15:15:59 +00:00
|
|
|
string const msg(_(res) + ' ' + commandshortcut);
|
|
|
|
owner->message(msg);
|
1999-11-22 16:19:48 +00:00
|
|
|
}
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
return res;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-22 16:19:48 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
void LyXFunc::setupLocalKeymap()
|
|
|
|
{
|
2001-03-07 16:18:05 +00:00
|
|
|
keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
|
|
|
|
cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
|
1999-12-16 06:43:25 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
void LyXFunc::MenuNew(bool fromTemplate)
|
|
|
|
{
|
2000-10-11 21:06:43 +00:00
|
|
|
string initpath = lyxrc.document_path;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
if (owner->view()->available()) {
|
2000-11-14 02:01:57 +00:00
|
|
|
string const trypath = owner->buffer()->filepath;
|
1999-12-16 06:43:25 +00:00
|
|
|
// If directory is writeable, use this as default.
|
|
|
|
if (IsDirWriteable(trypath) == 1)
|
|
|
|
initpath = trypath;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-08-08 11:08:07 +00:00
|
|
|
static int newfile_number = 0;
|
2000-08-08 13:55:26 +00:00
|
|
|
string s;
|
2000-11-14 02:01:57 +00:00
|
|
|
|
2000-08-08 11:08:07 +00:00
|
|
|
if (lyxrc.new_ask_filename) {
|
2001-03-07 14:25:31 +00:00
|
|
|
FileDialog fileDlg(owner, _("Enter filename for new document"),
|
2001-04-17 15:15:59 +00:00
|
|
|
LFUN_SELECT_FILE_SYNC,
|
|
|
|
make_pair(string(_("Documents")),
|
|
|
|
string(lyxrc.document_path)),
|
|
|
|
make_pair(string(_("Templates")),
|
|
|
|
string(lyxrc.template_path)));
|
|
|
|
|
|
|
|
FileDialog::Result result =
|
|
|
|
fileDlg.Select(initpath,
|
|
|
|
_("*.lyx|LyX Documents (*.lyx)"),
|
|
|
|
_("newfile"));
|
1999-12-16 06:43:25 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
if (result.second.empty()) {
|
2001-04-24 17:33:01 +00:00
|
|
|
owner->message(_("Canceled."));
|
2000-08-08 11:08:07 +00:00
|
|
|
lyxerr.debug() << "New Document Cancelled." << endl;
|
|
|
|
return;
|
|
|
|
}
|
2000-07-26 13:43:16 +00:00
|
|
|
|
2000-08-08 11:08:07 +00:00
|
|
|
// get absolute path of file and make sure the filename ends
|
|
|
|
// with .lyx
|
2001-03-07 14:25:31 +00:00
|
|
|
s = MakeAbsPath(result.second);
|
2000-08-08 11:08:07 +00:00
|
|
|
if (!IsLyXFilename(s))
|
|
|
|
s += ".lyx";
|
|
|
|
|
|
|
|
// Check if the document already is open
|
|
|
|
if (bufferlist.exists(s)) {
|
2001-04-17 15:15:59 +00:00
|
|
|
switch (AskConfirmation(_("Document is already open:"),
|
|
|
|
MakeDisplayPath(s, 50),
|
|
|
|
_("Do you want to close that document now?\n"
|
|
|
|
"('No' will just switch to the open version)")))
|
1999-12-16 06:43:25 +00:00
|
|
|
{
|
|
|
|
case 1: // Yes: close the document
|
|
|
|
if (!bufferlist.close(bufferlist.getBuffer(s)))
|
|
|
|
// If close is canceled, we cancel here too.
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case 2: // No: switch to the open document
|
|
|
|
owner->view()->buffer(bufferlist.getBuffer(s));
|
|
|
|
return;
|
|
|
|
case 3: // Cancel: Do nothing
|
2001-04-24 17:33:01 +00:00
|
|
|
owner->message(_("Canceled."));
|
1999-12-16 06:43:25 +00:00
|
|
|
return;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2000-08-08 11:08:07 +00:00
|
|
|
}
|
|
|
|
// Check whether the file already exists
|
|
|
|
if (IsLyXFilename(s)) {
|
|
|
|
FileInfo fi(s);
|
|
|
|
if (fi.readable() &&
|
|
|
|
AskQuestion(_("File already exists:"),
|
|
|
|
MakeDisplayPath(s, 50),
|
|
|
|
_("Do you want to open the document?"))) {
|
|
|
|
// loads document
|
2001-04-24 17:33:01 +00:00
|
|
|
owner->message(_("Opening document") + ' '
|
|
|
|
+ MakeDisplayPath(s) + "...");
|
2000-10-11 21:06:43 +00:00
|
|
|
XFlush(fl_get_display());
|
2000-08-08 11:08:07 +00:00
|
|
|
owner->view()->buffer(
|
|
|
|
bufferlist.loadLyXFile(s));
|
2001-04-24 17:33:01 +00:00
|
|
|
owner->message(_("Document") + ' '
|
|
|
|
+ MakeDisplayPath(s) + ' '
|
|
|
|
+ _("opened."));
|
2000-08-08 11:08:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2000-10-02 16:44:47 +00:00
|
|
|
s = AddName(lyxrc.document_path,
|
|
|
|
"newfile" + tostr(++newfile_number) + ".lyx");
|
1999-12-16 06:43:25 +00:00
|
|
|
FileInfo fi(s);
|
2000-08-08 11:08:07 +00:00
|
|
|
while (bufferlist.exists(s) || fi.readable()) {
|
|
|
|
++newfile_number;
|
2000-10-02 16:44:47 +00:00
|
|
|
s = AddName(lyxrc.document_path,
|
|
|
|
"newfile" + tostr(newfile_number) +
|
|
|
|
".lyx");
|
2000-08-08 11:08:07 +00:00
|
|
|
fi.newFile(s);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-12-16 06:43:25 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
// The template stuff
|
|
|
|
string templname;
|
|
|
|
if (fromTemplate) {
|
2001-03-07 14:25:31 +00:00
|
|
|
FileDialog fileDlg(owner, _("Select template file"),
|
|
|
|
LFUN_SELECT_FILE_SYNC,
|
2001-04-17 15:15:59 +00:00
|
|
|
make_pair(string(_("Documents")),
|
|
|
|
string(lyxrc.document_path)),
|
|
|
|
make_pair(string(_("Templates")),
|
|
|
|
string(lyxrc.template_path)));
|
|
|
|
|
|
|
|
FileDialog::Result result =
|
|
|
|
fileDlg.Select(initpath,
|
|
|
|
_("*.lyx|LyX Documents (*.lyx)"));
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
return;
|
|
|
|
|
|
|
|
string const fname = result.second;
|
|
|
|
|
|
|
|
if (fname.empty())
|
|
|
|
return;
|
2000-10-26 17:31:11 +00:00
|
|
|
templname = fname;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-12-16 06:43:25 +00:00
|
|
|
|
|
|
|
// find a free buffer
|
|
|
|
lyxerr.debug() << "Find a free buffer." << endl;
|
|
|
|
owner->view()->buffer(bufferlist.newFile(s, templname));
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
void LyXFunc::Open(string const & fname)
|
1999-12-16 06:43:25 +00:00
|
|
|
{
|
2000-03-12 10:35:05 +00:00
|
|
|
string initpath = lyxrc.document_path;
|
1999-12-16 06:43:25 +00:00
|
|
|
|
|
|
|
if (owner->view()->available()) {
|
2000-11-14 02:01:57 +00:00
|
|
|
string const trypath = owner->buffer()->filepath;
|
1999-12-16 06:43:25 +00:00
|
|
|
// If directory is writeable, use this as default.
|
|
|
|
if (IsDirWriteable(trypath) == 1)
|
|
|
|
initpath = trypath;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
string filename;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
if (fname.empty()) {
|
|
|
|
FileDialog fileDlg(owner, _("Select document to open"),
|
|
|
|
LFUN_FILE_OPEN,
|
2001-04-17 15:15:59 +00:00
|
|
|
make_pair(string(_("Documents")),
|
|
|
|
string(lyxrc.document_path)),
|
|
|
|
make_pair(string(_("Examples")),
|
|
|
|
string(AddPath(system_lyxdir, "examples"))));
|
|
|
|
|
|
|
|
FileDialog::Result result =
|
|
|
|
fileDlg.Select(initpath,
|
|
|
|
"*.lyx|LyX Documents (*.lyx)");
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
return;
|
|
|
|
|
|
|
|
filename = result.second;
|
|
|
|
|
|
|
|
// check selected filename
|
|
|
|
if (filename.empty()) {
|
2001-04-24 17:33:01 +00:00
|
|
|
owner->message(_("Canceled."));
|
2001-03-07 14:25:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
filename = fname;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// get absolute path of file and make sure the filename ends
|
|
|
|
// with .lyx
|
|
|
|
filename = MakeAbsPath(filename);
|
|
|
|
if (!IsLyXFilename(filename))
|
|
|
|
filename += ".lyx";
|
|
|
|
|
|
|
|
// loads document
|
2001-04-24 17:33:01 +00:00
|
|
|
owner->message(_("Opening document") + ' '
|
|
|
|
+ MakeDisplayPath(filename) + "...");
|
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-04-24 17:33:01 +00:00
|
|
|
owner->message(_("Document") + ' '
|
|
|
|
+ MakeDisplayPath(filename)
|
|
|
|
+ ' ' + _("opened."));
|
1999-09-27 18:44:28 +00:00
|
|
|
} else {
|
2001-04-24 17:33:01 +00:00
|
|
|
owner->message(_("Could not open document") + ' '
|
|
|
|
+ MakeDisplayPath(filename));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
|
2000-04-28 11:18:04 +00:00
|
|
|
// checks for running without gui are missing.
|
2000-10-23 12:16:05 +00:00
|
|
|
void LyXFunc::doImport(string const & argument)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-10-23 12:16:05 +00:00
|
|
|
string format;
|
|
|
|
string filename = split(argument, format, ' ');
|
|
|
|
lyxerr.debug() << "LyXFunc::doImport: " << format
|
|
|
|
<< " file: " << filename << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-04-28 11:18:04 +00:00
|
|
|
if (filename.empty()) { // need user interaction
|
|
|
|
string initpath = lyxrc.document_path;
|
|
|
|
|
|
|
|
if (owner->view()->available()) {
|
2000-11-14 02:01:57 +00:00
|
|
|
string const trypath = owner->buffer()->filepath;
|
2000-04-28 11:18:04 +00:00
|
|
|
// If directory is writeable, use this as default.
|
|
|
|
if (IsDirWriteable(trypath) == 1)
|
|
|
|
initpath = trypath;
|
|
|
|
}
|
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
string const text = _("Select ") + formats.PrettyName(format)
|
2000-10-23 12:16:05 +00:00
|
|
|
+ _(" file to import");
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
FileDialog fileDlg(owner, text,
|
|
|
|
LFUN_IMPORT,
|
2001-04-17 15:15:59 +00:00
|
|
|
make_pair(string(_("Documents")),
|
|
|
|
string(lyxrc.document_path)),
|
|
|
|
make_pair(string(_("Examples")),
|
|
|
|
string(AddPath(system_lyxdir, "examples"))));
|
2001-03-07 14:25:31 +00:00
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
string const extension = "*." + formats.Extension(format)
|
|
|
|
+ "| " + formats.PrettyName(format)
|
|
|
|
+ " (*." + formats.Extension(format) + ")";
|
2001-03-07 14:25:31 +00:00
|
|
|
|
2001-04-17 15:15:59 +00:00
|
|
|
FileDialog::Result result = fileDlg.Select(initpath,
|
|
|
|
extension);
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
return;
|
|
|
|
|
|
|
|
filename = result.second;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-04-28 11:18:04 +00:00
|
|
|
// check selected filename
|
2001-04-17 15:15:59 +00:00
|
|
|
if (filename.empty())
|
2001-04-24 17:33:01 +00:00
|
|
|
owner->message(_("Canceled."));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2000-04-28 11:18:04 +00:00
|
|
|
// still no filename? abort
|
|
|
|
if (filename.empty())
|
|
|
|
return;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// get absolute path of file
|
|
|
|
filename = MakeAbsPath(filename);
|
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
string const lyxfile = ChangeExtension(filename, ".lyx");
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Check if the document already is open
|
2000-04-28 11:18:04 +00:00
|
|
|
if (bufferlist.exists(lyxfile)) {
|
2000-11-04 10:00:12 +00:00
|
|
|
switch (AskConfirmation(_("Document is already open:"),
|
2001-04-17 15:15:59 +00:00
|
|
|
MakeDisplayPath(lyxfile, 50),
|
|
|
|
_("Do you want to close that document now?\n"
|
|
|
|
"('No' will just switch to the open version)")))
|
1999-12-16 06:43:25 +00:00
|
|
|
{
|
|
|
|
case 1: // Yes: close the document
|
2000-04-28 11:18:04 +00:00
|
|
|
if (!bufferlist.close(bufferlist.getBuffer(lyxfile)))
|
1999-09-27 18:44:28 +00:00
|
|
|
// If close is canceled, we cancel here too.
|
1999-12-16 06:43:25 +00:00
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case 2: // No: switch to the open document
|
2000-04-28 11:18:04 +00:00
|
|
|
owner->view()->buffer(bufferlist.getBuffer(lyxfile));
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
1999-12-16 06:43:25 +00:00
|
|
|
case 3: // Cancel: Do nothing
|
2001-04-24 17:33:01 +00:00
|
|
|
owner->message(_("Canceled."));
|
1999-12-16 06:43:25 +00:00
|
|
|
return;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check if a LyX document by the same root exists in filesystem
|
2000-11-14 02:01:57 +00:00
|
|
|
FileInfo const f(lyxfile, true);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (f.exist() && !AskQuestion(_("A document by the name"),
|
2000-04-28 11:18:04 +00:00
|
|
|
MakeDisplayPath(lyxfile),
|
1999-09-27 18:44:28 +00:00
|
|
|
_("already exists. Overwrite?"))) {
|
2001-04-24 17:33:01 +00:00
|
|
|
owner->message(_("Canceled"));
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-04-28 11:18:04 +00:00
|
|
|
// filename should be valid now
|
2001-04-17 15:15:59 +00:00
|
|
|
|
2000-10-23 12:16:05 +00:00
|
|
|
Importer::Import(owner, filename, format);
|
2000-03-20 18:55:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void LyXFunc::reloadBuffer()
|
|
|
|
{
|
2000-11-14 02:01:57 +00:00
|
|
|
string const fn = owner->buffer()->fileName();
|
1999-11-09 23:52:04 +00:00
|
|
|
if (bufferlist.close(owner->buffer()))
|
1999-11-22 16:19:48 +00:00
|
|
|
owner->view()->buffer(bufferlist.loadLyXFile(fn));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LyXFunc::CloseBuffer()
|
|
|
|
{
|
1999-11-09 23:52:04 +00:00
|
|
|
if (bufferlist.close(owner->buffer()) && !quitting) {
|
1999-11-05 06:02:34 +00:00
|
|
|
if (bufferlist.empty()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
// need this otherwise SEGV may occur while trying to
|
|
|
|
// set variables that don't exist
|
|
|
|
// since there's no current buffer
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->getDialogs()->hideBufferDependent();
|
2000-11-14 02:01:57 +00:00
|
|
|
} else {
|
1999-11-22 16:19:48 +00:00
|
|
|
owner->view()->buffer(bufferlist.first());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Each "owner" should have it's own message method. lyxview and
|
|
|
|
// the minibuffer would use the minibuffer, but lyxserver would
|
|
|
|
// send an ERROR signal to its client. Alejandro 970603
|
|
|
|
// This func is bit problematic when it comes to NLS, to make the
|
|
|
|
// lyx servers client be language indepenent we must not translate
|
|
|
|
// strings sent to this func.
|
1999-11-22 16:19:48 +00:00
|
|
|
void LyXFunc::setErrorMessage(string const & m) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
dispatch_buffer = m;
|
|
|
|
errorstat = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
void LyXFunc::setMessage(string const & m)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
dispatch_buffer = m;
|
|
|
|
}
|
2001-04-17 15:15:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
void LyXFunc::initMiniBuffer()
|
|
|
|
{
|
|
|
|
string text = _("Welcome to LyX!");
|
|
|
|
|
|
|
|
// When meta-fake key is pressed, show the key sequence so far + "M-".
|
|
|
|
if (wasMetaKey()) {
|
|
|
|
keyseqStr();
|
|
|
|
text += "M-";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Else, when a non-complete key sequence is pressed,
|
|
|
|
// show the available options.
|
|
|
|
else if (keyseqUncomplete())
|
|
|
|
text = keyseqOptions();
|
|
|
|
|
|
|
|
// Else, show the buffer state.
|
|
|
|
else if (owner->view()->available()) {
|
|
|
|
Buffer * tmpbuf = owner->buffer();
|
|
|
|
|
|
|
|
string const nicename =
|
|
|
|
MakeDisplayPath(tmpbuf->fileName());
|
|
|
|
// Should we do this instead? (kindo like emacs)
|
|
|
|
// leaves more room for other information
|
|
|
|
text = "LyX: ";
|
|
|
|
text += nicename;
|
|
|
|
if (tmpbuf->lyxvc.inUse()) {
|
|
|
|
text += " [";
|
|
|
|
text += tmpbuf->lyxvc.version();
|
|
|
|
text += ' ';
|
|
|
|
text += tmpbuf->lyxvc.locker();
|
|
|
|
if (tmpbuf->isReadonly())
|
|
|
|
text += " (RO)";
|
|
|
|
text += ']';
|
|
|
|
} else if (tmpbuf->isReadonly())
|
|
|
|
text += " [RO]";
|
|
|
|
if (!tmpbuf->isLyxClean())
|
|
|
|
text += _(" (Changed)");
|
|
|
|
} else {
|
|
|
|
if (text != _("Welcome to LyX!")) // this is a hack
|
|
|
|
text = _("* No document open *");
|
|
|
|
}
|
|
|
|
|
|
|
|
owner->message(text);
|
|
|
|
}
|
|
|
|
|