Add several "Raw" functions for setting/getting text from the document

buffer. They behave similarly to the same methods without the "Raw" in
the name, except they don't use wxStrings.  This can save some
conversions to/from unicode and utf-8 in a Unicode build.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33639 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2005-04-16 04:53:01 +00:00
parent 22faef6ced
commit 41a499cd92
10 changed files with 596 additions and 6 deletions

View File

@@ -1632,8 +1632,9 @@ bool wxStyledTextCtrl::GetUseVerticalScrollBar() {
}
// Append a string to the end of the document without changing the selection.
void wxStyledTextCtrl::AppendText(int length, const wxString& text) {
SendMsg(2282, length, (long)(const char*)wx2stc(text));
void wxStyledTextCtrl::AppendText(const wxString& text) {
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
SendMsg(2282, strlen(buf), (long)(const char*)buf);
}
// Is drawing done in two phases with backgrounds drawn before foregrounds?
@@ -2675,6 +2676,109 @@ bool wxStyledTextCtrl::GetUseAntiAliasing() {
return m_swx->GetUseAntiAliasing();
}
void wxStyledTextCtrl::AddTextRaw(const char* text)
{
SendMsg(SCI_ADDTEXT, strlen(text), (long)text);
}
void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text)
{
SendMsg(SCI_INSERTTEXT, pos, (long)text);
}
wxCharBuffer wxStyledTextCtrl::GetCurLineRaw(int* linePos)
{
int len = LineLength(GetCurrentLine());
if (!len) {
if (linePos) *linePos = 0;
wxCharBuffer empty;
return empty;
}
wxCharBuffer buf(len);
int pos = SendMsg(SCI_GETCURLINE, len, (long)buf.data());
if (linePos) *linePos = pos;
return buf;
}
wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line)
{
int len = LineLength(line);
if (!len) {
wxCharBuffer empty;
return empty;
}
wxCharBuffer buf(len);
SendMsg(SCI_GETLINE, line, (long)buf.data());
return buf;
}
wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw()
{
int start;
int end;
GetSelection(&start, &end);
int len = end - start;
if (!len) {
wxCharBuffer empty;
return empty;
}
wxCharBuffer buf(len);
SendMsg(SCI_GETSELTEXT, 0, (long)buf.data());
return buf;
}
wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos)
{
if (endPos < startPos) {
int temp = startPos;
startPos = endPos;
endPos = temp;
}
int len = endPos - startPos;
if (!len) {
wxCharBuffer empty;
return empty;
}
wxCharBuffer buf(len);
TextRange tr;
tr.lpstrText = buf.data();
tr.chrg.cpMin = startPos;
tr.chrg.cpMax = endPos;
SendMsg(SCI_GETTEXTRANGE, 0, (long)&tr);
return buf;
}
void wxStyledTextCtrl::SetTextRaw(const char* text)
{
SendMsg(SCI_SETTEXT, 0, (long)text);
}
wxCharBuffer wxStyledTextCtrl::GetTextRaw()
{
int len = GetTextLength();
wxCharBuffer buf(len);
SendMsg(SCI_GETTEXT, len, (long)buf.data());
return buf;
}
void wxStyledTextCtrl::AppendTextRaw(const char* text)
{
SendMsg(SCI_APPENDTEXT, strlen(text), (long)text);
}
//----------------------------------------------------------------------
// Event handlers