Remove more conversion from Scintilla

This commit is contained in:
Don Ho 2022-01-18 18:50:28 +01:00
parent 9b832dbb2c
commit 4f15b01591
16 changed files with 71 additions and 53 deletions

View File

@ -325,7 +325,7 @@ generic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand
} }
const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, size_t codepage, int lenMbcs, int *pLenWc, int *pBytesNotProcessed) const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, size_t codepage, int lenMbcs, int* pLenWc, int* pBytesNotProcessed)
{ {
// Do not process NULL pointer // Do not process NULL pointer
if (!mbcs2Convert) if (!mbcs2Convert)
@ -429,7 +429,7 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, size_t
} }
const char* WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, size_t codepage, int lenWc, int *pLenMbcs) const char* WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, size_t codepage, int lenWc, int* pLenMbcs)
{ {
if (nullptr == wcharStr2Convert) if (nullptr == wcharStr2Convert)
return nullptr; return nullptr;
@ -449,7 +449,7 @@ const char* WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, siz
} }
const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, size_t codepage, long *mstart, long *mend) const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, size_t codepage, long* mstart, long* mend)
{ {
if (nullptr == wcharStr2Convert) if (nullptr == wcharStr2Convert)
return nullptr; return nullptr;

View File

@ -94,12 +94,12 @@ public:
return instance; return instance;
} }
const wchar_t * char2wchar(const char *mbStr, size_t codepage, int lenIn=-1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL); const wchar_t * char2wchar(const char *mbStr, size_t codepage, int lenMbcs =-1, int* pLenOut=NULL, int* pBytesNotProcessed=NULL);
const wchar_t * char2wchar(const char *mbcs2Convert, size_t codepage, INT_PTR* mstart, INT_PTR* mend); const wchar_t * char2wchar(const char *mbcs2Convert, size_t codepage, INT_PTR* mstart, INT_PTR* mend);
const char * wchar2char(const wchar_t *wcStr, size_t codepage, int lenIn = -1, int *pLenOut = NULL); const char * wchar2char(const wchar_t *wcStr, size_t codepage, int lenIn = -1, int* pLenOut = NULL);
const char * wchar2char(const wchar_t *wcStr, size_t codepage, long *mstart, long *mend); const char * wchar2char(const wchar_t *wcStr, size_t codepage, long* mstart, long* mend);
const char * encode(UINT fromCodepage, UINT toCodepage, const char *txt2Encode, int lenIn = -1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL) const char * encode(UINT fromCodepage, UINT toCodepage, const char *txt2Encode, int lenIn = -1, int* pLenOut=NULL, int* pBytesNotProcessed=NULL)
{ {
int lenWc = 0; int lenWc = 0;
const wchar_t * strW = char2wchar(txt2Encode, fromCodepage, lenIn, &lenWc, pBytesNotProcessed); const wchar_t * strW = char2wchar(txt2Encode, fromCodepage, lenIn, &lenWc, pBytesNotProcessed);

View File

@ -167,7 +167,7 @@ INT_PTR CALLBACK HashFromFilesDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
int len = static_cast<int>(::SendMessage(::GetDlgItem(_hSelf, IDC_HASH_RESULT_EDIT), WM_GETTEXTLENGTH, 0, 0)); int len = static_cast<int>(::SendMessage(::GetDlgItem(_hSelf, IDC_HASH_RESULT_EDIT), WM_GETTEXTLENGTH, 0, 0));
if (len) if (len)
{ {
wchar_t *rStr = new wchar_t[len+1]; wchar_t* rStr = new wchar_t[len+1];
::GetDlgItemText(_hSelf, IDC_HASH_RESULT_EDIT, rStr, len + 1); ::GetDlgItemText(_hSelf, IDC_HASH_RESULT_EDIT, rStr, len + 1);
str2Clipboard(rStr, _hSelf); str2Clipboard(rStr, _hSelf);
delete[] rStr; delete[] rStr;
@ -243,7 +243,7 @@ void HashFromTextDlg::generateHash()
{ {
// it's important to get text from UNICODE then convert it to UTF8 // it's important to get text from UNICODE then convert it to UTF8
// So we get the result of UTF8 text (tested with Chinese). // So we get the result of UTF8 text (tested with Chinese).
wchar_t *text = new wchar_t[len + 1]; wchar_t* text = new wchar_t[len + 1];
::GetDlgItemText(_hSelf, IDC_HASH_TEXT_EDIT, text, len + 1); ::GetDlgItemText(_hSelf, IDC_HASH_TEXT_EDIT, text, len + 1);
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
const char *newText = wmc.wchar2char(text, SC_CP_UTF8); const char *newText = wmc.wchar2char(text, SC_CP_UTF8);
@ -277,7 +277,7 @@ void HashFromTextDlg::generateHashPerLine()
int len = static_cast<int>(::SendMessage(::GetDlgItem(_hSelf, IDC_HASH_TEXT_EDIT), WM_GETTEXTLENGTH, 0, 0)); int len = static_cast<int>(::SendMessage(::GetDlgItem(_hSelf, IDC_HASH_TEXT_EDIT), WM_GETTEXTLENGTH, 0, 0));
if (len) if (len)
{ {
wchar_t *text = new wchar_t[len + 1]; wchar_t* text = new wchar_t[len + 1];
::GetDlgItemText(_hSelf, IDC_HASH_TEXT_EDIT, text, len + 1); ::GetDlgItemText(_hSelf, IDC_HASH_TEXT_EDIT, text, len + 1);
std::wstringstream ss(text); std::wstringstream ss(text);
@ -455,7 +455,7 @@ INT_PTR CALLBACK HashFromTextDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
int len = static_cast<int>(::SendMessage(::GetDlgItem(_hSelf, IDC_HASH_RESULT_FOMTEXT_EDIT), WM_GETTEXTLENGTH, 0, 0)); int len = static_cast<int>(::SendMessage(::GetDlgItem(_hSelf, IDC_HASH_RESULT_FOMTEXT_EDIT), WM_GETTEXTLENGTH, 0, 0));
if (len) if (len)
{ {
wchar_t *rStr = new wchar_t[len+1]; wchar_t* rStr = new wchar_t[len+1];
::GetDlgItemText(_hSelf, IDC_HASH_RESULT_FOMTEXT_EDIT, rStr, len + 1); ::GetDlgItemText(_hSelf, IDC_HASH_RESULT_FOMTEXT_EDIT, rStr, len + 1);
str2Clipboard(rStr, _hSelf); str2Clipboard(rStr, _hSelf);
delete[] rStr; delete[] rStr;

View File

@ -3740,9 +3740,11 @@ void Notepad_plus::updateStatusBar()
// STATUSBAR_DOC_TYPE , STATUSBAR_EOF_FORMAT , STATUSBAR_UNICODE_TYPE // STATUSBAR_DOC_TYPE , STATUSBAR_EOF_FORMAT , STATUSBAR_UNICODE_TYPE
TCHAR strDocLen[256]; TCHAR strDocLen[256];
size_t docLen = _pEditView->getCurrentDocLen();
INT_PTR nbLine = _pEditView->execute(SCI_GETLINECOUNT);
wsprintf(strDocLen, TEXT("length : %s lines : %s"), wsprintf(strDocLen, TEXT("length : %s lines : %s"),
commafyInt(_pEditView->getCurrentDocLen()).c_str(), commafyInt(docLen).c_str(),
commafyInt(_pEditView->execute(SCI_GETLINECOUNT)).c_str()); commafyInt(nbLine).c_str());
_statusBar.setText(strDocLen, STATUSBAR_DOC_SIZE); _statusBar.setText(strDocLen, STATUSBAR_DOC_SIZE);
TCHAR strSel[64]; TCHAR strSel[64];
@ -3813,9 +3815,11 @@ void Notepad_plus::updateStatusBar()
} }
TCHAR strLnColSel[128]; TCHAR strLnColSel[128];
INT_PTR curLN = _pEditView->getCurrentLineNumber();
INT_PTR curCN = _pEditView->getCurrentColumnNumber();
wsprintf(strLnColSel, TEXT("Ln : %s Col : %s %s"), wsprintf(strLnColSel, TEXT("Ln : %s Col : %s %s"),
commafyInt(_pEditView->getCurrentLineNumber() + 1).c_str(), commafyInt(curLN + 1).c_str(),
commafyInt(_pEditView->getCurrentColumnNumber() + 1).c_str(), commafyInt(curCN + 1).c_str(),
strSel); strSel);
_statusBar.setText(strLnColSel, STATUSBAR_CUR_POS); _statusBar.setText(strLnColSel, STATUSBAR_CUR_POS);

View File

@ -504,14 +504,14 @@ private:
void bookmarkAdd(INT_PTR lineno) const { void bookmarkAdd(INT_PTR lineno) const {
if (lineno == -1) if (lineno == -1)
lineno = static_cast<int32_t>(_pEditView->getCurrentLineNumber()); lineno = _pEditView->getCurrentLineNumber();
if (!bookmarkPresent(lineno)) if (!bookmarkPresent(lineno))
_pEditView->execute(SCI_MARKERADD, lineno, MARK_BOOKMARK); _pEditView->execute(SCI_MARKERADD, lineno, MARK_BOOKMARK);
} }
void bookmarkDelete(size_t lineno) const { void bookmarkDelete(size_t lineno) const {
if (lineno == -1) if (lineno == -1)
lineno = static_cast<int32_t>(_pEditView->getCurrentLineNumber()); lineno = _pEditView->getCurrentLineNumber();
while (bookmarkPresent(lineno)) while (bookmarkPresent(lineno))
_pEditView->execute(SCI_MARKERDELETE, lineno, MARK_BOOKMARK); _pEditView->execute(SCI_MARKERDELETE, lineno, MARK_BOOKMARK);
} }
@ -525,7 +525,7 @@ private:
void bookmarkToggle(INT_PTR lineno) const { void bookmarkToggle(INT_PTR lineno) const {
if (lineno == -1) if (lineno == -1)
lineno = static_cast<int32_t>(_pEditView->getCurrentLineNumber()); lineno = _pEditView->getCurrentLineNumber();
if (bookmarkPresent(lineno)) if (bookmarkPresent(lineno))
bookmarkDelete(lineno); bookmarkDelete(lineno);

View File

@ -3128,10 +3128,10 @@ void Notepad_plus::command(int id)
size_t selectionStart = _pEditView->execute(SCI_GETSELECTIONSTART); size_t selectionStart = _pEditView->execute(SCI_GETSELECTIONSTART);
size_t selectionEnd = _pEditView->execute(SCI_GETSELECTIONEND); size_t selectionEnd = _pEditView->execute(SCI_GETSELECTIONEND);
int32_t strLen = static_cast<int32_t>(selectionEnd - selectionStart); INT_PTR strLen = selectionEnd - selectionStart;
if (strLen) if (strLen)
{ {
int strSize = strLen + 1; INT_PTR strSize = strLen + 1;
char *selectedStr = new char[strSize]; char *selectedStr = new char[strSize];
_pEditView->execute(SCI_GETSELTEXT, 0, reinterpret_cast<LPARAM>(selectedStr)); _pEditView->execute(SCI_GETSELTEXT, 0, reinterpret_cast<LPARAM>(selectedStr));

View File

@ -183,7 +183,7 @@ void AutoCompletion::getWordArray(vector<generic_string> & wordArray, TCHAR *beg
wordArray.push_back(w); wordArray.push_back(w);
} }
} }
posFind = _pEditView->searchInTarget(expr.c_str(), static_cast<int32_t>(expr.length()), wordEnd, docLength); posFind = _pEditView->searchInTarget(expr.c_str(), expr.length(), wordEnd, docLength);
} }
} }

View File

@ -664,7 +664,7 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin
Utf8_16_Read UnicodeConvertor; //declare here so we can get information after loading is done Utf8_16_Read UnicodeConvertor; //declare here so we can get information after loading is done
char data[blockSize + 8]; // +8 for incomplete multibyte char char* data = new char[blockSize + 8]; // +8 for incomplete multibyte char
LoadedFileFormat loadedFileFormat; LoadedFileFormat loadedFileFormat;
loadedFileFormat._encoding = encoding; loadedFileFormat._encoding = encoding;
@ -672,6 +672,9 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin
loadedFileFormat._language = L_TEXT; loadedFileFormat._language = L_TEXT;
bool res = loadFileData(doc, backupFileName ? backupFileName : fullpath, data, &UnicodeConvertor, loadedFileFormat); bool res = loadFileData(doc, backupFileName ? backupFileName : fullpath, data, &UnicodeConvertor, loadedFileFormat);
delete[] data;
if (res) if (res)
{ {
Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_REGULAR, fullpath); Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_REGULAR, fullpath);
@ -722,7 +725,7 @@ bool FileManager::reloadBuffer(BufferID id)
Document doc = buf->getDocument(); Document doc = buf->getDocument();
Utf8_16_Read UnicodeConvertor; Utf8_16_Read UnicodeConvertor;
char data[blockSize + 8]; // +8 for incomplete multibyte char char* data = new char[blockSize + 8]; // +8 for incomplete multibyte char
LoadedFileFormat loadedFileFormat; LoadedFileFormat loadedFileFormat;
loadedFileFormat._encoding = buf->getEncoding(); loadedFileFormat._encoding = buf->getEncoding();
@ -736,6 +739,7 @@ bool FileManager::reloadBuffer(BufferID id)
bool res = loadFileData(doc, buf->getFullPathName(), data, &UnicodeConvertor, loadedFileFormat); bool res = loadFileData(doc, buf->getFullPathName(), data, &UnicodeConvertor, loadedFileFormat);
delete[] data;
buf->_canNotify = true; buf->_canNotify = true;
if (res) if (res)
@ -1342,7 +1346,7 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, char* data,
unsigned __int64 fileSize =_ftelli64(fp); unsigned __int64 fileSize =_ftelli64(fp);
rewind(fp); rewind(fp);
// size/6 is the normal room Scintilla keeps for editing, but here we limit it to 1MiB when loading (maybe we want to load big files without editing them too much) // size/6 is the normal room Scintilla keeps for editing, but here we limit it to 1MiB when loading (maybe we want to load big files without editing them too much)
unsigned __int64 bufferSizeRequested = fileSize + min(1<<20, fileSize/6); unsigned __int64 bufferSizeRequested = fileSize +min(1 << 20, fileSize / 6);
NppParameters& nppParam = NppParameters::getInstance(); NppParameters& nppParam = NppParameters::getInstance();
NativeLangSpeaker* pNativeSpeaker = nppParam.getNativeLangSpeaker(); NativeLangSpeaker* pNativeSpeaker = nppParam.getNativeLangSpeaker();

View File

@ -131,7 +131,7 @@ private:
private: private:
Notepad_plus* _pNotepadPlus = nullptr; Notepad_plus* _pNotepadPlus = nullptr;
ScintillaEditView* _pscratchTilla = nullptr; ScintillaEditView* _pscratchTilla = nullptr;
Document _scratchDocDefault; Document _scratchDocDefault = 0;
std::vector<Buffer*> _buffers; std::vector<Buffer*> _buffers;
BufferID _nextBufferID = 0; BufferID _nextBufferID = 0;
size_t _nbBufs = 0; size_t _nbBufs = 0;

View File

@ -782,6 +782,7 @@ void ScintillaEditView::setUserLexer(const TCHAR *userLangName)
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>(name), reinterpret_cast<LPARAM>(userLangContainer->_isPrefix[i] ? "1" : "0")); execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>(name), reinterpret_cast<LPARAM>(userLangContainer->_isPrefix[i] ? "1" : "0"));
} }
char* temp = new char[max_char];
for (int i = 0 ; i < SCE_USER_KWLIST_TOTAL ; ++i) for (int i = 0 ; i < SCE_USER_KWLIST_TOTAL ; ++i)
{ {
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
@ -793,7 +794,6 @@ void ScintillaEditView::setUserLexer(const TCHAR *userLangName)
} }
else // OPERATORS2, FOLDERS_IN_CODE2, FOLDERS_IN_COMMENT, KEYWORDS1-8 else // OPERATORS2, FOLDERS_IN_CODE2, FOLDERS_IN_COMMENT, KEYWORDS1-8
{ {
char temp[max_char];
bool inDoubleQuote = false; bool inDoubleQuote = false;
bool inSingleQuote = false; bool inSingleQuote = false;
bool nonWSFound = false; bool nonWSFound = false;
@ -844,6 +844,7 @@ void ScintillaEditView::setUserLexer(const TCHAR *userLangName)
execute(SCI_SETKEYWORDS, setKeywordsCounter++, reinterpret_cast<LPARAM>(temp)); execute(SCI_SETKEYWORDS, setKeywordsCounter++, reinterpret_cast<LPARAM>(temp));
} }
} }
delete[] temp;
char intBuffer[32]; char intBuffer[32];
@ -1927,12 +1928,6 @@ void ScintillaEditView::activateBuffer(BufferID buffer)
restoreCurrentPosPreStep(); restoreCurrentPosPreStep();
//setup line number margin
INT_PTR numLines = execute(SCI_GETLINECOUNT);
char numLineStr[32];
itoa(static_cast<int>(numLines), numLineStr, 10);
runMarkers(true, 0, true, false); runMarkers(true, 0, true, false);
return; //all done return; //all done
} }
@ -2335,7 +2330,7 @@ void ScintillaEditView::addGenericText(const TCHAR * text2Append) const
execute(SCI_ADDTEXT, strlen(text2AppendA), reinterpret_cast<LPARAM>(text2AppendA)); execute(SCI_ADDTEXT, strlen(text2AppendA), reinterpret_cast<LPARAM>(text2AppendA));
} }
void ScintillaEditView::addGenericText(const TCHAR * text2Append, long *mstart, long *mend) const void ScintillaEditView::addGenericText(const TCHAR * text2Append, long* mstart, long* mend) const
{ {
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
size_t cp = execute(SCI_GETCODEPAGE); size_t cp = execute(SCI_GETCODEPAGE);

View File

@ -248,7 +248,7 @@ public:
INT_PTR searchInTarget(const TCHAR * Text2Find, size_t lenOfText2Find, size_t fromPos, size_t toPos) const; INT_PTR searchInTarget(const TCHAR * Text2Find, size_t lenOfText2Find, size_t fromPos, size_t toPos) const;
void appandGenericText(const TCHAR * text2Append) const; void appandGenericText(const TCHAR * text2Append) const;
void addGenericText(const TCHAR * text2Append) const; void addGenericText(const TCHAR * text2Append) const;
void addGenericText(const TCHAR * text2Append, long *mstart, long *mend) const; void addGenericText(const TCHAR * text2Append, long* mstart, long* mend) const;
INT_PTR replaceTarget(const TCHAR * str2replace, INT_PTR fromTargetPos = -1, INT_PTR toTargetPos = -1) const; INT_PTR replaceTarget(const TCHAR * str2replace, INT_PTR fromTargetPos = -1, INT_PTR toTargetPos = -1) const;
INT_PTR replaceTargetRegExMode(const TCHAR * re, INT_PTR fromTargetPos = -1, INT_PTR toTargetPos = -1) const; INT_PTR replaceTargetRegExMode(const TCHAR * re, INT_PTR fromTargetPos = -1, INT_PTR toTargetPos = -1) const;
void showAutoComletion(size_t lenEntered, const TCHAR * list); void showAutoComletion(size_t lenEntered, const TCHAR * list);

View File

@ -522,8 +522,10 @@ void CommentStyleDialog::setKeywords2List(int id)
} }
if (index != -1) if (index != -1)
{ {
TCHAR newList[max_char] = TEXT(""); TCHAR* newList = new TCHAR[max_char];
TCHAR buffer[max_char] = TEXT(""); newList[0] = '\0';
TCHAR* buffer = new TCHAR[max_char];
buffer[0] = '\0';
TCHAR intBuffer[10] = {'0', 0}; TCHAR intBuffer[10] = {'0', 0};
const int list[] = { const int list[] = {
@ -542,6 +544,8 @@ void CommentStyleDialog::setKeywords2List(int id)
} }
wcscpy_s(_pUserLang->_keywordLists[index], newList); wcscpy_s(_pUserLang->_keywordLists[index], newList);
delete[] newList;
delete[] buffer;
} }
} }
@ -583,7 +587,8 @@ void CommentStyleDialog::retrieve(TCHAR *dest, const TCHAR *toRetrieve, TCHAR *p
void CommentStyleDialog::updateDlg() void CommentStyleDialog::updateDlg()
{ {
TCHAR buffer[max_char] = TEXT(""); TCHAR* buffer = new TCHAR[max_char];
buffer[0] = '\0';
TCHAR intBuffer[10] = {'0', 0}; TCHAR intBuffer[10] = {'0', 0};
const int list[] = { const int list[] = {
@ -618,11 +623,14 @@ void CommentStyleDialog::updateDlg()
::SendDlgItemMessage(_hSelf, IDC_NUMBER_SUFFIX1_EDIT, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(_pUserLang->_keywordLists[SCE_USER_KWLIST_NUMBER_SUFFIX1])); ::SendDlgItemMessage(_hSelf, IDC_NUMBER_SUFFIX1_EDIT, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(_pUserLang->_keywordLists[SCE_USER_KWLIST_NUMBER_SUFFIX1]));
::SendDlgItemMessage(_hSelf, IDC_NUMBER_SUFFIX2_EDIT, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(_pUserLang->_keywordLists[SCE_USER_KWLIST_NUMBER_SUFFIX2])); ::SendDlgItemMessage(_hSelf, IDC_NUMBER_SUFFIX2_EDIT, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(_pUserLang->_keywordLists[SCE_USER_KWLIST_NUMBER_SUFFIX2]));
::SendDlgItemMessage(_hSelf, IDC_NUMBER_RANGE_EDIT, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(_pUserLang->_keywordLists[SCE_USER_KWLIST_NUMBER_RANGE])); ::SendDlgItemMessage(_hSelf, IDC_NUMBER_RANGE_EDIT, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(_pUserLang->_keywordLists[SCE_USER_KWLIST_NUMBER_RANGE]));
delete[] buffer;
} }
void SymbolsStyleDialog::updateDlg() void SymbolsStyleDialog::updateDlg()
{ {
TCHAR buffer[max_char] = TEXT(""); TCHAR* buffer = new TCHAR[max_char];
buffer[0] = '\0';
const int list[] = { const int list[] = {
IDC_DELIMITER1_BOUNDARYOPEN_EDIT, IDC_DELIMITER1_BOUNDARYOPEN_EDIT,
IDC_DELIMITER1_ESCAPE_EDIT, IDC_DELIMITER1_ESCAPE_EDIT,
@ -660,6 +668,8 @@ void SymbolsStyleDialog::updateDlg()
retrieve(buffer, _pUserLang->_keywordLists[SCE_USER_KWLIST_DELIMITERS], intBuffer); retrieve(buffer, _pUserLang->_keywordLists[SCE_USER_KWLIST_DELIMITERS], intBuffer);
::SendDlgItemMessage(_hSelf, list[i], WM_SETTEXT, 0, reinterpret_cast<LPARAM>(buffer)); ::SendDlgItemMessage(_hSelf, list[i], WM_SETTEXT, 0, reinterpret_cast<LPARAM>(buffer));
delete[] buffer;
} }
::SendDlgItemMessage(_hSelf, IDC_OPERATOR1_EDIT, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(_pUserLang->_keywordLists[SCE_USER_KWLIST_OPERATORS1])); ::SendDlgItemMessage(_hSelf, IDC_OPERATOR1_EDIT, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(_pUserLang->_keywordLists[SCE_USER_KWLIST_OPERATORS1]));
@ -810,8 +820,10 @@ void SymbolsStyleDialog::setKeywords2List(int id)
case IDC_DELIMITER8_ESCAPE_EDIT : case IDC_DELIMITER8_ESCAPE_EDIT :
case IDC_DELIMITER8_BOUNDARYCLOSE_EDIT : case IDC_DELIMITER8_BOUNDARYCLOSE_EDIT :
{ {
TCHAR newList[max_char] = TEXT(""); TCHAR* newList = new TCHAR[max_char];
TCHAR buffer[max_char] = TEXT(""); newList[0] = '\0';
TCHAR* buffer = new TCHAR[max_char];
buffer[0] = '\0';
TCHAR intBuffer[10] = {'0', 0}; TCHAR intBuffer[10] = {'0', 0};
const int list[] = { const int list[] = {
@ -854,6 +866,8 @@ void SymbolsStyleDialog::setKeywords2List(int id)
} }
wcscpy_s(_pUserLang->_keywordLists[SCE_USER_KWLIST_DELIMITERS], newList); wcscpy_s(_pUserLang->_keywordLists[SCE_USER_KWLIST_DELIMITERS], newList);
delete[] newList;
delete[] buffer;
break; break;
} }
default : default :

View File

@ -353,7 +353,7 @@ bool Utf8_16_Write::writeFile(const void* p, unsigned long _size)
case uni16BE: case uni16BE:
case uni16LE: { case uni16LE: {
static const unsigned int bufSize = 64*1024; static const unsigned int bufSize = 64*1024;
utf16 buf[bufSize]; utf16* buf = new utf16[bufSize];
Utf8_Iter iter8; Utf8_Iter iter8;
iter8.set(static_cast<const ubyte*>(p), _size, m_eEncoding); iter8.set(static_cast<const ubyte*>(p), _size, m_eEncoding);
@ -370,6 +370,7 @@ bool Utf8_16_Write::writeFile(const void* p, unsigned long _size)
} }
} }
isOK = true; isOK = true;
delete[] buf;
break; break;
} }
default: default:

View File

@ -32,7 +32,7 @@ using namespace std;
FunctionListPanel::~FunctionListPanel() FunctionListPanel::~FunctionListPanel()
{ {
for (const auto s : posStrs) for (const auto s : _posStrs)
{ {
delete s; delete s;
} }
@ -41,8 +41,8 @@ FunctionListPanel::~FunctionListPanel()
void FunctionListPanel::addEntry(const TCHAR *nodeName, const TCHAR *displayText, size_t pos) void FunctionListPanel::addEntry(const TCHAR *nodeName, const TCHAR *displayText, size_t pos)
{ {
HTREEITEM itemParent = NULL; HTREEITEM itemParent = NULL;
TCHAR posStr[32]; std::wstring posStr = std::to_wstring(pos);
generic_itoa(static_cast<int32_t>(pos), posStr, 10);
HTREEITEM root = _treeView.getRoot(); HTREEITEM root = _treeView.getRoot();
if (nodeName != NULL && *nodeName != '\0') if (nodeName != NULL && *nodeName != '\0')
@ -51,7 +51,7 @@ void FunctionListPanel::addEntry(const TCHAR *nodeName, const TCHAR *displayText
if (!itemParent) if (!itemParent)
{ {
generic_string* invalidValueStr = new generic_string(posStr); generic_string* invalidValueStr = new generic_string(posStr);
posStrs.push_back(invalidValueStr); _posStrs.push_back(invalidValueStr);
LPARAM lParamInvalidPosStr = reinterpret_cast<LPARAM>(invalidValueStr); LPARAM lParamInvalidPosStr = reinterpret_cast<LPARAM>(invalidValueStr);
itemParent = _treeView.addItem(nodeName, root, INDEX_NODE, lParamInvalidPosStr); itemParent = _treeView.addItem(nodeName, root, INDEX_NODE, lParamInvalidPosStr);
@ -61,7 +61,7 @@ void FunctionListPanel::addEntry(const TCHAR *nodeName, const TCHAR *displayText
itemParent = root; itemParent = root;
generic_string* posString = new generic_string(posStr); generic_string* posString = new generic_string(posStr);
posStrs.push_back(posString); _posStrs.push_back(posString);
LPARAM lParamPosStr = reinterpret_cast<LPARAM>(posString); LPARAM lParamPosStr = reinterpret_cast<LPARAM>(posString);
_treeView.addItem(displayText, itemParent, INDEX_LEAF, lParamPosStr); _treeView.addItem(displayText, itemParent, INDEX_LEAF, lParamPosStr);
@ -115,7 +115,7 @@ size_t FunctionListPanel::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSym
else // nothing found else // nothing found
{ {
cntOpen = 0; // get me out of here cntOpen = 0; // get me out of here
targetEnd = static_cast<int32_t>(begin); targetEnd = begin;
} }
targetStart = (*_ppEditView)->searchInTarget(exprToSearch.c_str(), exprToSearch.length(), targetEnd, docLen); targetStart = (*_ppEditView)->searchInTarget(exprToSearch.c_str(), exprToSearch.length(), targetEnd, docLen);
@ -223,7 +223,7 @@ void FunctionListPanel::sortOrUnsort()
const TCHAR *fn = ((*_ppEditView)->getCurrentBuffer())->getFileName(); const TCHAR *fn = ((*_ppEditView)->getCurrentBuffer())->getFileName();
generic_string* invalidValueStr = new generic_string(TEXT("-1")); generic_string* invalidValueStr = new generic_string(TEXT("-1"));
posStrs.push_back(invalidValueStr); _posStrs.push_back(invalidValueStr);
LPARAM lParamInvalidPosStr = reinterpret_cast<LPARAM>(invalidValueStr); LPARAM lParamInvalidPosStr = reinterpret_cast<LPARAM>(invalidValueStr);
_treeViewSearchResult.addItem(fn, NULL, INDEX_ROOT, lParamInvalidPosStr); _treeViewSearchResult.addItem(fn, NULL, INDEX_ROOT, lParamInvalidPosStr);
@ -367,7 +367,7 @@ void FunctionListPanel::reload()
if (parsedOK) if (parsedOK)
{ {
generic_string* invalidValueStr = new generic_string(TEXT("-1")); generic_string* invalidValueStr = new generic_string(TEXT("-1"));
posStrs.push_back(invalidValueStr); _posStrs.push_back(invalidValueStr);
LPARAM lParamInvalidPosStr = reinterpret_cast<LPARAM>(invalidValueStr); LPARAM lParamInvalidPosStr = reinterpret_cast<LPARAM>(invalidValueStr);
_treeView.addItem(fn, NULL, INDEX_ROOT, lParamInvalidPosStr); _treeView.addItem(fn, NULL, INDEX_ROOT, lParamInvalidPosStr);
@ -386,7 +386,7 @@ void FunctionListPanel::reload()
const TCHAR *fullFilePath = currentBuf->getFullPathName(); const TCHAR *fullFilePath = currentBuf->getFullPathName();
generic_string* fullPathStr = new generic_string(fullFilePath); generic_string* fullPathStr = new generic_string(fullFilePath);
posStrs.push_back(fullPathStr); _posStrs.push_back(fullPathStr);
LPARAM lParamFullPathStr = reinterpret_cast<LPARAM>(fullPathStr); LPARAM lParamFullPathStr = reinterpret_cast<LPARAM>(fullPathStr);
_treeView.setItemParam(root, lParamFullPathStr); _treeView.setItemParam(root, lParamFullPathStr);
@ -654,7 +654,7 @@ void FunctionListPanel::searchFuncAndSwitchView()
const TCHAR *fn = ((*_ppEditView)->getCurrentBuffer())->getFileName(); const TCHAR *fn = ((*_ppEditView)->getCurrentBuffer())->getFileName();
generic_string* invalidValueStr = new generic_string(TEXT("-1")); generic_string* invalidValueStr = new generic_string(TEXT("-1"));
posStrs.push_back(invalidValueStr); _posStrs.push_back(invalidValueStr);
LPARAM lParamInvalidPosStr = reinterpret_cast<LPARAM>(invalidValueStr); LPARAM lParamInvalidPosStr = reinterpret_cast<LPARAM>(invalidValueStr);
_treeViewSearchResult.addItem(fn, NULL, INDEX_ROOT, lParamInvalidPosStr); _treeViewSearchResult.addItem(fn, NULL, INDEX_ROOT, lParamInvalidPosStr);

View File

@ -117,7 +117,7 @@ private:
std::vector<foundInfo> _foundFuncInfos; std::vector<foundInfo> _foundFuncInfos;
std::vector<generic_string*> posStrs; std::vector<generic_string*> _posStrs;
ScintillaEditView **_ppEditView = nullptr; ScintillaEditView **_ppEditView = nullptr;
FunctionParsersManager _funcParserMgr; FunctionParsersManager _funcParserMgr;

View File

@ -219,7 +219,7 @@ protected:
int _nSrcTab = -1; int _nSrcTab = -1;
int _nTabDragged = -1; int _nTabDragged = -1;
int _previousTabSwapped = -1; int _previousTabSwapped = -1;
POINT _draggingPoint; // coordinate of Screen POINT _draggingPoint = {}; // coordinate of Screen
WNDPROC _tabBarDefaultProc = nullptr; WNDPROC _tabBarDefaultProc = nullptr;
RECT _currentHoverTabRect; RECT _currentHoverTabRect;