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
|
2000-02-04 09:38:32 +00:00
|
|
|
* Copyright 1995-2000 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>
|
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
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
#include "version.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lyxlookup.h"
|
|
|
|
#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"
|
|
|
|
#include "lyx.h"
|
|
|
|
#include "intl.h"
|
|
|
|
#include "lyx_main.h"
|
|
|
|
#include "lyx_cb.h"
|
1999-11-22 16:19:48 +00:00
|
|
|
#include "LyXAction.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "insets/inseturl.h"
|
|
|
|
#include "insets/insetlatexaccent.h"
|
|
|
|
#include "insets/insettoc.h"
|
|
|
|
#include "insets/insetref.h"
|
|
|
|
#include "insets/insetparent.h"
|
1999-11-15 12:01:38 +00:00
|
|
|
#include "insets/insetindex.h"
|
|
|
|
#include "insets/insetinclude.h"
|
|
|
|
#include "insets/insetbib.h"
|
2000-06-07 08:53:40 +00:00
|
|
|
#include "insets/insetcite.h"
|
2000-02-25 12:06:15 +00:00
|
|
|
#include "insets/insettext.h"
|
|
|
|
#include "insets/insetert.h"
|
2000-06-12 11:27:15 +00:00
|
|
|
#include "insets/insetexternal.h"
|
2000-02-29 02:19:17 +00:00
|
|
|
#include "insets/insetgraphics.h"
|
2000-03-08 13:52:57 +00:00
|
|
|
#include "insets/insetfoot.h"
|
2000-06-28 13:35:52 +00:00
|
|
|
#include "insets/insetmarginal.h"
|
|
|
|
#include "insets/insetminipage.h"
|
|
|
|
#include "insets/insetfloat.h"
|
|
|
|
#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 "filedlg.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-03-01 04:56:55 +00:00
|
|
|
#include "lyxfr1.h"
|
2000-04-12 14:20:08 +00:00
|
|
|
#include "bufferview_funcs.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"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
using std::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
|
|
|
|
2000-03-17 10:14:46 +00:00
|
|
|
extern void InsertAsciiFile(BufferView *, string const &, bool);
|
2000-09-14 17:53:12 +00:00
|
|
|
extern void math_insert_symbol(string const &);
|
2000-07-20 10:04:27 +00:00
|
|
|
extern bool math_insert_greek(char);
|
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;
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
extern kb_keymap * toplevel_keymap;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-08-08 15:36:25 +00:00
|
|
|
extern bool MenuWrite(Buffer *);
|
2000-07-26 13:43:16 +00:00
|
|
|
extern bool MenuWriteAs(Buffer *);
|
1999-12-16 06:43:25 +00:00
|
|
|
extern int MenuRunLaTeX(Buffer *);
|
|
|
|
extern int MenuBuildProg(Buffer *);
|
|
|
|
extern int MenuRunChktex(Buffer *);
|
|
|
|
extern void MenuPrint(Buffer *);
|
1999-09-27 18:44:28 +00:00
|
|
|
extern void MenuSendto();
|
|
|
|
extern void QuitLyX();
|
|
|
|
extern void MenuFax(Buffer *);
|
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-04-11 22:55:29 +00:00
|
|
|
extern void AutoSave(BufferView *);
|
2000-09-14 17:53:12 +00:00
|
|
|
extern void MenuInsertLabel(string const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
extern void MenuLayoutCharacter();
|
|
|
|
extern void MenuLayoutParagraph();
|
|
|
|
extern void MenuLayoutPreamble();
|
|
|
|
extern void MenuLayoutSave();
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
extern Buffer * NewLyxFile(string const &);
|
|
|
|
extern void LoadLyXFile(string const &);
|
2000-02-04 09:38:32 +00:00
|
|
|
extern void Reconfigure(BufferView *);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-02-29 02:19:17 +00:00
|
|
|
extern LyXTextClass::size_type current_layout;
|
1999-09-27 18:44:28 +00:00
|
|
|
extern int getISOCodeFromLaTeX(char *);
|
|
|
|
|
|
|
|
extern void ShowLatexLog();
|
|
|
|
|
|
|
|
/* === globals =========================================================== */
|
|
|
|
|
|
|
|
bool LyXFunc::show_sc = true;
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
void LyXFunc::moveCursorUpdate(bool selecting)
|
|
|
|
{
|
1999-12-10 00:07:59 +00:00
|
|
|
if (selecting || owner->view()->text->mark_set) {
|
2000-06-16 15:13:25 +00:00
|
|
|
owner->view()->text->SetSelection();
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->toggleToggle();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(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
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
|
|
|
|
{
|
|
|
|
string argument;
|
|
|
|
|
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
|
|
|
char * tmp = XKeysymToString(keysym);
|
|
|
|
string stm = (tmp ? tmp : "");
|
|
|
|
lyxerr << "KeySym is "
|
|
|
|
<< stm
|
|
|
|
<< "["
|
|
|
|
<< keysym << "]"
|
|
|
|
<< endl;
|
|
|
|
}
|
|
|
|
// Do nothing if we have nothing (JMarc)
|
|
|
|
if (keysym == NoSymbol) {
|
|
|
|
lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
|
|
|
|
<< endl;
|
|
|
|
//return 0;
|
|
|
|
return FL_PREEMPT;
|
|
|
|
}
|
2000-10-12 01:18:11 +00:00
|
|
|
|
|
|
|
if (owner->view()->available()) {
|
|
|
|
// this function should be used always [asierra060396]
|
|
|
|
UpdatableInset * tli = owner->view()->theLockingInset();
|
|
|
|
if (tli && (keysym == XK_Escape)) {
|
|
|
|
if (tli == tli->GetLockingInset()) {
|
|
|
|
owner->view()->unlockInset(tli);
|
|
|
|
owner->view()->text->CursorRight(owner->view());
|
|
|
|
moveCursorUpdate(false);
|
|
|
|
owner->showState();
|
|
|
|
} else {
|
|
|
|
tli->UnlockInsetInInset(owner->view(),
|
|
|
|
tli->GetLockingInset(),true);
|
|
|
|
}
|
|
|
|
//return 0;
|
|
|
|
return FL_PREEMPT;
|
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?
|
|
|
|
if((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
|
|
|
|
|| keysym == XK_Mode_switch || keysym == 0x0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// 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));
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
if ( (action != LFUN_CANCEL) && (action != LFUN_META_FAKE) ) {
|
|
|
|
|
|
|
|
// remove Caps Lock and Mod2 as a modifiers
|
|
|
|
action = keyseq.addkey(keysym,
|
|
|
|
(state | meta_fake_bit)
|
|
|
|
&(ShiftMask|ControlMask
|
|
|
|
|Mod1Mask));
|
|
|
|
}
|
|
|
|
// 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);
|
|
|
|
lyxerr << "Key ["
|
|
|
|
<< 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)
|
|
|
|
|
|
|
|
if(keyseq.length > 1 || keyseq.length < -1) {
|
|
|
|
string buf;
|
|
|
|
keyseq.print(buf);
|
|
|
|
owner->getMiniBuffer()->Set(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action == -1) {
|
|
|
|
if (keyseq.length < -1) { // unknown key sequence...
|
|
|
|
string buf;
|
|
|
|
LyXBell();
|
|
|
|
keyseq.print(buf);
|
|
|
|
owner->getMiniBuffer()->Set(_("Unknown sequence:"), buf);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
char isochar = keyseq.getiso();
|
|
|
|
if (!(state & ControlMask) &&
|
|
|
|
!(state & Mod1Mask) &&
|
|
|
|
(isochar && keysym < 0xF000)) {
|
|
|
|
argument += isochar;
|
|
|
|
}
|
|
|
|
if (argument.empty()) {
|
|
|
|
lyxerr.debug() << "Empty argument!" << endl;
|
|
|
|
// This can`t possibly be of any use
|
|
|
|
// so we`ll skip the dispatch.
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2000-08-22 18:28:11 +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;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-15 09:41:24 +00:00
|
|
|
#if 0
|
1999-11-22 16:19:48 +00:00
|
|
|
int LyXFunc::processKeyEvent(XEvent * ev)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
char s_r[10];
|
2000-08-14 15:31:16 +00:00
|
|
|
KeySym keysym_return = 0;
|
1999-10-20 14:35:05 +00:00
|
|
|
string argument;
|
1999-11-22 16:19:48 +00:00
|
|
|
XKeyEvent * keyevent = &ev->xkey;
|
1999-12-16 06:43:25 +00:00
|
|
|
int num_bytes = LyXLookupString(ev, s_r, 10, &keysym_return);
|
2000-01-27 16:17:47 +00:00
|
|
|
s_r[num_bytes] = '\0';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-07 18:44:17 +00:00
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
2000-01-27 01:29:01 +00:00
|
|
|
char * tmp = XKeysymToString(keysym_return);
|
|
|
|
string stm = (tmp ? tmp : "");
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr << "KeySym is "
|
2000-01-27 01:29:01 +00:00
|
|
|
<< stm
|
1999-10-07 18:44:17 +00:00
|
|
|
<< "["
|
|
|
|
<< keysym_return << "]"
|
|
|
|
<< " and num_bytes is "
|
|
|
|
<< num_bytes
|
|
|
|
<< " the string returned is \""
|
2000-08-14 15:31:16 +00:00
|
|
|
<< s_r << '\"'
|
|
|
|
<< endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
// Do nothing if we have nothing (JMarc)
|
|
|
|
if (num_bytes == 0 && keysym_return == NoSymbol) {
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
|
|
|
|
<< endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this function should be used always [asierra060396]
|
2000-10-03 13:55:48 +00:00
|
|
|
UpdatableInset * tli = owner->view()->theLockingInset();
|
2000-04-10 14:29:05 +00:00
|
|
|
if (owner->view()->available() && tli && (keysym_return==XK_Escape)) {
|
|
|
|
if (tli == tli->GetLockingInset()) {
|
|
|
|
owner->view()->unlockInset(tli);
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->CursorRight(owner->view());
|
2000-04-10 14:29:05 +00:00
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
2000-04-10 14:29:05 +00:00
|
|
|
} else {
|
|
|
|
tli->UnlockInsetInInset(owner->view(),
|
2000-06-23 15:02:46 +00:00
|
|
|
tli->GetLockingInset(),true);
|
2000-04-10 14:29:05 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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?
|
|
|
|
if((keysym_return >= XK_Shift_L && keysym_return <= XK_Hyper_R)
|
|
|
|
|| keysym_return == XK_Mode_switch || keysym_return == 0x0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// Do a one-deep top-level lookup for
|
|
|
|
// cancel and meta-fake keys. RVDK_PATCH_5
|
|
|
|
cancel_meta_seq.reset();
|
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
int action = cancel_meta_seq.addkey(keysym_return, keyevent->state
|
|
|
|
&(ShiftMask|ControlMask
|
|
|
|
|Mod1Mask));
|
1999-09-27 18:44:28 +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.
|
|
|
|
if ( (action != LFUN_CANCEL) && (action != LFUN_META_FAKE) ) {
|
|
|
|
|
|
|
|
// remove Caps Lock and Mod2 as a modifiers
|
|
|
|
action = keyseq.addkey(keysym_return,
|
|
|
|
(keyevent->state | meta_fake_bit)
|
|
|
|
&(ShiftMask|ControlMask
|
|
|
|
|Mod1Mask));
|
|
|
|
}
|
|
|
|
// Dont remove this unless you know what you are doing.
|
|
|
|
meta_fake_bit = 0;
|
|
|
|
|
|
|
|
if (action == 0) action = LFUN_PREFIX;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
if (lyxerr.debugging(Debug::KEY)) {
|
1999-12-16 06:43:25 +00:00
|
|
|
string buf;
|
|
|
|
keyseq.print(buf);
|
1999-12-10 00:07:59 +00:00
|
|
|
lyxerr << "Key ["
|
|
|
|
<< action << "]["
|
2000-08-14 15:31:16 +00:00
|
|
|
<< buf << "]"
|
|
|
|
<< "["
|
|
|
|
<< num_bytes << "]"
|
|
|
|
<< endl;
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// already here we know if it any point in going further
|
|
|
|
// why not return already here if action == -1 and
|
|
|
|
// num_bytes == 0? (Lgb)
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
if(keyseq.length > 1 || keyseq.length < -1) {
|
1999-12-16 06:43:25 +00:00
|
|
|
string buf;
|
|
|
|
keyseq.print(buf);
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->getMiniBuffer()->Set(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action == -1) {
|
1999-12-16 06:43:25 +00:00
|
|
|
if (keyseq.length < -1) { // unknown key sequence...
|
|
|
|
string buf;
|
1999-12-10 00:07:59 +00:00
|
|
|
LyXBell();
|
1999-12-16 06:43:25 +00:00
|
|
|
keyseq.print(buf);
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->getMiniBuffer()->Set(_("Unknown sequence:"), buf);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
char isochar = keyseq.getiso();
|
|
|
|
if (!(keyevent->state&ControlMask) &&
|
|
|
|
!(keyevent->state&Mod1Mask) &&
|
|
|
|
(isochar && keysym_return < 0xF000)) {
|
|
|
|
argument += isochar;
|
|
|
|
}
|
|
|
|
if (argument.empty()) {
|
|
|
|
lyxerr.debug() << "Empty argument!" << endl;
|
|
|
|
// This can`t possibly be of any use
|
|
|
|
// so we`ll skip the dispatch.
|
|
|
|
return 0;
|
|
|
|
}
|
2000-08-14 15:31:16 +00:00
|
|
|
}
|
|
|
|
else
|
1999-12-10 00:07:59 +00:00
|
|
|
if (action == LFUN_SELFINSERT) {
|
|
|
|
argument = s_r[0];
|
|
|
|
}
|
2000-08-14 15:31:16 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
bool tmp_sc = show_sc;
|
|
|
|
show_sc = false;
|
2000-09-19 11:18:35 +00:00
|
|
|
Dispatch(action, argument);
|
1999-12-10 00:07:59 +00:00
|
|
|
show_sc = tmp_sc;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2000-08-14 15:31:16 +00:00
|
|
|
#endif
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
LyXFunc::func_status LyXFunc::getStatus(int ac) const
|
|
|
|
{
|
|
|
|
kb_action action;
|
|
|
|
func_status flag = LyXFunc::OK;
|
|
|
|
string argument;
|
|
|
|
Buffer * buf = owner->buffer();
|
|
|
|
|
|
|
|
if (lyxaction.isPseudoAction(ac))
|
|
|
|
action = lyxaction.retrieveActionArg(ac, argument);
|
2000-06-12 11:27:15 +00:00
|
|
|
else
|
1999-12-10 00:07:59 +00:00
|
|
|
action = static_cast<kb_action>(ac);
|
|
|
|
|
|
|
|
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;
|
|
|
|
case LFUN_FAX:
|
2000-10-02 16:44:47 +00:00
|
|
|
disable = !Exporter::IsExportable(buf, "ps")
|
|
|
|
|| lyxrc.fax_command == "none";
|
1999-12-16 06:43:25 +00:00
|
|
|
break;
|
|
|
|
case LFUN_IMPORT:
|
2000-10-23 12:16:05 +00:00
|
|
|
disable = !Importer::IsImportable(argument);
|
1999-12-16 06:43:25 +00:00
|
|
|
break;
|
|
|
|
case LFUN_UNDO:
|
|
|
|
disable = buf->undostack.empty();
|
|
|
|
break;
|
|
|
|
case LFUN_REDO:
|
|
|
|
disable = buf->redostack.empty();
|
|
|
|
break;
|
|
|
|
case LFUN_SPELLCHECK:
|
2000-03-12 10:35:05 +00:00
|
|
|
disable = lyxrc.isp_command == "none";
|
1999-12-16 06:43:25 +00:00
|
|
|
break;
|
|
|
|
case LFUN_RUNCHKTEX:
|
2000-03-12 10:35:05 +00:00
|
|
|
disable = lyxrc.chktex_command == "none";
|
1999-12-16 06:43:25 +00:00
|
|
|
break;
|
2000-07-25 10:46:18 +00:00
|
|
|
case LFUN_BUILDPROG:
|
2000-10-23 12:16:05 +00:00
|
|
|
disable = !Exporter::IsExportable(buf, "program");
|
2000-07-31 12:51:19 +00:00
|
|
|
break;
|
|
|
|
|
2000-08-01 09:35:42 +00:00
|
|
|
case LFUN_LAYOUT_TABULAR:
|
|
|
|
disable = true;
|
2000-10-03 13:55:48 +00:00
|
|
|
if (owner->view()->theLockingInset()) {
|
|
|
|
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;
|
2000-08-31 11:51:59 +00:00
|
|
|
case LFUN_REF_BACK:
|
|
|
|
disable = owner->view()->NoSavedPositions();
|
|
|
|
break;
|
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-08-17 15:20:30 +00:00
|
|
|
LyXFont font;
|
2000-10-03 13:55:48 +00:00
|
|
|
if (owner->view()->theLockingInset() &&
|
|
|
|
owner->view()->theLockingInset()->getLyXText(owner->view()))
|
|
|
|
font = owner->view()->theLockingInset()->
|
2000-08-17 15:20:30 +00:00
|
|
|
getLyXText(owner->view())->real_current_font;
|
|
|
|
else
|
|
|
|
font = owner->view()->text->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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
string const & do_not_use_this_arg)
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
|
|
|
string argument;
|
|
|
|
kb_action action;
|
2000-10-02 16:44:47 +00:00
|
|
|
LyXText * text = 0;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
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
|
2000-08-01 09:35:42 +00:00
|
|
|
if (getStatus(ac) & 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
string shortcuts = toplevel_keymap->findbinding(pseudoaction);
|
|
|
|
|
|
|
|
if (!shortcuts.empty()) {
|
|
|
|
comname += ": " + shortcuts;
|
|
|
|
} else if (!argsadded) {
|
|
|
|
comname += " " + argument;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!comname.empty()) {
|
|
|
|
comname = strip(comname);
|
|
|
|
commandshortcut = "(" + comname + ')';
|
|
|
|
owner->getMiniBuffer()->Set(commandshortcut);
|
|
|
|
// 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();
|
2000-06-08 23:16:16 +00:00
|
|
|
if (owner->view()->text->cursor.par()->
|
|
|
|
IsInset(owner->view()->text->cursor.pos())) {
|
2000-03-31 10:35:53 +00:00
|
|
|
inset = static_cast<UpdatableInset*>(
|
2000-06-08 23:16:16 +00:00
|
|
|
owner->view()->text->cursor.par()->
|
2000-03-31 10:35:53 +00:00
|
|
|
GetInset(owner->view()->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*>(
|
2000-06-08 23:16:16 +00:00
|
|
|
owner->view()->text->cursor.par()->
|
2000-02-25 12:06:15 +00:00
|
|
|
GetInset(owner->view()->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 {
|
|
|
|
setMessage(N_("Text mode"));
|
2000-04-03 11:36:35 +00:00
|
|
|
switch(action) {
|
|
|
|
case LFUN_UNKNOWN_ACTION:
|
|
|
|
case LFUN_BREAKPARAGRAPH:
|
|
|
|
case LFUN_BREAKLINE:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->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:
|
2000-06-08 23:16:16 +00:00
|
|
|
if (!owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->CursorRight(owner->view());
|
2000-04-03 11:36:35 +00:00
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
2000-04-03 11:36:35 +00:00
|
|
|
}
|
|
|
|
return string();
|
|
|
|
case LFUN_LEFT:
|
2000-06-08 23:16:16 +00:00
|
|
|
if (owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->CursorRight(owner->view());
|
2000-04-03 11:36:35 +00:00
|
|
|
moveCursorUpdate(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:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->CursorDown(owner->view());
|
2000-04-19 14:42:19 +00:00
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
2000-04-19 14:42:19 +00:00
|
|
|
return string();
|
2000-04-03 11:36:35 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
2000-10-10 10:38:11 +00:00
|
|
|
if (owner->view()->theLockingInset())
|
|
|
|
text = owner->view()->theLockingInset()->
|
|
|
|
getLyXText(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
|
2000-10-02 15:20:53 +00:00
|
|
|
if (!text)
|
|
|
|
text = owner->view()->text;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
switch(action) {
|
|
|
|
// --- 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
LyXText * ltCur = owner->view()->text ;
|
|
|
|
|
|
|
|
if (!searched_string.empty() &&
|
|
|
|
((action == LFUN_WORDFINDBACKWARD) ?
|
2000-09-26 13:54:57 +00:00
|
|
|
ltCur->SearchBackward(owner->view(), searched_string) :
|
|
|
|
ltCur->SearchForward(owner->view(), searched_string))) {
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// ??? What is that ???
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(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();
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->ClearSelection();
|
|
|
|
|
|
|
|
// Move cursor so that successive C-s 's will not stand in place.
|
|
|
|
if( action == LFUN_WORDFINDFORWARD )
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->CursorRightOneWord(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(false);
|
|
|
|
|
|
|
|
// ??? Needed ???
|
|
|
|
// set the new selection
|
|
|
|
// SetSelectionOverLenChars(owner->view()->currentBuffer()->text, iLenSelected);
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->toggleSelection(false);
|
1999-12-10 00:07:59 +00:00
|
|
|
} else
|
|
|
|
LyXBell();
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
case LFUN_PREFIX:
|
|
|
|
{
|
2000-02-17 19:59:08 +00:00
|
|
|
if (owner->view()->available()) {
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(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);
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->getMiniBuffer()->Set(buf, string(), string(), 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// --- Misc -------------------------------------------
|
|
|
|
case LFUN_EXEC_COMMAND:
|
2000-10-13 12:20:38 +00:00
|
|
|
owner->getMiniBuffer()->PrepareForCommand();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_CANCEL: // RVDK_PATCH_5
|
|
|
|
keyseq.reset();
|
|
|
|
meta_fake_bit = 0;
|
|
|
|
if(owner->view()->available())
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
case LFUN_APPENDIX:
|
|
|
|
if (owner->view()->available()) {
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->toggleAppendix(owner->view());
|
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
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_MENUOPEN:
|
|
|
|
MenuOpen();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_CLOSEBUFFER:
|
|
|
|
CloseBuffer();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MENUWRITE:
|
2000-07-26 13:43:16 +00:00
|
|
|
if (!owner->buffer()->isUnnamed()) {
|
|
|
|
owner->getMiniBuffer()->Set(_("Saving document"),
|
|
|
|
MakeDisplayPath(owner->buffer()->fileName()),
|
|
|
|
"...");
|
|
|
|
MenuWrite(owner->buffer());
|
|
|
|
//owner->getMiniBuffer()-> {
|
|
|
|
// Set(_("Document saved as"),
|
|
|
|
// MakeDisplayPath(owner->buffer()->fileName()));
|
|
|
|
//} else {
|
|
|
|
//owner->getMiniBuffer()->Set(_("Save failed!"));
|
|
|
|
//}
|
|
|
|
} else {
|
|
|
|
MenuWriteAs(owner->buffer());
|
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MENUWRITEAS:
|
|
|
|
MenuWriteAs(owner->buffer());
|
|
|
|
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_FAX:
|
|
|
|
MenuFax(owner->buffer());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_EXPORT:
|
2000-08-30 03:40:51 +00:00
|
|
|
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:
|
2000-05-20 21:37:05 +00:00
|
|
|
case LFUN_LOFVIEW:
|
|
|
|
case LFUN_LOTVIEW:
|
|
|
|
case LFUN_LOAVIEW:
|
|
|
|
{
|
2000-08-01 17:33:32 +00:00
|
|
|
InsetCommandParams p;
|
|
|
|
|
|
|
|
if( action == LFUN_TOCVIEW )
|
|
|
|
p.setCmdName( "tableofcontents" );
|
|
|
|
else if( action == LFUN_LOAVIEW )
|
|
|
|
p.setCmdName( "listofalgorithms" );
|
|
|
|
else if( action == LFUN_LOFVIEW )
|
|
|
|
p.setCmdName( "listoffigures" );
|
|
|
|
else
|
|
|
|
p.setCmdName( "listoftables" );
|
|
|
|
|
|
|
|
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
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_TOC_INSERT:
|
|
|
|
case LFUN_LOA_INSERT:
|
2000-08-01 17:33:32 +00:00
|
|
|
case LFUN_LOF_INSERT:
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_LOT_INSERT:
|
|
|
|
{
|
2000-08-01 17:33:32 +00:00
|
|
|
InsetCommandParams p;
|
|
|
|
|
|
|
|
if( action == LFUN_TOC_INSERT )
|
|
|
|
p.setCmdName( "tableofcontents" );
|
|
|
|
else if( action == LFUN_LOA_INSERT )
|
|
|
|
p.setCmdName( "listofalgorithms" );
|
|
|
|
else if( action == LFUN_LOF_INSERT )
|
|
|
|
p.setCmdName( "listoffigures" );
|
|
|
|
else
|
|
|
|
p.setCmdName( "listoftables" );
|
|
|
|
|
|
|
|
Inset * inset = new InsetTOC( p );
|
|
|
|
if( !owner->view()->insertInset( inset, "Standard", true ) )
|
|
|
|
delete inset;
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2000-07-28 14:28:54 +00:00
|
|
|
case LFUN_TABULAR_FEATURE:
|
2000-08-07 15:21:05 +00:00
|
|
|
case LFUN_SCROLL_INSET:
|
2000-07-28 14:28:54 +00:00
|
|
|
// this is not handled here as this funktion is only aktive
|
|
|
|
// if we have a locking_inset and that one is (or contains)
|
|
|
|
// a tabular-inset
|
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
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
|
|
|
|
2000-07-24 21:49:58 +00:00
|
|
|
case LFUN_INSET_GRAPHICS:
|
2000-02-29 02:19:17 +00:00
|
|
|
{
|
|
|
|
Inset * new_inset = new InsetGraphics;
|
2000-07-31 12:30:10 +00:00
|
|
|
if (!owner->view()->insertInset(new_inset)) {
|
2000-05-15 14:49:36 +00:00
|
|
|
delete new_inset;
|
2000-07-31 12:30:10 +00:00
|
|
|
} else {
|
2000-08-08 09:18:39 +00:00
|
|
|
// this is need because you don't use a inset->Edit()
|
|
|
|
owner->view()->updateInset(new_inset, true);
|
|
|
|
new_inset->Edit(owner->view(), 0, 0, 0);
|
2000-07-31 12:30:10 +00:00
|
|
|
}
|
2000-02-29 02:19:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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:
|
2000-03-01 04:56:55 +00:00
|
|
|
{
|
|
|
|
// Ok this is one _very_ bad solution, but I think that some
|
|
|
|
// of this will be rewritten as part of GUI indep anyway.
|
|
|
|
// Lgb
|
|
|
|
static LyXFindReplace FR_;
|
|
|
|
FR_.StartSearch(owner->view());
|
|
|
|
}
|
2000-05-20 01:38:25 +00:00
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
case LFUN_PASTE:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->paste();
|
2000-04-03 11:36:35 +00:00
|
|
|
owner->view()->setState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_PASTESELECTION:
|
|
|
|
{
|
|
|
|
bool asPara = false;
|
|
|
|
if (argument == "paragraph") asPara = true;
|
2000-05-20 21:37:05 +00:00
|
|
|
owner->view()->pasteClipboard(asPara);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
2000-05-20 01:38:25 +00:00
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_CUT:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->cut();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_COPY:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->copy();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LAYOUT_COPY:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->copyEnvironment();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LAYOUT_PASTE:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->pasteEnvironment();
|
2000-04-03 11:36:35 +00:00
|
|
|
owner->view()->setState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_GOTOERROR:
|
|
|
|
owner->view()->gotoError();
|
|
|
|
break;
|
|
|
|
|
|
|
|
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();
|
2000-09-28 14:05:24 +00:00
|
|
|
owner->view()->fitCursor(owner->view()->text);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_GOTONOTE:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->gotoNote();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2000-07-19 17:16:27 +00:00
|
|
|
|
|
|
|
#ifndef NEW_INSETS
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_OPENSTUFF:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->openStuff();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2000-07-19 17:16:27 +00:00
|
|
|
#endif
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
case LFUN_HYPHENATION:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->hyphenationPoint();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LDOTS:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->ldots();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_END_OF_SENTENCE:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->endOfSentenceDot();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MENU_SEPARATOR:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->menuSeparator();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_HFILL:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->hfill();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DEPTH:
|
2000-02-04 09:38:32 +00:00
|
|
|
changeDepth(owner->view(), 0);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DEPTH_MIN:
|
2000-02-04 09:38:32 +00:00
|
|
|
changeDepth(owner->view(), -1);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DEPTH_PLUS:
|
2000-02-04 09:38:32 +00:00
|
|
|
changeDepth(owner->view(), 1);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_FREE:
|
2000-04-11 22:55:29 +00:00
|
|
|
Free(owner->view());
|
2000-04-24 20:58:23 +00:00
|
|
|
owner->view()->setState();
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
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;
|
2000-07-19 17:16:27 +00:00
|
|
|
#ifndef NEW_INSETS
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_MELT:
|
2000-02-04 09:38:32 +00:00
|
|
|
Melt(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2000-07-19 17:16:27 +00:00
|
|
|
#endif
|
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;
|
2000-07-19 17:16:27 +00:00
|
|
|
#ifndef NEW_INSETS
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_FOOTMELT:
|
|
|
|
if (owner->view()->available()
|
|
|
|
&& !owner->view()->text->selection
|
2000-06-08 23:16:16 +00:00
|
|
|
&& owner->view()->text->cursor.par()->footnoteflag
|
1999-12-10 00:07:59 +00:00
|
|
|
!= LyXParagraph::NO_FOOTNOTE)
|
1999-12-16 06:43:25 +00:00
|
|
|
{ // only melt footnotes with FOOTMELT, not margins etc
|
2000-06-08 23:16:16 +00:00
|
|
|
if(owner->view()->text->cursor.par()->footnotekind == LyXParagraph::FOOTNOTE)
|
2000-02-04 09:38:32 +00:00
|
|
|
Melt(owner->view());
|
1999-12-16 06:43:25 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
else
|
2000-02-04 09:38:32 +00:00
|
|
|
Foot(owner->view());
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->setState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MARGINMELT:
|
|
|
|
if (owner->view()->available()
|
|
|
|
&& !owner->view()->text->selection
|
2000-06-08 23:16:16 +00:00
|
|
|
&& owner->view()->text->cursor.par()->footnoteflag
|
1999-12-10 00:07:59 +00:00
|
|
|
!= LyXParagraph::NO_FOOTNOTE) {
|
|
|
|
// only melt margins
|
2000-06-08 23:16:16 +00:00
|
|
|
if(owner->view()->text->cursor.par()->footnotekind == LyXParagraph::MARGIN)
|
2000-02-04 09:38:32 +00:00
|
|
|
Melt(owner->view());
|
|
|
|
} else
|
|
|
|
Margin(owner->view());
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->setState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
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;
|
|
|
|
|
|
|
|
case LFUN_HELP_OPEN: {
|
|
|
|
string arg = argument;
|
|
|
|
if (arg.empty()) {
|
|
|
|
setErrorMessage(N_("Missing argument"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ProhibitInput(owner->view());
|
|
|
|
string fname = i18nLibFileSearch("doc", arg, "lyx");
|
|
|
|
if (fname.empty()) {
|
|
|
|
lyxerr << "LyX: unable to find documentation file `"
|
|
|
|
<< arg << "'. Bad installation?" << endl;
|
|
|
|
AllowInput(owner->view());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
owner->getMiniBuffer()->Set(_("Opening help file"),
|
|
|
|
MakeDisplayPath(fname),"...");
|
|
|
|
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:
|
|
|
|
{
|
|
|
|
owner->buffer()->lyxvc.showLog();
|
|
|
|
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_INSERT:
|
|
|
|
{
|
|
|
|
MenuInsertLyXFile(argument);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_FILE_INSERT_ASCII:
|
|
|
|
{
|
|
|
|
bool asPara = (argument == "paragraph");
|
2000-03-17 10:14:46 +00:00
|
|
|
InsertAsciiFile(owner->view(), string(), asPara);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
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:
|
1999-12-16 06:43:25 +00:00
|
|
|
owner->view()->buffer(bufferlist.loadLyXFile(argument));
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LATEX_LOG:
|
|
|
|
ShowLatexLog();
|
|
|
|
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:
|
|
|
|
{
|
|
|
|
lyxerr.debug() << "LFUN_LAYOUT: (arg) "
|
|
|
|
<< argument << endl;
|
|
|
|
|
|
|
|
// Derive layout number from given argument (string)
|
|
|
|
// and current buffer's textclass (number). */
|
2000-02-15 13:30:49 +00:00
|
|
|
LyXTextClassList::ClassList::size_type tclass =
|
2000-04-19 01:42:55 +00:00
|
|
|
owner->view()->buffer()->params.textclass;
|
2000-02-29 02:19:17 +00:00
|
|
|
pair <bool, LyXTextClass::size_type> layout =
|
2000-02-15 13:30:49 +00:00
|
|
|
textclasslist.NumberOfLayout(tclass, argument);
|
|
|
|
|
|
|
|
// If the entry is obsolete, use the new one instead.
|
|
|
|
if (layout.first) {
|
|
|
|
string obs = textclasslist.Style(tclass,layout.second)
|
|
|
|
.obsoleted_by();
|
|
|
|
if (!obs.empty())
|
|
|
|
layout =
|
|
|
|
textclasslist.NumberOfLayout(tclass, obs);
|
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// see if we found the layout number:
|
2000-02-15 13:30:49 +00:00
|
|
|
if (!layout.first) {
|
1999-12-10 00:07:59 +00:00
|
|
|
setErrorMessage(string(N_("Layout ")) + argument +
|
|
|
|
N_(" not known"));
|
|
|
|
break;
|
|
|
|
}
|
2000-02-15 13:30:49 +00:00
|
|
|
|
|
|
|
if (current_layout != layout.second) {
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->hideCursor();
|
2000-02-15 13:30:49 +00:00
|
|
|
current_layout = layout.second;
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->
|
2000-06-12 11:27:15 +00:00
|
|
|
SetLayout(owner->view(), layout.second);
|
2000-07-24 13:53:19 +00:00
|
|
|
owner->setLayout(layout.second);
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
2000-04-03 11:36:35 +00:00
|
|
|
owner->view()->setState();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
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
|
|
|
#ifdef USE_OLD_PARAGRAPH_LAYOUT
|
1999-12-10 00:07:59 +00:00
|
|
|
MenuLayoutParagraph();
|
2000-09-25 15:59:27 +00:00
|
|
|
#else
|
|
|
|
owner->getDialogs()->showLayoutParagraph();
|
|
|
|
#endif
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LAYOUT_CHARACTER:
|
|
|
|
MenuLayoutCharacter();
|
|
|
|
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:
|
|
|
|
MenuLayoutPreamble();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LAYOUT_SAVE_DEFAULT:
|
|
|
|
MenuLayoutSave();
|
|
|
|
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;
|
|
|
|
|
2000-03-17 10:14:46 +00:00
|
|
|
case LFUN_LANGUAGE:
|
2000-04-11 22:55:29 +00:00
|
|
|
Lang(owner->view(), argument);
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->setState();
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
2000-02-03 19:51:27 +00:00
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_EMPH:
|
2000-04-11 22:55:29 +00:00
|
|
|
Emph(owner->view());
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2000-05-30 19:31:11 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_BOLD:
|
2000-04-11 22:55:29 +00:00
|
|
|
Bold(owner->view());
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_NOUN:
|
2000-04-11 22:55:29 +00:00
|
|
|
Noun(owner->view());
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_CODE:
|
2000-04-11 22:55:29 +00:00
|
|
|
Code(owner->view());
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_SANS:
|
2000-04-11 22:55:29 +00:00
|
|
|
Sans(owner->view());
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_ROMAN:
|
2000-04-11 22:55:29 +00:00
|
|
|
Roman(owner->view());
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DEFAULT:
|
2000-04-11 22:55:29 +00:00
|
|
|
StyleReset(owner->view());
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_UNDERLINE:
|
2000-04-11 22:55:29 +00:00
|
|
|
Underline(owner->view());
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_FONT_SIZE:
|
2000-04-11 22:55:29 +00:00
|
|
|
FontSize(owner->view(), argument);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_FONT_STATE:
|
2000-04-11 22:55:29 +00:00
|
|
|
setMessage(CurrentState(owner->view()));
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_UPCASE_WORD:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-10-02 15:20:53 +00:00
|
|
|
text->ChangeWordCase(owner->view(), LyXText::text_uppercase);
|
|
|
|
if (text->inset_owner)
|
|
|
|
owner->view()->updateInset(text->inset_owner, true);
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LOWCASE_WORD:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-10-02 15:20:53 +00:00
|
|
|
text->ChangeWordCase(owner->view(), LyXText::text_lowercase);
|
|
|
|
if (text->inset_owner)
|
|
|
|
owner->view()->updateInset(text->inset_owner, true);
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_CAPITALIZE_WORD:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-10-02 15:20:53 +00:00
|
|
|
text->ChangeWordCase(owner->view(),
|
|
|
|
LyXText::text_capitalization);
|
|
|
|
if (text->inset_owner)
|
|
|
|
owner->view()->updateInset(text->inset_owner, true);
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_INSERT_LABEL:
|
2000-09-26 13:54:57 +00:00
|
|
|
MenuInsertLabel(argument);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
2000-08-08 13:55:26 +00:00
|
|
|
case LFUN_REF_INSERT:
|
2000-08-31 11:51:59 +00:00
|
|
|
if (argument.empty()) {
|
|
|
|
InsetCommandParams p("ref");
|
|
|
|
owner->getDialogs()->createRef(p.getAsString());
|
|
|
|
} else {
|
|
|
|
InsetCommandParams p;
|
|
|
|
p.setFromString(argument);
|
|
|
|
|
2000-10-10 11:50:43 +00:00
|
|
|
InsetRef * inset = new InsetRef(p, *owner->buffer());
|
2000-08-31 11:51:59 +00:00
|
|
|
if (!owner->view()->insertInset(inset))
|
|
|
|
delete inset;
|
|
|
|
else
|
|
|
|
owner->view()->updateInset(inset, true);
|
|
|
|
}
|
|
|
|
break;
|
2000-08-08 13:55:26 +00:00
|
|
|
|
|
|
|
case LFUN_REF_BACK:
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
|
|
|
owner->view()->restorePosition();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-08-08 13:55:26 +00:00
|
|
|
case LFUN_REF_GOTO:
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
|
|
|
string label(argument);
|
|
|
|
if (label.empty()) {
|
|
|
|
InsetRef * inset =
|
|
|
|
static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE));
|
|
|
|
if (inset)
|
|
|
|
label = inset->getContents();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!label.empty()) {
|
|
|
|
owner->view()->savePosition();
|
2000-05-19 16:46:01 +00:00
|
|
|
if (!owner->view()->gotoLabel(label))
|
|
|
|
WriteAlert(_("Error"),
|
|
|
|
_("Couldn't find this label"),
|
|
|
|
_("in current document."));
|
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
|
|
|
|
|
|
|
|
// --- Cursor Movements -----------------------------
|
|
|
|
case LFUN_RIGHT:
|
|
|
|
{
|
|
|
|
LyXText * tmptext = owner->view()->text;
|
2000-06-08 23:16:16 +00:00
|
|
|
bool is_rtl = tmptext->cursor.par()->isRightToLeftPar(owner->buffer()->params);
|
1999-12-10 00:07:59 +00:00
|
|
|
if(!tmptext->mark_set)
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-04-10 21:40:13 +00:00
|
|
|
if (is_rtl)
|
2000-06-12 11:27:15 +00:00
|
|
|
tmptext->CursorLeft(owner->view(), false);
|
2000-06-08 23:16:16 +00:00
|
|
|
if (tmptext->cursor.pos() < tmptext->cursor.par()->Last()
|
|
|
|
&& tmptext->cursor.par()->GetChar(tmptext->cursor.pos())
|
1999-12-10 00:07:59 +00:00
|
|
|
== LyXParagraph::META_INSET
|
2000-06-08 23:16:16 +00:00
|
|
|
&& tmptext->cursor.par()->GetInset(tmptext->cursor.pos())
|
|
|
|
&& tmptext->cursor.par()->GetInset(tmptext->cursor.pos())->Editable() == Inset::HIGHLY_EDITABLE){
|
|
|
|
Inset * tmpinset = tmptext->cursor.par()->GetInset(tmptext->cursor.pos());
|
1999-12-10 00:07:59 +00:00
|
|
|
setMessage(tmpinset->EditMessage());
|
2000-02-25 12:06:15 +00:00
|
|
|
tmpinset->Edit(owner->view(), 0, 0, 0);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-04-10 21:40:13 +00:00
|
|
|
if (!is_rtl)
|
2000-06-12 11:27:15 +00:00
|
|
|
tmptext->CursorRight(owner->view(), false);
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LEFT:
|
|
|
|
{
|
2000-02-10 17:53:36 +00:00
|
|
|
// This is soooo ugly. Isn`t it possible to make
|
|
|
|
// it simpler? (Lgb)
|
|
|
|
LyXText * txt = owner->view()->text;
|
2000-06-08 23:16:16 +00:00
|
|
|
bool is_rtl = txt->cursor.par()->isRightToLeftPar(owner->buffer()->params);
|
2000-02-10 17:53:36 +00:00
|
|
|
if(!txt->mark_set) owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-09-28 14:05:24 +00:00
|
|
|
LyXCursor cur = txt->cursor;
|
2000-04-10 21:40:13 +00:00
|
|
|
if (!is_rtl)
|
2000-06-12 11:27:15 +00:00
|
|
|
txt->CursorLeft(owner->view(), false);
|
2000-09-28 14:05:24 +00:00
|
|
|
if ((cur != txt->cursor) && // only if really moved!
|
|
|
|
txt->cursor.pos() < txt->cursor.par()->Last() &&
|
|
|
|
(txt->cursor.par()->GetChar(txt->cursor.pos()) ==
|
|
|
|
LyXParagraph::META_INSET) &&
|
|
|
|
txt->cursor.par()->GetInset(txt->cursor.pos()) &&
|
|
|
|
(txt->cursor.par()->GetInset(txt->cursor.pos())->Editable()
|
|
|
|
== Inset::HIGHLY_EDITABLE))
|
|
|
|
{
|
2000-06-08 23:16:16 +00:00
|
|
|
Inset * tmpinset = txt->cursor.par()->GetInset(txt->cursor.pos());
|
2000-02-10 17:53:36 +00:00
|
|
|
setMessage(tmpinset->EditMessage());
|
2000-06-12 11:27:15 +00:00
|
|
|
LyXFont font = txt->GetFont(owner->view()->buffer(),
|
|
|
|
txt->cursor.par(),
|
2000-06-08 23:16:16 +00:00
|
|
|
txt->cursor.pos());
|
2000-02-22 00:36:17 +00:00
|
|
|
tmpinset->Edit(owner->view(),
|
2000-07-05 14:57:48 +00:00
|
|
|
tmpinset->x() +
|
|
|
|
tmpinset->width(owner->view(),font),
|
|
|
|
tmpinset->descent(owner->view(),font),
|
2000-05-15 14:49:36 +00:00
|
|
|
0);
|
2000-02-10 17:53:36 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-04-10 21:40:13 +00:00
|
|
|
if (is_rtl)
|
2000-06-12 11:27:15 +00:00
|
|
|
txt->CursorRight(owner->view(), false);
|
2000-02-10 17:53:36 +00:00
|
|
|
|
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_UP:
|
2000-01-07 03:42:16 +00:00
|
|
|
if(!owner->view()->text->mark_set) owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::UPDATE);
|
|
|
|
owner->view()->text->CursorUp(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DOWN:
|
|
|
|
if(!owner->view()->text->mark_set)
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::UPDATE);
|
|
|
|
owner->view()->text->CursorDown(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_UP_PARAGRAPH:
|
|
|
|
if(!owner->view()->text->mark_set)
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::UPDATE);
|
|
|
|
owner->view()->text->CursorUpParagraph(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DOWN_PARAGRAPH:
|
|
|
|
if(!owner->view()->text->mark_set)
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::UPDATE);
|
|
|
|
owner->view()->text->CursorDownParagraph(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_PRIOR:
|
2000-10-10 10:38:11 +00:00
|
|
|
if(!text->mark_set)
|
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::UPDATE);
|
2000-10-10 10:38:11 +00:00
|
|
|
owner->view()->cursorPrevious(text);
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
2000-10-10 10:38:11 +00:00
|
|
|
if (text->inset_owner)
|
|
|
|
owner->view()->updateInset(text->inset_owner, false);
|
|
|
|
else
|
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_NEXT:
|
2000-10-10 10:38:11 +00:00
|
|
|
if(!text->mark_set)
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::UPDATE);
|
2000-10-10 10:38:11 +00:00
|
|
|
owner->view()->cursorNext(text);
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
2000-10-10 10:38:11 +00:00
|
|
|
if (text->inset_owner)
|
|
|
|
owner->view()->updateInset(text->inset_owner, false);
|
|
|
|
else
|
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_HOME:
|
|
|
|
if(!owner->view()->text->mark_set)
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
|
|
|
owner->view()->text->CursorHome(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_END:
|
|
|
|
if(!owner->view()->text->mark_set)
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
|
|
|
owner->view()->text->CursorEnd(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
2000-05-22 15:20:02 +00:00
|
|
|
case LFUN_SHIFT_TAB:
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_TAB:
|
|
|
|
if(!owner->view()->text->mark_set)
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
|
|
|
owner->view()->text->CursorTab(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_WORDRIGHT:
|
2000-10-02 15:20:53 +00:00
|
|
|
if(!text->mark_set)
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-10-02 15:20:53 +00:00
|
|
|
if (text->cursor.par()->isRightToLeftPar(owner->buffer()->params))
|
|
|
|
text->CursorLeftOneWord(owner->view());
|
2000-04-10 21:40:13 +00:00
|
|
|
else
|
2000-10-02 15:20:53 +00:00
|
|
|
text->CursorRightOneWord(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
2000-10-02 15:20:53 +00:00
|
|
|
if (text->inset_owner)
|
|
|
|
owner->view()->updateInset(text->inset_owner, true);
|
1999-12-10 00:07:59 +00:00
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_WORDLEFT:
|
2000-10-02 15:20:53 +00:00
|
|
|
if(!text->mark_set)
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-10-02 15:20:53 +00:00
|
|
|
if (text->cursor.par()->isRightToLeftPar(owner->buffer()->params))
|
|
|
|
text->CursorRightOneWord(owner->view());
|
2000-04-10 21:40:13 +00:00
|
|
|
else
|
2000-10-02 15:20:53 +00:00
|
|
|
text->CursorLeftOneWord(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
2000-10-02 15:20:53 +00:00
|
|
|
if (text->inset_owner)
|
|
|
|
owner->view()->updateInset(text->inset_owner, true);
|
1999-12-10 00:07:59 +00:00
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_BEGINNINGBUF:
|
|
|
|
if(!owner->view()->text->mark_set)
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
|
|
|
owner->view()->text->CursorTop(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_ENDBUF:
|
|
|
|
if(!owner->view()->text->mark_set)
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
|
|
|
owner->view()->text->CursorBottom(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
/* cursor selection ---------------------------- */
|
|
|
|
case LFUN_RIGHTSEL:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-06-08 23:16:16 +00:00
|
|
|
if (owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params))
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->CursorLeft(owner->view());
|
2000-04-10 21:40:13 +00:00
|
|
|
else
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->CursorRight(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(true);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_LEFTSEL:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-06-08 23:16:16 +00:00
|
|
|
if (owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params))
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->CursorRight(owner->view());
|
2000-04-10 21:40:13 +00:00
|
|
|
else
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->CursorLeft(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(true);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_UPSEL:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
|
|
|
owner->view()->text->CursorUp(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(true);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DOWNSEL:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
|
|
|
owner->view()->text->CursorDown(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(true);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_UP_PARAGRAPHSEL:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
|
|
|
owner->view()->text->CursorUpParagraph(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(true);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DOWN_PARAGRAPHSEL:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
|
|
|
owner->view()->text->CursorDownParagraph(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(true);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_PRIORSEL:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-10-10 10:38:11 +00:00
|
|
|
owner->view()->cursorPrevious(text);
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
2000-10-10 10:38:11 +00:00
|
|
|
if (text->inset_owner)
|
|
|
|
owner->view()->updateInset(text->inset_owner, false);
|
|
|
|
else
|
|
|
|
moveCursorUpdate(true);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_NEXTSEL:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-10-10 10:38:11 +00:00
|
|
|
owner->view()->cursorNext(text);
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
2000-10-10 10:38:11 +00:00
|
|
|
if (text->inset_owner)
|
|
|
|
owner->view()->updateInset(text->inset_owner, false);
|
|
|
|
else
|
|
|
|
moveCursorUpdate(true);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_HOMESEL:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
|
|
|
owner->view()->text->CursorHome(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(true);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_ENDSEL:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
|
|
|
owner->view()->text->CursorEnd(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(true);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_WORDRIGHTSEL:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-06-08 23:16:16 +00:00
|
|
|
if (owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params))
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->CursorLeftOneWord(owner->view());
|
2000-04-10 21:40:13 +00:00
|
|
|
else
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->CursorRightOneWord(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(true);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_WORDLEFTSEL:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-06-08 23:16:16 +00:00
|
|
|
if (owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params))
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->CursorRightOneWord(owner->view());
|
2000-04-10 21:40:13 +00:00
|
|
|
else
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->CursorLeftOneWord(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(true);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_BEGINNINGBUFSEL:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
|
|
|
owner->view()->text->CursorTop(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(true);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_ENDBUFSEL:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
|
|
|
owner->view()->text->CursorBottom(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->FinishUndo();
|
|
|
|
moveCursorUpdate(true);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// --- text changing commands ------------------------
|
|
|
|
case LFUN_BREAKLINE:
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->InsertChar(owner->view(), LyXParagraph::META_NEWLINE);
|
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
moveCursorUpdate(false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_PROTECTEDSPACE:
|
2000-03-09 03:36:48 +00:00
|
|
|
{
|
|
|
|
LyXLayout const & style =
|
|
|
|
textclasslist.Style(owner->view()->buffer()->params.textclass,
|
2000-06-08 23:16:16 +00:00
|
|
|
owner->view()->text->cursor.par()->GetLayout());
|
2000-03-09 03:36:48 +00:00
|
|
|
|
|
|
|
if (style.free_spacing) {
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->InsertChar(owner->view(), ' ');
|
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
2000-03-09 03:36:48 +00:00
|
|
|
} else {
|
|
|
|
owner->view()->protectedBlank();
|
|
|
|
}
|
|
|
|
moveCursorUpdate(false);
|
|
|
|
}
|
2000-04-24 20:58:23 +00:00
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
case LFUN_SETMARK:
|
2000-10-02 15:20:53 +00:00
|
|
|
if(text->mark_set) {
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
1999-12-10 00:07:59 +00:00
|
|
|
setMessage(N_("Mark removed"));
|
|
|
|
} else {
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-10-02 15:20:53 +00:00
|
|
|
text->mark_set = 1;
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
1999-12-10 00:07:59 +00:00
|
|
|
setMessage(N_("Mark set"));
|
|
|
|
}
|
2000-10-02 15:20:53 +00:00
|
|
|
text->sel_cursor = text->cursor;
|
|
|
|
if (text->inset_owner)
|
|
|
|
owner->view()->updateInset(text->inset_owner, true);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DELETE:
|
|
|
|
if (!owner->view()->text->selection) {
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->Delete(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->sel_cursor =
|
|
|
|
owner->view()->text->cursor;
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
// It is possible to make it a lot faster still
|
|
|
|
// just comment out the lone below...
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->showCursor();
|
1999-12-10 00:07:59 +00:00
|
|
|
} else {
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->cut();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
2000-02-03 19:51:27 +00:00
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->setState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DELETE_SKIP:
|
|
|
|
{
|
|
|
|
// Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
|
|
|
|
|
|
|
|
LyXCursor cursor = owner->view()->text->cursor;
|
|
|
|
|
|
|
|
if (!owner->view()->text->selection) {
|
2000-06-08 23:16:16 +00:00
|
|
|
if (cursor.pos() == cursor.par()->Last()) {
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->CursorRight(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
cursor = owner->view()->text->cursor;
|
2000-06-08 23:16:16 +00:00
|
|
|
if (cursor.pos() == 0
|
|
|
|
&& !(cursor.par()->added_space_top
|
1999-12-10 00:07:59 +00:00
|
|
|
== VSpace (VSpace::NONE))) {
|
|
|
|
owner->view()->text->SetParagraph
|
2000-06-12 11:27:15 +00:00
|
|
|
(owner->view(),
|
|
|
|
cursor.par()->line_top,
|
2000-06-08 23:16:16 +00:00
|
|
|
cursor.par()->line_bottom,
|
|
|
|
cursor.par()->pagebreak_top,
|
|
|
|
cursor.par()->pagebreak_bottom,
|
1999-12-10 00:07:59 +00:00
|
|
|
VSpace(VSpace::NONE),
|
2000-06-08 23:16:16 +00:00
|
|
|
cursor.par()->added_space_bottom,
|
|
|
|
cursor.par()->align,
|
|
|
|
cursor.par()->labelwidthstring, 0);
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->CursorLeft(owner->view());
|
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
} else {
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->CursorLeft(owner->view());
|
|
|
|
owner->view()->text->Delete(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->sel_cursor =
|
|
|
|
owner->view()->text->cursor;
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
} else {
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->Delete(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->sel_cursor =
|
|
|
|
owner->view()->text->cursor;
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
} else {
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->cut();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* -------> Delete word forward. */
|
|
|
|
case LFUN_DELETE_WORD_FORWARD:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-10-02 15:20:53 +00:00
|
|
|
text->DeleteWordForward(owner->view());
|
|
|
|
if (text->inset_owner)
|
|
|
|
owner->view()->updateInset(text->inset_owner, true);
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* -------> Delete word backward. */
|
|
|
|
case LFUN_DELETE_WORD_BACKWARD:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-10-02 15:20:53 +00:00
|
|
|
text->DeleteWordBackward(owner->view());
|
|
|
|
if (text->inset_owner)
|
|
|
|
owner->view()->updateInset(text->inset_owner, true);
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
moveCursorUpdate(false);
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* -------> Kill to end of line. */
|
|
|
|
case LFUN_DELETE_LINE_FORWARD:
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-10-02 15:20:53 +00:00
|
|
|
text->DeleteLineForward(owner->view());
|
|
|
|
if (text->inset_owner)
|
|
|
|
owner->view()->updateInset(text->inset_owner, true);
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
moveCursorUpdate(false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* -------> Set mark off. */
|
|
|
|
case LFUN_MARK_OFF:
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-10-02 15:20:53 +00:00
|
|
|
text->sel_cursor = text->cursor;
|
1999-12-10 00:07:59 +00:00
|
|
|
setMessage(N_("Mark off"));
|
2000-10-02 15:20:53 +00:00
|
|
|
if (text->inset_owner)
|
|
|
|
owner->view()->updateInset(text->inset_owner, true);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* -------> Set mark on. */
|
|
|
|
case LFUN_MARK_ON:
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->mark_set = 1;
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-10-02 15:20:53 +00:00
|
|
|
text->sel_cursor = text->cursor;
|
|
|
|
if (text->inset_owner)
|
|
|
|
owner->view()->updateInset(text->inset_owner, true);
|
1999-12-10 00:07:59 +00:00
|
|
|
setMessage(N_("Mark on"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_BACKSPACE:
|
|
|
|
{
|
|
|
|
if (!owner->view()->text->selection) {
|
|
|
|
if (owner->getIntl()->getTrans()->backspace()) {
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->Backspace(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->sel_cursor =
|
|
|
|
owner->view()->text->cursor;
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
// It is possible to make it a lot faster still
|
|
|
|
// just comment out the lone below...
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->showCursor();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
} else {
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->cut();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->setState();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_BACKSPACE_SKIP:
|
|
|
|
{
|
|
|
|
// Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
|
|
|
|
|
|
|
|
LyXCursor cursor = owner->view()->text->cursor;
|
|
|
|
|
|
|
|
if (!owner->view()->text->selection) {
|
2000-06-08 23:16:16 +00:00
|
|
|
if (cursor.pos() == 0
|
|
|
|
&& !(cursor.par()->added_space_top
|
1999-12-10 00:07:59 +00:00
|
|
|
== VSpace (VSpace::NONE))) {
|
|
|
|
owner->view()->text->SetParagraph
|
2000-06-12 11:27:15 +00:00
|
|
|
(owner->view(),
|
|
|
|
cursor.par()->line_top,
|
2000-06-08 23:16:16 +00:00
|
|
|
cursor.par()->line_bottom,
|
|
|
|
cursor.par()->pagebreak_top,
|
|
|
|
cursor.par()->pagebreak_bottom,
|
|
|
|
VSpace(VSpace::NONE), cursor.par()->added_space_bottom,
|
|
|
|
cursor.par()->align,
|
|
|
|
cursor.par()->labelwidthstring, 0);
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
} else {
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->Backspace(owner->view());
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->sel_cursor
|
|
|
|
= cursor;
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
} else
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->cut();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_BREAKPARAGRAPH:
|
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->BreakParagraph(owner->view(), 0);
|
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->sel_cursor =
|
|
|
|
owner->view()->text->cursor;
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
|
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->BreakParagraph(owner->view(), 1);
|
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->sel_cursor =
|
|
|
|
owner->view()->text->cursor;
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case LFUN_BREAKPARAGRAPH_SKIP:
|
|
|
|
{
|
|
|
|
// When at the beginning of a paragraph, remove
|
|
|
|
// indentation and add a "defskip" at the top.
|
|
|
|
// Otherwise, do the same as LFUN_BREAKPARAGRAPH.
|
|
|
|
|
|
|
|
LyXCursor cursor = owner->view()->text->cursor;
|
|
|
|
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-08 23:16:16 +00:00
|
|
|
if (cursor.pos() == 0) {
|
|
|
|
if (cursor.par()->added_space_top == VSpace(VSpace::NONE)) {
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->SetParagraph
|
2000-06-12 11:27:15 +00:00
|
|
|
(owner->view(),
|
|
|
|
cursor.par()->line_top,
|
2000-06-08 23:16:16 +00:00
|
|
|
cursor.par()->line_bottom,
|
|
|
|
cursor.par()->pagebreak_top,
|
|
|
|
cursor.par()->pagebreak_bottom,
|
|
|
|
VSpace(VSpace::DEFSKIP), cursor.par()->added_space_bottom,
|
|
|
|
cursor.par()->align,
|
|
|
|
cursor.par()->labelwidthstring, 1);
|
2000-06-12 11:27:15 +00:00
|
|
|
//owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->BreakParagraph(owner->view(), 0);
|
|
|
|
//owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->sel_cursor = cursor;
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->setState();
|
2000-07-20 11:39:14 +00:00
|
|
|
owner->showState();
|
2000-04-11 22:55:29 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_PARAGRAPH_SPACING:
|
|
|
|
{
|
2000-06-08 23:16:16 +00:00
|
|
|
LyXParagraph * par = owner->view()->text->cursor.par();
|
2000-04-11 22:55:29 +00:00
|
|
|
Spacing::Space cur_spacing = par->spacing.getSpace();
|
|
|
|
float cur_value = 1.0;
|
|
|
|
if (cur_spacing == Spacing::Other) {
|
|
|
|
cur_value = par->spacing.getValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
istringstream istr(argument);
|
2000-09-18 17:39:21 +00:00
|
|
|
|
2000-04-11 22:55:29 +00:00
|
|
|
string tmp;
|
|
|
|
istr >> tmp;
|
|
|
|
Spacing::Space new_spacing = cur_spacing;
|
|
|
|
float new_value = cur_value;
|
2000-04-12 14:20:08 +00:00
|
|
|
if (tmp.empty()) {
|
|
|
|
lyxerr << "Missing argument to `paragraph-spacing'"
|
|
|
|
<< endl;
|
|
|
|
} else if (tmp == "single") {
|
2000-04-11 22:55:29 +00:00
|
|
|
new_spacing = Spacing::Single;
|
|
|
|
} else if (tmp == "onehalf") {
|
|
|
|
new_spacing = Spacing::Onehalf;
|
|
|
|
} else if (tmp == "double") {
|
|
|
|
new_spacing = Spacing::Double;
|
|
|
|
} else if (tmp == "other") {
|
|
|
|
new_spacing = Spacing::Other;
|
|
|
|
float tmpval = 0.0;
|
|
|
|
istr >> tmpval;
|
|
|
|
lyxerr << "new_value = " << tmpval << endl;
|
|
|
|
if (tmpval != 0.0)
|
|
|
|
new_value = tmpval;
|
|
|
|
} else if (tmp == "default") {
|
|
|
|
new_spacing = Spacing::Default;
|
|
|
|
} else {
|
|
|
|
lyxerr << _("Unknown spacing argument: ")
|
|
|
|
<< argument << endl;
|
|
|
|
}
|
|
|
|
if (cur_spacing != new_spacing || cur_value != new_value) {
|
|
|
|
par->spacing.set(new_spacing, new_value);
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->RedoParagraph(owner->view());
|
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
2000-04-11 22:55:29 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_QUOTE:
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->InsertChar(owner->view(), '\"'); // This " matches the single quote in the code
|
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
moveCursorUpdate(false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_HTMLURL:
|
|
|
|
case LFUN_URL:
|
|
|
|
{
|
2000-07-27 08:55:59 +00:00
|
|
|
InsetCommandParams p;
|
1999-12-10 00:07:59 +00:00
|
|
|
if (action == LFUN_HTMLURL)
|
2000-07-27 08:55:59 +00:00
|
|
|
p.setCmdName("htmlurl");
|
1999-12-10 00:07:59 +00:00
|
|
|
else
|
2000-07-27 08:55:59 +00:00
|
|
|
p.setCmdName("url");
|
|
|
|
owner->getDialogs()->createUrl( p.getAsString() );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_INSERT_URL:
|
|
|
|
{
|
|
|
|
InsetCommandParams p;
|
|
|
|
p.setFromString( argument );
|
|
|
|
|
|
|
|
InsetUrl * inset = new InsetUrl( p );
|
|
|
|
if (!owner->view()->insertInset(inset))
|
|
|
|
delete inset;
|
2000-05-15 14:49:36 +00:00
|
|
|
else
|
2000-07-27 08:55:59 +00:00
|
|
|
owner->view()->updateInset( inset, true );
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
break;
|
2000-07-27 08:55:59 +00:00
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
case LFUN_INSET_TEXT:
|
|
|
|
{
|
2000-06-28 13:35:52 +00:00
|
|
|
InsetText * new_inset = new InsetText;
|
2000-05-15 14:49:36 +00:00
|
|
|
if (owner->view()->insertInset(new_inset))
|
|
|
|
new_inset->Edit(owner->view(), 0, 0, 0);
|
|
|
|
else
|
|
|
|
delete new_inset;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
break;
|
2000-06-28 13:35:52 +00:00
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
case LFUN_INSET_ERT:
|
|
|
|
{
|
2000-06-28 13:35:52 +00:00
|
|
|
InsetERT * new_inset = new InsetERT;
|
2000-06-12 11:27:15 +00:00
|
|
|
if (owner->view()->insertInset(new_inset))
|
|
|
|
new_inset->Edit(owner->view(), 0, 0, 0);
|
|
|
|
else
|
|
|
|
delete new_inset;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_INSET_EXTERNAL:
|
|
|
|
{
|
2000-06-28 13:35:52 +00:00
|
|
|
InsetExternal * new_inset = new InsetExternal;
|
2000-05-15 14:49:36 +00:00
|
|
|
if (owner->view()->insertInset(new_inset))
|
|
|
|
new_inset->Edit(owner->view(), 0, 0, 0);
|
|
|
|
else
|
|
|
|
delete new_inset;
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
2000-03-08 15:11:29 +00:00
|
|
|
break;
|
2000-04-11 22:55:29 +00:00
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
case LFUN_INSET_FOOTNOTE:
|
|
|
|
{
|
2000-06-28 13:35:52 +00:00
|
|
|
InsetFoot * new_inset = new InsetFoot;
|
|
|
|
if (owner->view()->insertInset(new_inset))
|
|
|
|
new_inset->Edit(owner->view(), 0, 0, 0);
|
|
|
|
else
|
|
|
|
delete new_inset;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_INSET_MARGINAL:
|
|
|
|
{
|
|
|
|
InsetMarginal * new_inset = new InsetMarginal;
|
|
|
|
if (owner->view()->insertInset(new_inset))
|
|
|
|
new_inset->Edit(owner->view(), 0, 0, 0);
|
|
|
|
else
|
|
|
|
delete new_inset;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_INSET_MINIPAGE:
|
|
|
|
{
|
|
|
|
InsetMinipage * new_inset = new InsetMinipage;
|
2000-05-15 14:49:36 +00:00
|
|
|
if (owner->view()->insertInset(new_inset))
|
|
|
|
new_inset->Edit(owner->view(), 0, 0, 0);
|
|
|
|
else
|
|
|
|
delete new_inset;
|
2000-03-08 13:52:57 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
case LFUN_INSET_FLOAT:
|
|
|
|
{
|
2000-07-15 23:51:46 +00:00
|
|
|
// check if the float type exist
|
|
|
|
if (floatList.typeExist(argument)) {
|
|
|
|
InsetFloat * new_inset = new InsetFloat(argument);
|
|
|
|
if (owner->view()->insertInset(new_inset))
|
|
|
|
new_inset->Edit(owner->view(), 0, 0, 0);
|
|
|
|
else
|
|
|
|
delete new_inset;
|
|
|
|
} else {
|
|
|
|
lyxerr << "Non-existant float type: "
|
|
|
|
<< argument << endl;
|
|
|
|
}
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_INSET_LIST:
|
|
|
|
{
|
|
|
|
InsetList * new_inset = new InsetList;
|
|
|
|
if (owner->view()->insertInset(new_inset))
|
|
|
|
new_inset->Edit(owner->view(), 0, 0, 0);
|
|
|
|
else
|
|
|
|
delete new_inset;
|
|
|
|
}
|
|
|
|
break;
|
2000-07-04 19:16:35 +00:00
|
|
|
|
|
|
|
case LFUN_INSET_THEOREM:
|
|
|
|
{
|
|
|
|
InsetTheorem * new_inset = new InsetTheorem;
|
|
|
|
if (owner->view()->insertInset(new_inset))
|
|
|
|
new_inset->Edit(owner->view(), 0, 0, 0);
|
|
|
|
else
|
|
|
|
delete new_inset;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-07-18 17:45:27 +00:00
|
|
|
case LFUN_INSET_CAPTION:
|
|
|
|
{
|
|
|
|
// Do we have a locking inset...
|
2000-10-03 13:55:48 +00:00
|
|
|
if (owner->view()->theLockingInset()) {
|
2000-07-18 17:45:27 +00:00
|
|
|
lyxerr << "Locking inset code: "
|
2000-10-03 13:55:48 +00:00
|
|
|
<< static_cast<int>(owner->view()->theLockingInset()->LyxCode());
|
2000-07-18 17:45:27 +00:00
|
|
|
InsetCaption * new_inset = new InsetCaption;
|
2000-10-03 13:55:48 +00:00
|
|
|
new_inset->setOwner(owner->view()->theLockingInset());
|
2000-07-18 17:45:27 +00:00
|
|
|
new_inset->SetAutoBreakRows(true);
|
|
|
|
new_inset->SetDrawFrame(0, InsetText::LOCKED);
|
|
|
|
new_inset->SetFrameColor(0, LColor::footnoteframe);
|
|
|
|
if (owner->view()->insertInset(new_inset))
|
|
|
|
new_inset->Edit(owner->view(), 0, 0, 0);
|
|
|
|
else
|
|
|
|
delete new_inset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-04-19 14:42:19 +00:00
|
|
|
case LFUN_INSET_TABULAR:
|
|
|
|
{
|
2000-04-21 15:16:22 +00:00
|
|
|
int r = 2, c = 2;
|
|
|
|
if (!argument.empty())
|
2000-09-26 13:54:57 +00:00
|
|
|
::sscanf(argument.c_str(),"%d%d", &r, &c);
|
2000-07-18 17:45:27 +00:00
|
|
|
InsetTabular * new_inset =
|
2000-10-10 11:50:43 +00:00
|
|
|
new InsetTabular(*owner->buffer(), r, c);
|
2000-05-15 14:49:36 +00:00
|
|
|
if (owner->view()->insertInset(new_inset))
|
|
|
|
new_inset->Edit(owner->view(), 0, 0, 0);
|
|
|
|
else
|
|
|
|
delete new_inset;
|
2000-04-19 14:42:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// --- lyxserver commands ----------------------------
|
|
|
|
|
|
|
|
case LFUN_CHARATCURSOR:
|
|
|
|
{
|
|
|
|
LyXParagraph::size_type pos =
|
2000-06-08 23:16:16 +00:00
|
|
|
owner->view()->text->cursor.pos();
|
|
|
|
if(pos < owner->view()->text->cursor.par()->size())
|
2000-03-16 04:29:22 +00:00
|
|
|
//dispatch_buffer = owner->view()->text->
|
2000-06-08 23:16:16 +00:00
|
|
|
// cursor.par()->text[pos];
|
2000-03-16 04:29:22 +00:00
|
|
|
dispatch_buffer =
|
|
|
|
owner->view()->text->
|
2000-06-08 23:16:16 +00:00
|
|
|
cursor.par()->GetChar(pos);
|
1999-12-10 00:07:59 +00:00
|
|
|
else
|
|
|
|
dispatch_buffer = "EOF";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_GETXY:
|
|
|
|
dispatch_buffer =
|
2000-06-08 23:16:16 +00:00
|
|
|
tostr(owner->view()->text->cursor.x()) + ' '
|
|
|
|
+ tostr(owner->view()->text->cursor.y());
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_SETXY:
|
|
|
|
{
|
2000-09-29 18:44:07 +00:00
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
::sscanf(argument.c_str(), " %d %d", &x, &y);
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->SetCursorFromCoordinates(owner->view(), x, y);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_GETLAYOUT:
|
|
|
|
dispatch_buffer =
|
2000-06-08 23:16:16 +00:00
|
|
|
tostr(owner->view()->text->cursor.par()->layout);
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_GETFONT:
|
|
|
|
{
|
2000-04-11 22:55:29 +00:00
|
|
|
LyXFont & font = owner->view()->text->current_font;
|
|
|
|
if(font.shape() == LyXFont::ITALIC_SHAPE)
|
1999-12-10 00:07:59 +00:00
|
|
|
dispatch_buffer = 'E';
|
2000-04-11 22:55:29 +00:00
|
|
|
else if(font.shape() == LyXFont::SMALLCAPS_SHAPE)
|
1999-12-10 00:07:59 +00:00
|
|
|
dispatch_buffer = 'N';
|
|
|
|
else
|
|
|
|
dispatch_buffer = '0';
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_GETLATEX:
|
|
|
|
{
|
2000-04-11 22:55:29 +00:00
|
|
|
LyXFont & font = owner->view()->text->current_font;
|
|
|
|
if(font.latex() == LyXFont::ON)
|
1999-12-10 00:07:59 +00:00
|
|
|
dispatch_buffer = 'L';
|
|
|
|
else
|
|
|
|
dispatch_buffer = '0';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_GETNAME:
|
|
|
|
setMessage(owner->buffer()->fileName());
|
|
|
|
lyxerr.debug() << "FNAME["
|
|
|
|
<< owner->buffer()->fileName()
|
|
|
|
<< "] " << endl;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_NOTIFY:
|
|
|
|
{
|
1999-12-16 06:43:25 +00:00
|
|
|
string buf;
|
|
|
|
keyseq.print(buf);
|
1999-12-10 00:07:59 +00:00
|
|
|
dispatch_buffer = buf;
|
|
|
|
lyxserver->notifyClient(dispatch_buffer);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_GOTOFILEROW:
|
|
|
|
{
|
|
|
|
char file_name[100];
|
2000-10-11 21:06:43 +00:00
|
|
|
int row;
|
2000-09-26 13:54:57 +00:00
|
|
|
::sscanf(argument.c_str(), " %s %d", file_name, &row);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// Must replace extension of the file to be .lyx and get full path
|
2000-05-11 16:12:46 +00:00
|
|
|
string s = ChangeExtension(string(file_name), ".lyx");
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// 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
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->setCursorFromRow(row);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// Recenter screen
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->center();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-08-31 11:51:59 +00:00
|
|
|
case LFUN_GOTO_PARAGRAPH:
|
|
|
|
{
|
|
|
|
istringstream istr(argument);
|
|
|
|
|
|
|
|
int id;
|
|
|
|
istr >> id;
|
|
|
|
LyXParagraph * par = owner->view()->text->GetParFromID(id);
|
|
|
|
|
|
|
|
// Set the cursor
|
|
|
|
owner->view()->text->SetCursor(owner->view(), par, 0);
|
|
|
|
owner->view()->setState();
|
|
|
|
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;
|
|
|
|
|
|
|
|
// --- accented characters ---------------------------
|
|
|
|
|
|
|
|
case LFUN_UMLAUT:
|
|
|
|
case LFUN_CIRCUMFLEX:
|
|
|
|
case LFUN_GRAVE:
|
|
|
|
case LFUN_ACUTE:
|
|
|
|
case LFUN_TILDE:
|
|
|
|
case LFUN_CEDILLA:
|
|
|
|
case LFUN_MACRON:
|
|
|
|
case LFUN_DOT:
|
|
|
|
case LFUN_UNDERDOT:
|
|
|
|
case LFUN_UNDERBAR:
|
|
|
|
case LFUN_CARON:
|
|
|
|
case LFUN_SPECIAL_CARON:
|
|
|
|
case LFUN_BREVE:
|
|
|
|
case LFUN_TIE:
|
|
|
|
case LFUN_HUNG_UMLAUT:
|
|
|
|
case LFUN_CIRCLE:
|
|
|
|
case LFUN_OGONEK:
|
|
|
|
{
|
2000-04-29 00:47:16 +00:00
|
|
|
char c = 0;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
if (keyseq.length == -1 && keyseq.getiso() != 0)
|
|
|
|
c = keyseq.getiso();
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
owner->getIntl()->getTrans()->
|
|
|
|
deadkey(c, get_accent(action).accent,
|
|
|
|
owner->view()->text);
|
|
|
|
|
|
|
|
// Need to reset, in case the minibuffer calls these
|
|
|
|
// actions
|
|
|
|
keyseq.reset();
|
1999-12-16 06:43:25 +00:00
|
|
|
keyseq.length = 0;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// copied verbatim from do_accent_char
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
2000-04-29 00:47:16 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
owner->view()->text->sel_cursor =
|
|
|
|
owner->view()->text->cursor;
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
|
|
|
|
case LFUN_MATH_DELIM:
|
|
|
|
case LFUN_INSERT_MATRIX:
|
|
|
|
{
|
|
|
|
if (owner->view()->available()) {
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->
|
1999-12-10 00:07:59 +00:00
|
|
|
open_new_inset(new InsetFormula(false));
|
2000-02-25 13:35:38 +00:00
|
|
|
owner->view()
|
2000-10-03 13:55:48 +00:00
|
|
|
->theLockingInset()
|
2000-02-25 13:35:38 +00:00
|
|
|
->LocalDispatch(owner->view(),
|
|
|
|
action,
|
|
|
|
argument);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_INSERT_MATH:
|
|
|
|
{
|
2000-09-26 13:54:57 +00:00
|
|
|
math_insert_symbol(argument);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MATH_DISPLAY:
|
|
|
|
{
|
|
|
|
if (owner->view()->available())
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->open_new_inset(new InsetFormula(true));
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case LFUN_MATH_MACRO:
|
|
|
|
{
|
|
|
|
if (owner->view()->available()) {
|
|
|
|
string s(argument);
|
|
|
|
if (s.empty())
|
1999-12-16 06:43:25 +00:00
|
|
|
setErrorMessage(N_("Missing argument"));
|
1999-12-10 00:07:59 +00:00
|
|
|
else {
|
1999-12-16 06:43:25 +00:00
|
|
|
string s1 = token(s, ' ', 1);
|
2000-09-26 13:54:57 +00:00
|
|
|
int na = s1.empty() ? 0 : lyx::atoi(s1);
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->
|
1999-12-16 06:43:25 +00:00
|
|
|
open_new_inset(new InsetFormulaMacro(token(s, ' ', 0), na));
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MATH_MODE: // Open or create a math inset
|
2000-07-25 10:46:18 +00:00
|
|
|
{
|
1999-12-10 00:07:59 +00:00
|
|
|
if (owner->view()->available())
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->open_new_inset(new InsetFormula);
|
1999-12-10 00:07:59 +00:00
|
|
|
setMessage(N_("Math editor mode"));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
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:
|
|
|
|
{
|
|
|
|
show_symbols_form(this);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-08-03 12:56:25 +00:00
|
|
|
case LFUN_CITATION_CREATE:
|
2000-07-07 07:46:37 +00:00
|
|
|
{
|
2000-08-01 17:33:32 +00:00
|
|
|
// Should do this "at source"
|
2000-08-03 12:56:25 +00:00
|
|
|
InsetCommandParams p( "cite" );
|
2000-08-01 17:33:32 +00:00
|
|
|
|
|
|
|
if (contains(argument, "|")) {
|
|
|
|
p.setContents( token(argument, '|', 0) );
|
|
|
|
p.setOptions( token(argument, '|', 1) );
|
|
|
|
} else {
|
|
|
|
p.setContents( argument );
|
|
|
|
}
|
|
|
|
|
|
|
|
owner->getDialogs()->createCitation( p.getAsString() );
|
2000-07-07 07:46:37 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-08-03 12:56:25 +00:00
|
|
|
case LFUN_CITATION_INSERT:
|
2000-07-07 07:46:37 +00:00
|
|
|
{
|
2000-07-27 08:55:59 +00:00
|
|
|
InsetCommandParams p;
|
|
|
|
p.setFromString( argument );
|
2000-07-07 07:46:37 +00:00
|
|
|
|
2000-07-27 08:55:59 +00:00
|
|
|
InsetCitation * inset = new InsetCitation( p );
|
2000-07-07 07:46:37 +00:00
|
|
|
if (!owner->view()->insertInset(inset))
|
|
|
|
delete inset;
|
|
|
|
else
|
|
|
|
owner->view()->updateInset( inset, true );
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_INSERT_BIBTEX:
|
|
|
|
{
|
|
|
|
// ale970405+lasgoutt970425
|
|
|
|
// The argument can be up to two tokens separated
|
|
|
|
// by a space. The first one is the bibstyle.
|
2000-08-04 13:12:30 +00:00
|
|
|
string db = token(argument, ' ', 0);
|
|
|
|
string bibstyle = token(argument, ' ', 1);
|
1999-12-10 00:07:59 +00:00
|
|
|
if (bibstyle.empty())
|
|
|
|
bibstyle = "plain";
|
2000-08-04 13:12:30 +00:00
|
|
|
|
|
|
|
InsetCommandParams p( "BibTeX", db, bibstyle );
|
2000-10-03 09:13:34 +00:00
|
|
|
InsetBibtex * inset = new InsetBibtex(p);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2000-08-04 13:12:30 +00:00
|
|
|
if (owner->view()->insertInset(inset)) {
|
|
|
|
if (argument.empty())
|
|
|
|
inset->Edit(owner->view(), 0, 0, 0);
|
2000-05-15 14:49:36 +00:00
|
|
|
} else
|
2000-08-04 13:12:30 +00:00
|
|
|
delete inset;
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// BibTeX data bases
|
|
|
|
case LFUN_BIBDB_ADD:
|
|
|
|
{
|
|
|
|
InsetBibtex * inset =
|
|
|
|
static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
|
|
|
|
if (inset) {
|
|
|
|
inset->addDatabase(argument);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_BIBDB_DEL:
|
|
|
|
{
|
|
|
|
InsetBibtex * inset =
|
|
|
|
static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
|
|
|
|
if (inset) {
|
|
|
|
inset->delDatabase(argument);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_BIBTEX_STYLE:
|
|
|
|
{
|
|
|
|
InsetBibtex * inset =
|
|
|
|
static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
|
|
|
|
if (inset) {
|
|
|
|
inset->setOptions(argument);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-08-03 12:56:25 +00:00
|
|
|
case LFUN_INDEX_CREATE:
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
2000-08-03 12:56:25 +00:00
|
|
|
InsetCommandParams p( "index" );
|
|
|
|
|
2000-08-04 13:12:30 +00:00
|
|
|
if( argument.empty() ) {
|
|
|
|
// Get the word immediately preceding the cursor
|
|
|
|
LyXParagraph::size_type curpos =
|
2000-06-08 23:16:16 +00:00
|
|
|
owner->view()->text->cursor.pos() - 1;
|
1999-12-16 06:43:25 +00:00
|
|
|
|
2000-08-04 13:12:30 +00:00
|
|
|
string curstring;
|
|
|
|
if( curpos >= 0 )
|
|
|
|
curstring = owner->view()->text
|
|
|
|
->cursor.par()->GetWord(curpos);
|
|
|
|
|
2000-08-03 12:56:25 +00:00
|
|
|
p.setContents( curstring );
|
2000-08-04 13:12:30 +00:00
|
|
|
} else {
|
|
|
|
p.setContents( argument );
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
2000-08-03 12:56:25 +00:00
|
|
|
|
|
|
|
owner->getDialogs()->createIndex( p.getAsString() );
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
2000-08-03 12:56:25 +00:00
|
|
|
|
|
|
|
case LFUN_INDEX_INSERT:
|
|
|
|
{
|
|
|
|
InsetCommandParams p;
|
|
|
|
p.setFromString( argument );
|
2000-08-04 13:12:30 +00:00
|
|
|
InsetIndex * inset = new InsetIndex( p );
|
|
|
|
|
|
|
|
if (!owner->view()->insertInset(inset))
|
|
|
|
delete inset;
|
|
|
|
else
|
|
|
|
owner->view()->updateInset( inset, true );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_INDEX_INSERT_LAST:
|
|
|
|
{
|
|
|
|
// Get word immediately preceding the cursor
|
|
|
|
LyXParagraph::size_type curpos =
|
|
|
|
owner->view()->text->cursor.pos() - 1;
|
|
|
|
// Can't do that at the beginning of a paragraph
|
|
|
|
if( curpos < 0 ) break;
|
|
|
|
|
|
|
|
string curstring( owner->view()->text
|
|
|
|
->cursor.par()->GetWord(curpos) );
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2000-08-04 13:12:30 +00:00
|
|
|
InsetCommandParams p( "index", curstring );
|
2000-08-03 12:56:25 +00:00
|
|
|
InsetIndex * inset = new InsetIndex( p );
|
2000-08-04 13:12:30 +00:00
|
|
|
|
2000-08-03 12:56:25 +00:00
|
|
|
if (!owner->view()->insertInset(inset))
|
|
|
|
delete inset;
|
|
|
|
else
|
|
|
|
owner->view()->updateInset( inset, true );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_INDEX_PRINT:
|
|
|
|
{
|
2000-08-04 13:12:30 +00:00
|
|
|
InsetCommandParams p( "printindex" );
|
2000-08-03 12:56:25 +00:00
|
|
|
Inset * inset = new InsetPrintIndex(p);
|
|
|
|
if (!owner->view()->insertInset(inset, "Standard", true))
|
|
|
|
delete inset;
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_PARENTINSERT:
|
|
|
|
{
|
|
|
|
lyxerr << "arg " << argument << endl;
|
2000-08-04 13:12:30 +00:00
|
|
|
InsetCommandParams p( "lyxparent", argument );
|
2000-10-10 11:50:43 +00:00
|
|
|
Inset * inset = new InsetParent(p, *owner->buffer());
|
2000-08-04 13:12:30 +00:00
|
|
|
if (!owner->view()->insertInset(inset, "Standard", true))
|
|
|
|
delete inset;
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_CHILDINSERT:
|
|
|
|
{
|
2000-08-04 13:12:30 +00:00
|
|
|
InsetCommandParams p( "Include", argument );
|
2000-10-10 11:50:43 +00:00
|
|
|
Inset * inset = new InsetInclude(p, *owner->buffer());
|
2000-08-04 13:12:30 +00:00
|
|
|
if (owner->view()->insertInset(inset, "Standard", true))
|
|
|
|
inset->Edit(owner->view(), 0, 0, 0);
|
2000-05-15 14:49:36 +00:00
|
|
|
else
|
2000-08-04 13:12:30 +00:00
|
|
|
delete inset;
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_CHILDOPEN:
|
|
|
|
{
|
|
|
|
string filename =
|
|
|
|
MakeAbsPath(argument,
|
|
|
|
OnlyPath(owner->buffer()->fileName()));
|
|
|
|
setMessage(N_("Opening child document ") +
|
|
|
|
MakeDisplayPath(filename) + "...");
|
|
|
|
owner->view()->savePosition();
|
|
|
|
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_INSERT_NOTE:
|
2000-01-08 21:02:58 +00:00
|
|
|
owner->view()->insertNote();
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2000-07-19 17:16:27 +00:00
|
|
|
#ifndef NEW_INSETS
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_INSERTFOOTNOTE:
|
|
|
|
{
|
|
|
|
LyXParagraph::footnote_kind kind;
|
|
|
|
if (argument == "footnote")
|
|
|
|
{ kind = LyXParagraph::FOOTNOTE; }
|
|
|
|
else if (argument == "margin")
|
|
|
|
{ kind = LyXParagraph::MARGIN; }
|
|
|
|
else if (argument == "figure")
|
|
|
|
{ kind = LyXParagraph::FIG; }
|
|
|
|
else if (argument == "table")
|
|
|
|
{ kind = LyXParagraph::TAB; }
|
|
|
|
else if (argument == "wide-fig")
|
|
|
|
{ kind = LyXParagraph::WIDE_FIG; }
|
|
|
|
else if (argument == "wide-tab")
|
|
|
|
{ kind = LyXParagraph::WIDE_TAB; }
|
|
|
|
else if (argument == "algorithm")
|
|
|
|
{ kind = LyXParagraph::ALGORITHM; }
|
|
|
|
else {
|
|
|
|
setErrorMessage(N_("Unknown kind of footnote"));
|
|
|
|
break;
|
|
|
|
}
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->InsertFootnoteEnvironment(owner->view(), kind);
|
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
2000-02-17 19:59:08 +00:00
|
|
|
owner->view()->setState();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
break;
|
2000-09-26 13:54:57 +00:00
|
|
|
#endif
|
1999-12-10 00:07:59 +00:00
|
|
|
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_SELFINSERT:
|
|
|
|
{
|
2000-10-18 12:00:53 +00:00
|
|
|
LyXFont old_font(owner->view()->text->real_current_font);
|
1999-12-10 00:07:59 +00:00
|
|
|
for (string::size_type i = 0; i < argument.length(); ++i) {
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->InsertChar(owner->view(), argument[i]);
|
1999-12-10 00:07:59 +00:00
|
|
|
// This needs to be in the loop, or else we
|
|
|
|
// won't break lines correctly. (Asger)
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
owner->view()->text->sel_cursor =
|
|
|
|
owner->view()->text->cursor;
|
|
|
|
moveCursorUpdate(false);
|
2000-10-18 12:00:53 +00:00
|
|
|
|
|
|
|
// real_current_font.number can change so we need to
|
|
|
|
// update the minibuffer
|
|
|
|
if (old_font != owner->view()->text->real_current_font)
|
|
|
|
owner->showState();
|
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
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
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-02-01 13:58:06 +00:00
|
|
|
case LFUN_DATE_INSERT: // jdblair: date-insert cmd
|
2000-02-01 11:32:33 +00:00
|
|
|
{
|
2000-06-08 23:16:16 +00:00
|
|
|
struct tm * now_tm;
|
2000-02-01 11:32:33 +00:00
|
|
|
|
2000-06-08 23:16:16 +00:00
|
|
|
time_t now_time_t = time(NULL);
|
2000-02-01 11:32:33 +00:00
|
|
|
now_tm = localtime(&now_time_t);
|
2000-06-08 23:16:16 +00:00
|
|
|
setlocale(LC_TIME, "");
|
|
|
|
string arg;
|
2000-02-01 11:32:33 +00:00
|
|
|
if (!argument.empty())
|
|
|
|
arg = argument;
|
2000-06-08 23:16:16 +00:00
|
|
|
else
|
2000-03-12 10:35:05 +00:00
|
|
|
arg = lyxrc.date_insert_format;
|
2000-06-08 23:16:16 +00:00
|
|
|
char datetmp[32];
|
2000-09-26 13:54:57 +00:00
|
|
|
int datetmp_len = ::strftime(datetmp, 32, arg.c_str(), now_tm);
|
2000-02-01 11:32:33 +00:00
|
|
|
for (int i = 0; i < datetmp_len; i++) {
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->InsertChar(owner->view(), datetmp[i]);
|
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
2000-02-01 11:32:33 +00:00
|
|
|
}
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2000-02-01 11:32:33 +00:00
|
|
|
owner->view()->text->sel_cursor = owner->view()->text->cursor;
|
|
|
|
moveCursorUpdate(false);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
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:
|
|
|
|
{
|
|
|
|
string lyx_name, x11_name;
|
|
|
|
x11_name = split(argument, lyx_name, ' ');
|
|
|
|
if (lyx_name.empty() || x11_name.empty()) {
|
|
|
|
LyXBell();
|
|
|
|
setErrorMessage(N_("Syntax: set-color <lyx_name>"
|
|
|
|
" <x11_name>"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lcolor.setColor(lyx_name, x11_name)) {
|
|
|
|
static string err1 (N_("Set-color \""));
|
|
|
|
static string err2 (N_("\" failed - color is undefined "
|
|
|
|
"or may not be redefined"));
|
|
|
|
LyXBell();
|
|
|
|
setErrorMessage(err1 + lyx_name + err2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
|
|
|
|
owner->view()->redraw();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
case LFUN_UNKNOWN_ACTION:
|
|
|
|
{
|
1999-12-20 17:38:37 +00:00
|
|
|
if(!owner->buffer()) {
|
|
|
|
LyXBell();
|
|
|
|
setErrorMessage(N_("No document open"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
if (owner->buffer()->isReadonly()) {
|
|
|
|
LyXBell();
|
|
|
|
setErrorMessage(N_("Document is read only"));
|
|
|
|
break;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
if (!argument.empty()) {
|
|
|
|
|
|
|
|
/* Automatically delete the currently selected
|
|
|
|
* text and replace it with what is being
|
|
|
|
* typed in now. Depends on lyxrc settings
|
|
|
|
* "auto_region_delete", which defaults to
|
|
|
|
* true (on). */
|
|
|
|
|
2000-03-12 10:35:05 +00:00
|
|
|
if ( lyxrc.auto_region_delete ) {
|
1999-12-10 00:07:59 +00:00
|
|
|
if (owner->view()->text->selection){
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->text->CutSelection(owner->view(), false);
|
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-07 03:42:16 +00:00
|
|
|
owner->view()->beforeChange();
|
2000-10-18 12:00:53 +00:00
|
|
|
LyXFont old_font(owner->view()->text->real_current_font);
|
1999-12-10 00:07:59 +00:00
|
|
|
for (string::size_type i = 0;
|
|
|
|
i < argument.length(); ++i) {
|
|
|
|
if (greek_kb_flag) {
|
|
|
|
if (!math_insert_greek(argument[i]))
|
|
|
|
owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->view()->text);
|
|
|
|
} else
|
|
|
|
owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->view()->text);
|
1999-11-22 16:19:48 +00:00
|
|
|
}
|
2000-04-26 13:57:28 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
owner->view()->text->sel_cursor =
|
|
|
|
owner->view()->text->cursor;
|
|
|
|
moveCursorUpdate(false);
|
2000-10-18 12:00:53 +00:00
|
|
|
|
|
|
|
// real_current_font.number can change so we need to
|
|
|
|
// update the minibuffer
|
|
|
|
if (old_font != owner->view()->text->real_current_font)
|
|
|
|
owner->showState();
|
1999-12-10 00:07:59 +00:00
|
|
|
return string();
|
1999-11-22 16:19:48 +00:00
|
|
|
} else {
|
1999-12-10 00:07:59 +00:00
|
|
|
// why is an "Unknown action" with empty
|
|
|
|
// argument even dispatched in the first
|
|
|
|
// place? I`ll probably change that. (Lgb)
|
|
|
|
LyXBell();
|
|
|
|
setErrorMessage(N_("Unknown action"));
|
1999-11-22 16:19:48 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
2000-10-02 06:11:02 +00:00
|
|
|
}
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
default:
|
|
|
|
lyxerr << "A truly unknown func!" << endl;
|
|
|
|
break;
|
|
|
|
} // end of switch
|
|
|
|
exit_with_message:
|
1999-11-22 16:19:48 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
string res = getMessage();
|
1999-11-22 16:19:48 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
if (res.empty()) {
|
|
|
|
if (!commandshortcut.empty()) {
|
|
|
|
string newbuf = owner->getMiniBuffer()->GetText();
|
|
|
|
if (newbuf != commandshortcut) {
|
|
|
|
owner->getMiniBuffer()->Set(newbuf
|
|
|
|
+ " " +
|
|
|
|
commandshortcut);
|
|
|
|
}
|
1999-12-03 13:51:01 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
} else {
|
2000-10-11 21:06:43 +00:00
|
|
|
string msg(_(res));
|
|
|
|
msg += " ";
|
|
|
|
msg += commandshortcut;
|
|
|
|
owner->getMiniBuffer()->Set(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()
|
|
|
|
{
|
|
|
|
keyseq.stdmap = keyseq.curmap = toplevel_keymap;
|
|
|
|
cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap;
|
|
|
|
}
|
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 fname;
|
|
|
|
string initpath = lyxrc.document_path;
|
1999-12-16 06:43:25 +00:00
|
|
|
LyXFileDlg fileDlg;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
if (owner->view()->available()) {
|
|
|
|
string trypath = owner->buffer()->filepath;
|
|
|
|
// 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-08-08 11:08:07 +00:00
|
|
|
|
|
|
|
if (lyxrc.new_ask_filename) {
|
|
|
|
ProhibitInput(owner->view());
|
|
|
|
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
|
|
|
|
fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
|
|
|
|
fname = fileDlg.Select(_("Enter Filename for new document"),
|
|
|
|
initpath, "*.lyx", _("newfile"));
|
|
|
|
AllowInput(owner->view());
|
1999-12-16 06:43:25 +00:00
|
|
|
|
2000-08-08 11:08:07 +00:00
|
|
|
if (fname.empty()) {
|
|
|
|
owner->getMiniBuffer()->Set(_("Canceled."));
|
|
|
|
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
|
2000-08-08 13:55:26 +00:00
|
|
|
s = MakeAbsPath(fname);
|
2000-08-08 11:08:07 +00:00
|
|
|
if (!IsLyXFilename(s))
|
|
|
|
s += ".lyx";
|
|
|
|
|
|
|
|
// Check if the document already is open
|
|
|
|
if (bufferlist.exists(s)) {
|
|
|
|
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
|
|
|
|
owner->getMiniBuffer()->Set(_("Canceled."));
|
|
|
|
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
|
|
|
|
owner->getMiniBuffer()->Set(_("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));
|
|
|
|
owner->getMiniBuffer()->Set(_("Document"),
|
|
|
|
MakeDisplayPath(s),
|
|
|
|
_("opened."));
|
|
|
|
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) {
|
2000-04-11 22:55:29 +00:00
|
|
|
ProhibitInput(owner->view());
|
1999-12-16 06:43:25 +00:00
|
|
|
fname = fileDlg.Select(_("Choose template"),
|
2000-03-12 10:35:05 +00:00
|
|
|
lyxrc.template_path,
|
1999-12-16 06:43:25 +00:00
|
|
|
"*.lyx");
|
2000-10-19 09:11:39 +00:00
|
|
|
if (fname.empty())
|
|
|
|
return;
|
1999-12-16 06:43:25 +00:00
|
|
|
templname = fname;
|
2000-04-11 22:55:29 +00:00
|
|
|
AllowInput(owner->view());
|
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
|
|
|
|
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
void LyXFunc::MenuOpen()
|
|
|
|
{
|
2000-03-12 10:35:05 +00:00
|
|
|
string initpath = lyxrc.document_path;
|
1999-12-16 06:43:25 +00:00
|
|
|
LyXFileDlg fileDlg;
|
|
|
|
|
|
|
|
if (owner->view()->available()) {
|
|
|
|
string trypath = owner->buffer()->filepath;
|
|
|
|
// If directory is writeable, use this as default.
|
|
|
|
if (IsDirWriteable(trypath) == 1)
|
|
|
|
initpath = trypath;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// launches dialog
|
2000-04-11 22:55:29 +00:00
|
|
|
ProhibitInput(owner->view());
|
2000-03-12 10:35:05 +00:00
|
|
|
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
|
1999-09-27 18:44:28 +00:00
|
|
|
fileDlg.SetButton(1, _("Examples"),
|
|
|
|
AddPath(system_lyxdir, "examples"));
|
1999-10-02 16:21:10 +00:00
|
|
|
string filename = fileDlg.Select(_("Select Document to Open"),
|
1999-12-16 06:43:25 +00:00
|
|
|
initpath, "*.lyx");
|
2000-04-11 22:55:29 +00:00
|
|
|
AllowInput(owner->view());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// check selected filename
|
|
|
|
if (filename.empty()) {
|
|
|
|
owner->getMiniBuffer()->Set(_("Canceled."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get absolute path of file and make sure the filename ends
|
|
|
|
// with .lyx
|
|
|
|
filename = MakeAbsPath(filename);
|
|
|
|
if (!IsLyXFilename(filename))
|
|
|
|
filename += ".lyx";
|
|
|
|
|
|
|
|
// loads document
|
|
|
|
owner->getMiniBuffer()->Set(_("Opening document"),
|
|
|
|
MakeDisplayPath(filename), "...");
|
|
|
|
Buffer * openbuf = bufferlist.loadLyXFile(filename);
|
|
|
|
if (openbuf) {
|
1999-11-22 16:19:48 +00:00
|
|
|
owner->view()->buffer(openbuf);
|
1999-09-27 18:44:28 +00:00
|
|
|
owner->getMiniBuffer()->Set(_("Document"),
|
|
|
|
MakeDisplayPath(filename),
|
|
|
|
_("opened."));
|
|
|
|
} else {
|
|
|
|
owner->getMiniBuffer()->Set(_("Could not open document"),
|
|
|
|
MakeDisplayPath(filename));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
LyXFileDlg fileDlg;
|
|
|
|
|
|
|
|
if (owner->view()->available()) {
|
|
|
|
string trypath = owner->buffer()->filepath;
|
|
|
|
// If directory is writeable, use this as default.
|
|
|
|
if (IsDirWriteable(trypath) == 1)
|
|
|
|
initpath = trypath;
|
|
|
|
}
|
|
|
|
|
|
|
|
// launches dialog
|
|
|
|
ProhibitInput(owner->view());
|
|
|
|
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
|
|
|
|
fileDlg.SetButton(1, _("Examples"),
|
|
|
|
AddPath(system_lyxdir, "examples"));
|
2000-10-23 12:16:05 +00:00
|
|
|
string text = _("Select ") + Formats::PrettyName(format)
|
|
|
|
+ _(" file to import");
|
|
|
|
string format2 = (format == "textparagraph") ? "text" : format;
|
|
|
|
string extension = "*." + Formats::Extension(format2);
|
|
|
|
filename = fileDlg.Select(text, initpath, extension);
|
2000-04-28 11:18:04 +00:00
|
|
|
AllowInput(owner->view());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-04-28 11:18:04 +00:00
|
|
|
// check selected filename
|
|
|
|
if (filename.empty())
|
|
|
|
owner->getMiniBuffer()->Set(_("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-05-11 16:12:46 +00:00
|
|
|
string 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)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
switch(AskConfirmation(_("Document is already open:"),
|
2000-04-28 11:18:04 +00:00
|
|
|
MakeDisplayPath(lyxfile, 50),
|
1999-09-27 18:44:28 +00:00
|
|
|
_("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
|
|
|
|
owner->getMiniBuffer()->Set(_("Canceled."));
|
|
|
|
return;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check if a LyX document by the same root exists in filesystem
|
2000-04-28 11:18:04 +00:00
|
|
|
FileInfo 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?"))) {
|
|
|
|
owner->getMiniBuffer()->Set(_("Canceled."));
|
|
|
|
return;
|
|
|
|
}
|
2000-04-28 11:18:04 +00:00
|
|
|
// filename should be valid now
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-10-23 12:16:05 +00:00
|
|
|
Importer::Import(owner, filename, format);
|
2000-03-20 18:55:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
void LyXFunc::MenuInsertLyXFile(string const & filen)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string filename = filen;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (filename.empty()) {
|
|
|
|
// Launch a file browser
|
2000-03-12 10:35:05 +00:00
|
|
|
string initpath = lyxrc.document_path;
|
1999-09-27 18:44:28 +00:00
|
|
|
LyXFileDlg fileDlg;
|
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
if (owner->view()->available()) {
|
1999-11-09 23:52:04 +00:00
|
|
|
string trypath = owner->buffer()->filepath;
|
1999-09-27 18:44:28 +00:00
|
|
|
// If directory is writeable, use this as default.
|
|
|
|
if (IsDirWriteable(trypath) == 1)
|
|
|
|
initpath = trypath;
|
|
|
|
}
|
|
|
|
|
|
|
|
// launches dialog
|
2000-04-11 22:55:29 +00:00
|
|
|
ProhibitInput(owner->view());
|
2000-03-12 10:35:05 +00:00
|
|
|
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
|
1999-09-27 18:44:28 +00:00
|
|
|
fileDlg.SetButton(1, _("Examples"),
|
|
|
|
AddPath(system_lyxdir, "examples"));
|
|
|
|
filename = fileDlg.Select(_("Select Document to Insert"),
|
|
|
|
initpath, "*.lyx");
|
2000-04-11 22:55:29 +00:00
|
|
|
AllowInput(owner->view());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// check selected filename
|
|
|
|
if (filename.empty()) {
|
|
|
|
owner->getMiniBuffer()->Set(_("Canceled."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// get absolute path of file and make sure the filename ends
|
|
|
|
// with .lyx
|
|
|
|
filename = MakeAbsPath(filename);
|
|
|
|
if (!IsLyXFilename(filename))
|
|
|
|
filename += ".lyx";
|
|
|
|
|
|
|
|
// Inserts document
|
|
|
|
owner->getMiniBuffer()->Set(_("Inserting document"),
|
|
|
|
MakeDisplayPath(filename), "...");
|
2000-01-08 21:02:58 +00:00
|
|
|
bool res = owner->view()->insertLyXFile(filename);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (res) {
|
|
|
|
owner->getMiniBuffer()->Set(_("Document"),
|
|
|
|
MakeDisplayPath(filename),
|
|
|
|
_("inserted."));
|
|
|
|
} else {
|
|
|
|
owner->getMiniBuffer()->Set(_("Could not insert document"),
|
|
|
|
MakeDisplayPath(filename));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LyXFunc::reloadBuffer()
|
|
|
|
{
|
1999-12-10 00:07:59 +00:00
|
|
|
string 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();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
else {
|
1999-11-22 16:19:48 +00:00
|
|
|
owner->view()->buffer(bufferlist.first());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
Inset * LyXFunc::getInsetByCode(Inset::Code code)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-12-10 00:07:59 +00:00
|
|
|
LyXCursor cursor = owner->view()->text->cursor;
|
2000-05-19 16:46:01 +00:00
|
|
|
Buffer * buffer = owner->view()->buffer();
|
2000-10-11 21:06:43 +00:00
|
|
|
Buffer::inset_iterator it =
|
|
|
|
find_if(Buffer::inset_iterator(cursor.par(),
|
|
|
|
cursor.pos()),
|
|
|
|
buffer->inset_iterator_end(),
|
|
|
|
compare_memfun(&Inset::LyxCode, code));
|
|
|
|
return it != buffer->inset_iterator_end() ? (*it) : 0;
|
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;
|
|
|
|
}
|