diff --git a/PowerEditor/installer/packageAll.bat b/PowerEditor/installer/packageAll.bat index 2eda3186..f31835dc 100644 --- a/PowerEditor/installer/packageAll.bat +++ b/PowerEditor/installer/packageAll.bat @@ -41,6 +41,7 @@ copy /Y LINEDRAW.TTF .\zipped.package.release\ansi\ copy /Y ".\plugins\Config\tidy\*.*" .\zipped.package.release\ansi\plugins\Config\tidy "C:\Program Files\7-Zip\7z.exe" a -tzip -r npp.bin.zip .\zipped.package.release\* +"C:\Program Files\7-Zip\7z.exe" a -r npp.bin.7z .\zipped.package.release\* "C:\Program Files\NSIS\makensis.exe" ..\installer\nppSetup.nsi cd ..\installer\ diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index f852ff53..ee411922 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -238,7 +238,13 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa execute(SCI_BEGINUNDOACTION); ColumnModeInfo colInfos = getColumnModeSelectInfo(); - columnReplace(colInfos, (TCHAR)wParam); + generic_string str(1, (TCHAR)wParam); + columnReplace(colInfos, str.c_str()); + + int selStart = execute(SCI_GETSELECTIONSTART)+1; + int selEnd = execute(SCI_GETSELECTIONEND); + execute(SCI_SETSELECTIONSTART, selStart); + execute(SCI_SETSELECTIONEND, selEnd); execute(SCI_ENDUNDOACTION); execute(SCI_SETCURRENTPOS,colInfos[colInfos.size()-1].second); @@ -249,9 +255,9 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa execute(SCI_SETSEL, pos, pos); } return TRUE; - } + } break; - } + } case WM_MOUSEHWHEEL : { @@ -1913,81 +1919,88 @@ const char * ScintillaEditView::getCompleteKeywordList(std::basic_string & return kwl.c_str(); } -void ScintillaEditView::convertSelectedTextTo(bool Case) + +void ScintillaEditView::convertSelectedTextTo(bool Case) { - unsigned int codepage = _codepage; - UniMode um = getCurrentBuffer()->getUnicodeMode(); - if (um != uni8Bit) - codepage = CP_UTF8; + unsigned int codepage = _codepage; + UniMode um = getCurrentBuffer()->getUnicodeMode(); + if (um != uni8Bit) + codepage = CP_UTF8; - if (execute(SCI_SELECTIONISRECTANGLE)) - { - execute(SCI_BEGINUNDOACTION); + if (execute(SCI_SELECTIONISRECTANGLE)) + { + execute(SCI_BEGINUNDOACTION); - ColumnModeInfo cmi = getColumnModeSelectInfo(); - const int len = cmi[0].second - cmi[0].first; - char *srcStr = new char[len+1]; - wchar_t *destStr = new wchar_t[len+3]; - for (size_t i = 0 ; i < cmi.size() ; i++) - { - int start = cmi[i].first; - int end = cmi[i].second; - getText(srcStr, start, end); + int selStart = execute(SCI_GETSELECTIONSTART); + int selEnd = execute(SCI_GETSELECTIONEND); - int nbChar = ::MultiByteToWideChar(codepage, 0, srcStr, len, destStr, len); + ColumnModeInfo cmi = getColumnModeSelectInfo(); + const int len = cmi[0].second - cmi[0].first; + char *srcStr = new char[len+1]; + wchar_t *destStr = new wchar_t[len+3]; + for (size_t i = 0 ; i < cmi.size() ; i++) + { + int start = cmi[i].first; + int end = cmi[i].second; + getText(srcStr, start, end); - for (int j = 0 ; j < nbChar ; j++) - { - if (Case == UPPERCASE) - destStr[j] = (wchar_t)::CharUpperW((LPWSTR)destStr[j]); - else - destStr[j] = (wchar_t)::CharLowerW((LPWSTR)destStr[j]); - } - ::WideCharToMultiByte(codepage, 0, destStr, len, srcStr, len, NULL, NULL); + int nbChar = ::MultiByteToWideChar(codepage, 0, srcStr, len, destStr, len); - execute(SCI_SETTARGETSTART, start); - execute(SCI_SETTARGETEND, end); - execute(SCI_REPLACETARGET, -1, (LPARAM)srcStr); - } + for (int j = 0 ; j < nbChar ; j++) + { + if (Case == UPPERCASE) + destStr[j] = (wchar_t)::CharUpperW((LPWSTR)destStr[j]); + else + destStr[j] = (wchar_t)::CharLowerW((LPWSTR)destStr[j]); + } + ::WideCharToMultiByte(codepage, 0, destStr, len, srcStr, len, NULL, NULL); - delete [] srcStr; - delete [] destStr; + execute(SCI_SETTARGETSTART, start); + execute(SCI_SETTARGETEND, end); + execute(SCI_REPLACETARGET, -1, (LPARAM)srcStr); + } - execute(SCI_ENDUNDOACTION); - return; - } + delete [] srcStr; + delete [] destStr; - size_t selectionStart = execute(SCI_GETSELECTIONSTART); - size_t selectionEnd = execute(SCI_GETSELECTIONEND); - - int strSize = ((selectionEnd > selectionStart)?(selectionEnd - selectionStart):(selectionStart - selectionEnd))+1; - - if (strSize) - { - char *selectedStr = new char[strSize+1]; - int strWSize = strSize * 2; - wchar_t *selectedStrW = new wchar_t[strWSize+3]; + execute(SCI_SETSELECTIONSTART, selStart); + execute(SCI_SETSELECTIONEND, selEnd); - execute(SCI_GETSELTEXT, 0, (LPARAM)selectedStr); + execute(SCI_ENDUNDOACTION); + return; + } - int nbChar = ::MultiByteToWideChar(codepage, 0, selectedStr, strSize, selectedStrW, strWSize); + size_t selectionStart = execute(SCI_GETSELECTIONSTART); + size_t selectionEnd = execute(SCI_GETSELECTIONEND); + + int strSize = ((selectionEnd > selectionStart)?(selectionEnd - selectionStart):(selectionStart - selectionEnd))+1; + if (strSize) + { + char *selectedStr = new char[strSize+1]; + int strWSize = strSize * 2; + wchar_t *selectedStrW = new wchar_t[strWSize+3]; - for (int i = 0 ; i < nbChar ; i++) - { - if (Case == UPPERCASE) - selectedStrW[i] = (WCHAR)::CharUpperW((LPWSTR)selectedStrW[i]); - else - selectedStrW[i] = (WCHAR)::CharLowerW((LPWSTR)selectedStrW[i]); - } - ::WideCharToMultiByte(codepage, 0, selectedStrW, strWSize, selectedStr, strSize, NULL, NULL); + execute(SCI_GETSELTEXT, 0, (LPARAM)selectedStr); - execute(SCI_REPLACESEL, strSize, (LPARAM)selectedStr); - execute(SCI_SETSEL, selectionStart, selectionEnd); - delete [] selectedStr; - delete [] selectedStrW; - } + int nbChar = ::MultiByteToWideChar(codepage, 0, selectedStr, strSize, selectedStrW, strWSize); + + for (int i = 0 ; i < nbChar ; i++) + { + if (Case == UPPERCASE) + selectedStrW[i] = (WCHAR)::CharUpperW((LPWSTR)selectedStrW[i]); + else + selectedStrW[i] = (WCHAR)::CharLowerW((LPWSTR)selectedStrW[i]); + } + ::WideCharToMultiByte(codepage, 0, selectedStrW, strWSize, selectedStr, strSize, NULL, NULL); + + execute(SCI_REPLACESEL, strSize, (LPARAM)selectedStr); + execute(SCI_SETSEL, selectionStart, selectionEnd); + delete [] selectedStr; + delete [] selectedStrW; + } } + bool ScintillaEditView::expandWordSelection() { int caretPos = execute(SCI_GETCURRENTPOS, 0, 0); @@ -2195,26 +2208,6 @@ void ScintillaEditView::columnReplace(ColumnModeInfo & cmi, int initial, int inc } -void ScintillaEditView::columnReplace(const ColumnModeInfo & cmi, const TCHAR ch) -{ - for (size_t i = 0 ; i < cmi.size() ; i++) - { - int len = cmi[i].second - cmi[i].first; - generic_string str(len, ch); - execute(SCI_SETTARGETSTART, cmi[i].first); - execute(SCI_SETTARGETEND, cmi[i].second); - -#ifdef UNICODE - WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); - unsigned int cp = execute(SCI_GETCODEPAGE); - const char *strA = wmc->wchar2char(str.c_str(), cp); - execute(SCI_REPLACETARGET, -1, (LPARAM)strA); -#else - execute(SCI_REPLACETARGET, -1, (LPARAM)str.c_str()); -#endif - } -} - void ScintillaEditView::foldChanged(int line, int levelNow, int levelPrev) { if (levelNow & SC_FOLDLEVELHEADERFLAG) //line can be folded diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index c3613bb7..a51ef7bb 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -463,7 +463,6 @@ public: ColumnModeInfo getColumnModeSelectInfo(); void columnReplace(ColumnModeInfo & cmi, const TCHAR *str); - void columnReplace(const ColumnModeInfo & cmi, const TCHAR ch); void columnReplace(ColumnModeInfo & cmi, int initial, int incr, UCHAR format); void foldChanged(int line, int levelNow, int levelPrev);