wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src clipboard.hpp clipboard.cpp


From: Jon Daniel
Subject: [Wesnoth-cvs-commits] wesnoth/src clipboard.hpp clipboard.cpp
Date: Fri, 11 Mar 2005 23:48:37 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Jon Daniel <address@hidden>     05/03/12 04:48:37

Modified files:
        src            : clipboard.hpp clipboard.cpp 

Log message:
        * added copy_ucs2_from_clipboard and copy_ucs2_to_clipboard functions 
for X11
        now BeOS is still missing.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/clipboard.hpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/clipboard.cpp.diff?tr1=1.13&tr2=1.14&r1=text&r2=text

Patches:
Index: wesnoth/src/clipboard.cpp
diff -u wesnoth/src/clipboard.cpp:1.13 wesnoth/src/clipboard.cpp:1.14
--- wesnoth/src/clipboard.cpp:1.13      Sat Mar 12 01:42:38 2005
+++ wesnoth/src/clipboard.cpp   Sat Mar 12 04:48:37 2005
@@ -226,6 +226,16 @@
        }
 }
 
+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 @@
        //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()
 {
Index: wesnoth/src/clipboard.hpp
diff -u wesnoth/src/clipboard.hpp:1.4 wesnoth/src/clipboard.hpp:1.5
--- wesnoth/src/clipboard.hpp:1.4       Sun Aug 15 15:55:26 2004
+++ wesnoth/src/clipboard.hpp   Sat Mar 12 04:48:37 2005
@@ -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();
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]