From eddafe55e875ffae7e14d42154c8d030e4b8bde8 Mon Sep 17 00:00:00 2001 From: dail8859 Date: Tue, 13 Sep 2016 09:58:15 -0400 Subject: [PATCH] CallTip text uses start/stop/separator settings Closes #2274 Closes #2278 --- PowerEditor/src/MISC/Common/Common.cpp | 2 - PowerEditor/src/MISC/Common/Common.h | 2 + .../src/ScitillaComponent/FunctionCallTip.cpp | 59 ++++++------------- 3 files changed, 20 insertions(+), 43 deletions(-) diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index 5e3600c9..cd6cb064 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -26,7 +26,6 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include #include -#include #include #include #include @@ -38,7 +37,6 @@ WcharMbcsConvertor* WcharMbcsConvertor::_pSelf = new WcharMbcsConvertor; -typedef std::basic_stringstream generic_stringstream; diff --git a/PowerEditor/src/MISC/Common/Common.h b/PowerEditor/src/MISC/Common/Common.h index 650b4c73..9a350e98 100644 --- a/PowerEditor/src/MISC/Common/Common.h +++ b/PowerEditor/src/MISC/Common/Common.h @@ -27,6 +27,7 @@ #pragma once #include #include +#include #include #include #include @@ -65,6 +66,7 @@ const bool dirDown = false; #define COPYDATA_FILENAMES COPYDATA_FILENAMESW typedef std::basic_string generic_string; +typedef std::basic_stringstream generic_stringstream; generic_string folderBrowser(HWND parent, const generic_string & title = TEXT(""), int outputCtrlID = 0, const TCHAR *defaultStr = NULL); generic_string getFolderName(HWND parent, const TCHAR *defaultDir = NULL); diff --git a/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp b/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp index 04d923a1..83d60aa3 100644 --- a/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp +++ b/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp @@ -398,69 +398,46 @@ void FunctionCallTip::showCalltip() } } } - const TCHAR * curRetValText = _retVals.at(_currentOverload); - const TCHAR * curDescriptionText = _descriptions.at(_currentOverload); - bool hasDescr = true; - if (!curDescriptionText[0]) - hasDescr = false; - int bytesNeeded = lstrlen(curRetValText) + lstrlen(_funcName) + 5;//'retval funcName (params)\0' - if (hasDescr) - bytesNeeded += lstrlen(curDescriptionText); + generic_stringstream callTipText; - size_t nrParams = params.size(); - for(size_t i = 0; i < nrParams; ++i) { - bytesNeeded += lstrlen(params.at(i)) + 2; //'param, ' + if (_currentNrOverloads > 1) + { + callTipText << TEXT("\001") << _currentOverload + 1 << TEXT(" of ") << _currentNrOverloads << TEXT("\002"); } - if (_currentNrOverloads > 1) { - bytesNeeded += 24; // /\00001 of 00003\/ - } - - const int maxLen = 2048; - if (bytesNeeded >= maxLen) - return; - - TCHAR textBuffer[maxLen]; - textBuffer[0] = 0; - - if (_currentNrOverloads > 1) { - wsprintf(textBuffer, TEXT("\001%u of %u\002"), _currentOverload+1, _currentNrOverloads); - } - - lstrcat(textBuffer, curRetValText); - lstrcat(textBuffer, TEXT(" ")); - lstrcat(textBuffer, _funcName); - lstrcat(textBuffer, TEXT(" (")); + callTipText << _retVals.at(_currentOverload) << TEXT(' ') << _funcName << TEXT(' ') << _start; int highlightstart = 0; int highlightend = 0; - for(size_t i = 0; i < nrParams; ++i) + size_t nrParams = params.size(); + for (size_t i = 0; i < nrParams; ++i) { if (int(i) == _currentParam) { - highlightstart = lstrlen(textBuffer); + highlightstart = static_cast(callTipText.str().length()); highlightend = highlightstart + lstrlen(params.at(i)); } - lstrcat(textBuffer, params.at(i)); - if (i < nrParams-1) - lstrcat(textBuffer, TEXT(", ")); + callTipText << params.at(i); + if (i < nrParams - 1) + callTipText << _param << TEXT(' '); } - lstrcat(textBuffer, TEXT(")")); - if (hasDescr) { - lstrcat(textBuffer, TEXT("\n")); - lstrcat(textBuffer, curDescriptionText); + callTipText << _stop; + if (_descriptions.at(_currentOverload)[0]) + { + callTipText << TEXT("\n") << _descriptions.at(_currentOverload); } if (isVisible()) _pEditView->execute(SCI_CALLTIPCANCEL); else _startPos = _curPos; - _pEditView->showCallTip(_startPos, textBuffer); + _pEditView->showCallTip(_startPos, callTipText.str().c_str()); _selfActivated = true; - if (highlightstart != highlightend) { + if (highlightstart != highlightend) + { _pEditView->execute(SCI_CALLTIPSETHLT, highlightstart, highlightend); } }