2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file text3.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-08-20 13:00:25 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Asger Alstrup
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Alfredo Braunstein
|
|
|
|
|
* \author Angus Leeming
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
2002-08-20 13:00:25 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "lyxtext.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
|
2004-03-18 13:57:20 +00:00
|
|
|
|
#include "FloatList.h"
|
|
|
|
|
#include "FuncStatus.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "buffer.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
|
#include "bufferparams.h"
|
2002-08-20 13:00:25 +00:00
|
|
|
|
#include "BufferView.h"
|
2003-11-04 12:36:59 +00:00
|
|
|
|
#include "cursor.h"
|
2004-08-14 14:03:42 +00:00
|
|
|
|
#include "coordcache.h"
|
2004-03-25 09:16:36 +00:00
|
|
|
|
#include "CutAndPaste.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "debug.h"
|
2003-10-29 10:47:21 +00:00
|
|
|
|
#include "dispatchresult.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "factory.h"
|
2002-08-20 13:00:25 +00:00
|
|
|
|
#include "funcrequest.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "gettext.h"
|
|
|
|
|
#include "intl.h"
|
|
|
|
|
#include "language.h"
|
2004-02-06 13:59:26 +00:00
|
|
|
|
#include "lyxfunc.h"
|
2004-02-13 11:05:29 +00:00
|
|
|
|
#include "lyxlex.h"
|
2002-08-20 13:00:25 +00:00
|
|
|
|
#include "lyxrc.h"
|
2003-09-06 12:36:58 +00:00
|
|
|
|
#include "lyxrow.h"
|
2003-09-06 17:23:08 +00:00
|
|
|
|
#include "paragraph.h"
|
2003-11-10 18:15:55 +00:00
|
|
|
|
#include "paragraph_funcs.h"
|
2002-08-20 13:00:25 +00:00
|
|
|
|
#include "ParagraphParameters.h"
|
2003-10-14 13:01:49 +00:00
|
|
|
|
#include "undo.h"
|
2003-09-09 17:00:19 +00:00
|
|
|
|
#include "vspace.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
|
2002-08-29 13:41:58 +00:00
|
|
|
|
#include "frontends/Dialogs.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
|
|
2002-08-27 12:32:04 +00:00
|
|
|
|
#include "insets/insetcommand.h"
|
2004-02-12 16:36:01 +00:00
|
|
|
|
#include "insets/insetfloatlist.h"
|
2003-03-12 19:16:42 +00:00
|
|
|
|
#include "insets/insetnewline.h"
|
2004-02-20 10:32:44 +00:00
|
|
|
|
#include "insets/insetquotes.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "insets/insetspecialchar.h"
|
|
|
|
|
#include "insets/insettext.h"
|
|
|
|
|
|
|
|
|
|
#include "support/lstrings.h"
|
2004-02-11 14:45:44 +00:00
|
|
|
|
#include "support/lyxlib.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "support/tostr.h"
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2004-01-26 10:13:15 +00:00
|
|
|
|
#include "mathed/math_hullinset.h"
|
2004-04-13 06:27:29 +00:00
|
|
|
|
#include "mathed/math_macrotemplate.h"
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2003-09-05 22:17:02 +00:00
|
|
|
|
#include <clocale>
|
2004-07-24 10:55:30 +00:00
|
|
|
|
#include <sstream>
|
2002-08-27 13:39:27 +00:00
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using lyx::pos_type;
|
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
using lyx::cap::copySelection;
|
|
|
|
|
using lyx::cap::cutSelection;
|
|
|
|
|
using lyx::cap::pasteSelection;
|
|
|
|
|
using lyx::cap::replaceSelection;
|
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using lyx::support::isStrUnsignedInt;
|
|
|
|
|
using lyx::support::strToUnsignedInt;
|
2004-02-11 14:45:44 +00:00
|
|
|
|
using lyx::support::atoi;
|
|
|
|
|
using lyx::support::token;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
|
2002-08-20 17:31:23 +00:00
|
|
|
|
using std::endl;
|
2002-09-03 12:31:22 +00:00
|
|
|
|
using std::find;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-09-05 18:02:24 +00:00
|
|
|
|
using std::istringstream;
|
2002-09-03 12:31:22 +00:00
|
|
|
|
using std::vector;
|
2003-09-08 00:33:41 +00:00
|
|
|
|
|
|
|
|
|
|
2002-08-20 15:26:52 +00:00
|
|
|
|
extern string current_layout;
|
2002-08-28 10:45:38 +00:00
|
|
|
|
|
2002-08-20 15:26:52 +00:00
|
|
|
|
|
2002-08-27 13:17:22 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
// globals...
|
|
|
|
|
LyXFont freefont(LyXFont::ALL_IGNORE);
|
|
|
|
|
bool toggleall = false;
|
|
|
|
|
|
|
|
|
|
|
2004-02-13 07:30:59 +00:00
|
|
|
|
void toggleAndShow(LCursor & cur, LyXText * text,
|
2003-11-10 09:06:48 +00:00
|
|
|
|
LyXFont const & font, bool toggleall = true)
|
|
|
|
|
{
|
2004-02-13 07:30:59 +00:00
|
|
|
|
text->toggleFree(cur, font, toggleall);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
|
|
|
|
if (font.language() != ignore_language ||
|
|
|
|
|
font.number() != LyXFont::IGNORE) {
|
2004-02-13 07:30:59 +00:00
|
|
|
|
Paragraph & par = cur.paragraph();
|
2004-04-08 15:03:33 +00:00
|
|
|
|
text->bidi.computeTables(par, cur.buffer(), cur.textRow());
|
2004-01-13 10:37:38 +00:00
|
|
|
|
if (cur.boundary() !=
|
2004-04-08 15:03:33 +00:00
|
|
|
|
text->bidi.isBoundary(cur.buffer(), par,
|
2004-01-13 10:37:38 +00:00
|
|
|
|
cur.pos(),
|
2003-11-10 09:06:48 +00:00
|
|
|
|
text->real_current_font))
|
2004-11-24 21:53:46 +00:00
|
|
|
|
text->setCursor(cur, cur.pit(), cur.pos(),
|
2004-01-13 10:37:38 +00:00
|
|
|
|
false, !cur.boundary());
|
2003-11-10 09:06:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-01-20 14:25:24 +00:00
|
|
|
|
void moveCursor(LCursor & cur, bool selecting)
|
2002-08-27 14:43:49 +00:00
|
|
|
|
{
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (selecting || cur.mark())
|
|
|
|
|
cur.setSelection();
|
|
|
|
|
if (!cur.selection())
|
|
|
|
|
cur.bv().haveSelection(false);
|
|
|
|
|
cur.bv().switchKeyMap();
|
2002-08-27 14:43:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-03-08 21:14:45 +00:00
|
|
|
|
void finishChange(LCursor & cur, bool selecting)
|
2002-08-27 13:17:22 +00:00
|
|
|
|
{
|
|
|
|
|
finishUndo();
|
2004-02-06 13:59:26 +00:00
|
|
|
|
moveCursor(cur, selecting);
|
2002-08-27 13:17:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-02-11 14:45:44 +00:00
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
|
2004-02-11 14:45:44 +00:00
|
|
|
|
{
|
2004-03-08 21:14:45 +00:00
|
|
|
|
recordUndo(cur);
|
2004-02-11 14:45:44 +00:00
|
|
|
|
string sel = cur.selectionAsString(false);
|
|
|
|
|
lyxerr << "selection is: '" << sel << "'" << endl;
|
|
|
|
|
|
|
|
|
|
if (sel.empty()) {
|
2004-08-12 19:49:25 +00:00
|
|
|
|
const int old_pos = cur.pos();
|
2004-03-18 12:53:43 +00:00
|
|
|
|
cur.insert(new MathHullInset);
|
2004-08-12 19:49:25 +00:00
|
|
|
|
BOOST_ASSERT(old_pos == cur.pos());
|
2004-04-07 08:07:26 +00:00
|
|
|
|
cur.nextInset()->edit(cur, true);
|
2004-02-11 14:45:44 +00:00
|
|
|
|
cur.dispatch(FuncRequest(LFUN_MATH_MUTATE, "simple"));
|
2004-11-30 01:59:49 +00:00
|
|
|
|
// don't do that also for LFUN_MATH_MODE
|
|
|
|
|
// unless you want end up with always changing
|
|
|
|
|
// to mathrm when opening an inlined inset --
|
|
|
|
|
// I really hate "LyXfunc overloading"...
|
2004-02-11 14:45:44 +00:00
|
|
|
|
if (display)
|
|
|
|
|
cur.dispatch(FuncRequest(LFUN_MATH_DISPLAY));
|
|
|
|
|
cur.dispatch(FuncRequest(LFUN_INSERT_MATH, cmd.argument));
|
|
|
|
|
} else {
|
2004-11-30 01:59:49 +00:00
|
|
|
|
// create a macro if we see "\\newcommand"
|
|
|
|
|
// somewhere, and an ordinary formula
|
|
|
|
|
// otherwise
|
2004-03-25 09:16:36 +00:00
|
|
|
|
cutSelection(cur, true, true);
|
2004-03-18 12:53:43 +00:00
|
|
|
|
if (sel.find("\\newcommand") == string::npos
|
|
|
|
|
&& sel.find("\\def") == string::npos)
|
2004-02-11 14:45:44 +00:00
|
|
|
|
{
|
|
|
|
|
cur.insert(new MathHullInset);
|
2004-03-18 12:53:43 +00:00
|
|
|
|
cur.dispatch(FuncRequest(LFUN_RIGHT));
|
2004-02-11 14:45:44 +00:00
|
|
|
|
cur.dispatch(FuncRequest(LFUN_MATH_MUTATE, "simple"));
|
|
|
|
|
cur.dispatch(FuncRequest(LFUN_INSERT_MATH, sel));
|
|
|
|
|
} else {
|
2004-04-18 07:32:34 +00:00
|
|
|
|
istringstream is(sel);
|
|
|
|
|
cur.insert(new MathMacroTemplate(is));
|
2004-02-11 14:45:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cur.message(N_("Math editor mode"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
|
2002-08-28 12:09:19 +00:00
|
|
|
|
|
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
namespace bv_funcs {
|
|
|
|
|
|
|
|
|
|
string const freefont2string()
|
|
|
|
|
{
|
|
|
|
|
string data;
|
|
|
|
|
if (font2string(freefont, toggleall, data))
|
|
|
|
|
return data;
|
|
|
|
|
return string();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-13 11:05:29 +00:00
|
|
|
|
bool LyXText::gotoNextInset(LCursor & cur,
|
2004-11-25 19:13:07 +00:00
|
|
|
|
vector<InsetBase_code> const & codes, string const & contents)
|
2002-08-27 12:32:04 +00:00
|
|
|
|
{
|
2004-02-13 11:05:29 +00:00
|
|
|
|
BOOST_ASSERT(this == cur.text());
|
2004-11-24 21:53:46 +00:00
|
|
|
|
pit_type end = paragraphs().size();
|
|
|
|
|
pit_type pit = cur.pit();
|
2004-02-13 11:05:29 +00:00
|
|
|
|
pos_type pos = cur.pos();
|
2003-04-14 17:57:40 +00:00
|
|
|
|
|
2004-01-26 10:13:15 +00:00
|
|
|
|
InsetBase * inset;
|
2002-08-27 12:32:04 +00:00
|
|
|
|
do {
|
2004-03-25 09:16:36 +00:00
|
|
|
|
if (pos + 1 < pars_[pit].size()) {
|
2003-04-14 17:57:40 +00:00
|
|
|
|
++pos;
|
2002-08-27 12:32:04 +00:00
|
|
|
|
} else {
|
2003-04-14 17:57:40 +00:00
|
|
|
|
++pit;
|
|
|
|
|
pos = 0;
|
2002-08-27 12:32:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-14 17:57:40 +00:00
|
|
|
|
} while (pit != end &&
|
2004-03-25 09:16:36 +00:00
|
|
|
|
!(pars_[pit].isInset(pos) &&
|
|
|
|
|
(inset = pars_[pit].getInset(pos)) != 0 &&
|
2003-04-14 17:57:40 +00:00
|
|
|
|
find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end() &&
|
|
|
|
|
(contents.empty() ||
|
2004-03-25 09:16:36 +00:00
|
|
|
|
static_cast<InsetCommand *>(pars_[pit].getInset(pos))->getContents()
|
2003-04-14 17:57:40 +00:00
|
|
|
|
== contents)));
|
|
|
|
|
|
2003-10-09 10:52:12 +00:00
|
|
|
|
if (pit == end)
|
|
|
|
|
return false;
|
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
setCursor(cur, pit, pos, false);
|
2003-10-09 10:52:12 +00:00
|
|
|
|
return true;
|
2002-08-27 12:32:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-02-13 11:05:29 +00:00
|
|
|
|
void LyXText::gotoInset(LCursor & cur,
|
2004-11-25 19:13:07 +00:00
|
|
|
|
vector<InsetBase_code> const & codes, bool same_content)
|
2002-08-27 12:32:04 +00:00
|
|
|
|
{
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.clearSelection();
|
2002-08-27 12:32:04 +00:00
|
|
|
|
|
|
|
|
|
string contents;
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (same_content
|
|
|
|
|
&& cur.pos() < cur.lastpos()
|
|
|
|
|
&& cur.paragraph().isInset(cur.pos())) {
|
2004-01-26 10:13:15 +00:00
|
|
|
|
InsetBase const * inset = cur.paragraph().getInset(cur.pos());
|
2002-08-27 12:32:04 +00:00
|
|
|
|
if (find(codes.begin(), codes.end(), inset->lyxCode())
|
|
|
|
|
!= codes.end())
|
|
|
|
|
contents = static_cast<InsetCommand const *>(inset)->getContents();
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-13 11:05:29 +00:00
|
|
|
|
if (!gotoNextInset(cur, codes, contents)) {
|
2004-11-24 21:53:46 +00:00
|
|
|
|
if (cur.pos() || cur.pit() != 0) {
|
2004-03-01 17:12:09 +00:00
|
|
|
|
CursorSlice tmp = cur.top();
|
2004-11-24 21:53:46 +00:00
|
|
|
|
cur.pit() = 0;
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.pos() = 0;
|
2004-02-13 11:05:29 +00:00
|
|
|
|
if (!gotoNextInset(cur, codes, contents)) {
|
2004-03-18 13:28:49 +00:00
|
|
|
|
cur.top() = tmp;
|
2004-02-13 07:30:59 +00:00
|
|
|
|
cur.message(_("No more insets"));
|
2002-08-27 12:32:04 +00:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2004-02-13 07:30:59 +00:00
|
|
|
|
cur.message(_("No more insets"));
|
2002-08-27 12:32:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.resetAnchor();
|
2002-08-27 12:32:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-25 19:13:07 +00:00
|
|
|
|
void LyXText::gotoInset(LCursor & cur, InsetBase_code code, bool same_content)
|
2002-08-27 12:32:04 +00:00
|
|
|
|
{
|
2004-11-25 19:13:07 +00:00
|
|
|
|
gotoInset(cur, vector<InsetBase_code>(1, code), same_content);
|
2002-08-27 12:32:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-08-22 13:02:14 +00:00
|
|
|
|
|
2004-02-12 16:36:01 +00:00
|
|
|
|
void LyXText::cursorPrevious(LCursor & cur)
|
2002-08-22 13:02:14 +00:00
|
|
|
|
{
|
2004-01-30 11:41:12 +00:00
|
|
|
|
pos_type cpos = cur.pos();
|
2004-11-24 21:53:46 +00:00
|
|
|
|
lyx::pit_type cpar = cur.pit();
|
2003-08-14 11:30:11 +00:00
|
|
|
|
|
2004-02-12 16:36:01 +00:00
|
|
|
|
int x = cur.x_target();
|
2004-11-30 01:59:49 +00:00
|
|
|
|
|
|
|
|
|
setCursorFromCoordinates(cur, x, 0);
|
|
|
|
|
cursorUp(cur);
|
2002-08-22 13:02:14 +00:00
|
|
|
|
|
2004-11-24 21:53:46 +00:00
|
|
|
|
if (cpar == cur.pit() && cpos == cur.pos()) {
|
2002-12-20 14:28:28 +00:00
|
|
|
|
// we have a row which is taller than the workarea. The
|
|
|
|
|
// simplest solution is to move to the previous row instead.
|
2004-02-20 17:19:53 +00:00
|
|
|
|
cursorUp(cur);
|
2003-10-23 15:44:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-04-08 15:03:33 +00:00
|
|
|
|
cur.bv().updateScrollbar();
|
2003-11-20 10:38:12 +00:00
|
|
|
|
finishUndo();
|
2002-08-22 13:02:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-02-12 16:36:01 +00:00
|
|
|
|
void LyXText::cursorNext(LCursor & cur)
|
2002-08-22 13:02:14 +00:00
|
|
|
|
{
|
2004-01-30 11:41:12 +00:00
|
|
|
|
pos_type cpos = cur.pos();
|
2004-11-24 21:53:46 +00:00
|
|
|
|
lyx::pit_type cpar = cur.pit();
|
2002-08-22 13:02:14 +00:00
|
|
|
|
|
2004-01-30 11:41:12 +00:00
|
|
|
|
int x = cur.x_target();
|
2004-11-30 01:59:49 +00:00
|
|
|
|
setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
|
|
|
|
|
cursorDown(cur);
|
2002-08-22 13:02:14 +00:00
|
|
|
|
|
2004-11-24 21:53:46 +00:00
|
|
|
|
if (cpar == cur.pit() && cpos == cur.pos()) {
|
2002-12-20 14:28:28 +00:00
|
|
|
|
// we have a row which is taller than the workarea. The
|
|
|
|
|
// simplest solution is to move to the next row instead.
|
2004-02-20 17:19:53 +00:00
|
|
|
|
cursorDown(cur);
|
2003-10-24 09:45:07 +00:00
|
|
|
|
}
|
2003-11-22 14:44:59 +00:00
|
|
|
|
|
2004-04-08 15:03:33 +00:00
|
|
|
|
cur.bv().updateScrollbar();
|
2003-11-20 10:38:12 +00:00
|
|
|
|
finishUndo();
|
2002-08-22 13:02:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-01-17 09:57:50 +00:00
|
|
|
|
namespace {
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
void specialChar(LCursor & cur, InsetSpecialChar::Kind kind)
|
2002-08-20 13:00:25 +00:00
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
lyx::cap::replaceSelection(cur);
|
2004-02-13 07:30:59 +00:00
|
|
|
|
cur.insert(new InsetSpecialChar(kind));
|
2004-11-02 14:25:14 +00:00
|
|
|
|
cur.posRight();
|
2002-08-20 13:00:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-02-18 11:47:16 +00:00
|
|
|
|
|
2004-02-13 11:05:29 +00:00
|
|
|
|
void doInsertInset(LCursor & cur, LyXText * text,
|
2004-02-13 07:30:59 +00:00
|
|
|
|
FuncRequest const & cmd, bool edit, bool pastesel)
|
2003-01-17 09:57:50 +00:00
|
|
|
|
{
|
2004-02-13 11:05:29 +00:00
|
|
|
|
InsetBase * inset = createInset(&cur.bv(), cmd);
|
2003-12-12 10:05:21 +00:00
|
|
|
|
if (!inset)
|
|
|
|
|
return;
|
|
|
|
|
|
2004-03-08 21:14:45 +00:00
|
|
|
|
recordUndo(cur);
|
2003-12-12 10:05:21 +00:00
|
|
|
|
bool gotsel = false;
|
2004-02-13 07:30:59 +00:00
|
|
|
|
if (cur.selection()) {
|
2004-02-13 11:05:29 +00:00
|
|
|
|
cur.bv().owner()->dispatch(FuncRequest(LFUN_CUT));
|
2003-12-12 10:05:21 +00:00
|
|
|
|
gotsel = true;
|
2003-01-17 09:57:50 +00:00
|
|
|
|
}
|
2004-02-13 07:30:59 +00:00
|
|
|
|
text->insertInset(cur, inset);
|
2004-08-12 19:49:25 +00:00
|
|
|
|
|
2004-02-04 09:44:12 +00:00
|
|
|
|
if (edit)
|
2004-02-13 07:30:59 +00:00
|
|
|
|
inset->edit(cur, true);
|
2004-08-12 19:49:25 +00:00
|
|
|
|
|
2004-02-04 09:44:12 +00:00
|
|
|
|
if (gotsel && pastesel)
|
2004-02-13 11:05:29 +00:00
|
|
|
|
cur.bv().owner()->dispatch(FuncRequest(LFUN_PASTE));
|
2003-01-17 09:57:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
|
|
|
|
|
|
void update(LCursor & cur)
|
|
|
|
|
{
|
|
|
|
|
//we don't call update(true, false) directly to save a metrics call
|
|
|
|
|
if (cur.bv().fitCursor())
|
|
|
|
|
cur.bv().update(false, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-13 01:35:47 +00:00
|
|
|
|
} // anon namespace
|
|
|
|
|
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2004-02-13 11:05:29 +00:00
|
|
|
|
void LyXText::number(LCursor & cur)
|
2003-11-10 09:06:48 +00:00
|
|
|
|
{
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setNumber(LyXFont::TOGGLE);
|
2004-02-13 11:05:29 +00:00
|
|
|
|
toggleAndShow(cur, this, font);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-02-16 11:58:51 +00:00
|
|
|
|
bool LyXText::isRTL(Paragraph const & par) const
|
2003-11-10 09:06:48 +00:00
|
|
|
|
{
|
2004-02-16 11:58:51 +00:00
|
|
|
|
return par.isRightToLeftPar(bv()->buffer()->params());
|
2003-11-10 09:06:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-03-18 12:53:43 +00:00
|
|
|
|
void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
2002-08-20 13:00:25 +00:00
|
|
|
|
{
|
2004-01-30 11:41:12 +00:00
|
|
|
|
lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
|
|
|
|
|
//lyxerr << "*** LyXText::dispatch: cmd: " << cmd << endl;
|
2002-08-22 15:04:27 +00:00
|
|
|
|
|
2004-03-18 13:57:20 +00:00
|
|
|
|
BOOST_ASSERT(cur.text() == this);
|
2004-01-20 14:25:24 +00:00
|
|
|
|
BufferView * bv = &cur.bv();
|
2004-03-01 17:12:09 +00:00
|
|
|
|
CursorSlice sl = cur.top();
|
2004-05-18 07:18:02 +00:00
|
|
|
|
bool sel = cur.selection();
|
|
|
|
|
bool moving = false;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
switch (cmd.action) {
|
|
|
|
|
|
|
|
|
|
case LFUN_APPENDIX: {
|
2004-02-13 07:30:59 +00:00
|
|
|
|
Paragraph & par = cur.paragraph();
|
|
|
|
|
bool start = !par.params().startOfAppendix();
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
// ensure that we have only one start_of_appendix in this document
|
2004-11-24 21:53:46 +00:00
|
|
|
|
for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
|
2004-03-25 09:16:36 +00:00
|
|
|
|
if (pars_[tmp].params().startOfAppendix()) {
|
|
|
|
|
recUndo(tmp);
|
|
|
|
|
pars_[tmp].params().startOfAppendix(false);
|
2002-10-30 21:02:40 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2004-02-13 07:30:59 +00:00
|
|
|
|
recordUndo(cur);
|
|
|
|
|
par.params().startOfAppendix(start);
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
// we can set the refreshing parameters now
|
2003-03-17 16:25:00 +00:00
|
|
|
|
updateCounters();
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case LFUN_DELETE_WORD_FORWARD:
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.clearSelection();
|
2004-02-12 16:36:01 +00:00
|
|
|
|
deleteWordForward(cur);
|
2004-03-08 21:14:45 +00:00
|
|
|
|
finishChange(cur, false);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_DELETE_WORD_BACKWARD:
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.clearSelection();
|
2004-02-12 16:36:01 +00:00
|
|
|
|
deleteWordBackward(cur);
|
2004-03-08 21:14:45 +00:00
|
|
|
|
finishChange(cur, false);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_DELETE_LINE_FORWARD:
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.clearSelection();
|
2004-02-12 16:36:01 +00:00
|
|
|
|
deleteLineForward(cur);
|
2004-03-08 21:14:45 +00:00
|
|
|
|
finishChange(cur, false);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2002-08-20 17:31:23 +00:00
|
|
|
|
case LFUN_WORDRIGHT:
|
2004-05-18 07:18:02 +00:00
|
|
|
|
moving = true;
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.mark())
|
|
|
|
|
cur.clearSelection();
|
2004-02-16 11:58:51 +00:00
|
|
|
|
if (isRTL(cur.paragraph()))
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorLeftOneWord(cur);
|
2002-08-20 13:00:25 +00:00
|
|
|
|
else
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorRightOneWord(cur);
|
2004-03-08 21:14:45 +00:00
|
|
|
|
finishChange(cur, false);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_WORDLEFT:
|
2004-05-18 07:18:02 +00:00
|
|
|
|
moving = true;
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.mark())
|
|
|
|
|
cur.clearSelection();
|
2004-02-16 11:58:51 +00:00
|
|
|
|
if (isRTL(cur.paragraph()))
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorRightOneWord(cur);
|
2002-08-20 13:00:25 +00:00
|
|
|
|
else
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorLeftOneWord(cur);
|
2004-03-08 21:14:45 +00:00
|
|
|
|
finishChange(cur, false);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2004-08-13 20:26:26 +00:00
|
|
|
|
case LFUN_BEGINNINGBUF:
|
2004-08-13 20:14:32 +00:00
|
|
|
|
if (cur.size() == 1) {
|
|
|
|
|
if (!cur.mark())
|
|
|
|
|
cur.clearSelection();
|
|
|
|
|
cursorTop(cur);
|
|
|
|
|
finishChange(cur, false);
|
|
|
|
|
} else {
|
|
|
|
|
cur.undispatched();
|
|
|
|
|
}
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
|
case LFUN_BEGINNINGBUFSEL:
|
|
|
|
|
if (cur.size() == 1) {
|
|
|
|
|
if (!cur.selection())
|
|
|
|
|
cur.resetAnchor();
|
|
|
|
|
cursorTop(cur);
|
|
|
|
|
finishChange(cur, true);
|
|
|
|
|
} else {
|
|
|
|
|
cur.undispatched();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2002-08-20 13:00:25 +00:00
|
|
|
|
case LFUN_ENDBUF:
|
2004-08-13 20:14:32 +00:00
|
|
|
|
if (cur.size() == 1) {
|
|
|
|
|
if (!cur.mark())
|
|
|
|
|
cur.clearSelection();
|
|
|
|
|
cursorBottom(cur);
|
|
|
|
|
finishChange(cur, false);
|
|
|
|
|
} else {
|
|
|
|
|
cur.undispatched();
|
|
|
|
|
}
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2004-11-30 01:59:49 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_ENDBUFSEL:
|
|
|
|
|
if (cur.size() == 1) {
|
|
|
|
|
if (!cur.selection())
|
|
|
|
|
cur.resetAnchor();
|
|
|
|
|
cursorBottom(cur);
|
|
|
|
|
finishChange(cur, true);
|
|
|
|
|
} else {
|
|
|
|
|
cur.undispatched();
|
|
|
|
|
}
|
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2004-02-20 17:19:53 +00:00
|
|
|
|
case LFUN_RIGHT:
|
2004-05-18 07:18:02 +00:00
|
|
|
|
moving = true;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
case LFUN_RIGHTSEL:
|
2004-03-25 09:16:36 +00:00
|
|
|
|
//lyxerr << "handle LFUN_RIGHT[SEL]:\n" << cur << endl;
|
2004-02-20 17:19:53 +00:00
|
|
|
|
cur.selHandle(cmd.action == LFUN_RIGHTSEL);
|
2004-02-16 11:58:51 +00:00
|
|
|
|
if (isRTL(cur.paragraph()))
|
2004-02-20 17:19:53 +00:00
|
|
|
|
cursorLeft(cur);
|
2002-08-20 13:00:25 +00:00
|
|
|
|
else
|
2004-02-20 17:19:53 +00:00
|
|
|
|
cursorRight(cur);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
if (sl == cur.top()) {
|
|
|
|
|
cur.undispatched();
|
2004-03-18 12:53:43 +00:00
|
|
|
|
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
}
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2004-02-20 17:19:53 +00:00
|
|
|
|
case LFUN_LEFT:
|
2004-05-18 07:18:02 +00:00
|
|
|
|
moving = true;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
case LFUN_LEFTSEL:
|
2004-03-25 09:16:36 +00:00
|
|
|
|
//lyxerr << "handle LFUN_LEFT[SEL]:\n" << cur << endl;
|
2004-02-20 17:19:53 +00:00
|
|
|
|
cur.selHandle(cmd.action == LFUN_LEFTSEL);
|
2004-02-16 11:58:51 +00:00
|
|
|
|
if (isRTL(cur.paragraph()))
|
2004-02-20 17:19:53 +00:00
|
|
|
|
cursorRight(cur);
|
2002-08-20 13:00:25 +00:00
|
|
|
|
else
|
2004-02-20 17:19:53 +00:00
|
|
|
|
cursorLeft(cur);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
if (sl == cur.top()) {
|
|
|
|
|
cur.undispatched();
|
2004-03-18 12:53:43 +00:00
|
|
|
|
cmd = FuncRequest(LFUN_FINISHED_LEFT);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
}
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2004-02-20 17:19:53 +00:00
|
|
|
|
case LFUN_UP:
|
2004-05-18 07:18:02 +00:00
|
|
|
|
moving = true;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
case LFUN_UPSEL:
|
2004-11-30 01:59:49 +00:00
|
|
|
|
update(cur);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
//lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
|
2004-02-20 17:19:53 +00:00
|
|
|
|
cur.selHandle(cmd.action == LFUN_UPSEL);
|
|
|
|
|
cursorUp(cur);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
if (sl == cur.top()) {
|
|
|
|
|
cur.undispatched();
|
2004-03-18 12:53:43 +00:00
|
|
|
|
cmd = FuncRequest(LFUN_FINISHED_UP);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
}
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2004-02-20 17:19:53 +00:00
|
|
|
|
case LFUN_DOWN:
|
2004-05-18 07:18:02 +00:00
|
|
|
|
moving = true;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
case LFUN_DOWNSEL:
|
2004-11-30 01:59:49 +00:00
|
|
|
|
update(cur);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
//lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
|
2004-02-20 17:19:53 +00:00
|
|
|
|
cur.selHandle(cmd.action == LFUN_DOWNSEL);
|
|
|
|
|
cursorDown(cur);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
if (sl == cur.top()) {
|
|
|
|
|
cur.undispatched();
|
2004-03-18 12:53:43 +00:00
|
|
|
|
cmd = FuncRequest(LFUN_FINISHED_DOWN);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
}
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_UP_PARAGRAPHSEL:
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.selection())
|
|
|
|
|
cur.resetAnchor();
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorUpParagraph(cur);
|
2004-02-06 13:59:26 +00:00
|
|
|
|
finishChange(cur, true);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_DOWN_PARAGRAPHSEL:
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.selection())
|
|
|
|
|
cur.resetAnchor();
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorDownParagraph(cur);
|
2004-02-06 13:59:26 +00:00
|
|
|
|
finishChange(cur, true);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_PRIORSEL:
|
2004-11-30 01:59:49 +00:00
|
|
|
|
update(cur);
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.selection())
|
|
|
|
|
cur.resetAnchor();
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorPrevious(cur);
|
2004-02-06 13:59:26 +00:00
|
|
|
|
finishChange(cur, true);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_NEXTSEL:
|
2004-11-30 01:59:49 +00:00
|
|
|
|
update(cur);
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.selection())
|
|
|
|
|
cur.resetAnchor();
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorNext(cur);
|
2004-02-06 13:59:26 +00:00
|
|
|
|
finishChange(cur, true);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_HOMESEL:
|
2004-11-30 01:59:49 +00:00
|
|
|
|
update(cur);
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.selection())
|
|
|
|
|
cur.resetAnchor();
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorHome(cur);
|
2004-02-06 13:59:26 +00:00
|
|
|
|
finishChange(cur, true);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_ENDSEL:
|
2004-11-30 01:59:49 +00:00
|
|
|
|
update(cur);
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.selection())
|
|
|
|
|
cur.resetAnchor();
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorEnd(cur);
|
2004-02-06 13:59:26 +00:00
|
|
|
|
finishChange(cur, true);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_WORDRIGHTSEL:
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.selection())
|
|
|
|
|
cur.resetAnchor();
|
2004-02-16 11:58:51 +00:00
|
|
|
|
if (isRTL(cur.paragraph()))
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorLeftOneWord(cur);
|
2002-08-20 13:00:25 +00:00
|
|
|
|
else
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorRightOneWord(cur);
|
2004-02-06 13:59:26 +00:00
|
|
|
|
finishChange(cur, true);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_WORDLEFTSEL:
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.selection())
|
|
|
|
|
cur.resetAnchor();
|
2004-02-16 11:58:51 +00:00
|
|
|
|
if (isRTL(cur.paragraph()))
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorRightOneWord(cur);
|
2002-08-20 13:00:25 +00:00
|
|
|
|
else
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorLeftOneWord(cur);
|
2004-02-06 13:59:26 +00:00
|
|
|
|
finishChange(cur, true);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2002-09-11 14:48:19 +00:00
|
|
|
|
case LFUN_WORDSEL: {
|
2004-02-13 07:30:59 +00:00
|
|
|
|
selectWord(cur, lyx::WHOLE_WORD);
|
2004-02-06 13:59:26 +00:00
|
|
|
|
finishChange(cur, true);
|
2002-09-11 14:48:19 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-20 13:00:25 +00:00
|
|
|
|
case LFUN_UP_PARAGRAPH:
|
2004-05-18 07:18:02 +00:00
|
|
|
|
moving = true;
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.mark())
|
|
|
|
|
cur.clearSelection();
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorUpParagraph(cur);
|
2004-03-08 21:14:45 +00:00
|
|
|
|
finishChange(cur, false);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_DOWN_PARAGRAPH:
|
2004-05-18 07:18:02 +00:00
|
|
|
|
moving = true;
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.mark())
|
|
|
|
|
cur.clearSelection();
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorDownParagraph(cur);
|
2004-02-06 13:59:26 +00:00
|
|
|
|
finishChange(cur, false);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_PRIOR:
|
2004-11-30 01:59:49 +00:00
|
|
|
|
update(cur);
|
2004-05-18 07:18:02 +00:00
|
|
|
|
moving = true;
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.mark())
|
|
|
|
|
cur.clearSelection();
|
2004-02-06 13:59:26 +00:00
|
|
|
|
finishChange(cur, false);
|
2004-11-24 21:53:46 +00:00
|
|
|
|
if (cur.pit() == 0 && cur.textRow().pos() == 0) {
|
2004-03-25 09:16:36 +00:00
|
|
|
|
cur.undispatched();
|
2004-03-18 12:53:43 +00:00
|
|
|
|
cmd = FuncRequest(LFUN_FINISHED_UP);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
} else {
|
2004-02-20 17:19:53 +00:00
|
|
|
|
cursorPrevious(cur);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
}
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_NEXT:
|
2004-11-30 01:59:49 +00:00
|
|
|
|
update(cur);
|
2004-05-18 07:18:02 +00:00
|
|
|
|
moving = true;
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.mark())
|
|
|
|
|
cur.clearSelection();
|
2004-02-06 13:59:26 +00:00
|
|
|
|
finishChange(cur, false);
|
2004-11-24 21:53:46 +00:00
|
|
|
|
if (cur.pit() == cur.lastpit()
|
2004-03-25 09:16:36 +00:00
|
|
|
|
&& cur.textRow().endpos() == cur.lastpos()) {
|
|
|
|
|
cur.undispatched();
|
2004-03-18 12:53:43 +00:00
|
|
|
|
cmd = FuncRequest(LFUN_FINISHED_DOWN);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
} else {
|
2004-02-20 17:19:53 +00:00
|
|
|
|
cursorNext(cur);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
}
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_HOME:
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.mark())
|
|
|
|
|
cur.clearSelection();
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorHome(cur);
|
2004-02-06 13:59:26 +00:00
|
|
|
|
finishChange(cur, false);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_END:
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.mark())
|
|
|
|
|
cur.clearSelection();
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorEnd(cur);
|
2004-02-06 13:59:26 +00:00
|
|
|
|
finishChange(cur, false);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2003-03-12 19:16:42 +00:00
|
|
|
|
case LFUN_BREAKLINE: {
|
|
|
|
|
// Not allowed by LaTeX (labels or empty par)
|
2004-02-13 07:30:59 +00:00
|
|
|
|
if (cur.pos() > cur.paragraph().beginOfBody()) {
|
2004-03-25 09:16:36 +00:00
|
|
|
|
lyx::cap::replaceSelection(cur);
|
2004-02-13 07:30:59 +00:00
|
|
|
|
cur.insert(new InsetNewline);
|
2004-11-02 14:25:14 +00:00
|
|
|
|
cur.posRight();
|
2004-02-06 16:50:29 +00:00
|
|
|
|
moveCursor(cur, false);
|
|
|
|
|
}
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2003-03-12 19:16:42 +00:00
|
|
|
|
}
|
2002-08-20 15:26:52 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_DELETE:
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.selection()) {
|
2004-02-12 16:36:01 +00:00
|
|
|
|
Delete(cur);
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.resetAnchor();
|
2002-08-20 15:26:52 +00:00
|
|
|
|
// It is possible to make it a lot faster still
|
|
|
|
|
// just comment out the line below...
|
|
|
|
|
} else {
|
2004-02-13 11:05:29 +00:00
|
|
|
|
cutSelection(cur, true, false);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
}
|
2004-01-20 14:25:24 +00:00
|
|
|
|
moveCursor(cur, false);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_DELETE_SKIP:
|
|
|
|
|
// Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.selection()) {
|
2004-02-12 16:36:01 +00:00
|
|
|
|
if (cur.pos() == cur.lastpos()) {
|
2004-02-20 17:19:53 +00:00
|
|
|
|
cursorRight(cur);
|
|
|
|
|
cursorLeft(cur);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
}
|
2004-02-12 16:36:01 +00:00
|
|
|
|
Delete(cur);
|
|
|
|
|
cur.resetAnchor();
|
2002-08-26 13:25:49 +00:00
|
|
|
|
} else {
|
2004-02-13 11:05:29 +00:00
|
|
|
|
cutSelection(cur, true, false);
|
2002-08-26 13:25:49 +00:00
|
|
|
|
}
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case LFUN_BACKSPACE:
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.selection()) {
|
2002-08-20 15:26:52 +00:00
|
|
|
|
if (bv->owner()->getIntl().getTransManager().backspace()) {
|
2004-02-12 16:36:01 +00:00
|
|
|
|
backspace(cur);
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.resetAnchor();
|
2002-08-20 15:26:52 +00:00
|
|
|
|
// It is possible to make it a lot faster still
|
|
|
|
|
// just comment out the line below...
|
|
|
|
|
}
|
2002-08-26 13:25:49 +00:00
|
|
|
|
} else {
|
2004-02-13 11:05:29 +00:00
|
|
|
|
cutSelection(cur, true, false);
|
2002-08-26 13:25:49 +00:00
|
|
|
|
}
|
2002-08-20 15:26:52 +00:00
|
|
|
|
bv->switchKeyMap();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_BACKSPACE_SKIP:
|
|
|
|
|
// Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!cur.selection()) {
|
2004-04-05 09:36:28 +00:00
|
|
|
|
#ifdef WITH_WARNINGS
|
2004-02-02 16:38:13 +00:00
|
|
|
|
#warning look here
|
2004-04-05 09:36:28 +00:00
|
|
|
|
#endif
|
2004-02-02 16:38:13 +00:00
|
|
|
|
//CursorSlice cur = cursor();
|
2004-02-12 16:36:01 +00:00
|
|
|
|
backspace(cur);
|
2004-02-02 16:38:13 +00:00
|
|
|
|
//anchor() = cur;
|
2002-08-26 13:25:49 +00:00
|
|
|
|
} else {
|
2004-02-13 11:05:29 +00:00
|
|
|
|
cutSelection(cur, true, false);
|
2002-08-26 13:25:49 +00:00
|
|
|
|
}
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_BREAKPARAGRAPH:
|
2004-03-25 09:16:36 +00:00
|
|
|
|
lyx::cap::replaceSelection(cur);
|
2004-02-12 16:36:01 +00:00
|
|
|
|
breakParagraph(cur, 0);
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.resetAnchor();
|
2002-08-20 15:26:52 +00:00
|
|
|
|
bv->switchKeyMap();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
|
2004-03-25 09:16:36 +00:00
|
|
|
|
lyx::cap::replaceSelection(cur);
|
2004-02-12 16:36:01 +00:00
|
|
|
|
breakParagraph(cur, 1);
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.resetAnchor();
|
2002-08-20 15:26:52 +00:00
|
|
|
|
bv->switchKeyMap();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_BREAKPARAGRAPH_SKIP: {
|
|
|
|
|
// When at the beginning of a paragraph, remove
|
2004-03-25 09:16:36 +00:00
|
|
|
|
// indentation. Otherwise, do the same as LFUN_BREAKPARAGRAPH.
|
|
|
|
|
lyx::cap::replaceSelection(cur);
|
|
|
|
|
if (cur.pos() == 0)
|
|
|
|
|
cur.paragraph().params().labelWidthString(string());
|
|
|
|
|
else
|
2004-02-12 16:36:01 +00:00
|
|
|
|
breakParagraph(cur, 0);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
cur.resetAnchor();
|
2002-08-20 15:26:52 +00:00
|
|
|
|
bv->switchKeyMap();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case LFUN_PARAGRAPH_SPACING: {
|
2004-02-12 16:36:01 +00:00
|
|
|
|
Paragraph & par = cur.paragraph();
|
|
|
|
|
Spacing::Space cur_spacing = par.params().spacing().getSpace();
|
2002-08-20 15:26:52 +00:00
|
|
|
|
float cur_value = 1.0;
|
|
|
|
|
if (cur_spacing == Spacing::Other)
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cur_value = par.params().spacing().getValue();
|
2002-08-20 15:26:52 +00:00
|
|
|
|
|
2003-09-15 11:00:00 +00:00
|
|
|
|
istringstream is(cmd.argument);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
string tmp;
|
|
|
|
|
is >> tmp;
|
|
|
|
|
Spacing::Space new_spacing = cur_spacing;
|
|
|
|
|
float new_value = cur_value;
|
|
|
|
|
if (tmp.empty()) {
|
|
|
|
|
lyxerr << "Missing argument to `paragraph-spacing'"
|
|
|
|
|
<< endl;
|
|
|
|
|
} else if (tmp == "single") {
|
|
|
|
|
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;
|
|
|
|
|
is >> 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: ")
|
|
|
|
|
<< cmd.argument << endl;
|
|
|
|
|
}
|
2004-11-30 01:59:49 +00:00
|
|
|
|
if (cur_spacing != new_spacing || cur_value != new_value)
|
2004-02-12 16:36:01 +00:00
|
|
|
|
par.params().spacing(Spacing(new_spacing, new_value));
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-13 20:16:34 +00:00
|
|
|
|
case LFUN_INSET_APPLY: {
|
|
|
|
|
string const name = cmd.getArg(0);
|
|
|
|
|
InsetBase * inset = bv->owner()->getDialogs().getOpenInset(name);
|
2004-03-18 12:53:43 +00:00
|
|
|
|
if (inset) {
|
|
|
|
|
FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument);
|
|
|
|
|
inset->dispatch(cur, fr);
|
|
|
|
|
} else {
|
|
|
|
|
FuncRequest fr(LFUN_INSET_INSERT, cmd.argument);
|
|
|
|
|
dispatch(cur, fr);
|
|
|
|
|
}
|
2003-11-13 20:16:34 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_INSERT: {
|
2004-03-08 21:14:45 +00:00
|
|
|
|
recordUndo(cur);
|
2004-01-26 10:13:15 +00:00
|
|
|
|
InsetBase * inset = createInset(bv, cmd);
|
2004-08-12 19:49:25 +00:00
|
|
|
|
if (inset) {
|
2004-02-13 07:30:59 +00:00
|
|
|
|
insertInset(cur, inset);
|
2004-08-12 19:49:25 +00:00
|
|
|
|
cur.posRight();
|
|
|
|
|
}
|
2003-11-13 20:16:34 +00:00
|
|
|
|
break;
|
2003-12-12 10:05:21 +00:00
|
|
|
|
}
|
2003-11-13 20:16:34 +00:00
|
|
|
|
|
2003-04-26 19:01:33 +00:00
|
|
|
|
case LFUN_INSET_SETTINGS:
|
2004-03-18 12:53:43 +00:00
|
|
|
|
if (cur.inset().asUpdatableInset())
|
|
|
|
|
cur.inset().asUpdatableInset()->showInsetDialog(bv);
|
2003-04-26 19:01:33 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2004-03-30 12:36:33 +00:00
|
|
|
|
case LFUN_NEXT_INSET_TOGGLE: {
|
|
|
|
|
InsetBase * inset = cur.nextInset();
|
|
|
|
|
if (inset) {
|
|
|
|
|
cur.clearSelection();
|
|
|
|
|
FuncRequest fr = cmd;
|
|
|
|
|
fr.action = LFUN_INSET_TOGGLE;
|
|
|
|
|
inset->dispatch(cur, fr);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case LFUN_KEYMAP_TOGGLE:
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.clearSelection();
|
2004-03-30 12:36:33 +00:00
|
|
|
|
bv->switchKeyMap();
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2003-05-22 10:40:57 +00:00
|
|
|
|
case LFUN_SPACE_INSERT:
|
2004-02-13 07:30:59 +00:00
|
|
|
|
if (cur.paragraph().layout()->free_spacing)
|
|
|
|
|
insertChar(cur, ' ');
|
2004-11-02 14:25:14 +00:00
|
|
|
|
else {
|
2004-02-13 11:05:29 +00:00
|
|
|
|
doInsertInset(cur, this, cmd, false, false);
|
2004-11-02 14:25:14 +00:00
|
|
|
|
cur.posRight();
|
|
|
|
|
}
|
2004-01-20 14:25:24 +00:00
|
|
|
|
moveCursor(cur, false);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_HYPHENATION:
|
2004-03-25 09:16:36 +00:00
|
|
|
|
specialChar(cur, InsetSpecialChar::HYPHENATION);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_LIGATURE_BREAK:
|
2004-03-25 09:16:36 +00:00
|
|
|
|
specialChar(cur, InsetSpecialChar::LIGATURE_BREAK);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_LDOTS:
|
2004-03-25 09:16:36 +00:00
|
|
|
|
specialChar(cur, InsetSpecialChar::LDOTS);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_END_OF_SENTENCE:
|
2004-03-25 09:16:36 +00:00
|
|
|
|
specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_MENU_SEPARATOR:
|
2004-03-25 09:16:36 +00:00
|
|
|
|
specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_UPCASE_WORD:
|
2004-02-13 07:30:59 +00:00
|
|
|
|
changeCase(cur, LyXText::text_uppercase);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_LOWCASE_WORD:
|
2004-02-13 07:30:59 +00:00
|
|
|
|
changeCase(cur, LyXText::text_lowercase);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_CAPITALIZE_WORD:
|
2004-02-13 07:30:59 +00:00
|
|
|
|
changeCase(cur, LyXText::text_capitalization);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_TRANSPOSE_CHARS:
|
2004-02-13 07:30:59 +00:00
|
|
|
|
recordUndo(cur);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2003-10-10 09:01:23 +00:00
|
|
|
|
case LFUN_PASTE:
|
2004-02-03 11:49:05 +00:00
|
|
|
|
cur.message(_("Paste"));
|
2004-03-25 09:16:36 +00:00
|
|
|
|
lyx::cap::replaceSelection(cur);
|
2004-04-05 09:36:28 +00:00
|
|
|
|
#ifdef WITH_WARNINGS
|
2003-06-17 15:33:49 +00:00
|
|
|
|
#warning FIXME Check if the arg is in the domain of available selections.
|
2004-04-05 09:36:28 +00:00
|
|
|
|
#endif
|
2003-10-10 09:01:23 +00:00
|
|
|
|
if (isStrUnsignedInt(cmd.argument))
|
2004-02-13 07:30:59 +00:00
|
|
|
|
pasteSelection(cur, strToUnsignedInt(cmd.argument));
|
2003-10-10 09:01:23 +00:00
|
|
|
|
else
|
2004-02-13 07:30:59 +00:00
|
|
|
|
pasteSelection(cur, 0);
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.clearSelection(); // bug 393
|
2002-08-26 13:25:49 +00:00
|
|
|
|
bv->switchKeyMap();
|
2003-10-10 09:01:23 +00:00
|
|
|
|
finishUndo();
|
2002-08-26 13:25:49 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_CUT:
|
2004-02-13 11:05:29 +00:00
|
|
|
|
cutSelection(cur, true, true);
|
2004-02-03 11:49:05 +00:00
|
|
|
|
cur.message(_("Cut"));
|
2002-08-26 13:25:49 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_COPY:
|
2004-02-13 11:05:29 +00:00
|
|
|
|
copySelection(cur);
|
2004-02-03 11:49:05 +00:00
|
|
|
|
cur.message(_("Copy"));
|
2002-08-26 13:25:49 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2002-08-20 13:00:25 +00:00
|
|
|
|
case LFUN_GETXY:
|
2004-03-01 17:12:09 +00:00
|
|
|
|
cur.message(tostr(cursorX(cur.top())) + ' '
|
|
|
|
|
+ tostr(cursorY(cur.top())));
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_SETXY: {
|
|
|
|
|
int x = 0;
|
|
|
|
|
int y = 0;
|
2003-09-15 11:00:00 +00:00
|
|
|
|
istringstream is(cmd.argument);
|
2002-08-21 06:50:42 +00:00
|
|
|
|
is >> x >> y;
|
|
|
|
|
if (!is)
|
2002-08-20 13:00:25 +00:00
|
|
|
|
lyxerr << "SETXY: Could not parse coordinates in '"
|
|
|
|
|
<< cmd.argument << std::endl;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
else
|
2004-02-13 13:51:12 +00:00
|
|
|
|
setCursorFromCoordinates(cur, x, y);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case LFUN_GETFONT:
|
|
|
|
|
if (current_font.shape() == LyXFont::ITALIC_SHAPE)
|
2004-02-03 11:49:05 +00:00
|
|
|
|
cur.message("E");
|
2002-08-20 13:00:25 +00:00
|
|
|
|
else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
|
2004-02-03 11:49:05 +00:00
|
|
|
|
cur.message("N");
|
2002-08-20 13:00:25 +00:00
|
|
|
|
else
|
2004-02-03 11:49:05 +00:00
|
|
|
|
cur.message("0");
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_GETLAYOUT:
|
2004-02-13 07:30:59 +00:00
|
|
|
|
cur.message(cur.paragraph().layout()->name());
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_LAYOUT: {
|
|
|
|
|
lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
|
|
|
|
|
<< cmd.argument << endl;
|
|
|
|
|
|
|
|
|
|
// This is not the good solution to the empty argument
|
|
|
|
|
// problem, but it will hopefully suffice for 1.2.0.
|
|
|
|
|
// The correct solution would be to augument the
|
|
|
|
|
// function list/array with information about what
|
|
|
|
|
// functions needs arguments and their type.
|
|
|
|
|
if (cmd.argument.empty()) {
|
2004-02-03 11:49:05 +00:00
|
|
|
|
cur.errorMessage(_("LyX function 'layout' needs an argument."));
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Derive layout number from given argument (string)
|
|
|
|
|
// and current buffer's textclass (number)
|
2003-09-09 09:47:59 +00:00
|
|
|
|
LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
|
2002-08-20 15:26:52 +00:00
|
|
|
|
bool hasLayout = tclass.hasLayout(cmd.argument);
|
|
|
|
|
string layout = cmd.argument;
|
|
|
|
|
|
|
|
|
|
// If the entry is obsolete, use the new one instead.
|
|
|
|
|
if (hasLayout) {
|
|
|
|
|
string const & obs = tclass[layout]->obsoleted_by();
|
|
|
|
|
if (!obs.empty())
|
|
|
|
|
layout = obs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!hasLayout) {
|
2004-02-03 11:49:05 +00:00
|
|
|
|
cur.errorMessage(string(N_("Layout ")) + cmd.argument +
|
2002-08-20 15:26:52 +00:00
|
|
|
|
N_(" not known"));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool change_layout = (current_layout != layout);
|
2003-05-19 07:12:09 +00:00
|
|
|
|
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (!change_layout && cur.selection() &&
|
2004-11-24 21:53:46 +00:00
|
|
|
|
cur.selBegin().pit() != cur.selEnd().pit())
|
2002-08-20 15:26:52 +00:00
|
|
|
|
{
|
2004-11-24 21:53:46 +00:00
|
|
|
|
pit_type spit = cur.selBegin().pit();
|
|
|
|
|
pit_type epit = cur.selEnd().pit() + 1;
|
2003-04-09 09:15:20 +00:00
|
|
|
|
while (spit != epit) {
|
2004-03-25 09:16:36 +00:00
|
|
|
|
if (pars_[spit].layout()->name() != current_layout) {
|
2002-08-20 15:26:52 +00:00
|
|
|
|
change_layout = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2003-04-09 09:15:20 +00:00
|
|
|
|
++spit;
|
2002-08-20 15:26:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-05-19 07:12:09 +00:00
|
|
|
|
|
2002-08-20 15:26:52 +00:00
|
|
|
|
if (change_layout) {
|
|
|
|
|
current_layout = layout;
|
2004-02-13 07:30:59 +00:00
|
|
|
|
setLayout(cur, layout);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
bv->owner()->setLayout(layout);
|
|
|
|
|
bv->switchKeyMap();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case LFUN_PASTESELECTION: {
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.clearSelection();
|
2002-08-29 13:41:58 +00:00
|
|
|
|
string const clip = bv->getClipboard();
|
2002-08-20 15:26:52 +00:00
|
|
|
|
if (!clip.empty()) {
|
|
|
|
|
if (cmd.argument == "paragraph")
|
2004-02-13 07:30:59 +00:00
|
|
|
|
insertStringAsParagraphs(cur, clip);
|
2002-08-20 17:31:23 +00:00
|
|
|
|
else
|
2004-02-13 07:30:59 +00:00
|
|
|
|
insertStringAsLines(cur, clip);
|
2002-08-20 15:26:52 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2002-08-27 12:32:04 +00:00
|
|
|
|
case LFUN_GOTOERROR:
|
2004-02-13 11:05:29 +00:00
|
|
|
|
gotoInset(cur, InsetBase::ERROR_CODE, false);
|
2002-08-27 12:32:04 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_GOTONOTE:
|
2004-02-13 11:05:29 +00:00
|
|
|
|
gotoInset(cur, InsetBase::NOTE_CODE, false);
|
2002-08-27 12:32:04 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2003-11-11 10:08:35 +00:00
|
|
|
|
case LFUN_REFERENCE_GOTO: {
|
2004-11-25 19:13:07 +00:00
|
|
|
|
vector<InsetBase_code> tmp;
|
2004-01-26 10:13:15 +00:00
|
|
|
|
tmp.push_back(InsetBase::LABEL_CODE);
|
|
|
|
|
tmp.push_back(InsetBase::REF_CODE);
|
2004-02-13 11:05:29 +00:00
|
|
|
|
gotoInset(cur, tmp, true);
|
2002-08-27 12:32:04 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-27 13:17:22 +00:00
|
|
|
|
case LFUN_QUOTE: {
|
2004-03-25 09:16:36 +00:00
|
|
|
|
lyx::cap::replaceSelection(cur);
|
2004-02-13 07:30:59 +00:00
|
|
|
|
Paragraph & par = cur.paragraph();
|
|
|
|
|
lyx::pos_type pos = cur.pos();
|
2002-08-27 13:17:22 +00:00
|
|
|
|
char c;
|
2004-02-13 07:30:59 +00:00
|
|
|
|
if (pos == 0)
|
2002-08-27 13:17:22 +00:00
|
|
|
|
c = ' ';
|
2004-02-13 07:30:59 +00:00
|
|
|
|
else if (cur.prevInset() && cur.prevInset()->isSpace())
|
2002-08-27 13:17:22 +00:00
|
|
|
|
c = ' ';
|
|
|
|
|
else
|
2004-02-13 07:30:59 +00:00
|
|
|
|
c = par.getChar(pos - 1);
|
2002-08-27 13:17:22 +00:00
|
|
|
|
|
2004-02-13 07:30:59 +00:00
|
|
|
|
LyXLayout_ptr const & style = par.layout();
|
2004-04-03 08:37:12 +00:00
|
|
|
|
|
2003-09-09 09:47:59 +00:00
|
|
|
|
BufferParams const & bufparams = bv->buffer()->params();
|
2004-02-20 10:32:44 +00:00
|
|
|
|
if (!style->pass_thru
|
|
|
|
|
&& par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
|
2004-04-03 08:37:12 +00:00
|
|
|
|
string arg = cmd.argument;
|
2004-02-20 10:32:44 +00:00
|
|
|
|
if (arg == "single")
|
|
|
|
|
cur.insert(new InsetQuotes(c,
|
2004-04-03 08:37:12 +00:00
|
|
|
|
bufparams.quotes_language,
|
2004-02-20 10:32:44 +00:00
|
|
|
|
InsetQuotes::SingleQ));
|
|
|
|
|
else if (arg == "double")
|
|
|
|
|
cur.insert(new InsetQuotes(c,
|
2004-04-03 08:37:12 +00:00
|
|
|
|
bufparams.quotes_language,
|
2004-02-20 10:32:44 +00:00
|
|
|
|
InsetQuotes::DoubleQ));
|
2004-08-13 20:26:26 +00:00
|
|
|
|
else
|
2004-04-03 08:37:12 +00:00
|
|
|
|
cur.insert(new InsetQuotes(c, bufparams));
|
2004-08-12 19:49:25 +00:00
|
|
|
|
cur.posRight();
|
2004-03-18 12:53:43 +00:00
|
|
|
|
}
|
2004-02-04 09:44:12 +00:00
|
|
|
|
else
|
2002-08-27 13:17:22 +00:00
|
|
|
|
bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "\""));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-28 10:45:38 +00:00
|
|
|
|
case LFUN_DATE_INSERT: {
|
2004-03-25 09:16:36 +00:00
|
|
|
|
lyx::cap::replaceSelection(cur);
|
2002-08-27 13:39:27 +00:00
|
|
|
|
time_t now_time_t = time(NULL);
|
|
|
|
|
struct tm * now_tm = localtime(&now_time_t);
|
|
|
|
|
setlocale(LC_TIME, "");
|
|
|
|
|
string arg;
|
|
|
|
|
if (!cmd.argument.empty())
|
|
|
|
|
arg = cmd.argument;
|
|
|
|
|
else
|
|
|
|
|
arg = lyxrc.date_insert_format;
|
|
|
|
|
char datetmp[32];
|
|
|
|
|
int const datetmp_len =
|
|
|
|
|
::strftime(datetmp, 32, arg.c_str(), now_tm);
|
|
|
|
|
|
2003-08-11 09:09:01 +00:00
|
|
|
|
for (int i = 0; i < datetmp_len; i++)
|
2004-02-13 07:30:59 +00:00
|
|
|
|
insertChar(cur, datetmp[i]);
|
2003-08-11 09:09:01 +00:00
|
|
|
|
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.resetAnchor();
|
|
|
|
|
moveCursor(cur, false);
|
2002-08-27 13:39:27 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-28 10:45:38 +00:00
|
|
|
|
case LFUN_MOUSE_TRIPLE:
|
2004-02-06 16:50:29 +00:00
|
|
|
|
if (cmd.button() == mouse_button::button1) {
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorHome(cur);
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.resetAnchor();
|
2004-02-12 16:36:01 +00:00
|
|
|
|
cursorEnd(cur);
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.setSelection();
|
|
|
|
|
bv->haveSelection(cur.selection());
|
2002-08-28 10:45:38 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_MOUSE_DOUBLE:
|
2004-02-06 16:50:29 +00:00
|
|
|
|
if (cmd.button() == mouse_button::button1) {
|
2004-02-13 07:30:59 +00:00
|
|
|
|
selectWord(cur, lyx::WHOLE_WORD_STRICT);
|
2004-01-20 14:25:24 +00:00
|
|
|
|
bv->haveSelection(cur.selection());
|
2002-08-28 10:45:38 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// Single-click on work area
|
2003-11-06 16:43:12 +00:00
|
|
|
|
case LFUN_MOUSE_PRESS: {
|
2004-02-06 16:50:29 +00:00
|
|
|
|
// Right click on a footnote flag opens float menu
|
|
|
|
|
if (cmd.button() == mouse_button::button3) {
|
|
|
|
|
cur.clearSelection();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-28 10:45:38 +00:00
|
|
|
|
// Middle button press pastes if we have a selection
|
|
|
|
|
// We do this here as if the selection was inside an inset
|
|
|
|
|
// it could get cleared on the unlocking of the inset so
|
|
|
|
|
// we have to check this first
|
|
|
|
|
bool paste_internally = false;
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (cmd.button() == mouse_button::button2 && cur.selection()) {
|
2002-08-28 10:45:38 +00:00
|
|
|
|
bv->owner()->dispatch(FuncRequest(LFUN_COPY));
|
|
|
|
|
paste_internally = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clear the selection
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.clearSelection();
|
2003-11-22 14:44:59 +00:00
|
|
|
|
|
2004-02-16 17:26:09 +00:00
|
|
|
|
setCursorFromCoordinates(cur, cmd.x, cmd.y);
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.resetAnchor();
|
2002-08-28 10:45:38 +00:00
|
|
|
|
finishUndo();
|
2004-11-30 01:59:49 +00:00
|
|
|
|
cur.setTargetX();
|
2004-01-30 11:41:12 +00:00
|
|
|
|
|
2004-04-13 17:38:16 +00:00
|
|
|
|
// Has the cursor just left the inset?
|
|
|
|
|
if (bv->cursor().inMathed() && !cur.inMathed())
|
|
|
|
|
bv->cursor().inset().notifyCursorLeaves(bv->cursor());
|
|
|
|
|
|
2004-04-07 08:07:26 +00:00
|
|
|
|
// Set cursor here.
|
|
|
|
|
bv->cursor() = cur;
|
|
|
|
|
|
2002-08-28 10:45:38 +00:00
|
|
|
|
// Insert primary selection with middle mouse
|
|
|
|
|
// if there is a local selection in the current buffer,
|
|
|
|
|
// insert this
|
|
|
|
|
if (cmd.button() == mouse_button::button2) {
|
|
|
|
|
if (paste_internally)
|
|
|
|
|
bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
|
|
|
|
|
else
|
|
|
|
|
bv->owner()->dispatch(FuncRequest(LFUN_PASTESELECTION, "paragraph"));
|
|
|
|
|
}
|
2004-04-07 08:07:26 +00:00
|
|
|
|
|
2002-08-28 10:45:38 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-14 20:34:46 +00:00
|
|
|
|
case LFUN_MOUSE_MOTION: {
|
|
|
|
|
// Only use motion with button 1
|
|
|
|
|
//if (cmd.button() != mouse_button::button1)
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
|
|
// ignore motions deeper nested than the real anchor
|
|
|
|
|
LCursor & bvcur = cur.bv().cursor();
|
2004-08-14 21:56:40 +00:00
|
|
|
|
if (bvcur.anchor_.hasPart(cur)) {
|
2004-11-30 01:59:49 +00:00
|
|
|
|
CursorSlice old = bvcur.top();
|
|
|
|
|
|
|
|
|
|
int const wh = bv->workHeight();
|
|
|
|
|
int const y = std::max(0, std::min(wh - 1, cmd.y));
|
|
|
|
|
|
|
|
|
|
setCursorFromCoordinates(cur, cmd.x, y);
|
|
|
|
|
cur.x_target() = cmd.x;
|
|
|
|
|
if (cmd.y >= wh)
|
|
|
|
|
cursorDown(cur);
|
|
|
|
|
else if (cmd.y < 0)
|
|
|
|
|
cursorUp(cur);
|
2004-08-14 21:56:40 +00:00
|
|
|
|
// This is to allow jumping over large insets
|
2004-11-30 01:59:49 +00:00
|
|
|
|
if (cur.top() == old) {
|
|
|
|
|
if (cmd.y >= wh)
|
2004-08-14 21:56:40 +00:00
|
|
|
|
cursorDown(cur);
|
2004-11-30 01:59:49 +00:00
|
|
|
|
else if (cmd.y < 0)
|
2004-08-14 21:56:40 +00:00
|
|
|
|
cursorUp(cur);
|
|
|
|
|
}
|
2004-08-14 20:34:46 +00:00
|
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
|
if (cur.top() == old)
|
|
|
|
|
cur.noUpdate();
|
|
|
|
|
else {
|
|
|
|
|
// don't set anchor_
|
|
|
|
|
bvcur.setCursor(cur);
|
|
|
|
|
bvcur.selection() = true;
|
|
|
|
|
lyxerr << "MOTION: " << bv->cursor() << endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
cur.undispatched();
|
2004-08-14 20:34:46 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
case LFUN_MOUSE_RELEASE: {
|
2002-08-28 10:45:38 +00:00
|
|
|
|
if (cmd.button() == mouse_button::button2)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// finish selection
|
|
|
|
|
if (cmd.button() == mouse_button::button1)
|
2004-01-20 14:25:24 +00:00
|
|
|
|
bv->haveSelection(cur.selection());
|
2002-08-28 10:45:38 +00:00
|
|
|
|
|
|
|
|
|
bv->switchKeyMap();
|
|
|
|
|
bv->owner()->updateMenubar();
|
2004-04-29 09:54:59 +00:00
|
|
|
|
bv->owner()->updateToolbars();
|
2002-08-28 10:45:38 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-20 13:00:25 +00:00
|
|
|
|
case LFUN_SELFINSERT: {
|
|
|
|
|
if (cmd.argument.empty())
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
// 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).
|
|
|
|
|
|
|
|
|
|
if (lyxrc.auto_region_delete) {
|
2004-01-20 14:25:24 +00:00
|
|
|
|
if (cur.selection())
|
2004-02-13 11:05:29 +00:00
|
|
|
|
cutSelection(cur, false, false);
|
2002-08-29 13:41:58 +00:00
|
|
|
|
bv->haveSelection(false);
|
2002-08-20 13:00:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.clearSelection();
|
2003-08-19 16:46:47 +00:00
|
|
|
|
LyXFont const old_font = real_current_font;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
string::const_iterator cit = cmd.argument.begin();
|
|
|
|
|
string::const_iterator end = cmd.argument.end();
|
|
|
|
|
for (; cit != end; ++cit)
|
|
|
|
|
bv->owner()->getIntl().getTransManager().
|
|
|
|
|
TranslateAndInsert(*cit, this);
|
|
|
|
|
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.resetAnchor();
|
|
|
|
|
moveCursor(cur, false);
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
// real_current_font.number can change so we need to
|
|
|
|
|
// update the minibuffer
|
|
|
|
|
if (old_font != real_current_font)
|
2003-08-19 16:46:47 +00:00
|
|
|
|
bv->updateScrollbar();
|
2002-08-20 15:26:52 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-11 13:59:39 +00:00
|
|
|
|
case LFUN_URL: {
|
|
|
|
|
InsetCommandParams p("url");
|
2003-02-27 13:26:07 +00:00
|
|
|
|
string const data = InsetCommandMailer::params2string("url", p);
|
2003-02-25 14:51:38 +00:00
|
|
|
|
bv->owner()->getDialogs().show("url", data, 0);
|
2002-08-29 13:41:58 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-11 13:59:39 +00:00
|
|
|
|
case LFUN_HTMLURL: {
|
|
|
|
|
InsetCommandParams p("htmlurl");
|
2003-02-27 13:26:07 +00:00
|
|
|
|
string const data = InsetCommandMailer::params2string("url", p);
|
2003-02-25 14:51:38 +00:00
|
|
|
|
bv->owner()->getDialogs().show("url", data, 0);
|
2002-08-29 13:41:58 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-13 20:16:34 +00:00
|
|
|
|
case LFUN_INSERT_LABEL: {
|
2004-04-19 02:39:05 +00:00
|
|
|
|
// Try to generate a valid label
|
|
|
|
|
string const contents = cmd.argument.empty() ?
|
|
|
|
|
cur.getPossibleLabel() : cmd.argument;
|
|
|
|
|
|
|
|
|
|
InsetCommandParams p("label", contents);
|
2003-11-13 20:16:34 +00:00
|
|
|
|
string const data = InsetCommandMailer::params2string("label", p);
|
2004-04-19 02:39:05 +00:00
|
|
|
|
|
|
|
|
|
if (cmd.argument.empty()) {
|
|
|
|
|
bv->owner()->getDialogs().show("label", data, 0);
|
|
|
|
|
} else {
|
|
|
|
|
FuncRequest fr(LFUN_INSET_INSERT, data);
|
|
|
|
|
dispatch(cur, fr);
|
|
|
|
|
}
|
2003-11-13 20:16:34 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-29 13:41:58 +00:00
|
|
|
|
|
2002-08-28 17:33:42 +00:00
|
|
|
|
#if 0
|
|
|
|
|
case LFUN_INSET_LIST:
|
|
|
|
|
case LFUN_INSET_THEOREM:
|
2003-01-17 09:57:50 +00:00
|
|
|
|
case LFUN_INSET_CAPTION:
|
2002-08-28 17:33:42 +00:00
|
|
|
|
#endif
|
|
|
|
|
case LFUN_INSERT_NOTE:
|
2003-11-12 14:38:26 +00:00
|
|
|
|
case LFUN_INSERT_CHARSTYLE:
|
2003-10-07 07:42:15 +00:00
|
|
|
|
case LFUN_INSERT_BOX:
|
2003-08-17 11:28:23 +00:00
|
|
|
|
case LFUN_INSERT_BRANCH:
|
2003-02-21 09:20:18 +00:00
|
|
|
|
case LFUN_INSERT_BIBITEM:
|
2002-08-28 17:33:42 +00:00
|
|
|
|
case LFUN_INSET_ERT:
|
|
|
|
|
case LFUN_INSET_FLOAT:
|
|
|
|
|
case LFUN_INSET_FOOTNOTE:
|
|
|
|
|
case LFUN_INSET_MARGINAL:
|
|
|
|
|
case LFUN_INSET_OPTARG:
|
|
|
|
|
case LFUN_INSET_WIDE_FLOAT:
|
2002-09-10 10:18:58 +00:00
|
|
|
|
case LFUN_INSET_WRAP:
|
2002-08-28 17:33:42 +00:00
|
|
|
|
case LFUN_TABULAR_INSERT:
|
2003-03-13 11:16:56 +00:00
|
|
|
|
case LFUN_ENVIRONMENT_INSERT:
|
2003-01-17 09:57:50 +00:00
|
|
|
|
// Open the inset, and move the current selection
|
|
|
|
|
// inside it.
|
2004-02-13 11:05:29 +00:00
|
|
|
|
doInsertInset(cur, this, cmd, true, true);
|
2004-08-12 19:49:25 +00:00
|
|
|
|
cur.posRight();
|
2003-01-17 09:57:50 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2002-08-28 17:33:42 +00:00
|
|
|
|
case LFUN_INDEX_INSERT:
|
2003-01-17 09:57:50 +00:00
|
|
|
|
// Just open the inset
|
2004-02-13 11:05:29 +00:00
|
|
|
|
doInsertInset(cur, this, cmd, true, false);
|
2004-08-12 19:49:25 +00:00
|
|
|
|
cur.posRight();
|
2003-01-17 09:57:50 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
|
case LFUN_INDEX_PRINT:
|
2002-08-28 17:33:42 +00:00
|
|
|
|
case LFUN_TOC_INSERT:
|
2003-03-11 15:01:29 +00:00
|
|
|
|
case LFUN_HFILL:
|
2003-10-27 12:41:26 +00:00
|
|
|
|
case LFUN_INSERT_LINE:
|
|
|
|
|
case LFUN_INSERT_PAGEBREAK:
|
2003-01-17 09:57:50 +00:00
|
|
|
|
// do nothing fancy
|
2004-02-13 11:05:29 +00:00
|
|
|
|
doInsertInset(cur, this, cmd, false, false);
|
2004-08-12 19:49:25 +00:00
|
|
|
|
cur.posRight();
|
2002-08-28 17:33:42 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2003-10-02 14:42:31 +00:00
|
|
|
|
case LFUN_DEPTH_MIN:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
changeDepth(cur, DEC_DEPTH);
|
2003-10-02 14:42:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_DEPTH_PLUS:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
changeDepth(cur, INC_DEPTH);
|
2003-10-02 14:42:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
case LFUN_MATH_DISPLAY:
|
2004-03-25 09:16:36 +00:00
|
|
|
|
mathDispatch(cur, cmd, true);
|
2004-02-11 14:45:44 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
case LFUN_MATH_IMPORT_SELECTION:
|
|
|
|
|
case LFUN_MATH_MODE:
|
2004-03-25 09:16:36 +00:00
|
|
|
|
mathDispatch(cur, cmd, false);
|
2004-02-11 14:45:44 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_MATH_MACRO:
|
|
|
|
|
if (cmd.argument.empty())
|
|
|
|
|
cur.errorMessage(N_("Missing argument"));
|
|
|
|
|
else {
|
|
|
|
|
string s = cmd.argument;
|
|
|
|
|
string const s1 = token(s, ' ', 1);
|
|
|
|
|
int const nargs = s1.empty() ? 0 : atoi(s1);
|
|
|
|
|
string const s2 = token(s, ' ', 2);
|
|
|
|
|
string const type = s2.empty() ? "newcommand" : s2;
|
2004-04-13 06:27:29 +00:00
|
|
|
|
cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, s2));
|
|
|
|
|
//cur.nextInset()->edit(cur, true);
|
2004-02-11 14:45:44 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_INSERT_MATH:
|
|
|
|
|
case LFUN_INSERT_MATRIX:
|
|
|
|
|
case LFUN_MATH_DELIM: {
|
|
|
|
|
cur.insert(new MathHullInset);
|
|
|
|
|
cur.dispatch(FuncRequest(LFUN_RIGHT));
|
|
|
|
|
cur.dispatch(FuncRequest(LFUN_MATH_MUTATE, "simple"));
|
|
|
|
|
cur.dispatch(cmd);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
break;
|
2004-02-11 14:45:44 +00:00
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2004-02-06 13:59:26 +00:00
|
|
|
|
case LFUN_EMPH: {
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setEmph(LyXFont::TOGGLE);
|
2004-02-13 07:30:59 +00:00
|
|
|
|
toggleAndShow(cur, this, font);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
break;
|
2004-02-06 13:59:26 +00:00
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2004-02-06 13:59:26 +00:00
|
|
|
|
case LFUN_BOLD: {
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setSeries(LyXFont::BOLD_SERIES);
|
2004-02-13 07:30:59 +00:00
|
|
|
|
toggleAndShow(cur, this, font);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
break;
|
2004-02-06 13:59:26 +00:00
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2004-02-06 13:59:26 +00:00
|
|
|
|
case LFUN_NOUN: {
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setNoun(LyXFont::TOGGLE);
|
2004-02-13 07:30:59 +00:00
|
|
|
|
toggleAndShow(cur, this, font);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
break;
|
2004-02-06 13:59:26 +00:00
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2004-02-06 13:59:26 +00:00
|
|
|
|
case LFUN_CODE: {
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
|
2004-02-13 07:30:59 +00:00
|
|
|
|
toggleAndShow(cur, this, font);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
break;
|
2004-02-06 13:59:26 +00:00
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2004-02-06 13:59:26 +00:00
|
|
|
|
case LFUN_SANS: {
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setFamily(LyXFont::SANS_FAMILY);
|
2004-02-13 07:30:59 +00:00
|
|
|
|
toggleAndShow(cur, this, font);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
break;
|
2004-02-06 13:59:26 +00:00
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2004-02-06 13:59:26 +00:00
|
|
|
|
case LFUN_ROMAN: {
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setFamily(LyXFont::ROMAN_FAMILY);
|
2004-02-13 07:30:59 +00:00
|
|
|
|
toggleAndShow(cur, this, font);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
break;
|
2004-02-06 13:59:26 +00:00
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2004-02-06 13:59:26 +00:00
|
|
|
|
case LFUN_DEFAULT: {
|
|
|
|
|
LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
|
2004-02-13 07:30:59 +00:00
|
|
|
|
toggleAndShow(cur, this, font);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
break;
|
2004-02-06 13:59:26 +00:00
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2004-02-06 13:59:26 +00:00
|
|
|
|
case LFUN_UNDERLINE: {
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setUnderbar(LyXFont::TOGGLE);
|
2004-02-13 07:30:59 +00:00
|
|
|
|
toggleAndShow(cur, this, font);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
break;
|
2004-02-06 13:59:26 +00:00
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2004-02-06 13:59:26 +00:00
|
|
|
|
case LFUN_FONT_SIZE: {
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setLyXSize(cmd.argument);
|
2004-02-13 07:30:59 +00:00
|
|
|
|
toggleAndShow(cur, this, font);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
break;
|
2004-02-06 13:59:26 +00:00
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2004-02-06 13:59:26 +00:00
|
|
|
|
case LFUN_LANGUAGE: {
|
|
|
|
|
Language const * lang = languages.getLanguage(cmd.argument);
|
|
|
|
|
if (!lang)
|
|
|
|
|
break;
|
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
font.setLanguage(lang);
|
2004-02-13 07:30:59 +00:00
|
|
|
|
toggleAndShow(cur, this, font);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
bv->switchKeyMap();
|
|
|
|
|
break;
|
2004-02-06 13:59:26 +00:00
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_FREEFONT_APPLY:
|
2004-02-13 07:30:59 +00:00
|
|
|
|
toggleAndShow(cur, this, freefont, toggleall);
|
|
|
|
|
cur.message(_("Character set"));
|
2003-11-10 09:06:48 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2004-02-06 13:59:26 +00:00
|
|
|
|
// Set the freefont using the contents of \param data dispatched from
|
|
|
|
|
// the frontends and apply it at the current cursor location.
|
|
|
|
|
case LFUN_FREEFONT_UPDATE: {
|
|
|
|
|
LyXFont font;
|
|
|
|
|
bool toggle;
|
|
|
|
|
if (bv_funcs::string2font(cmd.argument, font, toggle)) {
|
|
|
|
|
freefont = font;
|
|
|
|
|
toggleall = toggle;
|
2004-02-13 07:30:59 +00:00
|
|
|
|
toggleAndShow(cur, this, freefont, toggleall);
|
|
|
|
|
cur.message(_("Character set"));
|
2004-02-06 13:59:26 +00:00
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
break;
|
2004-02-06 13:59:26 +00:00
|
|
|
|
}
|
2003-11-22 14:44:59 +00:00
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
case LFUN_FINISHED_LEFT:
|
2004-08-14 15:55:22 +00:00
|
|
|
|
lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
|
2003-11-10 09:06:48 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_FINISHED_RIGHT:
|
2004-08-14 15:55:22 +00:00
|
|
|
|
lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
|
2004-03-25 09:16:36 +00:00
|
|
|
|
++cur.pos();
|
2003-11-10 09:06:48 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_FINISHED_UP:
|
2004-08-14 15:55:22 +00:00
|
|
|
|
lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
|
2004-02-20 17:19:53 +00:00
|
|
|
|
cursorUp(cur);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_FINISHED_DOWN:
|
2004-08-14 15:55:22 +00:00
|
|
|
|
lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
|
2004-02-20 17:19:53 +00:00
|
|
|
|
cursorDown(cur);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2004-02-06 13:59:26 +00:00
|
|
|
|
case LFUN_LAYOUT_PARAGRAPH: {
|
|
|
|
|
string data;
|
|
|
|
|
params2string(cur.paragraph(), data);
|
|
|
|
|
data = "show\n" + data;
|
|
|
|
|
bv->owner()->getDialogs().show("paragraph", data);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case LFUN_PARAGRAPH_UPDATE: {
|
|
|
|
|
if (!bv->owner()->getDialogs().visible("paragraph"))
|
|
|
|
|
break;
|
|
|
|
|
string data;
|
|
|
|
|
params2string(cur.paragraph(), data);
|
|
|
|
|
|
|
|
|
|
// Will the paragraph accept changes from the dialog?
|
2004-03-18 12:53:43 +00:00
|
|
|
|
InsetBase & inset = cur.inset();
|
|
|
|
|
bool const accept = !inset.forceDefaultParagraphs(&inset);
|
2004-02-06 13:59:26 +00:00
|
|
|
|
|
|
|
|
|
data = "update " + tostr(accept) + '\n' + data;
|
|
|
|
|
bv->owner()->getDialogs().update("paragraph", data);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
bv->owner()->getLyXFunc().handleKeyFunc(cmd.action);
|
|
|
|
|
if (!cmd.argument.empty())
|
|
|
|
|
bv->owner()->getIntl().getTransManager()
|
|
|
|
|
.TranslateAndInsert(cmd.argument[0], this);
|
|
|
|
|
break;
|
|
|
|
|
|
2004-02-12 16:36:01 +00:00
|
|
|
|
case LFUN_FLOAT_LIST: {
|
|
|
|
|
LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
|
|
|
|
|
if (tclass.floats().typeExist(cmd.argument)) {
|
|
|
|
|
// not quite sure if we want this...
|
|
|
|
|
recordUndo(cur);
|
|
|
|
|
cur.clearSelection();
|
|
|
|
|
breakParagraph(cur);
|
|
|
|
|
|
|
|
|
|
if (cur.lastpos() != 0) {
|
2004-02-20 17:19:53 +00:00
|
|
|
|
cursorLeft(cur);
|
2004-02-12 16:36:01 +00:00
|
|
|
|
breakParagraph(cur);
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-13 07:30:59 +00:00
|
|
|
|
setLayout(cur, tclass.defaultLayoutName());
|
2004-02-13 11:05:29 +00:00
|
|
|
|
setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
|
2004-03-08 21:14:45 +00:00
|
|
|
|
insertInset(cur, new InsetFloatList(cmd.argument));
|
2004-11-02 14:25:14 +00:00
|
|
|
|
cur.posRight();
|
2004-02-12 16:36:01 +00:00
|
|
|
|
} else {
|
|
|
|
|
lyxerr << "Non-existent float type: "
|
|
|
|
|
<< cmd.argument << endl;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-13 07:30:59 +00:00
|
|
|
|
case LFUN_ACCEPT_CHANGE: {
|
|
|
|
|
acceptChange(cur);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case LFUN_REJECT_CHANGE: {
|
|
|
|
|
rejectChange(cur);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case LFUN_THESAURUS_ENTRY: {
|
|
|
|
|
string arg = cmd.argument;
|
|
|
|
|
if (arg.empty()) {
|
|
|
|
|
arg = cur.selectionAsString(false);
|
|
|
|
|
// FIXME
|
|
|
|
|
if (arg.size() > 100 || arg.empty()) {
|
|
|
|
|
// Get word or selection
|
|
|
|
|
selectWordWhenUnderCursor(cur, lyx::WHOLE_WORD);
|
|
|
|
|
arg = cur.selectionAsString(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bv->owner()->getDialogs().show("thesaurus", arg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-13 11:05:29 +00:00
|
|
|
|
case LFUN_PARAGRAPH_APPLY: {
|
|
|
|
|
// Given data, an encoding of the ParagraphParameters
|
|
|
|
|
// generated in the Paragraph dialog, this function sets
|
|
|
|
|
// the current paragraph appropriately.
|
|
|
|
|
istringstream is(cmd.argument);
|
|
|
|
|
LyXLex lex(0, 0);
|
|
|
|
|
lex.setStream(is);
|
|
|
|
|
ParagraphParameters params;
|
|
|
|
|
params.read(lex);
|
|
|
|
|
setParagraph(cur,
|
|
|
|
|
params.spacing(),
|
|
|
|
|
params.align(),
|
|
|
|
|
params.labelWidthString(),
|
|
|
|
|
params.noindent());
|
|
|
|
|
cur.message(_("Paragraph layout set"));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-18 12:53:43 +00:00
|
|
|
|
case LFUN_INSET_DIALOG_SHOW: {
|
|
|
|
|
InsetBase * inset = cur.nextInset();
|
|
|
|
|
if (inset) {
|
|
|
|
|
FuncRequest fr(LFUN_INSET_DIALOG_SHOW);
|
|
|
|
|
inset->dispatch(cur, fr);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-20 17:19:53 +00:00
|
|
|
|
case LFUN_ESCAPE:
|
2004-03-25 09:16:36 +00:00
|
|
|
|
if (cur.selection()) {
|
2004-02-20 17:19:53 +00:00
|
|
|
|
cur.selection() = false;
|
2004-03-25 09:16:36 +00:00
|
|
|
|
} else {
|
|
|
|
|
cur.undispatched();
|
2004-03-18 12:53:43 +00:00
|
|
|
|
cmd = FuncRequest(LFUN_FINISHED_LEFT);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
}
|
2004-02-20 17:19:53 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2002-08-20 13:00:25 +00:00
|
|
|
|
default:
|
2004-03-01 17:12:09 +00:00
|
|
|
|
cur.undispatched();
|
2004-02-20 17:19:53 +00:00
|
|
|
|
break;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
}
|
2004-05-18 07:18:02 +00:00
|
|
|
|
|
|
|
|
|
// avoid to update when navigating
|
|
|
|
|
if (moving
|
|
|
|
|
&& &sl.inset() == &cur.inset()
|
|
|
|
|
&& sl.idx() == cur.idx()
|
|
|
|
|
&& sel == false
|
|
|
|
|
&& cur.selection() == false)
|
|
|
|
|
cur.noUpdate();
|
2004-02-20 17:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-08-20 13:00:25 +00:00
|
|
|
|
|
2004-03-18 13:57:20 +00:00
|
|
|
|
bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
|
2004-12-02 11:32:14 +00:00
|
|
|
|
FuncStatus & flag) const
|
2004-02-20 17:19:53 +00:00
|
|
|
|
{
|
2004-03-18 13:57:20 +00:00
|
|
|
|
BOOST_ASSERT(cur.text() == this);
|
|
|
|
|
LyXFont const & font = real_current_font;
|
|
|
|
|
bool enable = true;
|
|
|
|
|
|
|
|
|
|
switch (cmd.action) {
|
|
|
|
|
|
|
|
|
|
case LFUN_DEPTH_MIN:
|
|
|
|
|
enable = changeDepthAllowed(cur, DEC_DEPTH);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_DEPTH_PLUS:
|
|
|
|
|
enable = changeDepthAllowed(cur, INC_DEPTH);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_OPTARG:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
enable = numberOfOptArgs(cur.paragraph())
|
2004-11-19 16:17:52 +00:00
|
|
|
|
< cur.paragraph().layout()->optionalargs;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_APPENDIX:
|
|
|
|
|
flag.setOnOff(cur.paragraph().params().startOfAppendix());
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
// the functions which insert insets
|
2004-11-25 19:13:07 +00:00
|
|
|
|
InsetBase::Code code = InsetBase::NO_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
switch (cmd.action) {
|
|
|
|
|
case LFUN_DIALOG_SHOW_NEW_INSET:
|
|
|
|
|
if (cmd.argument == "bibitem")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::BIBITEM_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
else if (cmd.argument == "bibtex")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::BIBTEX_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
else if (cmd.argument == "box")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::BOX_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
else if (cmd.argument == "branch")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::BRANCH_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
else if (cmd.argument == "citation")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::CITE_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
else if (cmd.argument == "ert")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::ERT_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
else if (cmd.argument == "external")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::EXTERNAL_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
else if (cmd.argument == "float")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::FLOAT_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
else if (cmd.argument == "graphics")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::GRAPHICS_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
else if (cmd.argument == "include")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::INCLUDE_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
else if (cmd.argument == "index")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::INDEX_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
else if (cmd.argument == "label")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::LABEL_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
else if (cmd.argument == "note")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::NOTE_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
else if (cmd.argument == "ref")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::REF_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
else if (cmd.argument == "toc")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::TOC_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
else if (cmd.argument == "url")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::URL_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
else if (cmd.argument == "vspace")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::VSPACE_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
else if (cmd.argument == "wrap")
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::WRAP_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_ERT:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::ERT_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_INSET_FOOTNOTE:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::FOOT_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_TABULAR_INSERT:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::TABULAR_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_INSET_MARGINAL:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::MARGIN_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_INSET_FLOAT:
|
|
|
|
|
case LFUN_INSET_WIDE_FLOAT:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::FLOAT_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_INSET_WRAP:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::WRAP_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_FLOAT_LIST:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::FLOAT_LIST_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
#if 0
|
|
|
|
|
case LFUN_INSET_LIST:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::LIST_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_INSET_THEOREM:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::THEOREM_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
case LFUN_INSET_CAPTION:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::CAPTION_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_INSERT_NOTE:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::NOTE_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_INSERT_CHARSTYLE:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::CHARSTYLE_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
if (buf->params().getLyXTextClass().charstyles().empty())
|
|
|
|
|
enable = false;
|
|
|
|
|
break;
|
|
|
|
|
case LFUN_INSERT_BOX:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::BOX_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_INSERT_BRANCH:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::BRANCH_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
if (buf->params().branchlist().empty())
|
|
|
|
|
enable = false;
|
|
|
|
|
break;
|
|
|
|
|
case LFUN_INSERT_LABEL:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::LABEL_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_INSET_OPTARG:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::OPTARG_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_ENVIRONMENT_INSERT:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::BOX_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_INDEX_INSERT:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::INDEX_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_INDEX_PRINT:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::INDEX_PRINT_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_TOC_INSERT:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::TOC_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_HTMLURL:
|
|
|
|
|
case LFUN_URL:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::URL_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_QUOTE:
|
|
|
|
|
// always allow this, since we will inset a raw quote
|
|
|
|
|
// if an inset is not allowed.
|
|
|
|
|
break;
|
|
|
|
|
case LFUN_HYPHENATION:
|
|
|
|
|
case LFUN_LIGATURE_BREAK:
|
|
|
|
|
case LFUN_HFILL:
|
|
|
|
|
case LFUN_MENU_SEPARATOR:
|
|
|
|
|
case LFUN_LDOTS:
|
|
|
|
|
case LFUN_END_OF_SENTENCE:
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::SPECIALCHAR_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_SPACE_INSERT:
|
|
|
|
|
// slight hack: we know this is allowed in math mode
|
|
|
|
|
if (cur.inTexted())
|
2004-11-25 19:13:07 +00:00
|
|
|
|
code = InsetBase::SPACE_CODE;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case LFUN_INSET_DIALOG_SHOW: {
|
|
|
|
|
InsetBase * inset = cur.nextInset();
|
|
|
|
|
enable = inset;
|
|
|
|
|
if (inset) {
|
|
|
|
|
code = inset->lyxCode();
|
2004-11-25 19:13:07 +00:00
|
|
|
|
if (!(code == InsetBase::INCLUDE_CODE
|
|
|
|
|
|| code == InsetBase::BIBTEX_CODE
|
|
|
|
|
|| code == InsetBase::FLOAT_LIST_CODE
|
|
|
|
|
|| code == InsetBase::TOC_CODE))
|
2004-03-18 13:57:20 +00:00
|
|
|
|
enable = false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-25 19:13:07 +00:00
|
|
|
|
if (code != InsetBase::NO_CODE
|
2004-03-18 13:57:20 +00:00
|
|
|
|
&& (cur.empty() || !cur.inset().insetAllowed(code)))
|
|
|
|
|
enable = false;
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
case LFUN_DIALOG_SHOW_NEW_INSET:
|
|
|
|
|
case LFUN_INSET_ERT:
|
|
|
|
|
case LFUN_INSERT_BOX:
|
|
|
|
|
case LFUN_INSERT_BRANCH:
|
|
|
|
|
case LFUN_ENVIRONMENT_INSERT:
|
|
|
|
|
case LFUN_INDEX_INSERT:
|
|
|
|
|
case LFUN_INDEX_PRINT:
|
|
|
|
|
case LFUN_TOC_INSERT:
|
|
|
|
|
case LFUN_HTMLURL:
|
|
|
|
|
case LFUN_URL:
|
|
|
|
|
case LFUN_QUOTE:
|
|
|
|
|
case LFUN_HYPHENATION:
|
|
|
|
|
case LFUN_LIGATURE_BREAK:
|
|
|
|
|
case LFUN_HFILL:
|
|
|
|
|
case LFUN_MENU_SEPARATOR:
|
|
|
|
|
case LFUN_LDOTS:
|
|
|
|
|
case LFUN_END_OF_SENTENCE:
|
|
|
|
|
case LFUN_SPACE_INSERT:
|
2004-04-03 08:37:12 +00:00
|
|
|
|
case LFUN_INSET_DIALOG_SHOW:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_EMPH:
|
|
|
|
|
flag.setOnOff(font.emph() == LyXFont::ON);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_NOUN:
|
|
|
|
|
flag.setOnOff(font.noun() == LyXFont::ON);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_BOLD:
|
|
|
|
|
flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_SANS:
|
|
|
|
|
flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_ROMAN:
|
|
|
|
|
flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_CODE:
|
|
|
|
|
flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_DELETE_WORD_FORWARD:
|
|
|
|
|
case LFUN_DELETE_WORD_BACKWARD:
|
|
|
|
|
case LFUN_DELETE_LINE_FORWARD:
|
|
|
|
|
case LFUN_WORDRIGHT:
|
|
|
|
|
case LFUN_WORDLEFT:
|
|
|
|
|
case LFUN_RIGHT:
|
|
|
|
|
case LFUN_RIGHTSEL:
|
|
|
|
|
case LFUN_LEFT:
|
|
|
|
|
case LFUN_LEFTSEL:
|
|
|
|
|
case LFUN_UP:
|
|
|
|
|
case LFUN_UPSEL:
|
|
|
|
|
case LFUN_DOWN:
|
|
|
|
|
case LFUN_DOWNSEL:
|
|
|
|
|
case LFUN_UP_PARAGRAPHSEL:
|
|
|
|
|
case LFUN_DOWN_PARAGRAPHSEL:
|
|
|
|
|
case LFUN_PRIORSEL:
|
|
|
|
|
case LFUN_NEXTSEL:
|
|
|
|
|
case LFUN_HOMESEL:
|
|
|
|
|
case LFUN_ENDSEL:
|
|
|
|
|
case LFUN_WORDRIGHTSEL:
|
|
|
|
|
case LFUN_WORDLEFTSEL:
|
|
|
|
|
case LFUN_WORDSEL:
|
|
|
|
|
case LFUN_UP_PARAGRAPH:
|
|
|
|
|
case LFUN_DOWN_PARAGRAPH:
|
|
|
|
|
case LFUN_PRIOR:
|
|
|
|
|
case LFUN_NEXT:
|
|
|
|
|
case LFUN_HOME:
|
|
|
|
|
case LFUN_END:
|
|
|
|
|
case LFUN_BREAKLINE:
|
|
|
|
|
case LFUN_DELETE:
|
|
|
|
|
case LFUN_DELETE_SKIP:
|
|
|
|
|
case LFUN_BACKSPACE:
|
|
|
|
|
case LFUN_BACKSPACE_SKIP:
|
|
|
|
|
case LFUN_BREAKPARAGRAPH:
|
|
|
|
|
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
|
|
|
|
|
case LFUN_BREAKPARAGRAPH_SKIP:
|
|
|
|
|
case LFUN_PARAGRAPH_SPACING:
|
|
|
|
|
case LFUN_INSET_APPLY:
|
|
|
|
|
case LFUN_INSET_INSERT:
|
2004-03-30 12:36:33 +00:00
|
|
|
|
case LFUN_NEXT_INSET_TOGGLE:
|
2004-03-18 13:57:20 +00:00
|
|
|
|
case LFUN_UPCASE_WORD:
|
|
|
|
|
case LFUN_LOWCASE_WORD:
|
|
|
|
|
case LFUN_CAPITALIZE_WORD:
|
|
|
|
|
case LFUN_TRANSPOSE_CHARS:
|
|
|
|
|
case LFUN_PASTE:
|
|
|
|
|
case LFUN_CUT:
|
|
|
|
|
case LFUN_COPY:
|
|
|
|
|
case LFUN_GETXY:
|
|
|
|
|
case LFUN_SETXY:
|
|
|
|
|
case LFUN_GETFONT:
|
|
|
|
|
case LFUN_GETLAYOUT:
|
|
|
|
|
case LFUN_LAYOUT:
|
|
|
|
|
case LFUN_PASTESELECTION:
|
|
|
|
|
case LFUN_GOTOERROR:
|
|
|
|
|
case LFUN_GOTONOTE:
|
|
|
|
|
case LFUN_REFERENCE_GOTO:
|
|
|
|
|
case LFUN_DATE_INSERT:
|
|
|
|
|
case LFUN_SELFINSERT:
|
|
|
|
|
case LFUN_INSERT_LABEL:
|
|
|
|
|
case LFUN_INSERT_NOTE:
|
|
|
|
|
case LFUN_INSERT_CHARSTYLE:
|
|
|
|
|
case LFUN_INSERT_BIBITEM:
|
|
|
|
|
case LFUN_INSET_FLOAT:
|
|
|
|
|
case LFUN_INSET_FOOTNOTE:
|
|
|
|
|
case LFUN_INSET_MARGINAL:
|
|
|
|
|
case LFUN_INSET_WIDE_FLOAT:
|
|
|
|
|
case LFUN_INSET_WRAP:
|
|
|
|
|
case LFUN_TABULAR_INSERT:
|
|
|
|
|
case LFUN_INSERT_LINE:
|
|
|
|
|
case LFUN_INSERT_PAGEBREAK:
|
|
|
|
|
case LFUN_MATH_DISPLAY:
|
|
|
|
|
case LFUN_MATH_IMPORT_SELECTION:
|
|
|
|
|
case LFUN_MATH_MODE:
|
|
|
|
|
case LFUN_MATH_MACRO:
|
|
|
|
|
case LFUN_INSERT_MATH:
|
|
|
|
|
case LFUN_INSERT_MATRIX:
|
|
|
|
|
case LFUN_MATH_DELIM:
|
|
|
|
|
case LFUN_DEFAULT:
|
|
|
|
|
case LFUN_UNDERLINE:
|
|
|
|
|
case LFUN_FONT_SIZE:
|
|
|
|
|
case LFUN_LANGUAGE:
|
|
|
|
|
case LFUN_FREEFONT_APPLY:
|
|
|
|
|
case LFUN_FREEFONT_UPDATE:
|
|
|
|
|
case LFUN_LAYOUT_PARAGRAPH:
|
|
|
|
|
case LFUN_PARAGRAPH_UPDATE:
|
|
|
|
|
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:
|
|
|
|
|
case LFUN_FLOAT_LIST:
|
|
|
|
|
case LFUN_ACCEPT_CHANGE:
|
|
|
|
|
case LFUN_REJECT_CHANGE:
|
|
|
|
|
case LFUN_THESAURUS_ENTRY:
|
|
|
|
|
case LFUN_PARAGRAPH_APPLY:
|
|
|
|
|
case LFUN_ESCAPE:
|
2004-03-30 12:36:33 +00:00
|
|
|
|
case LFUN_KEYMAP_TOGGLE:
|
2004-08-13 20:14:32 +00:00
|
|
|
|
case LFUN_ENDBUF:
|
|
|
|
|
case LFUN_BEGINNINGBUF:
|
2004-11-30 01:59:49 +00:00
|
|
|
|
case LFUN_BEGINNINGBUFSEL:
|
|
|
|
|
case LFUN_ENDBUFSEL:
|
|
|
|
|
// these are handled in our dispatch()
|
2004-08-13 20:14:32 +00:00
|
|
|
|
enable = true;
|
|
|
|
|
break;
|
|
|
|
|
|
2004-03-18 13:57:20 +00:00
|
|
|
|
default:
|
2004-12-02 11:32:14 +00:00
|
|
|
|
return false;
|
2004-03-18 13:57:20 +00:00
|
|
|
|
}
|
|
|
|
|
flag.enabled(enable);
|
|
|
|
|
return true;
|
2002-08-20 13:00:25 +00:00
|
|
|
|
}
|