diff --git a/docs/changes.txt b/docs/changes.txt index 4de0e0d192..27a39e3bad 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -129,6 +129,7 @@ All (GUI): - Optimize font registration in PostScript code emitted by wxPostScriptDC. - Fix drawing filled arc with wxPostScriptDC::DrawArc(). - Optimize PostScript code emitted by wxPostScriptDC to draw elliptic arcs. +- Add wxStyledTextCtrl::AutoCompGetCurrentText() (NewPagodi). wxGTK: diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index a16c8ee7c5..ab5ffaad91 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -4498,6 +4498,9 @@ public: // Get currently selected item position in the auto-completion list int AutoCompGetCurrent() const; + // Get currently selected item text in the auto-completion list + wxString AutoCompGetCurrentText() const; + // Set auto-completion case insensitive behaviour to either prefer case-sensitive matches or have no preference. void AutoCompSetCaseInsensitiveBehaviour(int behaviour); diff --git a/interface/wx/stc/stc.h b/interface/wx/stc/stc.h index c3fafbbd86..e70954a4af 100644 --- a/interface/wx/stc/stc.h +++ b/interface/wx/stc/stc.h @@ -5757,6 +5757,13 @@ public: */ int AutoCompGetCurrent() const; + /** + Get currently selected item text in the auto-completion list + + @since 3.1.1 + */ + wxString AutoCompGetCurrentText() const; + /** Set auto-completion case insensitive behaviour to either prefer case-sensitive matches or have no preference. diff --git a/src/stc/gen_docs.py b/src/stc/gen_docs.py index 42b0680578..c9faa01003 100644 --- a/src/stc/gen_docs.py +++ b/src/stc/gen_docs.py @@ -85,6 +85,7 @@ docsMap = { 'AutoCGetCaseInsensitiveBehaviour':'Autocompletion', 'AutoCGetChooseSingle':'Autocompletion', 'AutoCGetCurrent':'Autocompletion', + 'AutoCGetCurrentText':'Autocompletion', 'AutoCGetDropRestOfWord':'Autocompletion', 'AutoCGetIgnoreCase':'Autocompletion', 'AutoCGetMaxHeight':'Autocompletion', @@ -806,6 +807,8 @@ docSubstitutions = { 'TextWidth':{'NUL terminated text argument.':''}, 'GetCurLine':{'Result is NUL-terminated.':'', 'Returns the index of the caret on the line.':''}, + 'AutoCGetCurrentText':{'Result is NUL-terminated.':'', + 'Returns the length of the item text':''}, 'StartStyling': {'The unused parameter is no longer used and should be set to 0.':''}, @@ -1330,6 +1333,7 @@ sinceAnnotations= { 'VCHomeDisplay':'3.1.0', 'VCHomeDisplayExtend':'3.1.0', + 'AutoCGetCurrentText':'3.1.1', 'FoldDisplayTextSetStyle':'3.1.1', 'GetDirectFunction':'3.1.1', 'GetDirectPointer':'3.1.1', diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index 38a45e96ae..ed8e850918 100755 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -522,7 +522,23 @@ methodOverrideMap = { 'AutoCGetTypeSeparator' : ('AutoCompGetTypeSeparator', 0, 0), 'AutoCSetTypeSeparator' : ('AutoCompSetTypeSeparator', 0, 0), 'AutoCGetCurrent' : ('AutoCompGetCurrent', 0, 0), - 'AutoCGetCurrentText' : (None, 0, 0), + + 'AutoCGetCurrentText' : + ('AutoCompGetCurrentText', + 'wxString %s() const;', + + '''wxString %s() const { + const int msg = %s; + long len = SendMsg(msg, 0, 0); + + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(msg, 0, (sptr_t)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf);''' + ), + 'AutoCSetMaxWidth' : ('AutoCompSetMaxWidth', 0, 0), 'AutoCGetMaxWidth' : ('AutoCompGetMaxWidth', 0, 0), 'AutoCSetMaxHeight' : ('AutoCompSetMaxHeight', 0, 0), diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 5b9dd0da4c..73883a3bd5 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -3618,6 +3618,19 @@ int wxStyledTextCtrl::AutoCompGetCurrent() const return SendMsg(SCI_AUTOCGETCURRENT, 0, 0); } +// Get currently selected item text in the auto-completion list +wxString wxStyledTextCtrl::AutoCompGetCurrentText() const { + const int msg = SCI_AUTOCGETCURRENTTEXT; + long len = SendMsg(msg, 0, 0); + + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(msg, 0, (sptr_t)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf); +} + // Set auto-completion case insensitive behaviour to either prefer case-sensitive matches or have no preference. void wxStyledTextCtrl::AutoCompSetCaseInsensitiveBehaviour(int behaviour) {