* Watch the system clipboard for changes.
* On the event of a clipboard change, check if the clipboard contains text now and replace the contents of the internal "mouse clipboard". So when right/middle clicking into the Terminal, the current system clipboard contents are inserted. As soon as the user selects text in the Terminal again, that text will have priority over the system clipboard, as before. Fixes ticket #3700. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29989 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e419aeed10
commit
b936fc6770
@ -937,12 +937,16 @@ TermView::AttachedToWindow()
|
||||
fTextBuffer->SetListener(thisMessenger);
|
||||
_SynchronizeWithTextBuffer(0, -1);
|
||||
}
|
||||
|
||||
be_clipboard->StartWatching(thisMessenger);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TermView::DetachedFromWindow()
|
||||
{
|
||||
be_clipboard->StopWatching(BMessenger(this));
|
||||
|
||||
delete fWinchRunner;
|
||||
fWinchRunner = NULL;
|
||||
|
||||
@ -1398,6 +1402,29 @@ TermView::MessageReceived(BMessage *msg)
|
||||
break;
|
||||
}
|
||||
|
||||
case B_CLIPBOARD_CHANGED:
|
||||
// This message originates from the system clipboard. Overwrite
|
||||
// the contents of the mouse clipboard with the ones from the
|
||||
// system clipboard, in case it contains text data.
|
||||
if (be_clipboard->Lock()) {
|
||||
if (gMouseClipboard->Lock()) {
|
||||
BMessage* clipMsgA = be_clipboard->Data();
|
||||
const char* text;
|
||||
ssize_t numBytes;
|
||||
if (clipMsgA->FindData("text/plain", B_MIME_TYPE,
|
||||
(const void**)&text, &numBytes) == B_OK ) {
|
||||
gMouseClipboard->Clear();
|
||||
BMessage* clipMsgB = gMouseClipboard->Data();
|
||||
clipMsgB->AddData("text/plain", B_MIME_TYPE,
|
||||
text, numBytes);
|
||||
gMouseClipboard->Commit();
|
||||
}
|
||||
gMouseClipboard->Unlock();
|
||||
}
|
||||
be_clipboard->Unlock();
|
||||
}
|
||||
break;
|
||||
|
||||
case B_SELECT_ALL:
|
||||
SelectAll();
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user