#include "Lexer.h"
#include "LyXRC.h"
#include "Paragraph.h"
-#include "paragraph_funcs.h"
#include "ParagraphParameters.h"
#include "TextClass.h"
#include "TextMetrics.h"
#include "frontends/Application.h"
#include "frontends/Clipboard.h"
-#include "frontends/LyXView.h"
#include "frontends/Selection.h"
-#include "frontends/WorkArea.h"
#include "insets/InsetCollapsable.h"
#include "insets/InsetCommand.h"
return;
}
cur.recordUndo();
- docstring const save_selection = grabAndEraseSelection(cur);
- selClearOrDel(cur);
- // replaceSelection(cur);
+ docstring sel = cur.selectionAsString(false);
+
+ // It may happen that sel is empty but there is a selection
+ replaceSelection(cur);
cur.insert(new InsetMathHull(hullRegexp));
cur.nextInset()->edit(cur, true);
- cur.niceInsert(save_selection);
+ cur.niceInsert(sel);
cur.message(_("Regexp editor mode"));
}
break;
}
- // Do we need to set insets' buffer_ members, because we copied
- // some stuff? We'll assume we do and reset it otherwise.
- bool set_buffers = true;
-
switch (mode) {
case OutlineUp: {
if (start == pars.begin())
pit_type const len = distance(start, finish);
pit_type const deletepit = pit + len;
buf.undo().recordUndo(cur, ATOMIC_UNDO, newpit, deletepit - 1);
- pars.insert(dest, start, finish);
- start = boost::next(pars.begin(), deletepit);
- pit = newpit;
- pars.erase(start, finish);
+ pars.splice(dest, start, finish);
+ cur.pit() = newpit;
break;
}
case OutlineDown: {
}
// One such was found:
pit_type newpit = distance(bgn, dest);
- pit_type const len = distance(start, finish);
buf.undo().recordUndo(cur, ATOMIC_UNDO, pit, newpit - 1);
- pars.insert(dest, start, finish);
- start = boost::next(bgn, pit);
- pit = newpit - len;
- pars.erase(start, finish);
+ pit_type const len = distance(start, finish);
+ pars.splice(dest, start, finish);
+ cur.pit() = newpit - len;
break;
}
case OutlineIn: {
}
}
}
- set_buffers = false;
break;
}
case OutlineOut: {
}
}
}
- set_buffers = false;
break;
}
}
- if (set_buffers)
- // FIXME This only really needs doing for the newly introduced
- // paragraphs. Something like:
- // pit_type const numpars = distance(start, finish);
- // start = boost::next(bgn, pit);
- // finish = boost::next(start, numpars);
- // for (; start != finish; ++start)
- // start->setBuffer(buf);
- // But while this seems to work, it is kind of fragile.
- buf.inset().setBuffer(buf);
}
pit_type const pit = cur.pit();
recUndo(cur, pit, pit + 1);
cur.finishUndo();
- swap(pars_[pit], pars_[pit + 1]);
+ pars_.swap(pit, pit + 1);
cur.buffer()->updateLabels();
needsUpdate = true;
++cur.pit();
pit_type const pit = cur.pit();
recUndo(cur, pit - 1, pit);
cur.finishUndo();
- swap(pars_[pit], pars_[pit - 1]);
+ pars_.swap(pit, pit - 1);
cur.buffer()->updateLabels();
--cur.pit();
needsUpdate = true;
case LFUN_INSET_BEGIN:
case LFUN_INSET_BEGIN_SELECT:
needsUpdate |= cur.selHandle(cmd.action == LFUN_INSET_BEGIN_SELECT);
- if (cur.depth() == 1 || cur.pos() > 0)
+ if (cur.depth() == 1 || !cur.top().at_begin())
needsUpdate |= cursorTop(cur);
else
cur.undispatched();
case LFUN_INSET_END:
case LFUN_INSET_END_SELECT:
needsUpdate |= cur.selHandle(cmd.action == LFUN_INSET_END_SELECT);
- if (cur.depth() == 1 || cur.pos() < cur.lastpos())
+ if (cur.depth() == 1 || !cur.top().at_end())
needsUpdate |= cursorBottom(cur);
else
cur.undispatched();
cur.updateFlags(Update::FitCursor);
break;
+ case LFUN_INSET_SELECT_ALL:
+ if (cur.depth() == 1 || !cur.selection() || !cur.selBegin().at_begin()
+ || !cur.selEnd().at_end()) {
+ needsUpdate |= cur.selHandle(false);
+ needsUpdate |= cursorTop(cur);
+ needsUpdate |= cur.selHandle(true);
+ needsUpdate |= cursorBottom(cur);
+ } else
+ cur.undispatched();
+ cur.updateFlags(Update::FitCursor);
+ break;
+
case LFUN_CHAR_FORWARD:
case LFUN_CHAR_FORWARD_SELECT:
//LYXERR0(" LFUN_CHAR_FORWARD[SEL]:\n" << cur);
case LFUN_ACCENT_HUNGARIAN_UMLAUT:
case LFUN_ACCENT_CIRCLE:
case LFUN_ACCENT_OGONEK:
- theLyXFunc().handleKeyFunc(cmd.action);
+ theApp()->handleKeyFunc(cmd.action);
if (!cmd.argument().empty())
// FIXME: Are all these characters encoded in one byte in utf8?
bv->translateAndInsert(cmd.argument()[0], this, cur);
break;
}
- if (lyxrc.spellcheck_continuously && cur.inTexted())
- // Take this opportunity to spellcheck current word.
- cur.paragraph().isMisspelled(cur.pos());
-
needsUpdate |= (cur.pos() != cur.lastpos()) && cur.selection();
// FIXME: The cursor flag is reset two lines below
case LFUN_INSET_END:
case LFUN_INSET_BEGIN_SELECT:
case LFUN_INSET_END_SELECT:
+ case LFUN_INSET_SELECT_ALL:
case LFUN_UNICODE_INSERT:
// these are handled in our dispatch()
enable = true;
case LFUN_FONT_UWAVE:
case LFUN_LABEL_GOTO:
case LFUN_LAYOUT_TABULAR:
- case LFUN_MENU_OPEN:
case LFUN_NOACTION:
case LFUN_NOTE_NEXT:
case LFUN_REFERENCE_NEXT:
- case LFUN_SERVER_GOTO_FILE_ROW:
- case LFUN_SERVER_NOTIFY:
case LFUN_SERVER_SET_XY:
case LFUN_TEXTSTYLE_APPLY:
case LFUN_TEXTSTYLE_UPDATE: