X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f8105809ef8f7cb0d1a9933f3f790b7b446c7cfa..f284605f65f6f957c90452b574f4131079819b53:/utils/configtool/src/utils.cpp diff --git a/utils/configtool/src/utils.cpp b/utils/configtool/src/utils.cpp index 2be69b4ab8..05849af70c 100644 --- a/utils/configtool/src/utils.cpp +++ b/utils/configtool/src/utils.cpp @@ -323,11 +323,13 @@ void apAddContextHelpButton(wxWindow* parent, wxSizer* sizer, int sizerFlags, in #endif contextButton->SetHelpText(_("Invokes context-sensitive help for the clicked-on window.")); +#if 0 if (wxGetApp().UsingTooltips()) { contextButton->SetToolTip(_("Invokes context-sensitive help for the clicked-on window.")); } #endif +#endif } // Get selected wxNotebook page @@ -475,3 +477,37 @@ wxString ctEscapeHTMLCharacters(const wxString& str) } return s; } + +// Match 'matchText' against 'matchAgainst', optionally constraining to +// whole-word only. +bool ctMatchString(const wxString& matchAgainst, const wxString& matchText, bool wholeWordOnly) +{ + // Fast operation if not matching against whole words only + if (!wholeWordOnly) + return (matchAgainst.Find(matchText) != -1); + + wxString left(matchAgainst); + bool success = FALSE; + int pos = 0; + int matchTextLen = (int) matchText.Length(); + while (!success && !matchAgainst.IsEmpty()) + { + pos = left.Find(matchText); + if (pos == -1) + return FALSE; + + bool firstCharOK = FALSE; + bool lastCharOK = FALSE; + if (pos == 0 || !wxIsalnum(left[(size_t) (pos-1)])) + firstCharOK = TRUE; + + if (((pos + matchTextLen) == (int) left.Length()) || !wxIsalnum(left[(size_t) (pos + matchTextLen)])) + lastCharOK = TRUE; + + if (firstCharOK && lastCharOK) + success = TRUE; + + left = left.Mid(pos+1); + } + return success; +}