[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src clipboard.cpp
From: |
Jon Daniel |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src clipboard.cpp |
Date: |
Fri, 11 Mar 2005 20:42:40 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Jon Daniel <address@hidden> 05/03/12 01:42:39
Modified files:
src : clipboard.cpp
Log message:
* added copy_ucs2_from_clipboard for win32
* updated copy_from_clipboard for win32
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/clipboard.cpp.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
Patches:
Index: wesnoth/src/clipboard.cpp
diff -u wesnoth/src/clipboard.cpp:1.12 wesnoth/src/clipboard.cpp:1.13
--- wesnoth/src/clipboard.cpp:1.12 Sat Mar 12 00:59:26 2005
+++ wesnoth/src/clipboard.cpp Sat Mar 12 01:42:38 2005
@@ -343,7 +343,7 @@
return;
EmptyClipboard();
- // convert newlines
+ //convert newlines
ucs2_string str;
str.reserve(text.size() + 1);
ucs2_string::const_iterator first = text.begin();
@@ -380,7 +380,7 @@
return;
EmptyClipboard();
- // convert newlines
+ //convert newlines
std::string str;
str.reserve(text.size());
std::string::const_iterator first = text.begin();
@@ -407,18 +407,65 @@
CloseClipboard();
}
-std::string copy_from_clipboard()
+ucs2_string copy_ucs2_from_clipboard()
{
- if(OpenClipboard(NULL)) {
- const HANDLE data = GetClipboardData(CF_TEXT);
- char* const buffer = reinterpret_cast<char*>(GlobalLock(data));
- GlobalUnlock(data);
- CloseClipboard();
+ if(!IsClipboardFormatAvailable(CF_UNICODETEXT))
+ return ucs2_string();
+ if(!OpenClipboard(NULL))
+ return ucs2_string();
- return buffer;
+ HGLOBAL hglb = GetClipboardData(CF_UNICODETEXT);
+ if(hglb == NULL) {
+ CloseClipboard();
+ return ucs2_string();
+ }
+ Uint16 const * buffer = reinterpret_cast<Uint16 const
*>(GlobalLock(hglb));
+ if(buffer == NULL) {
+ CloseClipboard();
+ return ucs2_string();
+ }
+
+ //convert newlines
+ ucs2_string str;
+ while(*buffer != '\0') {
+ if(*buffer != '\r')
+ str.push_back(*buffer);
+ ++buffer;
}
+ GlobalUnlock(hglb);
+ CloseClipboard();
+ return str;
+}
- return "";
+std::string copy_from_clipboard()
+{
+ if(!IsClipboardFormatAvailable(CF_TEXT))
+ return "";
+ if(!OpenClipboard(NULL))
+ return "";
+
+ HGLOBAL hglb = GetClipboardData(CF_TEXT);
+ if(hglb == NULL) {
+ CloseClipboard();
+ return "";
+ }
+ char const * buffer = reinterpret_cast<char*>(GlobalLock(hglb));
+ if(buffer == NULL) {
+ CloseClipboard();
+ return "";
+ }
+
+ //convert newlines
+ std::string str;
+ while(*buffer != '\0') {
+ if(*buffer != '\r')
+ str.push_back(*buffer);
+ ++buffer;
+ }
+
+ GlobalUnlock(hglb);
+ CloseClipboard();
+ return str;
}
#endif
- [Wesnoth-cvs-commits] wesnoth/src clipboard.cpp, Jon Daniel, 2005/03/10
- [Wesnoth-cvs-commits] wesnoth/src clipboard.cpp, Jon Daniel, 2005/03/11
- [Wesnoth-cvs-commits] wesnoth/src clipboard.cpp, Jon Daniel, 2005/03/11
- [Wesnoth-cvs-commits] wesnoth/src clipboard.cpp, Jon Daniel, 2005/03/11
- [Wesnoth-cvs-commits] wesnoth/src clipboard.cpp, Jon Daniel, 2005/03/11
- [Wesnoth-cvs-commits] wesnoth/src clipboard.cpp,
Jon Daniel <=
- [Wesnoth-cvs-commits] wesnoth/src clipboard.cpp, David White, 2005/03/13