* added copy_ucs2_from_clipboard and copy_ucs2_to_clipboard functions...

for X11. Now BeOS is still missing.
This commit is contained in:
Jon Daniel 2005-03-12 04:48:37 +00:00
parent cf82d4c121
commit 0d6e07757b
2 changed files with 29 additions and 1 deletions

View File

@ -226,6 +226,16 @@ void handle_system_event(const SDL_Event& event)
}
}
void copy_ucs2_to_clipboard(const ucs2_string& text)
{
if(text.empty())
return;
clipboard_string = ucs2_string_to_utf8_string(text);
UseX x11;
XSetSelectionOwner(x11->dpy(), XA_PRIMARY, x11->window(), CurrentTime);
XSetSelectionOwner(x11->dpy(), x11->XA_CLIPBOARD(), x11->window(), CurrentTime);
}
void copy_to_clipboard(const std::string& text)
{
if (text.empty()) {
@ -300,6 +310,23 @@ static bool try_grab_target(Atom target, std::string& ret)
//Timed out -- return empty string
return false;
}
ucs2_string copy_ucs2_from_clipboard()
{
if(!clipboard_string.empty()) {
return utf8_string_to_ucs2_string(clipboard_string);
utf8_string text;
UseX x11;
if(try_grab_target(x11->UTF8_STRING(), text))
return utf8_string_to_ucs2_string(text);
if(try_grab_target(x11->XA_COMPOUND_TEXT(), text))
return utf8_string_to_ucs2_string(text);
if(try_grab_target(x11->XA_TEXT(), text))
return utf8_string_to_ucs2_string(text);
if(try_grab_target(XA_STRING, text))
return utf8_string_to_ucs2_string(text);
return ucs2_string();
}
std::string copy_from_clipboard()
{

View File

@ -3,7 +3,8 @@
#include <string>
#include "SDL.h"
void copy_ucs2_to_clipboard(const ucs2_string& text);
ucs2_string copy_ucs2_from_clipboard();
void copy_to_clipboard(const std::string& text);
std::string copy_from_clipboard();