mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-14 18:24:10 +00:00
Added clipboard support for BEOS, patch #3153 from ahwayakchih
This commit is contained in:
parent
f40e3c7bfc
commit
d4c66068b3
@ -371,6 +371,43 @@ std::string copy_from_clipboard()
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __BEOS__
|
||||||
|
#include <Clipboard.h>
|
||||||
|
|
||||||
|
#define CLIPBOARD_FUNCS_DEFINED
|
||||||
|
|
||||||
|
void copy_to_clipboard(const std::string& text)
|
||||||
|
{
|
||||||
|
BMessage *clip;
|
||||||
|
if (be_clipboard->Lock())
|
||||||
|
{
|
||||||
|
be_clipboard->Clear();
|
||||||
|
if ((clip = be_clipboard->Data()))
|
||||||
|
{
|
||||||
|
clip->AddData("text/plain", B_MIME_TYPE, text.c_str(), text.size()+1);
|
||||||
|
be_clipboard->Commit();
|
||||||
|
}
|
||||||
|
be_clipboard->Unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string copy_from_clipboard()
|
||||||
|
{
|
||||||
|
const char* data;
|
||||||
|
ssize_t size;
|
||||||
|
BMessage *clip = NULL;
|
||||||
|
if (be_clipboard->Lock())
|
||||||
|
{
|
||||||
|
clip = be_clipboard->Data();
|
||||||
|
be_clipboard->Unlock();
|
||||||
|
}
|
||||||
|
if (clip != NULL && clip->FindData("text/plain", B_MIME_TYPE, (const void**)&data, &size) == B_OK)
|
||||||
|
return (const char*)data;
|
||||||
|
else
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef CLIPBOARD_FUNCS_DEFINED
|
#ifndef CLIPBOARD_FUNCS_DEFINED
|
||||||
|
|
||||||
void copy_to_clipboard(const std::string& text)
|
void copy_to_clipboard(const std::string& text)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user