Permalink
Browse files

Fix pasting multiline text in wxOSX to not use \r

Use wxMacConvertNewlines13To10(), not wxMacConvertNewlines10To13() when
copying content from native pasteboard. Perform this conversion not only
for 8bit text, but for UTF-16 one (which is the one actually used on
modern OS X versions) as well.
  • Loading branch information...
1 parent eecf084 commit 587067bc684c0a7619a5ca0ec99ca40afa9c6a1b @vslavik vslavik committed Jan 11, 2017
Showing with 14 additions and 2 deletions.
  1. +1 −0 include/wx/osx/core/cfstring.h
  2. +4 −2 src/osx/carbon/dataobj.cpp
  3. +9 −0 src/osx/core/cfstring.cpp
@@ -30,6 +30,7 @@ WXDLLIMPEXP_BASE void wxMacConvertNewlines13To10( wxString *data ) ;
WXDLLIMPEXP_BASE void wxMacConvertNewlines10To13( wxString *data ) ;
WXDLLIMPEXP_BASE void wxMacConvertNewlines13To10( char * data ) ;
+WXDLLIMPEXP_BASE void wxMacConvertNewlines13To10( char * data, size_t len ) ;
WXDLLIMPEXP_BASE void wxMacConvertNewlines10To13( char * data ) ;
WXDLLIMPEXP_BASE wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding) ;
@@ -487,8 +487,10 @@ bool wxDataObject::GetFromPasteboard( void * pb )
memset( buf, 0, flavorDataSize + 4 );
memcpy( buf, CFDataGetBytePtr( flavorData ), flavorDataSize );
- if (dataFormat.GetType() == wxDF_TEXT)
- wxMacConvertNewlines10To13( (char*) buf );
+ if (dataFormat.GetType() == wxDF_TEXT || dataFormat.GetType() == wxDF_UNICODETEXT)
+ {
+ wxMacConvertNewlines13To10( (char*) buf, flavorDataSize );
+ }
SetData( flavorFormat, flavorDataSize, buf );
transferred = true;
free( buf );
@@ -34,6 +34,15 @@ void wxMacConvertNewlines13To10( char * data )
}
}
+void wxMacConvertNewlines13To10( char * data, size_t len )
+{
+ for ( ; len; ++data, --len )
+ {
+ if ( *data == 0x0d )
+ *data = 0x0a;
+ }
+}
+
void wxMacConvertNewlines10To13( char * data )
{
char * buf = data ;

0 comments on commit 587067b

Please sign in to comment.