Simplify wxMacConvertNewlines helper functions
One is not used at all, two are only used in one place. Make the remaining two return a wxString instead of taking a wxString pointer parameter.
This commit is contained in:
parent
37e29d3451
commit
0b2ec56ae3
@ -26,12 +26,8 @@
|
||||
|
||||
class WXDLLIMPEXP_FWD_BASE wxString;
|
||||
|
||||
WXDLLIMPEXP_BASE void wxMacConvertNewlines13To10( wxString *data ) ;
|
||||
WXDLLIMPEXP_BASE void wxMacConvertNewlines10To13( wxString *data ) ;
|
||||
|
||||
WXDLLIMPEXP_BASE void wxMacConvertNewlines13To10( char * data ) ;
|
||||
WXDLLIMPEXP_BASE void wxMacConvertNewlines13To10( wxChar16 * data ) ;
|
||||
WXDLLIMPEXP_BASE void wxMacConvertNewlines10To13( char * data ) ;
|
||||
WXDLLIMPEXP_BASE wxString wxMacConvertNewlines13To10(const wxString& data);
|
||||
WXDLLIMPEXP_BASE wxString wxMacConvertNewlines10To13(const wxString& data);
|
||||
|
||||
WXDLLIMPEXP_BASE wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding) ;
|
||||
WXDLLIMPEXP_BASE wxFontEncoding wxMacGetFontEncFromSystemEnc(wxUint32 encoding) ;
|
||||
|
@ -489,11 +489,15 @@ bool wxDataObject::GetFromPasteboard( void * pb )
|
||||
|
||||
if (dataFormat.GetType() == wxDF_TEXT)
|
||||
{
|
||||
wxMacConvertNewlines13To10((char*) buf);
|
||||
for (char* p = static_cast<char*>(buf); *p; p++)
|
||||
if (*p == '\r')
|
||||
*p = '\n';
|
||||
}
|
||||
else if (dataFormat.GetType() == wxDF_UNICODETEXT)
|
||||
{
|
||||
wxMacConvertNewlines13To10((wxChar16*) buf);
|
||||
for (wxChar16* p = static_cast<wxChar16*>(buf); *p; p++)
|
||||
if (*p == '\r')
|
||||
*p = '\n';
|
||||
}
|
||||
SetData( flavorFormat, flavorDataSize, buf );
|
||||
transferred = true;
|
||||
|
@ -788,22 +788,22 @@ void wxNSTextViewControl::insertText(NSString* str, WXWidget slf, void *_cmd)
|
||||
|
||||
wxString wxNSTextViewControl::GetStringValue() const
|
||||
{
|
||||
wxString result;
|
||||
if (m_textView)
|
||||
{
|
||||
wxString result = wxCFStringRef::AsString([m_textView string], m_wxPeer->GetFont().GetEncoding());
|
||||
wxMacConvertNewlines13To10( &result ) ;
|
||||
return result;
|
||||
result = wxMacConvertNewlines13To10(
|
||||
wxCFStringRef::AsString([m_textView string], m_wxPeer->GetFont().GetEncoding()));
|
||||
}
|
||||
return wxEmptyString;
|
||||
return result;
|
||||
}
|
||||
|
||||
void wxNSTextViewControl::SetStringValue( const wxString &str)
|
||||
{
|
||||
wxString st = str;
|
||||
wxMacConvertNewlines10To13( &st );
|
||||
wxMacEditHelper helper(m_textView);
|
||||
|
||||
if (m_textView)
|
||||
{
|
||||
wxString st(wxMacConvertNewlines10To13(str));
|
||||
[m_textView setString: wxCFStringRef( st , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
|
||||
if ( m_wxPeer->HasFlag(wxTE_AUTO_URL) )
|
||||
{
|
||||
@ -984,8 +984,7 @@ void wxNSTextViewControl::ShowPosition(long pos)
|
||||
|
||||
void wxNSTextViewControl::WriteText(const wxString& str)
|
||||
{
|
||||
wxString st = str;
|
||||
wxMacConvertNewlines10To13( &st );
|
||||
wxString st(wxMacConvertNewlines10To13(str));
|
||||
wxMacEditHelper helper(m_textView);
|
||||
NSEvent* formerEvent = m_lastKeyDownEvent;
|
||||
m_lastKeyDownEvent = nil;
|
||||
|
@ -24,46 +24,17 @@
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
|
||||
void wxMacConvertNewlines13To10( char * data )
|
||||
{
|
||||
char * buf = data ;
|
||||
while( (buf=strchr(buf,0x0d)) != NULL )
|
||||
{
|
||||
*buf = 0x0a ;
|
||||
buf++ ;
|
||||
}
|
||||
}
|
||||
|
||||
void wxMacConvertNewlines13To10( wxChar16 * data )
|
||||
{
|
||||
for ( ; *data; ++data )
|
||||
{
|
||||
if ( *data == 0x0d )
|
||||
*data = 0x0a;
|
||||
}
|
||||
}
|
||||
|
||||
void wxMacConvertNewlines10To13( char * data )
|
||||
{
|
||||
char * buf = data ;
|
||||
while( (buf=strchr(buf,0x0a)) != NULL )
|
||||
{
|
||||
*buf = 0x0d ;
|
||||
buf++ ;
|
||||
}
|
||||
}
|
||||
|
||||
const wxString sCR((wxChar)13);
|
||||
const wxString sLF((wxChar)10);
|
||||
|
||||
void wxMacConvertNewlines13To10( wxString * data )
|
||||
wxString wxMacConvertNewlines13To10(const wxString& data)
|
||||
{
|
||||
data->Replace( sCR,sLF);
|
||||
return wxString(data)->Replace(sCR, sLF);
|
||||
}
|
||||
|
||||
void wxMacConvertNewlines10To13( wxString * data )
|
||||
wxString wxMacConvertNewlines10To13(const wxString& data)
|
||||
{
|
||||
data->Replace( sLF,sCR);
|
||||
return wxString(data)->Replace(sLF, sCR);
|
||||
}
|
||||
|
||||
wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding)
|
||||
@ -614,8 +585,7 @@ wxCFStringRef::wxCFStringRef( const wxString &st , wxFontEncoding WXUNUSED_IN_UN
|
||||
}
|
||||
else
|
||||
{
|
||||
wxString str = st ;
|
||||
wxMacConvertNewlines13To10( &str ) ;
|
||||
wxString str(wxMacConvertNewlines13To10(st));
|
||||
#if wxUSE_UNICODE
|
||||
#if wxUSE_UNICODE_WCHAR
|
||||
// native = wchar_t 4 bytes for us
|
||||
@ -700,8 +670,7 @@ wxString wxCFStringRef::AsString( CFStringRef ref, wxFontEncoding WXUNUSED_IN_UN
|
||||
#endif
|
||||
|
||||
delete[] buf ;
|
||||
wxMacConvertNewlines10To13( &result);
|
||||
return result ;
|
||||
return wxMacConvertNewlines10To13(result);
|
||||
}
|
||||
|
||||
wxString wxCFStringRef::AsString(wxFontEncoding encoding) const
|
||||
|
@ -336,23 +336,24 @@ bool wxUITextViewControl::CanFocus() const
|
||||
|
||||
wxString wxUITextViewControl::GetStringValue() const
|
||||
{
|
||||
wxString result;
|
||||
if (m_textView)
|
||||
{
|
||||
wxString result = wxCFStringRef::AsString([m_textView text], m_wxPeer->GetFont().GetEncoding());
|
||||
wxMacConvertNewlines13To10( &result ) ;
|
||||
return result;
|
||||
result = wxMacConvertNewlines13To10(
|
||||
wxCFStringRef::AsString([m_textView text], m_wxPeer->GetFont().GetEncoding()));
|
||||
}
|
||||
return wxEmptyString;
|
||||
return result;
|
||||
}
|
||||
|
||||
void wxUITextViewControl::SetStringValue( const wxString &str)
|
||||
{
|
||||
wxString st = str;
|
||||
wxMacConvertNewlines10To13( &st );
|
||||
wxMacEditHelper helper(m_textView);
|
||||
|
||||
if (m_textView)
|
||||
{
|
||||
wxString st(wxMacConvertNewlines10To13(str));
|
||||
[m_textView setText: wxCFStringRef( st , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
|
||||
}
|
||||
}
|
||||
|
||||
void wxUITextViewControl::Copy()
|
||||
@ -419,8 +420,7 @@ void wxUITextViewControl::SetSelection( long from , long to )
|
||||
|
||||
void wxUITextViewControl::WriteText(const wxString& str)
|
||||
{
|
||||
wxString st = str;
|
||||
wxMacConvertNewlines10To13( &st );
|
||||
wxString st(wxMacConvertNewlines10To13(str));
|
||||
wxMacEditHelper helper(m_textView);
|
||||
|
||||
wxCFStringRef insert( st , m_wxPeer->GetFont().GetEncoding() );
|
||||
|
Loading…
Reference in New Issue
Block a user