+void BufferView::Pimpl::selectionRequested()
+{
+ static string sel;
+
+ if (!available())
+ return;
+
+ LyXText * text = bv_->getLyXText();
+
+ if (text->selection.set() &&
+ (!bv_->text->xsel_cache.set() ||
+ text->selection.start != bv_->text->xsel_cache.start ||
+ text->selection.end != bv_->text->xsel_cache.end))
+ {
+ bv_->text->xsel_cache = text->selection;
+ sel = text->selectionAsString(bv_->buffer(), false);
+ } else if (!text->selection.set()) {
+ sel = string();
+ bv_->text->xsel_cache.set(false);
+ }
+ if (!sel.empty()) {
+ workarea_.putClipboard(sel);
+ }
+}
+
+
+void BufferView::Pimpl::selectionLost()
+{
+ if (active() && available()) {
+ hideCursor();
+ toggleSelection();
+ bv_->getLyXText()->clearSelection();
+ showCursor();
+ bv_->text->xsel_cache.set(false);
+ }
+}
+
+