/**
- * \file text3.cpp
+ * \file Text3.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Asger Alstrup
- * \author Lars Gullik Bjønnes
+ * \author Lars Gullik Bjønnes
* \author Alfredo Braunstein
* \author Angus Leeming
* \author John Levon
- * \author André Pönitz
+ * \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#include "frontends/Clipboard.h"
#include "frontends/Selection.h"
+#include "frontends/Application.h"
+#include "frontends/LyXView.h"
+#include "frontends/WorkArea.h"
#include "insets/InsetCollapsable.h"
#include "insets/InsetCommand.h"
using cap::pasteClipboardText;
using cap::pasteClipboardGraphics;
using cap::replaceSelection;
+using cap::grabAndEraseSelection;
+using cap::selClearOrDel;
// globals...
static Font freefont(ignore_font, ignore_language);
istringstream is(selstr);
Lexer lex;
lex.setStream(is);
- formula->readQuiet(lex);
- if (formula->getType() == hullNone) {
+ if (!formula->readQuiet(lex)) {
// No valid formula, let's try with delims
is.str("$" + selstr + "$");
lex.setStream(is);
- formula->readQuiet(lex);
- if (formula->getType() == hullNone) {
+ if (!formula->readQuiet(lex)) {
// Still not valid, leave it as is
valid = false;
delete formula;
}
+void regexpDispatch(Cursor & cur, FuncRequest const & cmd)
+{
+ BOOST_ASSERT(cmd.action == LFUN_REGEXP_MODE);
+ if (cur.inRegexped()) {
+ cur.message(_("Already in regexp mode"));
+ return;
+ }
+ cur.recordUndo();
+ docstring const save_selection = grabAndEraseSelection(cur);
+ selClearOrDel(cur);
+ // replaceSelection(cur);
+
+ cur.insert(new InsetMathHull(hullRegexp));
+ cur.nextInset()->edit(cur, true);
+ cur.niceInsert(save_selection);
+
+ cur.message(_("Regexp editor mode"));
+}
+
+
static void specialChar(Cursor & cur, InsetSpecialChar::Kind kind)
{
cur.recordUndo();
if (edit)
inset->edit(cur, true);
// Now put this into inset
- static_cast<InsetCollapsable *>(inset)->text().insertStringAsParagraphs(cur, ds);
+ static_cast<InsetCollapsable *>(inset)->
+ text().insertStringAsParagraphs(cur, ds);
return true;
}
recUndo(cur, pit, pit + 1);
cur.finishUndo();
swap(pars_[pit], pars_[pit + 1]);
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
needsUpdate = true;
++cur.pit();
break;
recUndo(cur, pit - 1, pit);
cur.finishUndo();
swap(pars_[pit], pars_[pit - 1]);
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
--cur.pit();
needsUpdate = true;
break;
par.params().startOfAppendix(start);
// we can set the refreshing parameters now
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
break;
}
case LFUN_WORD_DELETE_FORWARD:
- if (cur.selection()) {
+ if (cur.selection())
cutSelection(cur, true, false);
- } else
+ else
deleteWordForward(cur);
finishChange(cur, false);
break;
// stop/start the selection
bool select = cmd.action == LFUN_DOWN_SELECT ||
cmd.action == LFUN_UP_SELECT;
- cur.selHandle(select);
// move cursor up/down
bool up = cmd.action == LFUN_UP_SELECT || cmd.action == LFUN_UP;
- bool const successful = cur.upDownInText(up, needsUpdate);
- if (successful) {
- // redraw if you leave mathed (for the decorations)
+ bool const atFirstOrLastRow = cur.atFirstOrLastRow(up);
+
+ if (!atFirstOrLastRow) {
+ needsUpdate |= cur.selHandle(select);
+ cur.selHandle(select);
+ cur.upDownInText(up, needsUpdate);
needsUpdate |= cur.beforeDispatchCursor().inMathed();
- } else
+ } else {
+ // if the cursor cannot be moved up or down do not remove
+ // the selection right now, but wait for the next dispatch.
+ if (select)
+ needsUpdate |= cur.selHandle(select);
+ cur.upDownInText(up, needsUpdate);
cur.undispatched();
+ }
break;
}
cur.posForward();
// Some insets are numbered, others are shown in the outline pane so
// let's update the labels and the toc backend.
- updateLabels(bv->buffer());
+ bv->buffer().updateLabels();
break;
case LFUN_TABULAR_INSERT:
// date metrics.
FuncRequest cmd_caption(LFUN_CAPTION_INSERT);
doInsertInset(cur, cur.text(), cmd_caption, true, false);
- updateLabels(bv->buffer());
+ bv->buffer().updateLabels();
cur.updateFlags(Update::Force);
// FIXME: When leaving the Float (or Wrap) inset we should
// delete any empty paragraph left above or below the
mathDispatch(cur, cmd, true);
break;
+ case LFUN_REGEXP_MODE:
+ regexpDispatch(cur, cmd);
+ break;
+
case LFUN_MATH_MODE:
if (cmd.argument() == "on")
// don't pass "on" as argument
case LFUN_OUTLINE_UP:
outline(OutlineUp, cur);
setCursor(cur, cur.pit(), 0);
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
needsUpdate = true;
break;
case LFUN_OUTLINE_DOWN:
outline(OutlineDown, cur);
setCursor(cur, cur.pit(), 0);
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
needsUpdate = true;
break;
case LFUN_OUTLINE_IN:
outline(OutlineIn, cur);
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
needsUpdate = true;
break;
case LFUN_OUTLINE_OUT:
outline(OutlineOut, cur);
- updateLabels(cur.buffer());
+ cur.buffer().updateLabels();
needsUpdate = true;
break;