X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FText3.cpp;h=4c1d07bf46720cc8141b32cc79ba8a6034e76647;hb=55a3dd7b346d29a52ba305a4558e9e380ef50f47;hp=5079522bb47e3ab1f8aa425eeb74c68b8495ad57;hpb=370044551c4128e75552ffa3d3a7e706d4b5eadc;p=lyx.git diff --git a/src/Text3.cpp b/src/Text3.cpp index 5079522bb4..4c1d07bf46 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -45,7 +45,6 @@ #include "SpellChecker.h" #include "TextClass.h" #include "TextMetrics.h" -#include "VSpace.h" #include "WordLangTuple.h" #include "frontends/Application.h" @@ -68,6 +67,7 @@ #include "support/convert.h" #include "support/debug.h" #include "support/gettext.h" +#include "support/lassert.h" #include "support/lstrings.h" #include "support/lyxtime.h" #include "support/os.h" @@ -93,6 +93,7 @@ using cap::pasteClipboardGraphics; using cap::replaceSelection; using cap::grabAndEraseSelection; using cap::selClearOrDel; +using cap::pasteSimpleText; // globals... static Font freefont(ignore_font, ignore_language); @@ -245,8 +246,11 @@ static bool doInsertInset(Cursor & cur, Text * text, if (edit) inset->edit(cur, true); // Now put this into inset - cur.text()->insertStringAsLines(cur, ds, Font(inherit_font)); - cur.leaveInset(*inset); + Font const f(inherit_font, cur.current_font.language()); + if (!ds.empty()) { + cur.text()->insertStringAsLines(cur, ds, f); + cur.leaveInset(*inset); + } return true; } @@ -467,9 +471,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cur.noScreenUpdate(); LASSERT(cur.text() == this, /**/); - CursorSlice oldTopSlice = cur.top(); - bool oldBoundary = cur.boundary(); - bool sel = cur.selection(); + CursorSlice const oldTopSlice = cur.top(); + bool const oldBoundary = cur.boundary(); + bool const oldSelection = cur.selection(); // Signals that, even if needsUpdate == false, an update of the // cursor paragraph is required bool singleParUpdate = lyxaction.funcHasFlag(cmd.action(), @@ -477,9 +481,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) // Signals that a full-screen update is required bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action(), LyXAction::NoUpdate) || singleParUpdate); - int const last_pid = cur.paragraph().id(); - pos_type const last_pos = cur.pos(); - bool const last_misspelled = lyxrc.spellcheck_continuously && cur.paragraph().isMisspelled(cur.pos()); + bool const last_misspelled = lyxrc.spellcheck_continuously + && cur.paragraph().isMisspelled(cur.pos(), true); FuncCode const act = cmd.action(); switch (act) { @@ -627,8 +630,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) // provide it with two different cursors. Cursor dummy = cur; dummy.pos() = dummy.pit() = 0; - if (cur.bv().checkDepm(dummy, cur)) + if (cur.bv().checkDepm(dummy, cur)) { cur.forceBufferUpdate(); + // DEPM may have requested a screen update + cur.screenUpdateFlags( + cur.screenUpdate() | dummy.screenUpdate()); + } } } break; @@ -654,8 +661,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) Cursor dummy = cur; dummy.pos() = cur.lastpos(); dummy.pit() = cur.lastpit(); - if (cur.bv().checkDepm(dummy, cur)) + if (cur.bv().checkDepm(dummy, cur)) { cur.forceBufferUpdate(); + // DEPM may have requested a screen update + cur.screenUpdateFlags( + cur.screenUpdate() | dummy.screenUpdate()); + } } } break; @@ -838,8 +849,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) // provide it with two different cursors. Cursor dummy = cur; dummy.pos() = dummy.pit() = 0; - if (cur.bv().checkDepm(dummy, cur)) + if (cur.bv().checkDepm(dummy, cur)) { cur.forceBufferUpdate(); + // DEPM may have requested a screen update + cur.screenUpdateFlags( + cur.screenUpdate() | dummy.screenUpdate()); + } } } break; @@ -888,8 +903,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) Cursor dummy = cur; dummy.pos() = cur.lastpos(); dummy.pit() = cur.lastpit(); - if (cur.bv().checkDepm(dummy, cur)) + if (cur.bv().checkDepm(dummy, cur)) { cur.forceBufferUpdate(); + // DEPM may have requested a screen update + cur.screenUpdateFlags( + cur.screenUpdate() | dummy.screenUpdate()); + } } } break; @@ -1318,6 +1337,11 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) bv->buffer().errors("Paste"); break; + case LFUN_CLIPBOARD_PASTE_SIMPLE: + cur.clearSelection(); + pasteSimpleText(cur, cmd.argument() == "paragraph"); + break; + case LFUN_PRIMARY_SELECTION_PASTE: pasteString(cur, theSelection().get(), cmd.argument() == "paragraph"); @@ -1552,6 +1576,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cur.resetAnchor(); moveCursor(cur, false); + cur.markNewWordPosition(); bv->bookmarkEditPosition(); break; } @@ -1890,8 +1915,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) Language const * lang = languages.getLanguage(to_utf8(cmd.argument())); if (!lang) break; + selectWordWhenUnderCursor(cur, WHOLE_WORD_STRICT); Font font(ignore_font, lang); - toggleAndShow(cur, this, font); + toggleAndShow(cur, this, font, false); break; } @@ -2184,9 +2210,10 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) if (!cur.inTexted()) { // move from regular text to math needsUpdate = last_misspelled; - } else if (cur.paragraph().id() != last_pid || cur.pos() != last_pos) { + } else if (oldTopSlice != cur.top() || oldBoundary != cur.boundary()) { // move inside regular text - needsUpdate = last_misspelled || cur.paragraph().isMisspelled(cur.pos()); + needsUpdate = last_misspelled + || cur.paragraph().isMisspelled(cur.pos(), true); } } @@ -2212,7 +2239,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) if (!needsUpdate && &oldTopSlice.inset() == &cur.inset() && oldTopSlice.idx() == cur.idx() - && !sel // sel is a backup of cur.selection() at the beginning of the function. + && !oldSelection // oldSelection is a backup of cur.selection() at the beginning of the function. && !cur.selection()) // FIXME: it would be better if we could just do this // @@ -2373,7 +2400,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, // make sure we know about such floats if (cit == floats.end() || // and that we know how to generate a list of them - (!cit->second.needsFloatPkg() && cit->second.listCommand().empty())) { + (!cit->second.usesFloatPkg() && cit->second.listCommand().empty())) { flag.setUnknown(true); // probably not necessary, but... enable = false; @@ -2580,6 +2607,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, } case LFUN_CLIPBOARD_PASTE: + case LFUN_CLIPBOARD_PASTE_SIMPLE: enable = !theClipboard().empty(); break;