cur.recordUndo();
if (cmd.action() == LFUN_ARGUMENT_INSERT) {
bool cotextinsert = false;
- InsetArgument const * const ia = static_cast<InsetArgument const *>(inset);
+ InsetArgument * const ia = static_cast<InsetArgument *>(inset);
Layout const & lay = cur.paragraph().layout();
Layout::LaTeXArgMap args = lay.args();
Layout::LaTeXArgMap::const_iterator const lait = args.find(ia->name());
else
ds = cur.paragraph().asString();
text->insertInset(cur, inset);
+ ia->init(cur.paragraph());
if (edit)
inset->edit(cur, true);
// Now put co-text into inset
}
text->insertInset(cur, inset);
+ InsetText * inset_text = inset->asInsetText();
+ if (inset_text) {
+ Font const & font = inset->inheritFont()
+ ? cur.bv().textMetrics(text).displayFont(cur.pit(), cur.pos())
+ : buffer.params().getFont();
+ inset_text->setOuterFont(cur.bv(), font.fontInfo());
+ }
+
+ if (cmd.action() == LFUN_ARGUMENT_INSERT) {
+ InsetArgument * const ia = static_cast<InsetArgument *>(inset);
+ ia->init(cur.paragraph());
+ }
+
if (edit)
inset->edit(cur, true);
cur.buffer()->errors("Paste");
cur.clearSelection(); // bug 393
cur.finishUndo();
- InsetText * inset_text = inset->asInsetText();
if (inset_text) {
inset_text->fixParagraphsFont();
cur.pos() = 0;
bool const cur_moved = cursorForward(cur);
needsUpdate |= cur_moved;
- if (!cur_moved && oldTopSlice == cur.top()
- && cur.boundary() == oldBoundary) {
+ if (!cur_moved && cur.depth() > 1
+ && oldTopSlice == cur.top() && cur.boundary() == oldBoundary) {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_FORWARD);
- // we will probably be moving out the inset, so we should execute
- // the depm-mechanism, but only when the cursor has a place to
- // go outside this inset, i.e. in a slice above.
- if (cur.depth() > 1 && cur.pos() == cur.lastpos()
- && cur.pit() == cur.lastpit()) {
- // The cursor hasn't changed yet. To give the
- // DEPM the possibility of doing something we must
- // provide it with two different cursors.
- Cursor dummy = cur;
- dummy.pos() = dummy.pit() = 0;
- if (cur.bv().checkDepm(dummy, cur))
- cur.forceBufferUpdate();
- }
+ // we will be moving out the inset, so we should execute
+ // the depm-mechanism.
+ // The cursor hasn't changed yet. To give the DEPM the
+ // possibility of doing something we must provide it with
+ // two different cursors.
+ Cursor dummy = cur;
+ dummy.pos() = dummy.pit() = 0;
+ if (cur.bv().checkDepm(dummy, cur))
+ cur.forceBufferUpdate();
}
break;
}
bool const cur_moved = cursorBackward(cur);
needsUpdate |= cur_moved;
- if (!cur_moved && oldTopSlice == cur.top()
- && cur.boundary() == oldBoundary) {
+ if (!cur_moved && cur.depth() > 1
+ && oldTopSlice == cur.top() && cur.boundary() == oldBoundary) {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
- // we will probably be moving out the inset, so we should execute
- // the depm-mechanism, but only when the cursor has a place to
- // go outside this inset, i.e. in a slice above.
- if (cur.depth() > 1 && cur.pos() == 0 && cur.pit() == 0) {
- // The cursor hasn't changed yet. To give the
- // DEPM the possibility of doing something we must
- // provide it with two different cursors.
- Cursor dummy = cur;
- dummy.pos() = cur.lastpos();
- dummy.pit() = cur.lastpit();
- if (cur.bv().checkDepm(dummy, cur))
- cur.forceBufferUpdate();
- }
+ // we will be moving out the inset, so we should execute
+ // the depm-mechanism.
+ // The cursor hasn't changed yet. To give the DEPM the
+ // possibility of doing something we must provide it with
+ // two different cursors.
+ Cursor dummy = cur;
+ dummy.pos() = cur.lastpos();
+ dummy.pit() = cur.lastpit();
+ if (cur.bv().checkDepm(dummy, cur))
+ cur.forceBufferUpdate();
}
break;
}
needsUpdate |= cur.selHandle(act == LFUN_CHAR_LEFT_SELECT);
bool const cur_moved = cursorVisLeft(cur);
needsUpdate |= cur_moved;
- if (!cur_moved && oldTopSlice == cur.top()
- && cur.boundary() == oldBoundary) {
+ if (!cur_moved && cur.depth() > 1
+ && oldTopSlice == cur.top() && cur.boundary() == oldBoundary) {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_LEFT);
}
needsUpdate |= cur.selHandle(cmd.action() == LFUN_CHAR_RIGHT_SELECT);
bool const cur_moved = cursorVisRight(cur);
needsUpdate |= cur_moved;
- if (!cur_moved && oldTopSlice == cur.top()
- && cur.boundary() == oldBoundary) {
+ if (!cur_moved && cur.depth() > 1
+ && oldTopSlice == cur.top() && cur.boundary() == oldBoundary) {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
}
case LFUN_UP:
case LFUN_DOWN: {
// stop/start the selection
- bool select = cmd.action() == LFUN_DOWN_SELECT ||
- cmd.action() == LFUN_UP_SELECT;
-
+ bool const select = cmd.action() == LFUN_DOWN_SELECT
+ || cmd.action() == LFUN_UP_SELECT;
// move cursor up/down
- bool up = cmd.action() == LFUN_UP_SELECT || cmd.action() == LFUN_UP;
- bool const atFirstOrLastRow = cur.atFirstOrLastRow(up);
+ bool const up = cmd.action() == LFUN_UP_SELECT || cmd.action() == LFUN_UP;
- if (!atFirstOrLastRow) {
+ if (!cur.atFirstOrLastRow(up)) {
needsUpdate |= cur.selHandle(select);
cur.upDownInText(up, needsUpdate);
needsUpdate |= cur.beforeDispatchCursor().inMathed();
cur.forceBufferUpdate();
break;
}
+ needsUpdate |= cur.selHandle(select);
+ bool const can_move = cur.upDownInText(up, needsUpdate);
+ // if the cursor can be moved up or down at an upper level,
+ // delegate the dispatch to next level. Otherwise, we are
+ // done.
+ if (can_move) {
+ cmd = FuncRequest(up ? LFUN_FINISHED_UP : LFUN_FINISHED_DOWN);
+ cur.undispatched();
+ }
+ }
- // 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);
+ break;
+ }
+
+ case LFUN_FINISHED_UP:
+ case LFUN_FINISHED_DOWN: {
+ // move cursor up/down
+ bool const up = cmd.action() == LFUN_FINISHED_UP;
+
+ if (!cur.atFirstOrLastRow(up)) {
cur.upDownInText(up, needsUpdate);
- cur.undispatched();
+ needsUpdate |= cur.beforeDispatchCursor().inMathed();
+ } else {
+ bool const can_move = cur.upDownInText(up, needsUpdate);
+ // if the cursor can be moved up or down and we are not
+ // moving cusor at top level, wait for the next dispatch.
+ // Otherwise, we are done.
+ if (can_move)
+ cur.undispatched();
}
break;
needsUpdate |= cur.selHandle(cmd.action() == LFUN_WORD_RIGHT_SELECT);
bool const cur_moved = cursorVisRightOneWord(cur);
needsUpdate |= cur_moved;
- if (!cur_moved && oldTopSlice == cur.top()
- && cur.boundary() == oldBoundary) {
+ if (!cur_moved && cur.depth() > 1
+ && oldTopSlice == cur.top() && cur.boundary() == oldBoundary) {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
}
bool const cur_moved = cursorForwardOneWord(cur);
needsUpdate |= cur_moved;
- if (!cur_moved && oldTopSlice == cur.top()
- && cur.boundary() == oldBoundary) {
+ if (!cur_moved && cur.depth() > 1
+ && oldTopSlice == cur.top() && cur.boundary() == oldBoundary) {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_FORWARD);
- // we will probably be moving out the inset, so we should execute
- // the depm-mechanism, but only when the cursor has a place to
- // go outside this inset, i.e. in a slice above.
- if (cur.depth() > 1 && cur.pos() == cur.lastpos()
- && cur.pit() == cur.lastpit()) {
- // The cursor hasn't changed yet. To give the
- // DEPM the possibility of doing something we must
- // provide it with two different cursors.
- Cursor dummy = cur;
- dummy.pos() = dummy.pit() = 0;
- if (cur.bv().checkDepm(dummy, cur))
- cur.forceBufferUpdate();
- }
+ // we will be moving out the inset, so we should execute
+ // the depm-mechanism.
+ // The cursor hasn't changed yet. To give the DEPM the
+ // possibility of doing something we must provide it with
+ // two different cursors.
+ Cursor dummy = cur;
+ dummy.pos() = dummy.pit() = 0;
+ if (cur.bv().checkDepm(dummy, cur))
+ cur.forceBufferUpdate();
}
break;
}
needsUpdate |= cur.selHandle(cmd.action() == LFUN_WORD_LEFT_SELECT);
bool const cur_moved = cursorVisLeftOneWord(cur);
needsUpdate |= cur_moved;
- if (!cur_moved && oldTopSlice == cur.top()
- && cur.boundary() == oldBoundary) {
+ if (!cur_moved && cur.depth() > 1
+ && oldTopSlice == cur.top() && cur.boundary() == oldBoundary) {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_LEFT);
}
bool const cur_moved = cursorBackwardOneWord(cur);
needsUpdate |= cur_moved;
- if (!cur_moved && oldTopSlice == cur.top()
- && cur.boundary() == oldBoundary) {
+ if (!cur_moved && cur.depth() > 1
+ && oldTopSlice == cur.top() && cur.boundary() == oldBoundary) {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
- // we will probably be moving out the inset, so we should execute
- // the depm-mechanism, but only when the cursor has a place to
- // go outside this inset, i.e. in a slice above.
- if (cur.depth() > 1 && cur.pos() == 0
- && cur.pit() == 0) {
- // The cursor hasn't changed yet. To give the
- // DEPM the possibility of doing something we must
- // provide it with two different cursors.
- Cursor dummy = cur;
- dummy.pos() = cur.lastpos();
- dummy.pit() = cur.lastpit();
- if (cur.bv().checkDepm(dummy, cur))
- cur.forceBufferUpdate();
- }
+ // we will be moving out the inset, so we should execute
+ // the depm-mechanism.
+ // The cursor hasn't changed yet. To give the DEPM the
+ // possibility of doing something we must provide it with
+ // two different cursors.
+ Cursor dummy = cur;
+ dummy.pos() = cur.lastpos();
+ dummy.pit() = cur.lastpit();
+ if (cur.bv().checkDepm(dummy, cur))
+ cur.forceBufferUpdate();
}
break;
}
// inside it.
doInsertInset(cur, this, cmd, true, true);
cur.posForward();
- /* The font of the inset is computed in metrics(), and this is
- * used to compute the height of the caret (because the font
- * is stored in TextMetrics::font_). When we insert, we have
- * to make sure that metrics are computed so that the caret
- * height is correct. Arguably, this is hackish.*/
- bv->processUpdateFlags(Update::SinglePar);
cur.setCurrentFont();
// Some insets are numbered, others are shown in the outline pane so
// let's update the labels and the toc backend.
}
case LFUN_SPELLING_ADD_LOCAL: {
+ Language const * language = getLanguage(cur, cmd.getArg(1));
+ docstring word = from_utf8(cmd.getArg(0));
+ if (word.empty()) {
+ word = cur.selectionAsString(false);
+ if (word.size() > 100)
+ break;
+ if (word.empty()) {
+ // Get word or selection
+ selectWordWhenUnderCursor(cur, WHOLE_WORD);
+ word = cur.selectionAsString(false);
+ }
+ }
+ WordLangTuple wl(word, language);
+ if (!bv->buffer().params().spellignored(wl)) {
+ cur.recordUndoBufferParams();
+ bv->buffer().params().spellignore().push_back(wl);
+ cur.recordUndo();
+ // trigger re-check of whole buffer
+ ParagraphList & pars = bv->buffer().paragraphs();
+ ParagraphList::iterator pit = pars.begin();
+ ParagraphList::iterator pend = pars.end();
+ for (; pit != pend; ++pit)
+ pit->requestSpellCheck();
+ }
+ break;
+ }
+
+ case LFUN_SPELLING_REMOVE_LOCAL: {
Language const * language = getLanguage(cur, cmd.getArg(1));
docstring word = from_utf8(cmd.getArg(0));
if (word.empty()) {
}
WordLangTuple wl(word, language);
bool has_item = false;
- vector<WordLangTuple> il = bv->buffer().params().spellignore();
- vector<WordLangTuple>::const_iterator it = il.begin();
- for (; it != il.end(); ++it) {
+ vector<WordLangTuple>::const_iterator it = bv->buffer().params().spellignore().begin();
+ for (; it != bv->buffer().params().spellignore().end(); ++it) {
if (it->lang()->code() != wl.lang()->code())
continue;
if (it->word() == wl.word()) {
break;
}
}
- if (!has_item) {
+ if (has_item) {
cur.recordUndoBufferParams();
- bv->buffer().params().spellignore().push_back(wl);
+ bv->buffer().params().spellignore().erase(it);
cur.recordUndo();
- // trigger re-check
- WordLangTuple wl;
- docstring_list suggestions;
- Paragraph const & par = cur.paragraph();
- pos_type from = cur.pos();
- pos_type to = from;
- par.spellCheck(from, to, wl, suggestions, true, true);
+ // trigger re-check of whole buffer
+ ParagraphList & pars = bv->buffer().paragraphs();
+ ParagraphList::iterator pit = pars.begin();
+ ParagraphList::iterator pend = pars.end();
+ for (; pit != pend; ++pit)
+ pit->requestSpellCheck();
}
break;
}
-
+
case LFUN_SPELLING_IGNORE: {
Language const * language = getLanguage(cur, cmd.getArg(1));
code = BRANCH_CODE;
else if (cmd.argument() == "citation")
code = CITE_CODE;
+ else if (cmd.argument() == "counter")
+ code = COUNTER_CODE;
else if (cmd.argument() == "ert")
code = ERT_CODE;
else if (cmd.argument() == "external")
case LFUN_SPELLING_ADD:
case LFUN_SPELLING_ADD_LOCAL:
+ case LFUN_SPELLING_REMOVE_LOCAL:
case LFUN_SPELLING_IGNORE:
case LFUN_SPELLING_REMOVE:
enable = theSpellChecker() != nullptr;