#include "support/convert.h"
#include "support/debug.h"
+#include "support/docstring_list.h"
#include "support/filetools.h"
#include "support/gettext.h"
#include "support/lassert.h"
}
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 (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;
// 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.
break;
}
+ 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
+ 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);
+ }
+ break;
+ }
+
+ case LFUN_SPELLING_REMOVE_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);
+ bool has_item = false;
+ 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()) {
+ has_item = true;
+ break;
+ }
+ }
+ if (has_item) {
+ cur.recordUndoBufferParams();
+ 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);
+ }
+ break;
+ }
+
+
case LFUN_SPELLING_IGNORE: {
Language const * language = getLanguage(cur, cmd.getArg(1));
docstring word = from_utf8(cmd.getArg(0));
needsUpdate = true;
break;
- case LFUN_SERVER_GET_STATISTICS:
- {
- DocIterator from, to;
- if (cur.selection()) {
- from = cur.selectionBegin();
- to = cur.selectionEnd();
- } else {
- from = doc_iterator_begin(cur.buffer());
- to = doc_iterator_end(cur.buffer());
- }
-
- cur.buffer()->updateStatistics(from, to);
- string const arg0 = cmd.getArg(0);
- if (arg0 == "words") {
- cur.message(convert<docstring>(cur.buffer()->wordCount()));
- } else if (arg0 == "chars") {
- cur.message(convert<docstring>(cur.buffer()->charCount(false)));
- } else if (arg0 == "chars-space") {
- cur.message(convert<docstring>(cur.buffer()->charCount(true)));
- } else {
- cur.message(convert<docstring>(cur.buffer()->wordCount()) + " "
- + convert<docstring>(cur.buffer()->charCount(false)) + " "
- + convert<docstring>(cur.buffer()->charCount(true)));
- }
+ case LFUN_SERVER_GET_STATISTICS: {
+ DocIterator from, to;
+ if (cur.selection()) {
+ from = cur.selectionBegin();
+ to = cur.selectionEnd();
+ } else {
+ from = doc_iterator_begin(cur.buffer());
+ to = doc_iterator_end(cur.buffer());
+ }
+
+ cur.buffer()->updateStatistics(from, to);
+ string const arg0 = cmd.getArg(0);
+ if (arg0 == "words") {
+ cur.message(convert<docstring>(cur.buffer()->wordCount()));
+ } else if (arg0 == "chars") {
+ cur.message(convert<docstring>(cur.buffer()->charCount(false)));
+ } else if (arg0 == "chars-space") {
+ cur.message(convert<docstring>(cur.buffer()->charCount(true)));
+ } else {
+ cur.message(convert<docstring>(cur.buffer()->wordCount()) + " "
+ + convert<docstring>(cur.buffer()->charCount(false)) + " "
+ + convert<docstring>(cur.buffer()->charCount(true)));
}
break;
+ }
default:
LYXERR(Debug::ACTION, "Command " << cmd << " not DISPATCHED by Text");
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")
break;
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;
docstring const layout = resolveLayout(req_layout, cur);
enable = !owner_->forcePlainLayout() && !layout.empty();
- status.setOnOff(isAlreadyLayout(layout, cur));
+ status.setOnOff(!owner_->forcePlainLayout() && isAlreadyLayout(layout, cur));
break;
}