diff --git a/src/BufferView.C b/src/BufferView.C index 154755c15e..7e084ad548 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -63,6 +63,7 @@ #include "frontends/Alert.h" #include "frontends/FileDialog.h" #include "frontends/FontMetrics.h" +#include "frontends/Selection.h" #include "graphics/Previews.h" @@ -196,6 +197,7 @@ void BufferView::setBuffer(Buffer * b) cursor_.resetAnchor(); cursor_.setCursor(buffer_->getCursor().asDocIterator(&(buffer_->inset()))); cursor_.setSelection(); + theSelection().haveSelection(cursor_.selection()); } } @@ -1298,6 +1300,7 @@ void BufferView::putSelectionAt(DocIterator const & cur, cursor_.setSelection(cursor_, -length); } else cursor_.setSelection(cursor_, length); + theSelection().haveSelection(cursor_.selection()); } } diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index e561f591c3..d111dc8a85 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -46,6 +46,7 @@ #include "support/lstrings.h" #include "frontends/Clipboard.h" +#include "frontends/Selection.h" #include @@ -532,6 +533,7 @@ void cutSelection(LCursor & cur, bool doclear, bool realcut) // need a valid cursor. (Lgb) cur.clearSelection(); updateLabels(cur.buffer()); + theSelection().haveSelection(false); // tell tabular that a recent copy happened dirtyTabularStack(false); @@ -709,6 +711,7 @@ void eraseSelection(LCursor & cur) } // need a valid cursor. (Lgb) cur.clearSelection(); + theSelection().haveSelection(false); } else { lyxerr << "can't erase this selection 1" << endl; } diff --git a/src/cursor.C b/src/cursor.C index 9a41705786..e9c4d75349 100644 --- a/src/cursor.C +++ b/src/cursor.C @@ -41,6 +41,8 @@ #include "mathed/InsetMathScript.h" #include "mathed/MathMacroTable.h" +#include "frontends/Selection.h" + #include "support/limited_stack.h" #include @@ -558,6 +560,7 @@ bool LCursor::selHandle(bool sel) resetAnchor(); selection() = sel; + theSelection().haveSelection(sel); return true; } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 521806dea6..16c105524d 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -547,6 +547,8 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd) cell(cur.idx())->dispatch(cur, cmd); if (!cur.result().dispatched()) { isRightToLeft(cur) ? movePrevCell(cur) : moveNextCell(cur); + if (cmd.action == LFUN_CHAR_FORWARD_SELECT) + theSelection().haveSelection(cur.selection()); if (sl == cur.top()) cmd = FuncRequest(LFUN_FINISHED_RIGHT); else @@ -559,6 +561,8 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd) cell(cur.idx())->dispatch(cur, cmd); if (!cur.result().dispatched()) { isRightToLeft(cur) ? moveNextCell(cur) : movePrevCell(cur); + if (cmd.action == LFUN_CHAR_BACKWARD_SELECT) + theSelection().haveSelection(cur.selection()); if (sl == cur.top()) cmd = FuncRequest(LFUN_FINISHED_LEFT); else @@ -580,6 +584,8 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd) TextMetrics const & tm = cur.bv().textMetrics(cell(cur.idx())->getText(0)); cur.pos() = tm.x2pos(cur.pit(), 0, cur.targetX()); + if (cmd.action == LFUN_DOWN_SELECT) + theSelection().haveSelection(cur.selection()); } if (sl == cur.top()) { // we trick it to go to the RIGHT after leaving the @@ -605,6 +611,8 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd) ParagraphMetrics const & pm = tm.parMetrics(cur.lastpit()); cur.pos() = tm.x2pos(cur.pit(), pm.rows().size()-1, cur.targetX()); + if (cmd.action == LFUN_UP_SELECT) + theSelection().haveSelection(cur.selection()); } if (sl == cur.top()) { cmd = FuncRequest(LFUN_FINISHED_UP); @@ -1868,6 +1876,7 @@ void InsetTabular::cutSelection(LCursor & cur) if (cur.pos() > cur.lastpos()) cur.pos() = cur.lastpos(); cur.clearSelection(); + theSelection().haveSelection(false); } diff --git a/src/lyxfind.C b/src/lyxfind.C index 99181a4c09..d8e08dd803 100644 --- a/src/lyxfind.C +++ b/src/lyxfind.C @@ -29,6 +29,7 @@ #include "undo.h" #include "frontends/Alert.h" +#include "frontends/Selection.h" #include "support/convert.h" #include "support/docstream.h" @@ -356,6 +357,7 @@ bool findNextChange(BufferView * bv) // Now put cursor to end of selection: bv->cursor().setCursor(cur); bv->cursor().setSelection(); + theSelection().haveSelection(bv->cursor().selection()); // if we used a lfun like in find/replace, dispatch would do // that for us bv->update(); diff --git a/src/mathed/InsetMathHull.C b/src/mathed/InsetMathHull.C index a417f577d6..fc979083db 100644 --- a/src/mathed/InsetMathHull.C +++ b/src/mathed/InsetMathHull.C @@ -1398,6 +1398,7 @@ bool InsetMathHull::searchForward(BufferView * bv, string const & str, MathArray const & a = top.asInsetMath()->cell(top.idx_); if (a.matchpart(ar, top.pos_)) { bv->cursor().setSelection(it, ar.size()); + theSelection().haveSelection(bv->cursor().selection()); current = it; top.pos_ += ar.size(); bv->update(); diff --git a/src/text.C b/src/text.C index 0e394e0da8..2a9cc8a242 100644 --- a/src/text.C +++ b/src/text.C @@ -53,6 +53,7 @@ #include "frontends/FontMetrics.h" #include "frontends/Painter.h" +#include "frontends/Selection.h" #include "insets/insettext.h" #include "insets/insetbibitem.h" @@ -828,6 +829,7 @@ void LyXText::selectWord(LCursor & cur, word_location loc) cur.resetAnchor(); setCursor(cur, to.pit(), to.pos()); cur.setSelection(); + theSelection().haveSelection(cur.selection()); } diff --git a/src/text3.C b/src/text3.C index f448e414bc..2e595fadb8 100644 --- a/src/text3.C +++ b/src/text3.C @@ -121,8 +121,7 @@ namespace { { if (selecting || cur.mark()) cur.setSelection(); - if (!cur.selection()) - theSelection().haveSelection(false); + theSelection().haveSelection(cur.selection()); cur.bv().switchKeyMap(); } @@ -1065,7 +1064,9 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) if (lyxrc.auto_region_delete) { if (cur.selection()) cutSelection(cur, false, false); - theSelection().haveSelection(false); + // cutSelection clears the X selection. + else + theSelection().haveSelection(false); } cur.clearSelection();