X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FText3.cpp;h=ce6811452700f437ba63459a2d9806c3a78c539e;hb=23832ce191e0d63088dbb6a02e9f0ebc73472004;hp=1aee50488ac1b4bf40cbdca9711ca6ab7d937700;hpb=8e8c214bef6a44ce256305f1c44754a8fd9f9f23;p=lyx.git diff --git a/src/Text3.cpp b/src/Text3.cpp index 1aee50488a..ce68114527 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -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); @@ -246,8 +247,10 @@ static bool doInsertInset(Cursor & cur, Text * text, inset->edit(cur, true); // Now put this into inset Font const f(inherit_font, cur.current_font.language()); - cur.text()->insertStringAsLines(cur, ds, f); - cur.leaveInset(*inset); + if (!ds.empty()) { + cur.text()->insertStringAsLines(cur, ds, f); + cur.leaveInset(*inset); + } return true; } @@ -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"); @@ -1646,16 +1670,19 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_FLOAT_INSERT: case LFUN_FLOAT_WIDE_INSERT: case LFUN_WRAP_INSERT: { - // will some text be moved into the inset? - bool content = cur.selection(); + // will some content be moved into the inset? + bool const content = cur.selection(); + // does the content consist of multiple paragraphs? + bool const singlepar = (cur.selBegin().pit() == cur.selEnd().pit()); doInsertInset(cur, this, cmd, true, true); cur.posForward(); - // If some text is moved into the inset, doInsertInset - // puts the cursor outside the inset. To insert the - // caption we put it back into the inset. - if (content) + // If some single-par content is moved into the inset, + // doInsertInset puts the cursor outside the inset. + // To insert the caption we put it back into the inset. + // FIXME cleanup doInsertInset to avoid such dances! + if (content && singlepar) cur.backwardPos(); ParagraphList & pars = cur.text()->paragraphs(); @@ -2583,6 +2610,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, } case LFUN_CLIPBOARD_PASTE: + case LFUN_CLIPBOARD_PASTE_SIMPLE: enable = !theClipboard().empty(); break;