From 8de28db94f9d03acfcbbbac841c26a2c40223618 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 4 Sep 2001 23:42:13 +0000 Subject: [PATCH] A couple little fixes for wxSTC git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11559 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/include/wx/stc/stc.h | 10 +++++++--- contrib/src/stc/gen_iface.py | 25 ++++++++++++++++--------- contrib/src/stc/makefile.vc | 24 ++++++++++++++++-------- contrib/src/stc/stc.cpp | 24 ++++++++++++++---------- include/wx/stc/stc.h | 10 +++++++--- src/stc/gen_iface.py | 25 ++++++++++++++++--------- src/stc/makefile.vc | 24 ++++++++++++++++-------- src/stc/stc.cpp | 24 ++++++++++++++---------- 8 files changed, 106 insertions(+), 60 deletions(-) diff --git a/contrib/include/wx/stc/stc.h b/contrib/include/wx/stc/stc.h index 8dfe9a92f4..6618f7dec1 100644 --- a/contrib/include/wx/stc/stc.h +++ b/contrib/include/wx/stc/stc.h @@ -734,7 +734,11 @@ public: // Retrieve the text of the line containing the caret. // Returns the index of the caret on the line. - wxString GetCurLine(int* OUTPUT=NULL); + #ifdef SWIG + wxString GetCurLine(int* OUTPUT); +#else + wxString GetCurLine(int* linePos=NULL); +#endif // Retrieve the position of the last correctly styled character. int GetEndStyled(); @@ -1417,10 +1421,10 @@ public: int GetModEventMask(); // Change internal focus flag - void SetFocus(bool focus); + void SetSTCFocus(bool focus); // Get internal focus flag - bool GetFocus(); + bool GetSTCFocus(); // Change error status - 0 = OK void SetStatus(int statusCode); diff --git a/contrib/src/stc/gen_iface.py b/contrib/src/stc/gen_iface.py index e198bdc6e0..04303b8202 100644 --- a/contrib/src/stc/gen_iface.py +++ b/contrib/src/stc/gen_iface.py @@ -108,15 +108,19 @@ methodOverrideMap = { 0), 'GetCurLine' : (0, - 'wxString %s(int* OUTPUT=NULL);', + '#ifdef SWIG\n wxString %s(int* OUTPUT);\n#else\n wxString GetCurLine(int* linePos=NULL);\n#endif', '''wxString %s(int* linePos) { wxString text; int len = LineLength(GetCurrentLine()); - if (!len) return ""; - char* buf = text.GetWriteBuf(len); - - int pos = SendMsg(%s, len, (long)buf); + if (!len) { + if (linePos) *linePos = 0; + return ""; + } + // Need an extra byte because SCI_GETCURLINE writes a null to the string + char* buf = text.GetWriteBuf(len+1); + + int pos = SendMsg(%s, len+1, (long)buf); text.UngetWriteBuf(len); if (linePos) *linePos = pos; @@ -346,11 +350,11 @@ methodOverrideMap = { '''wxString %s() { wxString text; - int len = GetTextLength()+1; - char* buff = text.GetWriteBuf(len); + int len = GetTextLength(); + char* buff = text.GetWriteBuf(len+1); // leave room for the null... - SendMsg(%s, len, (long)buff); - text.UngetWriteBuf(len-1); + SendMsg(%s, len+1, (long)buff); + text.UngetWriteBuf(len); return text;''', ('Retrieve all the text in the document.', )), @@ -474,6 +478,9 @@ methodOverrideMap = { 0), 'GrabFocus' : (None, 0, 0, 0), + 'SetFocus' : ('SetSTCFocus', 0, 0, 0), + 'GetFocus' : ('GetSTCFocus', 0, 0, 0), + '' : ('', 0, 0, 0), diff --git a/contrib/src/stc/makefile.vc b/contrib/src/stc/makefile.vc index b8fce0a183..fa0f4a7e77 100644 --- a/contrib/src/stc/makefile.vc +++ b/contrib/src/stc/makefile.vc @@ -25,22 +25,30 @@ OBJECTS = \ $(D)\Indicator.obj \ $(D)\KeyMap.obj \ $(D)\KeyWords.obj \ + $(D)\LineMarker.obj \ + $(D)\PropSet.obj \ + $(D)\RESearch.obj \ + $(D)\ScintillaBase.obj \ + $(D)\Style.obj \ + $(D)\UniConversion.obj \ + $(D)\ViewStyle.obj \ + $(D)\WindowAccessor.obj \ + \ + $(D)\LexAda.obj \ + $(D)\LexAVE.obj \ + $(D)\LexConf.obj \ $(D)\LexCPP.obj \ + $(D)\LexEiffel.obj \ $(D)\LexHTML.obj \ + $(D)\LexLisp.obj \ $(D)\LexLua.obj \ $(D)\LexOthers.obj \ + $(D)\LexPascal.obj \ $(D)\LexPerl.obj \ $(D)\LexPython.obj \ + $(D)\LexRuby.obj \ $(D)\LexSQL.obj \ $(D)\LexVB.obj \ - $(D)\LineMarker.obj \ - $(D)\PosRegExp.obj \ - $(D)\PropSet.obj \ - $(D)\ScintillaBase.obj \ - $(D)\Style.obj \ - $(D)\UniConversion.obj \ - $(D)\ViewStyle.obj \ - $(D)\WindowAccessor.obj \ \ $(D)\PlatWX.obj \ $(D)\ScintillaWX.obj \ diff --git a/contrib/src/stc/stc.cpp b/contrib/src/stc/stc.cpp index 944df02c53..ba9cf82838 100644 --- a/contrib/src/stc/stc.cpp +++ b/contrib/src/stc/stc.cpp @@ -338,10 +338,14 @@ void wxStyledTextCtrl::SetAnchor(int posAnchor) { wxString wxStyledTextCtrl::GetCurLine(int* linePos) { wxString text; int len = LineLength(GetCurrentLine()); - if (!len) return ""; - char* buf = text.GetWriteBuf(len); - - int pos = SendMsg(2027, len, (long)buf); + if (!len) { + if (linePos) *linePos = 0; + return ""; + } + // Need an extra byte because SCI_GETCURLINE writes a null to the string + char* buf = text.GetWriteBuf(len+1); + + int pos = SendMsg(2027, len+1, (long)buf); text.UngetWriteBuf(len); if (linePos) *linePos = pos; @@ -1141,11 +1145,11 @@ void wxStyledTextCtrl::SetText(const wxString& text) { // Retrieve all the text in the document. wxString wxStyledTextCtrl::GetText() { wxString text; - int len = GetTextLength()+1; - char* buff = text.GetWriteBuf(len); + int len = GetTextLength(); + char* buff = text.GetWriteBuf(len+1); // leave room for the null... - SendMsg(2182, len, (long)buff); - text.UngetWriteBuf(len-1); + SendMsg(2182, len+1, (long)buff); + text.UngetWriteBuf(len); return text; } @@ -1526,12 +1530,12 @@ int wxStyledTextCtrl::GetModEventMask() { } // Change internal focus flag -void wxStyledTextCtrl::SetFocus(bool focus) { +void wxStyledTextCtrl::SetSTCFocus(bool focus) { SendMsg(2380, focus, 0); } // Get internal focus flag -bool wxStyledTextCtrl::GetFocus() { +bool wxStyledTextCtrl::GetSTCFocus() { return SendMsg(2381, 0, 0) != 0; } diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index 8dfe9a92f4..6618f7dec1 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -734,7 +734,11 @@ public: // Retrieve the text of the line containing the caret. // Returns the index of the caret on the line. - wxString GetCurLine(int* OUTPUT=NULL); + #ifdef SWIG + wxString GetCurLine(int* OUTPUT); +#else + wxString GetCurLine(int* linePos=NULL); +#endif // Retrieve the position of the last correctly styled character. int GetEndStyled(); @@ -1417,10 +1421,10 @@ public: int GetModEventMask(); // Change internal focus flag - void SetFocus(bool focus); + void SetSTCFocus(bool focus); // Get internal focus flag - bool GetFocus(); + bool GetSTCFocus(); // Change error status - 0 = OK void SetStatus(int statusCode); diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index e198bdc6e0..04303b8202 100644 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -108,15 +108,19 @@ methodOverrideMap = { 0), 'GetCurLine' : (0, - 'wxString %s(int* OUTPUT=NULL);', + '#ifdef SWIG\n wxString %s(int* OUTPUT);\n#else\n wxString GetCurLine(int* linePos=NULL);\n#endif', '''wxString %s(int* linePos) { wxString text; int len = LineLength(GetCurrentLine()); - if (!len) return ""; - char* buf = text.GetWriteBuf(len); - - int pos = SendMsg(%s, len, (long)buf); + if (!len) { + if (linePos) *linePos = 0; + return ""; + } + // Need an extra byte because SCI_GETCURLINE writes a null to the string + char* buf = text.GetWriteBuf(len+1); + + int pos = SendMsg(%s, len+1, (long)buf); text.UngetWriteBuf(len); if (linePos) *linePos = pos; @@ -346,11 +350,11 @@ methodOverrideMap = { '''wxString %s() { wxString text; - int len = GetTextLength()+1; - char* buff = text.GetWriteBuf(len); + int len = GetTextLength(); + char* buff = text.GetWriteBuf(len+1); // leave room for the null... - SendMsg(%s, len, (long)buff); - text.UngetWriteBuf(len-1); + SendMsg(%s, len+1, (long)buff); + text.UngetWriteBuf(len); return text;''', ('Retrieve all the text in the document.', )), @@ -474,6 +478,9 @@ methodOverrideMap = { 0), 'GrabFocus' : (None, 0, 0, 0), + 'SetFocus' : ('SetSTCFocus', 0, 0, 0), + 'GetFocus' : ('GetSTCFocus', 0, 0, 0), + '' : ('', 0, 0, 0), diff --git a/src/stc/makefile.vc b/src/stc/makefile.vc index b8fce0a183..fa0f4a7e77 100644 --- a/src/stc/makefile.vc +++ b/src/stc/makefile.vc @@ -25,22 +25,30 @@ OBJECTS = \ $(D)\Indicator.obj \ $(D)\KeyMap.obj \ $(D)\KeyWords.obj \ + $(D)\LineMarker.obj \ + $(D)\PropSet.obj \ + $(D)\RESearch.obj \ + $(D)\ScintillaBase.obj \ + $(D)\Style.obj \ + $(D)\UniConversion.obj \ + $(D)\ViewStyle.obj \ + $(D)\WindowAccessor.obj \ + \ + $(D)\LexAda.obj \ + $(D)\LexAVE.obj \ + $(D)\LexConf.obj \ $(D)\LexCPP.obj \ + $(D)\LexEiffel.obj \ $(D)\LexHTML.obj \ + $(D)\LexLisp.obj \ $(D)\LexLua.obj \ $(D)\LexOthers.obj \ + $(D)\LexPascal.obj \ $(D)\LexPerl.obj \ $(D)\LexPython.obj \ + $(D)\LexRuby.obj \ $(D)\LexSQL.obj \ $(D)\LexVB.obj \ - $(D)\LineMarker.obj \ - $(D)\PosRegExp.obj \ - $(D)\PropSet.obj \ - $(D)\ScintillaBase.obj \ - $(D)\Style.obj \ - $(D)\UniConversion.obj \ - $(D)\ViewStyle.obj \ - $(D)\WindowAccessor.obj \ \ $(D)\PlatWX.obj \ $(D)\ScintillaWX.obj \ diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 944df02c53..ba9cf82838 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -338,10 +338,14 @@ void wxStyledTextCtrl::SetAnchor(int posAnchor) { wxString wxStyledTextCtrl::GetCurLine(int* linePos) { wxString text; int len = LineLength(GetCurrentLine()); - if (!len) return ""; - char* buf = text.GetWriteBuf(len); - - int pos = SendMsg(2027, len, (long)buf); + if (!len) { + if (linePos) *linePos = 0; + return ""; + } + // Need an extra byte because SCI_GETCURLINE writes a null to the string + char* buf = text.GetWriteBuf(len+1); + + int pos = SendMsg(2027, len+1, (long)buf); text.UngetWriteBuf(len); if (linePos) *linePos = pos; @@ -1141,11 +1145,11 @@ void wxStyledTextCtrl::SetText(const wxString& text) { // Retrieve all the text in the document. wxString wxStyledTextCtrl::GetText() { wxString text; - int len = GetTextLength()+1; - char* buff = text.GetWriteBuf(len); + int len = GetTextLength(); + char* buff = text.GetWriteBuf(len+1); // leave room for the null... - SendMsg(2182, len, (long)buff); - text.UngetWriteBuf(len-1); + SendMsg(2182, len+1, (long)buff); + text.UngetWriteBuf(len); return text; } @@ -1526,12 +1530,12 @@ int wxStyledTextCtrl::GetModEventMask() { } // Change internal focus flag -void wxStyledTextCtrl::SetFocus(bool focus) { +void wxStyledTextCtrl::SetSTCFocus(bool focus) { SendMsg(2380, focus, 0); } // Get internal focus flag -bool wxStyledTextCtrl::GetFocus() { +bool wxStyledTextCtrl::GetSTCFocus() { return SendMsg(2381, 0, 0) != 0; } -- 2.45.2