diff --git a/PowerEditor/bin/change.log b/PowerEditor/bin/change.log index 5729cd02d..d26e6b64c 100644 --- a/PowerEditor/bin/change.log +++ b/PowerEditor/bin/change.log @@ -1,19 +1,22 @@ Notepad++ v5.6 new features and fixed bugs (from v5.5.1) : -1. Add languages encoding - Chinese traditional (BIG5), Chinese Simplified (GB2312), Japanese (Shift JIS), Korean (EUC), Thai (TIS-620), Hebrew (iso-8859-8), Hebrew (1255), Central European (1250), Cyrillic (1251), Cyrillic (KOI8-U), Cyrillic (KOI8-R), Cyrillic (Mac), Western European(1252), Greek (1253), Turkish(1254), Arabic (1256), Baltic (1257) and Vietnamese (1258). +1. Add languages encoding - Chinese traditional (BIG5), Chinese Simplified (GB2312), Japanese (Shift JIS), Korean (EUC), Thai (TIS-620), Hebrew (iso-8859-8), Hebrew (1255), Central European (1250), Cyrillic (1251), Cyrillic (KOI8-U), Cyrillic (KOI8-R), Cyrillic (Mac), Western European(1252), Greek (1253), Turkish(1254), Arabic (1256), Baltic (1257), Vietnamese (1258), ISO_8859-1 to ISO_8859-16 and a lot of more. 2. Add auto-detection of HTML and XML files encodings. 3. Add COBOL, D, Gui4Cli, PowerShell and R language support. 4. Add Marker Jumper feature (Jump down/up : Ctrl+Num/Ctrl+Shift+Num). 5. Add indent guide line highlighting for html/xml tags. 6. Add system tray context menu and new command argument "-systemtray". -7. Add new command argument "--help". -8. Fix Calltip hint bug and add a new capacity in it. -9. Add the ability to add the second keyword group for user in both LISP and Scheme languages. -10. Fix the wrap symbol display problem. -11. Add SQL ESC symbol '\'. -12. Fix column editor insert number bug in virtual space mode. -13. Fix status bar displaying "-2 char" issue for a empty document. -14. Fix installation of NppShell64 failed issue in installer. +7. Fix Unicode to ANSI encoding bug. +8. Fix last recent file list menu items localization encoding bug. +9. Fix last recent file number goes to zero issue. +10. Add new command argument "--help". +11. Fix Calltip hint bug and add a new capacity in it. +12. Add the ability to add the second keyword group for user in both LISP and Scheme languages. +13. Fix the wrap symbol display problem. +14. Add SQL ESC symbol '\'. +15. Fix column editor insert number bug in virtual space mode. +16. Fix status bar displaying "-2 char" issue for a empty document. +17. Fix installation of NppShell64 failed issue in installer. Included plugins (Unicode): diff --git a/PowerEditor/bin/npp.pdb b/PowerEditor/bin/npp.pdb index c91853a0c..5b39b66fd 100644 Binary files a/PowerEditor/bin/npp.pdb and b/PowerEditor/bin/npp.pdb differ diff --git a/PowerEditor/installer/nppSetup.nsi b/PowerEditor/installer/nppSetup.nsi index e79ad48af..0dcf05afa 100644 --- a/PowerEditor/installer/nppSetup.nsi +++ b/PowerEditor/installer/nppSetup.nsi @@ -460,10 +460,23 @@ GLOBAL_INST: MessageBox MB_OK "Due to the stabilty issue,$\nNppPlugin_ChangeMarker.dll will be moved to the directory $\"disabled$\"" /SD IDOK Rename "$INSTDIR\plugins\NppPlugin_ChangeMarker.dll" "$INSTDIR\plugins\disabled\NppPlugin_ChangeMarker.dll" Delete "$INSTDIR\plugins\NppPlugin_ChangeMarker.dll" - + + + + + ; Context Menu Management : removing old version of Context Menu module IfFileExists "$INSTDIR\nppcm.dll" 0 +3 Exec 'regsvr32 /u /s "$INSTDIR\nppcm.dll"' Delete "$INSTDIR\nppcm.dll" + + IfFileExists "$INSTDIR\NppShell.dll" 0 +3 + Exec 'regsvr32 /u /s "$INSTDIR\NppShell.dll"' + Delete "$INSTDIR\NppShell.dll" + + + + + ; detect the right of UserInfo::GetAccountType @@ -484,12 +497,12 @@ Section "Context Menu Entry" explorerContextMenu SetOverwrite try SetOutPath "$INSTDIR\" ${If} ${RunningX64} - File /oname=$INSTDIR\NppShell.dll "..\bin\NppShell64.dll" + File /oname=$INSTDIR\NppShell_01.dll "..\bin\NppShell64.dll" ${Else} File "..\bin\NppShell.dll" ${EndIf} - Exec 'regsvr32 /s "$INSTDIR\NppShell.dll"' + Exec 'regsvr32 /s "$INSTDIR\NppShell_01.dll"' SectionEnd SubSection "Auto-completion Files" autoCompletionComponent @@ -994,8 +1007,6 @@ SubSection un.Plugins SectionEnd - - Section un.FileBrowserLite Delete "$INSTDIR\plugins\LightExplorer.dll" Delete "$INSTDIR\lightExplorer.ini" @@ -1140,8 +1151,8 @@ Section un.AutoUpdater SectionEnd Section un.explorerContextMenu - Exec 'regsvr32 /u /s "$INSTDIR\NppShell.dll"' - Delete "$INSTDIR\NppShell.dll" + Exec 'regsvr32 /u /s "$INSTDIR\NppShell_01.dll"' + Delete "$INSTDIR\NppShell_01.dll" SectionEnd Section Uninstall diff --git a/PowerEditor/installer/packageAll.bat b/PowerEditor/installer/packageAll.bat index 3f81b68d3..a6cb5e7ca 100644 --- a/PowerEditor/installer/packageAll.bat +++ b/PowerEditor/installer/packageAll.bat @@ -24,6 +24,7 @@ copy /Y ".\plugins\*.*" .\zipped.package.release\unicode\plugins\ copy /Y ".\plugins\APIs\*.xml" .\zipped.package.release\unicode\plugins\APIs\ copy /Y ".\plugins\doc\*.*" .\zipped.package.release\unicode\plugins\doc\ copy /Y ".\plugins\Config\tidy\*.*" .\zipped.package.release\unicode\plugins\Config\tidy\ +del /F /S /Q .\localization\*.bak copy /Y ".\localization\*.*" .\zipped.package.release\unicode\localization\ copy /Y ".\themes\*.*" .\zipped.package.release\unicode\themes\ copy /Y ".\updater\gpup.exe" .\zipped.package.release\unicode\updater\ diff --git a/PowerEditor/src/EncodingMapper.cpp b/PowerEditor/src/EncodingMapper.cpp new file mode 100644 index 000000000..c0617599d --- /dev/null +++ b/PowerEditor/src/EncodingMapper.cpp @@ -0,0 +1,128 @@ +//this file is part of notepad++ +//Copyright (C)2003 Don HO +// +//This program is free software; you can redistribute it and/or +//modify it under the terms of the GNU General Public License +//as published by the Free Software Foundation; either +//version 2 of the License, or (at your option) any later version. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU General Public License for more details. +// +//You should have received a copy of the GNU General Public License +//along with this program; if not, write to the Free Software +//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +#include "precompiledHeaders.h" +#include "EncodingMapper.h" + +// Don't change the order +EncodingUnit encodings[] = { + {1250, "windows-1250"}, //IDM_FORMAT_WIN1250 + {1251, "windows-1251"}, //IDM_FORMAT_WIN1251 + {1252, "windows-1252"}, //IDM_FORMAT_WIN1252 + {1253, "windows-1253"}, //IDM_FORMAT_WIN1253 + {1254, "windows-1254"}, //IDM_FORMAT_WIN1254 + {1255, "windows-1255"}, //IDM_FORMAT_WIN1255 + {1256, "windows-1256"}, //IDM_FORMAT_WIN1256 + {1257, "windows-1257"}, //IDM_FORMAT_WIN1257 + {1258, "windows-1258"}, //IDM_FORMAT_WIN1258 + {28591, "latin1 ISO_8859-1 ISO-8859-1 CP819 IBM819 csISOLatin1 iso-ir-100 l1"}, //IDM_FORMAT_ISO_8859_1 + {28592, "latin2 ISO_8859-2 ISO-8859-2 csISOLatin2 iso-ir-101 l2"}, //IDM_FORMAT_ISO_8859_2 + {28593, "latin3 ISO_8859-3 ISO-8859-3 csISOLatin3 iso-ir-109 l3"}, //IDM_FORMAT_ISO_8859_3 + {28594, "latin4 ISO_8859-4 ISO-8859-4 csISOLatin4 iso-ir-110 l4"}, //IDM_FORMAT_ISO_8859_4 + {28595, "cyrillic ISO_8859-5 ISO-8859-5 csISOLatinCyrillic iso-ir-144"}, //IDM_FORMAT_ISO_8859_5 + {28596, "arabic ISO_8859-6 ISO-8859-6 csISOLatinArabic iso-ir-127 ASMO-708 ECMA-114"}, //IDM_FORMAT_ISO_8859_6 + {28597, "greek ISO_8859-7 ISO-8859-7 csISOLatinGreek greek8 iso-ir-126 ELOT_928 ECMA-118"}, //IDM_FORMAT_ISO_8859_7 + {28598, "hebrew ISO_8859-8 ISO-8859-8 csISOLatinHebrew iso-ir-138"}, //IDM_FORMAT_ISO_8859_8 + {28599, "latin5 ISO_8859-9 ISO-8859-9 csISOLatin5 iso-ir-148 l5"}, //IDM_FORMAT_ISO_8859_9 + {28600, "latin6 ISO_8859-10 ISO-8859-10 csISOLatin6 iso-ir-157 l6"}, //IDM_FORMAT_ISO_8859_10 + {28601, "ISO_8859-11 ISO-8859-11"}, //IDM_FORMAT_ISO_8859_11 + {28603, "ISO_8859-13 ISO-8859-13"}, //IDM_FORMAT_ISO_8859_13 + {28604, "iso-celtic latin8 ISO_8859-14 ISO-8859-14 18 iso-ir-199"}, //IDM_FORMAT_ISO_8859_14 + {28605, "Latin-9 ISO_8859-15 ISO-8859-15"}, //IDM_FORMAT_ISO_8859_15 + {28606, "latin10 ISO_8859-16 ISO-8859-16 110 iso-ir-226"}, //IDM_FORMAT_ISO_8859_16 + {950, "big5 csBig5"}, //IDM_FORMAT_BIG5 + {936, "gb2312 gbk csGB2312"}, //IDM_FORMAT_GB2312 + {932, "Shift_JIS MS_Kanji csShiftJIS csWindows31J"}, //IDM_FORMAT_SHIFT_JIS + {949, "windows-949 korean"}, //IDM_FORMAT_KOREAN_WIN + {51949, "euc-kr csEUCKR"}, //IDM_FORMAT_EUC_KR + {874, "tis-620"}, //IDM_FORMAT_TIS_620 + {855, "IBM855 cp855 855 csIBM855"}, //IDM_FORMAT_CP855 + {10007, "x-mac-cyrillic xmaccyrillic"}, //IDM_FORMAT_MAC_CYRILLIC + {21866, "koi8_u"}, //IDM_FORMAT_KOI8U_CYRILLIC + {20866, "koi8_r csKOI8R"}, //IDM_FORMAT_KOI8R_CYRILLIC + {437, "IBM437, cp437 437 csPC8CodePage437"}, //IDM_FORMAT_DOS437 + {367, "ASCII US-ASCII us ISO646-US csASCII cp367 IBM367"} //IDM_FORMAT_US_ASCII +}; + +EncodingMapper * EncodingMapper::_pSelf = new EncodingMapper; + +bool isInListA(const char *token, const char *list) { + if ((!token) || (!list)) + return false; + char word[64]; + int i = 0; + int j = 0; + for (; i <= int(strlen(list)) ; i++) + { + if ((list[i] == ' ')||(list[i] == '\0')) + { + if (j != 0) + { + word[j] = '\0'; + j = 0; + + if (!stricmp(token, word)) + return true; + } + } + else + { + word[j] = list[i]; + j++; + } + } + return false; +}; + +int EncodingMapper::getEncodingFromIndex(int index) const +{ + size_t nbItem = sizeof(encodings)/sizeof(EncodingUnit); + if (index < 0 || (size_t)index >= nbItem) + return -1; + return encodings[index]._codePage; +} + +int EncodingMapper::getIndexFromEncoding(int encoding) const +{ + bool found = false; + size_t nbItem = sizeof(encodings)/sizeof(EncodingUnit); + size_t i = 0; + for ( ; i < nbItem ; i++) + { + if (encodings[i]._codePage == encoding) + { + found = true; + break; + } + } + return found?i:-1; +} + +int EncodingMapper::getEncodingFromString(const char *encodingAlias) const +{ + size_t nbItem = sizeof(encodings)/sizeof(EncodingUnit); + int enc = -1; + for (size_t i = 0 ; i < nbItem ; i++) + { + if (isInListA(encodingAlias, encodings[i]._aliasList)) + { + enc = encodings[i]._codePage; + break; + } + } + return enc; +} \ No newline at end of file diff --git a/PowerEditor/src/EncodingMapper.h b/PowerEditor/src/EncodingMapper.h new file mode 100644 index 000000000..6afb76250 --- /dev/null +++ b/PowerEditor/src/EncodingMapper.h @@ -0,0 +1,40 @@ +//this file is part of notepad++ +//Copyright (C)2003 Don HO +// +//This program is free software; you can redistribute it and/or +//modify it under the terms of the GNU General Public License +//as published by the Free Software Foundation; either +//version 2 of the License, or (at your option) any later version. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU General Public License for more details. +// +//You should have received a copy of the GNU General Public License +//along with this program; if not, write to the Free Software +//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +#ifndef ENCODINGMAPPER_H +#define ENCODINGMAPPER_H + +struct EncodingUnit { + int _codePage; + char *_aliasList; +}; + +class EncodingMapper { +public: + static EncodingMapper * getInstance() {return _pSelf;}; + int getEncodingFromIndex(int index) const; + int getIndexFromEncoding(int encoding) const; + int getEncodingFromString(const char * encodingAlias) const; + +private: + EncodingMapper(){}; + ~EncodingMapper(){}; + static EncodingMapper *_pSelf; + EncodingUnit *_encodings; +}; + +#endif // ENCODINGMAPPER_H diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index 0e694ecfc..4ac5cfcfa 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -174,51 +174,36 @@ int filter(unsigned int code, struct _EXCEPTION_POINTERS *) return EXCEPTION_CONTINUE_SEARCH; } - -int getCpFromStringValue(const char * encodingStr) -{ - if (!encodingStr) - return CP_ACP; - if (stricmp("windows-1250", encodingStr) == 0) - return NPP_CP_WIN_1250; - if (stricmp("windows-1251", encodingStr) == 0) - return NPP_CP_WIN_1251; - if (stricmp("windows-1252", encodingStr) == 0) - return NPP_CP_WIN_1252; - if (stricmp("windows-1253", encodingStr) == 0) - return NPP_CP_WIN_1253; - if (stricmp("windows-1254", encodingStr) == 0) - return NPP_CP_WIN_1254; - if (stricmp("windows-1255", encodingStr) == 0) - return NPP_CP_WIN_1255; - if (stricmp("windows-1256", encodingStr) == 0) - return NPP_CP_WIN_1256; - if (stricmp("windows-1257", encodingStr) == 0) - return NPP_CP_WIN_1257; - if (stricmp("windows-1258", encodingStr) == 0) - return NPP_CP_WIN_1258; - - if (stricmp("big5", encodingStr) == 0) - return NPP_CP_BIG5; - if (stricmp("gb2312", encodingStr) == 0) - return NPP_CP_GB2312; - if (stricmp("shift_jis", encodingStr) == 0) - return NPP_CP_SHIFT_JIS; - if (stricmp("euc-kr", encodingStr) == 0) - return NPP_CP_EUC_KR; - if (stricmp("tis-620", encodingStr) == 0) - return NPP_CP_TIS_620; - - if (stricmp("iso-8859-8", encodingStr) == 0) - return NPP_CP_ISO_8859_8; - - if (stricmp("utf-8", encodingStr) == 0) - return CP_UTF8; - - return CP_ACP; +bool isInList(const TCHAR *token, const TCHAR *list) { + if ((!token) || (!list)) + return false; + TCHAR word[64]; + int i = 0; + int j = 0; + for (; i <= int(lstrlen(list)) ; i++) + { + if ((list[i] == ' ')||(list[i] == '\0')) + { + if (j != 0) + { + word[j] = '\0'; + j = 0; + + if (!generic_stricmp(token, word)) + return true; + } + } + else + { + word[j] = list[i]; + j++; + } + } + return false; } + generic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand) { TCHAR cleanedName[64] = TEXT(""); diff --git a/PowerEditor/src/MISC/Common/Common.h b/PowerEditor/src/MISC/Common/Common.h index f88420f2a..38726184f 100644 --- a/PowerEditor/src/MISC/Common/Common.h +++ b/PowerEditor/src/MISC/Common/Common.h @@ -18,28 +18,9 @@ #ifndef M30_IDE_COMMUN_H #define M30_IDE_COMMUN_H -#define NPP_CP_WIN_1250 1250 -#define NPP_CP_WIN_1251 1251 #define NPP_CP_WIN_1252 1252 -#define NPP_CP_WIN_1253 1253 -#define NPP_CP_WIN_1254 1254 -#define NPP_CP_WIN_1255 1255 -#define NPP_CP_WIN_1256 1256 -#define NPP_CP_WIN_1257 1257 -#define NPP_CP_WIN_1258 1258 - -#define NPP_CP_BIG5 950 -#define NPP_CP_EUC_KR 51949 -#define NPP_CP_SHIFT_JIS 932 -#define NPP_CP_GB2312 936 -#define NPP_CP_ISO_8859_8 28598 -#define NPP_CP_TIS_620 874 -#define NPP_CP_CYRILLIC_DOS 855 -#define NPP_CP_CYRILLIC_MAC 10007 -#define NPP_CP_CYRILLIC_KOI8_U 21866 -#define NPP_CP_CYRILLIC_KOI8_R 20866 #define NPP_CP_DOS_437 437 - +#define NPP_CP_BIG5 950 #ifdef UNICODE #define NppMainEntry wWinMain @@ -96,7 +77,7 @@ void printStr(const TCHAR *str2print); void writeLog(const TCHAR *logFileName, const char *log2write); int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep); -int getCpFromStringValue(const char * encodingStr); +//int getCpFromStringValue(const char * encodingStr); generic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand = false); std::vector tokenizeString(const generic_string & tokenString, const char delim); @@ -105,7 +86,7 @@ void ScreenRectToClientRect(HWND hWnd, RECT* rect); std::wstring string2wstring(const std::string & rString, UINT codepage); std::string wstring2string(const std::wstring & rwString, UINT codepage); - +bool isInList(const TCHAR *token, const TCHAR *list); TCHAR *BuildMenuFileName(TCHAR *buffer, int len, int pos, const TCHAR *filename); class WcharMbcsConvertor { diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index edf49dc1a..48e700279 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -14,11 +14,7 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -/* -#ifndef _WIN32_IE -#define _WIN32_IE 0x500 -#endif -*/ + #include "precompiledHeaders.h" #include "Notepad_plus.h" #include "FileDialog.h" @@ -32,6 +28,7 @@ #include "preferenceDlg.h" #include "TaskListDlg.h" #include "xmlMatchedTagsHighlighter.h" +#include "EncodingMapper.h" const TCHAR Notepad_plus::_className[32] = TEXT("Notepad++"); HWND Notepad_plus::gNppHWND = NULL; @@ -40,31 +37,6 @@ const char *urlHttpRegExpr = "http://[a-z0-9_\\-\\+~.:?&@=/%#]*"; int docTabIconIDs[] = {IDI_SAVED_ICON, IDI_UNSAVED_ICON, IDI_READONLY_ICON}; enum tb_stat {tb_saved, tb_unsaved, tb_ro}; -// Don't change the order -int encoding_table[] = { -NPP_CP_WIN_1250, //IDM_FORMAT_WIN1250 -NPP_CP_WIN_1251, //IDM_FORMAT_WIN1251 -NPP_CP_WIN_1252, //IDM_FORMAT_WIN1252 -NPP_CP_WIN_1253, //IDM_FORMAT_WIN1253 -NPP_CP_WIN_1254, //IDM_FORMAT_WIN1254 -NPP_CP_WIN_1255, //IDM_FORMAT_WIN1255 -NPP_CP_WIN_1256, //IDM_FORMAT_WIN1256 -NPP_CP_WIN_1257, //IDM_FORMAT_WIN1257 -NPP_CP_WIN_1258, //IDM_FORMAT_WIN1258 -NPP_CP_BIG5, //IDM_FORMAT_BIG5 -NPP_CP_GB2312, //IDM_FORMAT_GB2312 -NPP_CP_SHIFT_JIS, //IDM_FORMAT_SHIFT_JIS -NPP_CP_EUC_KR, //IDM_FORMAT_EUC_KR -NPP_CP_TIS_620, //IDM_FORMAT_TIS_620 -NPP_CP_ISO_8859_8, //IDM_FORMAT_ISO_8859_8 -NPP_CP_CYRILLIC_DOS, //IDM_FORMAT_CP855 -NPP_CP_CYRILLIC_MAC, //IDM_FORMAT_MAC_CYRILLIC -NPP_CP_CYRILLIC_KOI8_U, //IDM_FORMAT_KOI8U_CYRILLIC -NPP_CP_CYRILLIC_KOI8_R, //IDM_FORMAT_KOI8R_CYRILLIC -NPP_CP_DOS_437, //IDM_FORMAT_DOS437 -}; - - #define DIR_LEFT true #define DIR_RIGHT false @@ -118,8 +90,8 @@ Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _p if (declaration) { const char * encodingStr = declaration->Encoding(); - _nativeLangEncoding = getCpFromStringValue(encodingStr); - _lastRecentFileList.setLangEncoding(_nativeLangEncoding); + EncodingMapper *em = EncodingMapper::getInstance(); + _nativeLangEncoding = em->getEncodingFromString(encodingStr); } } } @@ -418,7 +390,6 @@ void Notepad_plus::destroy() bool Notepad_plus::saveGUIParams() { NppGUI & nppGUI = (NppGUI &)(NppParameters::getInstance())->getNppGUI(); - //nppGUI._statusBarShow = _statusBar.isVisible(); nppGUI._toolbarShow = _rebarTop.getIDVisible(REBAR_BAR_TOOLBAR); nppGUI._toolBarStatus = _toolBar.getState(); @@ -591,7 +562,8 @@ bool Notepad_plus::loadSession(Session & session) Buffer * buf = MainFileManager->getBufferByID(lastOpened); buf->setPosition(session._mainViewFiles[i], &_mainEditView); buf->setLangType(typeToSet, pLn); - buf->setEncoding(session._mainViewFiles[i]._encoding); + if (session._mainViewFiles[i]._encoding != -1) + buf->setEncoding(session._mainViewFiles[i]._encoding); //Force in the document so we can add the markers //Dont use default methods because of performance @@ -925,7 +897,8 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const char encodingStr[128]; _invisibleEditView.getText(encodingStr, startPos, endPos); - int enc = getCpFromStringValue(encodingStr); + EncodingMapper *em = EncodingMapper::getInstance(); + int enc = em->getEncodingFromString(encodingStr); return (enc==CP_ACP?-1:enc); } return -1; @@ -934,7 +907,6 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const { // find encoding by RegExpr const char *htmlHeaderRegExpr = ""; - const char *htmlHeaderRegExpr2 = ""; int startPos = 0; int endPos = lenFile-1; @@ -947,7 +919,7 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const if (posFound != -1) { - const char *charsetBlockRegExpr = "charset[ \\t]*=[ \\t]*.+\""; + const char *charsetBlockRegExpr = "charset[ \\t]*=[ \\t]*.+[\"]"; posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(charsetBlockRegExpr), (LPARAM)charsetBlockRegExpr); const char *charsetRegExpr = "=[ \\t]*[^\"]+"; @@ -961,11 +933,13 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const char encodingStr[128]; _invisibleEditView.getText(encodingStr, startPos, endPos); - int enc = getCpFromStringValue(encodingStr); + EncodingMapper *em = EncodingMapper::getInstance(); + int enc = em->getEncodingFromString(encodingStr); return (enc==CP_ACP?-1:enc); } else { + const char *htmlHeaderRegExpr2 = ""; posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(htmlHeaderRegExpr2), (LPARAM)htmlHeaderRegExpr2); if (posFound == -1) return -1; @@ -3260,7 +3234,7 @@ void Notepad_plus::setDisplayFormat(formatType f) switch (f) { case MAC_FORMAT : - str = TEXT("MAC"); + str = TEXT("Macintosh"); break; case UNIX_FORMAT : str = TEXT("UNIX"); @@ -3271,28 +3245,6 @@ void Notepad_plus::setDisplayFormat(formatType f) _statusBar.setText(str.c_str(), STATUSBAR_EOF_FORMAT); } -int Notepad_plus::getCmdIDFromEncoding(int encoding) const -{ - bool found = false; - size_t nbItem = sizeof(encoding_table)/sizeof(int); - size_t i = 0; - for ( ; i < nbItem ; i++) - { - if (encoding_table[i] == encoding) - { - found = true; - break; - } - - } - if (!found) - { - printStr(TEXT("Encoding problem. Encoding is not added in encoding_table?")); - return -1; - } - return i+IDM_FORMAT_ENCODE; -} - void Notepad_plus::setUniModeText() { Buffer *buf = _pEditView->getCurrentBuffer(); @@ -3323,9 +3275,15 @@ void Notepad_plus::setUniModeText() } else { - int cmdID = getCmdIDFromEncoding(encoding); + EncodingMapper *em = EncodingMapper::getInstance(); + int cmdID = em->getIndexFromEncoding(encoding); if (cmdID == -1) + { + printStr(TEXT("Encoding problem. Encoding is not added in encoding_table?")); return; + } + cmdID += IDM_FORMAT_ENCODE; + const int itemSize = 64; TCHAR uniModeText[itemSize]; ::GetMenuString(_mainMenuHandle, cmdID, uniModeText, itemSize, MF_BYCOMMAND); @@ -4624,35 +4582,54 @@ void Notepad_plus::command(int id) } break; } + + case IDM_FORMAT_WIN1250 : + case IDM_FORMAT_WIN1251 : + case IDM_FORMAT_WIN1252 : + case IDM_FORMAT_WIN1253 : + case IDM_FORMAT_WIN1254 : + case IDM_FORMAT_WIN1255 : + case IDM_FORMAT_WIN1256 : + case IDM_FORMAT_WIN1257 : + case IDM_FORMAT_WIN1258 : + case IDM_FORMAT_ISO_8859_1 : + case IDM_FORMAT_ISO_8859_2 : + case IDM_FORMAT_ISO_8859_3 : + case IDM_FORMAT_ISO_8859_4 : + case IDM_FORMAT_ISO_8859_5 : + case IDM_FORMAT_ISO_8859_6 : + case IDM_FORMAT_ISO_8859_7 : + case IDM_FORMAT_ISO_8859_8 : + case IDM_FORMAT_ISO_8859_9 : + case IDM_FORMAT_ISO_8859_10 : + case IDM_FORMAT_ISO_8859_11 : + case IDM_FORMAT_ISO_8859_13 : + case IDM_FORMAT_ISO_8859_14 : + case IDM_FORMAT_ISO_8859_15 : + case IDM_FORMAT_ISO_8859_16 : + case IDM_FORMAT_BIG5 : + case IDM_FORMAT_GB2312 : + case IDM_FORMAT_SHIFT_JIS : + case IDM_FORMAT_KOREAN_WIN : + case IDM_FORMAT_EUC_KR : + case IDM_FORMAT_TIS_620 : case IDM_FORMAT_CP855 : - case IDM_FORMAT_MAC_CYRILLIC : + case IDM_FORMAT_MAC_CYRILLIC : case IDM_FORMAT_KIO8U_CYRILLIC : case IDM_FORMAT_KIO8R_CYRILLIC : case IDM_FORMAT_DOS437 : - case IDM_FORMAT_WIN1255 : - case IDM_FORMAT_WIN1257 : - case IDM_FORMAT_WIN1258 : - case IDM_FORMAT_WIN1251 : - case IDM_FORMAT_WIN1252 : - case IDM_FORMAT_WIN1254 : - case IDM_FORMAT_ISO_8859_8 : - case IDM_FORMAT_WIN1250 : - case IDM_FORMAT_WIN1253 : - case IDM_FORMAT_WIN1256 : - case IDM_FORMAT_TIS_620 : - case IDM_FORMAT_GB2312 : - case IDM_FORMAT_SHIFT_JIS : - case IDM_FORMAT_EUC_KR : - case IDM_FORMAT_BIG5 : + case IDM_FORMAT_US_ASCII : { - size_t nbItem = sizeof(encoding_table)/sizeof(int); int index = id - IDM_FORMAT_ENCODE; - if (index < 0 || index >= int(nbItem)) + EncodingMapper *em = EncodingMapper::getInstance(); + int encoding = em->getEncodingFromIndex(index); + if (encoding == -1) { printStr(TEXT("Encoding problem. Command is not added in encoding_table?")); return; } + Buffer * buf = _pEditView->getCurrentBuffer(); if (buf->isDirty()) { @@ -4680,7 +4657,8 @@ void Notepad_plus::command(int id) if (!buf->isDirty()) { Buffer *buf = _pEditView->getCurrentBuffer(); - buf->setEncoding(encoding_table[index]); + buf->setEncoding(encoding); + buf->setUnicodeMode(uniCookie); fileReload(); } break; @@ -5918,7 +5896,8 @@ bool Notepad_plus::reloadLang() if (declaration) { const char * encodingStr = declaration->Encoding(); - _nativeLangEncoding = getCpFromStringValue(encodingStr); + EncodingMapper *em = EncodingMapper::getInstance(); + _nativeLangEncoding = em->getEncodingFromString(encodingStr); } pNppParam->reloadContextMenuFromXmlTree(_mainMenuHandle); @@ -6457,9 +6436,14 @@ void Notepad_plus::checkUnicodeMenuItems(/*UniMode um*/) const } else { - int cmdID = getCmdIDFromEncoding(encoding); + EncodingMapper *em = EncodingMapper::getInstance(); + int cmdID = em->getIndexFromEncoding(encoding); if (cmdID == -1) + { + printStr(TEXT("Encoding problem. Encoding is not added in encoding_table?")); return; + } + cmdID += IDM_FORMAT_ENCODE; // Uncheck all in the main encoding menu ::CheckMenuRadioItem(_mainMenuHandle, IDM_FORMAT_ANSI, IDM_FORMAT_AS_UTF_8, IDM_FORMAT_ANSI, MF_BYCOMMAND); @@ -8200,6 +8184,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa int pos = IDM_FILEMENU_LASTONE - IDM_FILE + 2; _lastRecentFileList.initMenu(hFileMenu, IDM_FILEMENU_LASTONE + 1, pos); + _lastRecentFileList.setLangEncoding(_nativeLangEncoding); for (int i = 0 ; i < nbLRFile ; i++) { generic_string * stdStr = pNppParam->getLRFile(i); diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index 084dbff98..dbb57ff00 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -398,9 +398,13 @@ BEGIN MENUITEM "Encode in UCS-2 Little Endian", IDM_FORMAT_UCS_2LE POPUP "Character sets" BEGIN + MENUITEM "Arabic(ISO)", IDM_FORMAT_ISO_8859_6 MENUITEM "Arabic(Windows)", IDM_FORMAT_WIN1256 + MENUITEM "Baltic Rim(ISO)", IDM_FORMAT_ISO_8859_13 MENUITEM "Baltic(Windows)", IDM_FORMAT_WIN1257 + MENUITEM "Celtic(ISO)", IDM_FORMAT_ISO_8859_14 MENUITEM "Cyrillic(DOS)", IDM_FORMAT_CP855 + MENUITEM "Cyrillic(ISO)", IDM_FORMAT_ISO_8859_5 MENUITEM "Cyrillic(Macintosh)", IDM_FORMAT_MAC_CYRILLIC MENUITEM "Cyrillic(KOI8-R)", IDM_FORMAT_KIO8R_CYRILLIC MENUITEM "Cyrillic(KOI8-U)", IDM_FORMAT_KIO8U_CYRILLIC @@ -409,14 +413,24 @@ BEGIN MENUITEM "Chinese Traditional(Big5)", IDM_FORMAT_BIG5 MENUITEM "Chinese Simplified(GB)", IDM_FORMAT_GB2312 MENUITEM "DOS ASCII", IDM_FORMAT_DOS437 + MENUITEM "Eastern European(ISO)", IDM_FORMAT_ISO_8859_2 + MENUITEM "Greek(ISO)", IDM_FORMAT_ISO_8859_7 MENUITEM "Greek(Windows)", IDM_FORMAT_WIN1253 MENUITEM "Hebrew(iso8859-8)", IDM_FORMAT_ISO_8859_8 MENUITEM "Hebrew(Windows)", IDM_FORMAT_WIN1255 MENUITEM "Japanese(Shift-JIS)", IDM_FORMAT_SHIFT_JIS MENUITEM "Korean(EUC)", IDM_FORMAT_EUC_KR + MENUITEM "Latin-6(ISO)", IDM_FORMAT_ISO_8859_10 + MENUITEM "Latin-15(ISO)", IDM_FORMAT_ISO_8859_15 + MENUITEM "North European(ISO)", IDM_FORMAT_ISO_8859_4 + MENUITEM "South-Eastern European(ISO)", IDM_FORMAT_ISO_8859_16 + MENUITEM "South European(ISO)", IDM_FORMAT_ISO_8859_3 + MENUITEM "Thai(ISO)", IDM_FORMAT_ISO_8859_11 MENUITEM "Thai(Windows)", IDM_FORMAT_TIS_620 + MENUITEM "Turkish(Windows)", IDM_FORMAT_ISO_8859_9 MENUITEM "Turkish(Windows)", IDM_FORMAT_WIN1254 MENUITEM "Western European(Windows)", IDM_FORMAT_WIN1252 + MENUITEM "Western European(ISO)", IDM_FORMAT_ISO_8859_1 MENUITEM "Vietnamese(Windows)", IDM_FORMAT_WIN1258 END MENUITEM SEPARATOR diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index a6fcf5d93..72d8321f3 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -377,33 +377,6 @@ ScintillaKeyDefinition scintKeyDefs[] = { //array of accelerator keys for all po // }; -static bool isInList(const TCHAR *token, const TCHAR *list) { - if ((!token) || (!list)) - return false; - TCHAR word[64]; - int i = 0; - int j = 0; - for (; i <= int(lstrlen(list)) ; i++) - { - if ((list[i] == ' ')||(list[i] == '\0')) - { - if (j != 0) - { - word[j] = '\0'; - j = 0; - - if (!generic_stricmp(token, word)) - return true; - } - } - else - { - word[j] = list[i]; - j++; - } - } - return false; -}; static int strVal(const TCHAR *str, int base) { if (!str) return -1; @@ -586,11 +559,12 @@ winVer getWindowsVersion() return WV_UNKNOWN; } + NppParameters * NppParameters::_pSelf = new NppParameters; int FileDialog::_dialogFileBoxId = (NppParameters::getInstance())->getWinVersion() < WV_W2K?edt1:cmb13; NppParameters::NppParameters() : _pXmlDoc(NULL),_pXmlUserDoc(NULL), _pXmlUserStylerDoc(NULL),\ - _pXmlUserLangDoc(NULL), /*_pXmlNativeLangDoc(NULL), */_pXmlNativeLangDocA(NULL),\ + _pXmlUserLangDoc(NULL), _pXmlNativeLangDocA(NULL),\ _nbLang(0), _nbFile(0), _nbMaxFile(10), _pXmlToolIconsDoc(NULL),\ _pXmlShortcutDoc(NULL), _pXmlContextMenuDoc(NULL), _pXmlSessionDoc(NULL), _pXmlBlacklistDoc(NULL),\ _nbUserLang(0), _nbExternalLang(0), _hUser32(NULL), _hUXTheme(NULL),\ @@ -1586,15 +1560,18 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p } void NppParameters::feedFileListParameters(TiXmlNode *node) { - _nbMaxFile = 10; - TiXmlNode *historyRoot = node->FirstChildElement(TEXT("History")); if (!historyRoot) return; - (historyRoot->ToElement())->Attribute(TEXT("nbMaxFile"), &_nbMaxFile); - if ((_nbMaxFile < 0) || (_nbMaxFile > 30)) + int nbMaxFile; + const TCHAR *nbMaxFileStr = (historyRoot->ToElement())->Attribute(TEXT("nbMaxFile"), &nbMaxFile); + + if ((nbMaxFile < 0) || (nbMaxFile > 50)) return; + if (nbMaxFileStr) + _nbMaxFile = nbMaxFile; + for (TiXmlNode *childNode = historyRoot->FirstChildElement(TEXT("File")); childNode && (_nbFile < NB_MAX_LRF_FILE); childNode = childNode->NextSibling(TEXT("File")) ) diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 76a41e059..7bbbf2bfa 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -57,35 +57,6 @@ Buffer::Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus } -void Buffer::determinateFormat(const char *data) { - _format = WIN_FORMAT; - size_t len = strlen(data); - for (size_t i = 0 ; i < len ; i++) - { - if (data[i] == CR) - { - if (data[i+1] == LF) - { - _format = WIN_FORMAT; - break; - } - else - { - _format = MAC_FORMAT; - break; - } - } - if (data[i] == LF) - { - _format = UNIX_FORMAT; - break; - } - } - - doNotify(BufferChangeFormat); - return; -} - void Buffer::setLangType(LangType lang, const TCHAR * userLangName) { if (lang == _lang && lang != L_USER) @@ -416,7 +387,9 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin ::GetFullPathName(filename, MAX_PATH, fullpath, NULL); ::GetLongPathName(fullpath, fullpath, MAX_PATH); Utf8_16_Read UnicodeConvertor; //declare here so we can get information after loading is done - bool res = loadFileData(doc, fullpath, &UnicodeConvertor, L_TXT, encoding); + + formatType format; + bool res = loadFileData(doc, fullpath, &UnicodeConvertor, L_TXT, encoding, &format); if (res) { Buffer * newBuf = new Buffer(this, _nextBufferID, doc, DOC_REGULAR, fullpath); @@ -426,32 +399,42 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin _nrBufs++; Buffer * buf = _buffers.at(_nrBufs - 1); - // 3 formats : WIN_FORMAT, UNIX_FORMAT and MAC_FORMAT - if (UnicodeConvertor.getNewBuf()) + if (encoding == -1) { - buf->determinateFormat(UnicodeConvertor.getNewBuf()); - } - else - { - buf->determinateFormat(""); - } - - UniMode encoding = UnicodeConvertor.getEncoding(); - if (encoding == uni7Bit) - { - NppParameters *pNppParamInst = NppParameters::getInstance(); - const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings(); - if (ndds._openAnsiAsUtf8) + // 3 formats : WIN_FORMAT, UNIX_FORMAT and MAC_FORMAT + if (UnicodeConvertor.getNewBuf()) { - encoding = uniCookie; + int format = getEOLFormatForm(UnicodeConvertor.getNewBuf()); + buf->setFormat(format == -1?WIN_FORMAT:(formatType)format); + } else { - encoding = uni8Bit; + buf->setFormat(WIN_FORMAT); } - } - buf->setUnicodeMode(encoding); + UniMode um = UnicodeConvertor.getEncoding(); + if (um == uni7Bit) + { + NppParameters *pNppParamInst = NppParameters::getInstance(); + const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings(); + if (ndds._openAnsiAsUtf8) + { + um = uniCookie; + } + else + { + um = uni8Bit; + } + } + buf->setUnicodeMode(um); + } + else + { + buf->setUnicodeMode(uniCookie); + buf->setFormat(format); + buf->setEncoding(encoding); + } //determine buffer properties _nextBufferID++; return id; @@ -470,15 +453,32 @@ bool FileManager::reloadBuffer(BufferID id) Document doc = buf->getDocument(); Utf8_16_Read UnicodeConvertor; buf->_canNotify = false; //disable notify during file load, we dont want dirty to be triggered - bool res = loadFileData(doc, buf->getFullPathName(), &UnicodeConvertor, buf->getLangType(), buf->getEncoding()); + int encoding = buf->getEncoding(); + formatType format; + bool res = loadFileData(doc, buf->getFullPathName(), &UnicodeConvertor, buf->getLangType(), encoding, &format); buf->_canNotify = true; - if (res) { - if (UnicodeConvertor.getNewBuf()) { - buf->determinateFormat(UnicodeConvertor.getNewBuf()); - } else { - buf->determinateFormat(""); + if (res) + { + if (encoding == -1) + { + if (UnicodeConvertor.getNewBuf()) + { + int format = getEOLFormatForm(UnicodeConvertor.getNewBuf()); + buf->setFormat(format == -1?WIN_FORMAT:(formatType)format); + } + else + { + buf->setFormat(WIN_FORMAT); + } + buf->setUnicodeMode(UnicodeConvertor.getEncoding()); } - buf->setUnicodeMode(UnicodeConvertor.getEncoding()); + else + { + buf->setEncoding(encoding); + buf->setFormat(format); + buf->setUnicodeMode(uniCookie); + } + } return res; } @@ -636,7 +636,7 @@ BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool d return id; } -bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Read * UnicodeConvertor, LangType language, int encoding) +bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Read * UnicodeConvertor, LangType language, int encoding, formatType *pFormat) { const int blockSize = 128 * 1024; //128 kB char data[blockSize+1]; @@ -677,9 +677,11 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Rea } bool success = true; + int format = -1; __try { size_t lenFile = 0; size_t lenConvert = 0; //just in case conversion results in 0, but file not empty + do { lenFile = fread(data, 1, blockSize, fp); if (encoding != -1) @@ -688,6 +690,8 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Rea WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); const char *newData = wmc->encode(encoding, SC_CP_UTF8, data); _pscratchTilla->execute(SCI_APPENDTEXT, strlen(newData), (LPARAM)newData); + if (format == -1) + format = getEOLFormatForm(data); } else { @@ -703,6 +707,10 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Rea fclose(fp); + if (pFormat != NULL) + { + *pFormat = (format == -1)?WIN_FORMAT:(formatType)format; + } _pscratchTilla->execute(SCI_EMPTYUNDOBUFFER); _pscratchTilla->execute(SCI_SETSAVEPOINT); if (ro) { @@ -755,3 +763,27 @@ int FileManager::docLength(Buffer * buffer) const _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault); return docLen; } + +int FileManager::getEOLFormatForm(const char *data) const +{ + size_t len = strlen(data); + for (size_t i = 0 ; i < len ; i++) + { + if (data[i] == CR) + { + if (i+1 < len && data[i+1] == LF) + { + return int(WIN_FORMAT); + } + else + { + return int(MAC_FORMAT); + } + } + if (data[i] == LF) + { + return int(UNIX_FORMAT); + } + } + return -1; +} \ No newline at end of file diff --git a/PowerEditor/src/ScitillaComponent/Buffer.h b/PowerEditor/src/ScitillaComponent/Buffer.h index 69c8b86d3..bb2f23bcd 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.h +++ b/PowerEditor/src/ScitillaComponent/Buffer.h @@ -60,7 +60,6 @@ struct HeaderLineState { const TCHAR UNTITLED_STR[] = TEXT("new "); //File manager class maintains all buffers -class Buffer; class FileManager { public: void init(Notepad_plus * pNotepadPlus, ScintillaEditView * pscratchTilla); @@ -106,6 +105,8 @@ public: int docLength(Buffer * buffer) const; + int getEOLFormatForm(const char *data) const; + private: FileManager() : _nextNewNumber(1), _nextBufferID(0), _pNotepadPlus(NULL), _nrBufs(0), _pscratchTilla(NULL){}; ~FileManager(); @@ -121,7 +122,7 @@ private: BufferID _nextBufferID; size_t _nrBufs; - bool loadFileData(Document doc, const TCHAR * filename, Utf8_16_Read * UnicodeConvertor, LangType language, int encoding = -1); + bool loadFileData(Document doc, const TCHAR * filename, Utf8_16_Read * UnicodeConvertor, LangType language, int encoding = -1, formatType *pFormat = NULL); }; #define MainFileManager FileManager::getInstance() @@ -246,8 +247,6 @@ public : void setHeaderLineState(const std::vector & folds, ScintillaEditView * identifier); std::vector & getHeaderLineState(ScintillaEditView * identifier); - void determinateFormat(const char *data); - bool isUserDefineLangExt() const { return (_userLangExt[0] != '\0'); }; diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp index 61d5d7d8a..34946b957 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp @@ -19,6 +19,7 @@ #include "WindowsDlg.h" #include "WindowsDlgRc.h" #include "DocTabView.h" +#include "EncodingMapper.h" #ifndef _countof #define _countof(x) (sizeof(x)/sizeof((x)[0])) @@ -409,7 +410,8 @@ bool WindowsDlg::changeDlgLang() if (declaration) { const char * encodingStr = declaration->Encoding(); - nativeLangEncoding = getCpFromStringValue(encodingStr); + EncodingMapper *em = EncodingMapper::getInstance(); + nativeLangEncoding = em->getEncodingFromString(encodingStr); } #endif diff --git a/PowerEditor/src/lastRecentFileList.cpp b/PowerEditor/src/lastRecentFileList.cpp index bc34dc778..8616e8934 100644 --- a/PowerEditor/src/lastRecentFileList.cpp +++ b/PowerEditor/src/lastRecentFileList.cpp @@ -40,6 +40,7 @@ void LastRecentFileList::updateMenu() { #ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); const wchar_t * openAllFileStrW = wmc->char2wchar(openAllFileStr, _nativeLangEncoding); + ::InsertMenu(_hMenu, _posBase + 1, MF_BYPOSITION, IDM_OPEN_ALL_RECENT_FILE, openAllFileStrW); const wchar_t * cleanFileListStrW = wmc->char2wchar(cleanFileListStr, _nativeLangEncoding); ::InsertMenu(_hMenu, _posBase + 2, MF_BYPOSITION, IDM_CLEAN_RECENT_FILE_LIST, cleanFileListStrW); diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h index 5532d828d..ed092a2b3 100644 --- a/PowerEditor/src/menuCmdID.h +++ b/PowerEditor/src/menuCmdID.h @@ -248,19 +248,34 @@ #define IDM_FORMAT_WIN1256 (IDM_FORMAT_ENCODE + 6) #define IDM_FORMAT_WIN1257 (IDM_FORMAT_ENCODE + 7) #define IDM_FORMAT_WIN1258 (IDM_FORMAT_ENCODE + 8) - #define IDM_FORMAT_BIG5 (IDM_FORMAT_ENCODE + 9) - #define IDM_FORMAT_GB2312 (IDM_FORMAT_ENCODE + 10) - #define IDM_FORMAT_SHIFT_JIS (IDM_FORMAT_ENCODE + 11) - #define IDM_FORMAT_EUC_KR (IDM_FORMAT_ENCODE + 12) - #define IDM_FORMAT_TIS_620 (IDM_FORMAT_ENCODE + 13) - #define IDM_FORMAT_ISO_8859_8 (IDM_FORMAT_ENCODE + 14) - #define IDM_FORMAT_CP855 (IDM_FORMAT_ENCODE + 15) - #define IDM_FORMAT_MAC_CYRILLIC (IDM_FORMAT_ENCODE + 16) - #define IDM_FORMAT_KIO8U_CYRILLIC (IDM_FORMAT_ENCODE + 17) - #define IDM_FORMAT_KIO8R_CYRILLIC (IDM_FORMAT_ENCODE + 18) - #define IDM_FORMAT_DOS437 (IDM_FORMAT_ENCODE + 19) - - #define IDM_FORMAT_ENCODE_END IDM_FORMAT_DOS437 + #define IDM_FORMAT_ISO_8859_1 (IDM_FORMAT_ENCODE + 9) + #define IDM_FORMAT_ISO_8859_2 (IDM_FORMAT_ENCODE + 10) + #define IDM_FORMAT_ISO_8859_3 (IDM_FORMAT_ENCODE + 11) + #define IDM_FORMAT_ISO_8859_4 (IDM_FORMAT_ENCODE + 12) + #define IDM_FORMAT_ISO_8859_5 (IDM_FORMAT_ENCODE + 13) + #define IDM_FORMAT_ISO_8859_6 (IDM_FORMAT_ENCODE + 14) + #define IDM_FORMAT_ISO_8859_7 (IDM_FORMAT_ENCODE + 15) + #define IDM_FORMAT_ISO_8859_8 (IDM_FORMAT_ENCODE + 16) + #define IDM_FORMAT_ISO_8859_9 (IDM_FORMAT_ENCODE + 17) + #define IDM_FORMAT_ISO_8859_10 (IDM_FORMAT_ENCODE + 18) + #define IDM_FORMAT_ISO_8859_11 (IDM_FORMAT_ENCODE + 19) + #define IDM_FORMAT_ISO_8859_13 (IDM_FORMAT_ENCODE + 20) + #define IDM_FORMAT_ISO_8859_14 (IDM_FORMAT_ENCODE + 21) + #define IDM_FORMAT_ISO_8859_15 (IDM_FORMAT_ENCODE + 22) + #define IDM_FORMAT_ISO_8859_16 (IDM_FORMAT_ENCODE + 23) + #define IDM_FORMAT_BIG5 (IDM_FORMAT_ENCODE + 24) + #define IDM_FORMAT_GB2312 (IDM_FORMAT_ENCODE + 25) + #define IDM_FORMAT_SHIFT_JIS (IDM_FORMAT_ENCODE + 26) + #define IDM_FORMAT_KOREAN_WIN (IDM_FORMAT_ENCODE + 27) + #define IDM_FORMAT_EUC_KR (IDM_FORMAT_ENCODE + 28) + #define IDM_FORMAT_TIS_620 (IDM_FORMAT_ENCODE + 29) + #define IDM_FORMAT_CP855 (IDM_FORMAT_ENCODE + 30) + #define IDM_FORMAT_MAC_CYRILLIC (IDM_FORMAT_ENCODE + 31) + #define IDM_FORMAT_KIO8U_CYRILLIC (IDM_FORMAT_ENCODE + 32) + #define IDM_FORMAT_KIO8R_CYRILLIC (IDM_FORMAT_ENCODE + 33) + #define IDM_FORMAT_DOS437 (IDM_FORMAT_ENCODE + 34) + #define IDM_FORMAT_US_ASCII (IDM_FORMAT_ENCODE + 35) + #define IDM_FORMAT_ENCODE_END IDM_FORMAT_US_ASCII #define IDM_LANG (IDM + 6000) #define IDM_LANGSTYLE_CONFIG_DLG (IDM_LANG + 1) diff --git a/PowerEditor/visual.net/notepadPlus.vcproj b/PowerEditor/visual.net/notepadPlus.vcproj index f35e057b3..d1fa42c92 100644 --- a/PowerEditor/visual.net/notepadPlus.vcproj +++ b/PowerEditor/visual.net/notepadPlus.vcproj @@ -454,6 +454,10 @@ RelativePath="..\src\ScitillaComponent\DocTabView.cpp" > + + @@ -751,6 +755,10 @@ RelativePath="..\src\ScitillaComponent\DocTabView.h" > + +