+2009-01-16 Carlos Alberto Cortez <calberto.cortez@ggmail.com>
+
+ * X11Structs.cs:
+ * XplatUIX11.cs: Properly encode/decode the unicode strings we
+ store/retrieve in the Clipboard. Also, since we try to convert the
+ data to different formats, separate the source and the result of
+ it, so we can always fallback to the original and don't mix wrong
+ conversions.
+
2009-01-16 Mike Gorse <mgorse@novell.com>
* TextControl.cs: Add UIASelectionChanged event.
} else if (property == OEMTEXT) {
Clipboard.Item = Marshal.PtrToStringAnsi(prop);
} else if (property == UNICODETEXT) {
- Clipboard.Item = Marshal.PtrToStringAnsi(prop);
+ Clipboard.Item = Marshal.PtrToStringUni (prop, Encoding.Unicode.GetMaxCharCount ((int)nitems));
} else if (property == RICHTEXTFORMAT)
Clipboard.Item = Marshal.PtrToStringAnsi(prop);
xevent.SelectionRequestEvent.target == (IntPtr)RICHTEXTFORMAT) {
Byte[] bytes;
- bytes = new ASCIIEncoding().GetBytes((string)Clipboard.Item);
+ bytes = new ASCIIEncoding().GetBytes((string)Clipboard.Source);
buffer = Marshal.AllocHGlobal(bytes.Length);
buflen = bytes.Length;
}
} else if (xevent.SelectionRequestEvent.target == OEMTEXT) {
// FIXME - this should encode into ISO2022
- buffer = Marshal.StringToHGlobalAnsi((string)Clipboard.Item);
+ buffer = Marshal.StringToHGlobalAnsi((string)Clipboard.Source);
while (Marshal.ReadByte(buffer, buflen) != 0) {
buflen++;
}
} else if (xevent.SelectionRequestEvent.target == UNICODETEXT) {
- buffer = Marshal.StringToHGlobalAnsi((string)Clipboard.Item);
- while (Marshal.ReadByte(buffer, buflen) != 0) {
- buflen++;
+ Byte [] bytes;
+
+ bytes = Encoding.Unicode.GetBytes ((string)Clipboard.Source);
+ buffer = Marshal.AllocHGlobal (bytes.Length);
+ buflen = bytes.Length;
+
+ for (int i = 0; i < buflen; i++) {
+ Marshal.WriteByte (buffer, i, bytes [i]);
}
} else {
buffer = IntPtr.Zero;
TranslatePropertyToClipboard(xevent.SelectionEvent.property);
} else {
Clipboard.Item = null;
+ Clipboard.Source = null;
}
} else {
Dnd.HandleSelectionNotifyEvent (ref xevent);
}
internal override void ClipboardStore(IntPtr handle, object obj, int type, XplatUI.ObjectToClipboard converter) {
+ Clipboard.Source = obj;
Clipboard.Item = obj;
Clipboard.Type = type;
Clipboard.Converter = converter;