From aa1f014acb0d3b74630044e41562931c382b4ddb Mon Sep 17 00:00:00 2001 From: donho Date: Fri, 15 Aug 2008 10:02:25 +0000 Subject: [PATCH] [NEW_FEATURE] Unicode path is supported. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@305 f5eea248-9336-0410-98b8-ebc06183d4e3 --- .../src/MISC/Exception/Win32Exception.h | 24 ++ PowerEditor/src/MISC/FileNameStringSplitter.h | 20 +- PowerEditor/src/Notepad_plus.cpp | 380 ++++++++++++------ PowerEditor/src/Notepad_plus.h | 70 ++-- PowerEditor/src/ScitillaComponent/Buffer.cpp | 63 +-- PowerEditor/src/ScitillaComponent/Buffer.h | 18 + .../src/ScitillaComponent/DocTabView.cpp | 15 +- .../src/ScitillaComponent/FindReplaceDlg.cpp | 24 +- .../src/ScitillaComponent/FindReplaceDlg.h | 11 +- PowerEditor/src/ScitillaComponent/Printer.cpp | 140 +++---- PowerEditor/src/ScitillaComponent/Printer.h | 4 +- .../ScitillaComponent/ScintillaEditView.cpp | 51 ++- .../src/ScitillaComponent/ScintillaEditView.h | 1 + .../UserDefineLangReference.h | 3 - PowerEditor/src/TinyXml/tinyxml.cpp | 9 +- PowerEditor/src/UniConversion.cpp | 44 ++ PowerEditor/src/UniConversion.h | 14 + PowerEditor/src/Utf8_16.cpp | 10 + PowerEditor/src/Utf8_16.h | 7 + .../WinControls/ColourPicker/ColourPopup.cpp | 4 +- .../src/WinControls/DockingWnd/DockingCont.h | 2 +- .../WinControls/DockingWnd/common_func.cpp | 19 +- PowerEditor/src/WinControls/Grid/BabyGrid.h | 7 +- .../src/WinControls/Grid/ShortcutMapper.h | 6 +- .../src/WinControls/Grid/ShortcutMapper_rc.h | 4 + .../OpenSaveFileDialog/FileDialog.cpp | 99 +++-- .../OpenSaveFileDialog/FileDialog.h | 23 +- .../StaticDialog/RunDlg/RunDlg.cpp | 103 +++-- .../WinControls/StaticDialog/RunDlg/RunDlg.h | 28 +- .../src/WinControls/StatusBar/StatusBar.h | 1 + PowerEditor/src/WinControls/TabBar/TabBar.cpp | 30 +- .../src/WinControls/WindowsDlg/SizeableDlg.h | 5 +- .../src/WinControls/WindowsDlg/WindowsDlg.cpp | 99 ++--- .../src/WinControls/WindowsDlg/WindowsDlg.h | 2 +- .../src/WinControls/WindowsDlg/WindowsDlgRc.h | 22 + PowerEditor/src/lastRecentFileList.cpp | 4 +- PowerEditor/src/winmain.cpp | 68 ++-- PowerEditor/src/xpm_icons.h | 5 + PowerEditor/visual.net/no_ms_shit.vsprops | 2 +- PowerEditor/visual.net/notepadPlus.vcproj | 15 +- 40 files changed, 946 insertions(+), 510 deletions(-) diff --git a/PowerEditor/src/MISC/Exception/Win32Exception.h b/PowerEditor/src/MISC/Exception/Win32Exception.h index 651388f83..51ea2b6a9 100644 --- a/PowerEditor/src/MISC/Exception/Win32Exception.h +++ b/PowerEditor/src/MISC/Exception/Win32Exception.h @@ -4,6 +4,28 @@ //By Bennett //Formatting Slightly modified for N++ +/* +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 WIN32EXCEPTION_H +#define WIN32EXCEPTION_H + #include "windows.h" #include @@ -41,3 +63,5 @@ private: friend void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS* info); }; + +#endif //WIN32EXCEPTION_H diff --git a/PowerEditor/src/MISC/FileNameStringSplitter.h b/PowerEditor/src/MISC/FileNameStringSplitter.h index 9c82b6d14..d97bf08a8 100644 --- a/PowerEditor/src/MISC/FileNameStringSplitter.h +++ b/PowerEditor/src/MISC/FileNameStringSplitter.h @@ -18,19 +18,19 @@ #ifndef FILENAME_STRING_SPLITTER_H #define FILENAME_STRING_SPLITTER_H -typedef std::vector stringVector; +typedef std::vector stringVectorW; class FileNameStringSplitter { public : - FileNameStringSplitter(const char *fileNameStr) { + FileNameStringSplitter(const wchar_t *fileNameStr) { //if (!fileNameStr) return; - char *pStr = NULL; + wchar_t *pStr = NULL; bool isInsideQuotes = false; - char str[256]; + wchar_t str[256]; int i = 0; bool fini = false; - for (pStr = (char *)fileNameStr ; !fini ; ) + for (pStr = (wchar_t *)fileNameStr ; !fini ; ) { switch (*pStr) { @@ -39,7 +39,7 @@ public : { str[i] = '\0'; if (str[0]) - _fileNames.push_back(std::string(str)); + _fileNames.push_back(std::wstring(str)); i = 0; } isInsideQuotes = !isInsideQuotes; @@ -56,7 +56,7 @@ public : { str[i] = '\0'; if (str[0]) - _fileNames.push_back(std::string(str)); + _fileNames.push_back(std::wstring(str)); i = 0; } pStr++; @@ -65,7 +65,7 @@ public : case '\0' : str[i] = *pStr; if (str[0]) - _fileNames.push_back(std::string(str)); + _fileNames.push_back(std::wstring(str)); fini = true; break; @@ -77,7 +77,7 @@ public : } }; - const char * getFileName(int index) const { + const wchar_t * getFileName(int index) const { return _fileNames[index].c_str(); }; @@ -86,7 +86,7 @@ public : }; private : - stringVector _fileNames; + stringVectorW _fileNames; }; #endif //FILENAME_STRING_SPLITTER_H diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 0410417ca..d58546ec8 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -40,9 +40,11 @@ #include #include #include "xmlMatchedTagsHighlighter.h" +#include "UniConversion.h" const char Notepad_plus::_className[32] = NOTEPAD_PP_CLASS_NAME; -const char *urlHttpRegExpr = "http://[a-z0-9_\\-\\+.:?&@=/%#]*"; +const wchar_t Notepad_plus::_classNameW[32] = NOTEPAD_PP_CLASS_NAME_W; +const char *urlHttpRE = "http://[a-z0-9_\\-\\+.:?&@=/%#]*"; int docTabIconIDs[] = {IDI_SAVED_ICON, IDI_UNSAVED_ICON, IDI_READONLY_ICON}; enum tb_stat {tb_saved, tb_unsaved, tb_ro}; @@ -182,10 +184,10 @@ Notepad_plus::~Notepad_plus() delete _pTrayIco; } -void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine, CmdLineParams *cmdLineParams) +void Notepad_plus::init(HINSTANCE hInst, HWND parent, const wchar_t *cmdLine, CmdLineParams *cmdLineParams) { Window::init(hInst, parent); - WNDCLASS nppClass; + WNDCLASSW nppClass; nppClass.style = CS_BYTEALIGNWINDOW | CS_DBLCLKS;//CS_HREDRAW | CS_VREDRAW; nppClass.lpfnWndProc = Notepad_plus_Proc; @@ -195,10 +197,10 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine, CmdLi nppClass.hIcon = ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_M30ICON)); nppClass.hCursor = ::LoadCursor(NULL, IDC_ARROW); nppClass.hbrBackground = ::CreateSolidBrush(::GetSysColor(COLOR_MENU)); - nppClass.lpszMenuName = MAKEINTRESOURCE(IDR_M30_MENU); - nppClass.lpszClassName = _className; + nppClass.lpszMenuName = MAKEINTRESOURCEW(IDR_M30_MENU); + nppClass.lpszClassName = _classNameW; - if (!::RegisterClass(&nppClass)) + if (!::RegisterClassW(&nppClass)) { systemMessage("System Err"); throw int(98); @@ -212,10 +214,10 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine, CmdLi if (cmdLineParams->_isNoPlugin) _pluginsManager.disable(); - _hSelf = ::CreateWindowEx( + _hSelf = ::CreateWindowExW( WS_EX_ACCEPTFILES | (_isRTL?WS_EX_LAYOUTRTL:0),\ - _className,\ - "Notepad++",\ + _classNameW,\ + L"Notepad++",\ WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,\ // CreateWindowEx bug : set all 0 to walk arround the pb 0, 0, 0, 0,\ @@ -478,7 +480,11 @@ bool Notepad_plus::loadSession(Session & session) session._mainViewFiles.erase(posIt); continue; //skip session files, not supporting recursive sessions } - if (PathFileExists(pFn)) { + + wchar_t fnW[MAX_PATH]; + char2wchar(pFn, fnW); + + if (PathFileExistsW(fnW)) { lastOpened = doOpen(pFn); } else { lastOpened = BUFFER_INVALID; @@ -525,7 +531,11 @@ bool Notepad_plus::loadSession(Session & session) session._subViewFiles.erase(posIt); continue; //skip session files, not supporting recursive sessions } - if (PathFileExists(pFn)) { + + wchar_t fnW[MAX_PATH]; + char2wchar(pFn, fnW); + + if (PathFileExistsW(fnW)) { lastOpened = doOpen(pFn); //check if already open in main. If so, clone if (_mainDocTab.getIndexByBuffer(lastOpened) != -1) { @@ -620,29 +630,32 @@ BufferID Notepad_plus::doOpen(const char *fileName, bool isReadOnly) return test; } - if (isFileSession(longFileName) && PathFileExists(longFileName)) { + WCHAR longFileNameW[MAX_PATH]; + char2wchar(longFileName, longFileNameW); + + if (isFileSession(longFileName) && PathFileExistsW(longFileNameW)) { fileLoadSession(longFileName); return BUFFER_INVALID; } - if (!PathFileExists(longFileName)) + if (!PathFileExistsW(longFileNameW)) { - char str2display[MAX_PATH*2]; - char longFileDir[MAX_PATH]; + wchar_t str2display[MAX_PATH*2]; + WCHAR longFileDir[MAX_PATH]; - strcpy(longFileDir, longFileName); - PathRemoveFileSpec(longFileDir); + wcscpy(longFileDir, longFileNameW); + PathRemoveFileSpecW(longFileDir); - if (PathFileExists(longFileDir)) + if (PathFileExistsW(longFileDir)) { - sprintf(str2display, "%s doesn't exist. Create it?", longFileName); + swprintf(str2display, L"%s doesn't exist. Create it?", longFileNameW); - if (::MessageBox(_hSelf, str2display, "Create new file", MB_YESNO) == IDYES) + if (::MessageBoxW(_hSelf, str2display, L"Create new file", MB_YESNO) == IDYES) { bool res = MainFileManager->createEmptyFile(longFileName); if (!res) { - sprintf(str2display, "Cannot create the file \"%s\"", longFileName); - ::MessageBox(_hSelf, str2display, "Create new file", MB_OK); + swprintf(str2display, L"Cannot create the file \"%s\"", longFileNameW); + ::MessageBoxW(_hSelf, str2display, L"Create new file", MB_OK); return BUFFER_INVALID; } } @@ -707,7 +720,6 @@ BufferID Notepad_plus::doOpen(const char *fileName, bool isReadOnly) } bool Notepad_plus::doReload(BufferID id, bool alert) { - /* //No activation when reloading, defer untill document is actually visible if (alert) { @@ -787,7 +799,7 @@ void Notepad_plus::doClose(BufferID id, int whichOne) { _pluginsManager.notify(&scnN); //add to recent files if its an existing file - if (!buf->isUntitled() && PathFileExists(buf->getFilePath())) + if (!buf->isUntitled() && PathFileExistsW(buf->getFilePathW())) { _lastRecentFileList.add(buf->getFilePath()); } @@ -1460,9 +1472,10 @@ void Notepad_plus::getMatchedFileNames(const char *dir, const vector & p { string dirFilter(dir); dirFilter += "*.*"; - WIN32_FIND_DATA foundData; + WIN32_FIND_DATAW foundData; - HANDLE hFile = ::FindFirstFile(dirFilter.c_str(), &foundData); + wstring dirFilterW = string2wstring(dirFilter); + HANDLE hFile = ::FindFirstFileW(dirFilterW.c_str(), &foundData); if (hFile != INVALID_HANDLE_VALUE) { @@ -1475,26 +1488,30 @@ void Notepad_plus::getMatchedFileNames(const char *dir, const vector & p } else if (isRecursive) { - if ((strcmp(foundData.cFileName, ".")) && (strcmp(foundData.cFileName, ".."))) + if ((wcscmp(foundData.cFileName, L".")) && (wcscmp(foundData.cFileName, L".."))) { string pathDir(dir); - pathDir += foundData.cFileName; - pathDir += "\\"; + wstring pathDirW = string2wstring(pathDir); + pathDirW += foundData.cFileName; + pathDirW += L"\\"; + pathDir = wstring2string(pathDirW); getMatchedFileNames(pathDir.c_str(), patterns, fileNames, isRecursive, isInHiddenDir); } } } else { - if (matchInList(foundData.cFileName, patterns)) + char filename[MAX_PATH]; + wchar2char(foundData.cFileName, filename); + if (matchInList(filename, patterns)) { string pathFile(dir); - pathFile += foundData.cFileName; + pathFile += filename; fileNames.push_back(pathFile.c_str()); } } } - while (::FindNextFile(hFile, &foundData)) + while (::FindNextFileW(hFile, &foundData)) { if (foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { @@ -1504,21 +1521,25 @@ void Notepad_plus::getMatchedFileNames(const char *dir, const vector & p } else if (isRecursive) { - if ((strcmp(foundData.cFileName, ".")) && (strcmp(foundData.cFileName, ".."))) + if ((wcscmp(foundData.cFileName, L".")) && (wcscmp(foundData.cFileName, L".."))) { string pathDir(dir); - pathDir += foundData.cFileName; - pathDir += "\\"; + wstring pathDirW = string2wstring(pathDir); + pathDirW += foundData.cFileName; + pathDirW += L"\\"; + pathDir = wstring2string(pathDirW); getMatchedFileNames(pathDir.c_str(), patterns, fileNames, isRecursive, isInHiddenDir); } } } else { - if (matchInList(foundData.cFileName, patterns)) + char filename[MAX_PATH]; + wchar2char(foundData.cFileName, filename); + if (matchInList(filename, patterns)) { string pathFile(dir); - pathFile += foundData.cFileName; + pathFile += filename; fileNames.push_back(pathFile.c_str()); } } @@ -1537,8 +1558,10 @@ bool Notepad_plus::findInFiles(bool isRecursive, bool isInHiddenDir) _findReplaceDlg.clearFinder(); const char *dir2Search = _findReplaceDlg.getDir2Search(); + wchar_t dir2SearchW[MAX_PATH]; + char2wchar(dir2Search, dir2SearchW); - if (!dir2Search[0] || !::PathFileExists(dir2Search)) + if (!dir2SearchW[0] || !::PathFileExistsW(dir2SearchW)) { return false; } @@ -1576,6 +1599,7 @@ bool Notepad_plus::findInFiles(bool isRecursive, bool isInHiddenDir) } bool Notepad_plus::findInOpenedFiles() { + int nbTotal = 0; ScintillaEditView *pOldView = _pEditView; _pEditView = &_invisibleEditView; @@ -2161,11 +2185,12 @@ BOOL Notepad_plus::notify(SCNotification *notification) _tabPopupMenu.enableItem(IDM_EDIT_SETREADONLY, !isSysReadOnly); _tabPopupMenu.enableItem(IDM_EDIT_CLEARREADONLY, isSysReadOnly); - bool isFileExisting = PathFileExists(buf->getFilePath()) != FALSE; + bool isFileExisting = PathFileExistsW(buf->getFilePathW()) != FALSE; _tabPopupMenu.enableItem(IDM_FILE_DELETE, isFileExisting); _tabPopupMenu.enableItem(IDM_FILE_RENAME, isFileExisting); _tabPopupMenu.display(p); + return TRUE; } @@ -2227,6 +2252,16 @@ BOOL Notepad_plus::notify(SCNotification *notification) xmlTagMatchHiliter.tagMatch(nppGUI._enableTagAttrsHilite); } _smartHighlighter.highlightView(notifyView); + + if (_linkTriggered) + { + int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL; + if ((urlAction == 1) || (urlAction == 2)) + addHotSpot(_isDocModifing); + _linkTriggered = false; + _isDocModifing = false; + } + updateStatusBar(); AutoCompletion * autoC = isFromPrimary?&_autoCompleteMain:&_autoCompleteSub; autoC->update(0); @@ -2236,14 +2271,15 @@ BOOL Notepad_plus::notify(SCNotification *notification) case SCN_SCROLLED: { _smartHighlighter.highlightView(notifyView); + ////_urlHighlighter.highlightView(notifyView); break; } - case TTN_GETDISPINFO: + case TTN_GETDISPINFOW: { - LPTOOLTIPTEXT lpttt; + LPTOOLTIPTEXTW lpttt; - lpttt = (LPTOOLTIPTEXT)notification; + lpttt = (LPTOOLTIPTEXTW)notification; lpttt->hinst = _hInst; POINT p; @@ -2273,7 +2309,9 @@ BOOL Notepad_plus::notify(SCNotification *notification) else break; - lpttt->lpszText = (LPSTR)tip.c_str(); + static wchar_t tipW[MAX_PATH]; + char2wchar(tip.c_str(), tipW); + lpttt->lpszText = tipW; } break; @@ -2290,6 +2328,12 @@ BOOL Notepad_plus::notify(SCNotification *notification) if (_syncInfo.doSync()) doSynScorll(HWND(notification->nmhdr.hwndFrom)); + ////if (_linkTriggered) + { + ////_urlHighlighter.highlightView(notifyView); + ////_linkTriggered = false; + } + if (_linkTriggered) { int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL; @@ -2298,11 +2342,33 @@ BOOL Notepad_plus::notify(SCNotification *notification) _linkTriggered = false; _isDocModifing = false; } + break; } case SCN_HOTSPOTDOUBLECLICK : { + /* + notifyView->execute(SCI_SETWORDCHARS, 0, (LPARAM)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-+.:?&@=/%#"); + + int pos = notifyView->execute(SCI_GETCURRENTPOS); + int startPos = static_cast(notifyView->execute(SCI_WORDSTARTPOSITION, pos, false)); + int endPos = static_cast(notifyView->execute(SCI_WORDENDPOSITION, pos, false)); + + notifyView->execute(SCI_SETTARGETSTART, startPos); + notifyView->execute(SCI_SETTARGETEND, endPos); + + int length = endPos-startPos+1; + char * currentWord = new char[length]; + notifyView->getText(currentWord, startPos, endPos); + + ::ShellExecute(_hSelf, "open", currentWord, NULL, NULL, SW_SHOW); + //Disabled: This message comes after SCN_DOUBLECLICK, so this method fails and prevents the next doubleclick from working + //_isHotspotDblClicked = true; + notifyView->execute(SCI_SETCHARSDEFAULT); + delete [] currentWord; + break; + */ notifyView->execute(SCI_SETWORDCHARS, 0, (LPARAM)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-+.:?&@=/%#"); int pos = notifyView->execute(SCI_GETCURRENTPOS); @@ -2312,7 +2378,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) notifyView->execute(SCI_SETTARGETSTART, startPos); notifyView->execute(SCI_SETTARGETEND, endPos); - int posFound = notifyView->execute(SCI_SEARCHINTARGET, strlen(urlHttpRegExpr), (LPARAM)urlHttpRegExpr); + int posFound = notifyView->execute(SCI_SEARCHINTARGET, strlen(urlHttpRE), (LPARAM)urlHttpRE); if (posFound != -1) { startPos = int(notifyView->execute(SCI_GETTARGETSTART)); @@ -2384,7 +2450,6 @@ BOOL Notepad_plus::notify(SCNotification *notification) } return FALSE; } - void Notepad_plus::findMatchingBracePos(int & braceAtCaret, int & braceOpposite) { int caretPos = int(_pEditView->execute(SCI_GETCURRENTPOS)); @@ -2453,6 +2518,7 @@ void Notepad_plus::charAdded(char chAdded) void Notepad_plus::addHotSpot(bool docIsModifing) { + //printStr("addHotSpot begin"); //bool docIsModifing = true; int posBegin2style = 0; if (docIsModifing) @@ -2483,7 +2549,7 @@ void Notepad_plus::addHotSpot(bool docIsModifing) ch = (unsigned char)_pEditView->execute(SCI_GETCHARAT, posBegin2style--); } } - int style_hotspot = 30; + int startPos = 0; int endPos = _pEditView->execute(SCI_GETTEXTLENGTH); @@ -2493,9 +2559,10 @@ void Notepad_plus::addHotSpot(bool docIsModifing) _pEditView->execute(SCI_SETTARGETSTART, startPos); _pEditView->execute(SCI_SETTARGETEND, endPos); - vector > hotspotStylers; - - int posFound = _pEditView->execute(SCI_SEARCHINTARGET, strlen(urlHttpRegExpr), (LPARAM)urlHttpRegExpr); + vector< pair > & hotspotStylers = (_pEditView->getCurrentBuffer())->getClickableStyles(); + int style_hotspot = hotspotStylers.size()==0?30:hotspotStylers[hotspotStylers.size() - 1].second - 1; + + int posFound = _pEditView->execute(SCI_SEARCHINTARGET, strlen(urlHttpRE), (LPARAM)urlHttpRE); while (posFound != -1) { @@ -2503,7 +2570,8 @@ void Notepad_plus::addHotSpot(bool docIsModifing) int end = int(_pEditView->execute(SCI_GETTARGETEND)); int foundTextLen = end - start; int idStyle = _pEditView->execute(SCI_GETSTYLEAT, posFound); - +//if (_pEditView->execute(SCI_STYLEGETHOTSPOT, idStyle) == FALSE) +{ if (end < posBegin2style - 1) { if (style_hotspot > 1) @@ -2512,11 +2580,12 @@ void Notepad_plus::addHotSpot(bool docIsModifing) else { int fs = -1; - for (size_t i = 0 ; i < hotspotStylers.size() ; i++) + size_t i = 0; + for ( ; i < hotspotStylers.size() ; i++) { - if (hotspotStylers[i].second == idStyle) + if (hotspotStylers[i].first._styleID == idStyle) { - fs = hotspotStylers[i].first; + fs = hotspotStylers[i].second; break; } } @@ -2526,33 +2595,57 @@ void Notepad_plus::addHotSpot(bool docIsModifing) _pEditView->execute(SCI_STARTSTYLING, start, 0xFF); _pEditView->execute(SCI_SETSTYLING, foundTextLen, fs); + Style styleToSet = hotspotStylers[i].first; + + if ( styleToSet._colorStyle & COLORSTYLE_FOREGROUND ) + _pEditView->execute(SCI_STYLESETFORE, fs, styleToSet._fgColor); + + if ( styleToSet._colorStyle & COLORSTYLE_BACKGROUND ) + _pEditView->execute(SCI_STYLESETBACK, fs, styleToSet._bgColor); + + if ((!styleToSet._fontName)||(strcmp(styleToSet._fontName, ""))) + _pEditView->execute(SCI_STYLESETFONT, (WPARAM)fs, (LPARAM)styleToSet._fontName); + + int fontStyle = styleToSet._fontStyle; + if (fontStyle != -1) + { + _pEditView->execute(SCI_STYLESETBOLD, (WPARAM)fs, fontStyle & FONTSTYLE_BOLD); + _pEditView->execute(SCI_STYLESETITALIC, (WPARAM)fs, fontStyle & FONTSTYLE_ITALIC); + _pEditView->execute(SCI_STYLESETUNDERLINE, (WPARAM)fs, fontStyle & FONTSTYLE_UNDERLINE); + } + + if (styleToSet._fontSize > 0) + _pEditView->execute(SCI_STYLESETSIZE, fs, styleToSet._fontSize); + + _pEditView->execute(SCI_STYLESETHOTSPOT, fs, TRUE); + _pEditView->execute(SCI_SETHOTSPOTACTIVEFORE, TRUE, blue); + _pEditView->execute(SCI_SETHOTSPOTSINGLELINE, fs, 0); + } else { - pair p(style_hotspot, idStyle); - hotspotStylers.push_back(p); int activeFG = 0xFF0000; char fontName[256]; - Style hotspotStyle; + Style associatedHotspotStyle; - hotspotStyle._styleID = style_hotspot; + associatedHotspotStyle._styleID = style_hotspot; _pEditView->execute(SCI_STYLEGETFONT, idStyle, (LPARAM)fontName); - hotspotStyle._fgColor = _pEditView->execute(SCI_STYLEGETFORE, idStyle); - hotspotStyle._bgColor = _pEditView->execute(SCI_STYLEGETBACK, idStyle); - hotspotStyle._fontSize = _pEditView->execute(SCI_STYLEGETSIZE, idStyle); + associatedHotspotStyle._fgColor = _pEditView->execute(SCI_STYLEGETFORE, idStyle); + associatedHotspotStyle._bgColor = _pEditView->execute(SCI_STYLEGETBACK, idStyle); + associatedHotspotStyle._fontSize = _pEditView->execute(SCI_STYLEGETSIZE, idStyle); int isBold = _pEditView->execute(SCI_STYLEGETBOLD, idStyle); int isItalic = _pEditView->execute(SCI_STYLEGETITALIC, idStyle); int isUnderline = _pEditView->execute(SCI_STYLEGETUNDERLINE, idStyle); - hotspotStyle._fontStyle = (isBold?FONTSTYLE_BOLD:0) | (isItalic?FONTSTYLE_ITALIC:0) | (isUnderline?FONTSTYLE_UNDERLINE:0); + associatedHotspotStyle._fontStyle = (isBold?FONTSTYLE_BOLD:0) | (isItalic?FONTSTYLE_ITALIC:0) | (isUnderline?FONTSTYLE_UNDERLINE:0); int fontStyle = (isBold?FONTSTYLE_BOLD:0) | (isItalic?FONTSTYLE_ITALIC:0) | (isUnderline?FONTSTYLE_UNDERLINE:0); int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL; if (urlAction == 2) - hotspotStyle._fontStyle |= FONTSTYLE_UNDERLINE; + associatedHotspotStyle._fontStyle |= FONTSTYLE_UNDERLINE; - _pEditView->setStyle(hotspotStyle); + _pEditView->setStyle(associatedHotspotStyle); _pEditView->execute(SCI_STYLESETHOTSPOT, style_hotspot, TRUE); _pEditView->execute(SCI_SETHOTSPOTACTIVEFORE, TRUE, activeFG); @@ -2560,20 +2653,27 @@ void Notepad_plus::addHotSpot(bool docIsModifing) _pEditView->execute(SCI_STARTSTYLING, start, 0x1F); _pEditView->execute(SCI_SETSTYLING, foundTextLen, style_hotspot); if (style_hotspot > 1) - style_hotspot--; + style_hotspot--; + + associatedHotspotStyle._styleID = idStyle; + pair p(associatedHotspotStyle, style_hotspot); + hotspotStylers.push_back(p); } } _pEditView->execute(SCI_SETTARGETSTART, posFound + foundTextLen); _pEditView->execute(SCI_SETTARGETEND, endPos); + posFound = _pEditView->execute(SCI_SEARCHINTARGET, strlen(urlHttpRE), (LPARAM)urlHttpRE); +} + - - posFound = _pEditView->execute(SCI_SEARCHINTARGET, strlen(urlHttpRegExpr), (LPARAM)urlHttpRegExpr); } _pEditView->execute(SCI_STARTSTYLING, endStyle, 0xFF); _pEditView->execute(SCI_SETSTYLING, 0, 0); + + //printStr("addHotSpot end"); } @@ -2884,14 +2984,14 @@ void Notepad_plus::command(int id) { Buffer * buf = _pEditView->getCurrentBuffer(); if (id == IDM_EDIT_FULLPATHTOCLIP) { - str2Cliboard(buf->getFilePath()); + str2CliboardW(buf->getFilePathW()); } else if (id == IDM_EDIT_CURRENTDIRTOCLIP) { - char dir[MAX_PATH]; - strcpy(dir, buf->getFilePath()); - PathRemoveFileSpec((LPSTR)dir); - str2Cliboard(dir); + wchar_t dir[MAX_PATH]; + wcscpy(dir, buf->getFilePathW()); + PathRemoveFileSpecW((LPWSTR)dir); + str2CliboardW(dir); } else if (id == IDM_EDIT_FILENAMETOCLIP) { - str2Cliboard(buf->getFileName()); + str2CliboardW(buf->getFileNameW()); } } break; @@ -3188,10 +3288,10 @@ void Notepad_plus::command(int id) { Buffer * buf = _pEditView->getCurrentBuffer(); - DWORD dwFileAttribs = ::GetFileAttributes(buf->getFileName()); + DWORD dwFileAttribs = ::GetFileAttributesW(buf->getFileNameW()); dwFileAttribs ^= FILE_ATTRIBUTE_READONLY; - ::SetFileAttributes(buf->getFileName(), dwFileAttribs); + ::SetFileAttributesW(buf->getFileNameW(), dwFileAttribs); buf->setFileReadOnly(false); } @@ -4311,14 +4411,14 @@ void Notepad_plus::setTitle() //Get the buffer Buffer * buf = _pEditView->getCurrentBuffer(); - string result = ""; + wstring result = L""; if (buf->isDirty()) { - result += "*"; + result += L"*"; } - result += buf->getFilePath(); - result += " - "; - result += _className; - ::SetWindowText(_hSelf, result.c_str()); + result += buf->getFilePathW(); + result += L" - "; + result += _classNameW; + ::SetWindowTextW(_hSelf, result.c_str()); } void Notepad_plus::activateNextDoc(bool direction) @@ -4407,8 +4507,10 @@ void Notepad_plus::dropFiles(HDROP hdrop) BufferID lastOpened = BUFFER_INVALID; for (int i = 0 ; i < filesDropped ; ++i) { + wchar_t pathDroppedW[MAX_PATH]; + ::DragQueryFileW(hdrop, i, pathDroppedW, sizeof(pathDroppedW)); char pathDropped[MAX_PATH]; - ::DragQueryFile(hdrop, i, pathDropped, sizeof(pathDropped)); + wchar2char(pathDroppedW, pathDropped); BufferID test = doOpen(pathDropped); if (test != BUFFER_INVALID) lastOpened = test; @@ -4728,6 +4830,7 @@ bool Notepad_plus::activateBuffer(BufferID id, int whichOne) { MainFileManager->reloadBuffer(id); pBuf->setNeedReload(false); } + if (whichOne == MAIN_VIEW) { if (_mainDocTab.activateBuffer(id)) //only activate if possible _mainEditView.activateBuffer(id); @@ -5760,7 +5863,6 @@ void Notepad_plus::getTaskListInfo(TaskListInfo *tli) LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { LRESULT result = FALSE; - NppParameters *pNppParam = NppParameters::getInstance(); switch (Message) { @@ -5768,7 +5870,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { // Note: lParam is -1 to prevent endless loops of calls ::SendMessage(_dockingManager.getHSelf(), WM_NCACTIVATE, wParam, (LPARAM)-1); - return ::DefWindowProc(hwnd, Message, wParam, lParam); + return ::DefWindowProcW(hwnd, Message, wParam, lParam); } case WM_CREATE: { @@ -6296,7 +6398,9 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa dir = (const char *)wParam; else { - ::GetCurrentDirectory(MAX_PATH, currentDir); + wchar_t currentDirW[MAX_PATH]; + ::GetCurrentDirectoryW(MAX_PATH, currentDirW); + wchar2char(currentDirW, currentDir); dir = currentDir; } @@ -6423,7 +6527,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case COPYDATA_FILENAMES : { CmdLineParams & cmdLineParams = pNppParam->getCmdLineParams(); - loadCommandlineParams((const char *)pCopyData->lpData, &cmdLineParams); + loadCommandlineParams((const wchar_t *)pCopyData->lpData, &cmdLineParams); break; } } @@ -6457,34 +6561,34 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_GETNAMEPART : case NPPM_GETEXTPART : { - char str[MAX_PATH]; + wchar_t str[MAX_PATH]; // par defaut : NPPM_GETCURRENTDIRECTORY - char *fileStr = strcpy(str, _pEditView->getCurrentBuffer()->getFilePath()); + wchar_t *fileStr = wcscpy(str, _pEditView->getCurrentBuffer()->getFilePathW()); if (Message == NPPM_GETCURRENTDIRECTORY) - PathRemoveFileSpec(str); + PathRemoveFileSpecW(str); else if (Message == NPPM_GETFILENAME) - fileStr = PathFindFileName(str); + fileStr = PathFindFileNameW(str); else if (Message == NPPM_GETNAMEPART) { - fileStr = PathFindFileName(str); - PathRemoveExtension(fileStr); + fileStr = PathFindFileNameW(str); + PathRemoveExtensionW(fileStr); } else if (Message == NPPM_GETEXTPART) - fileStr = PathFindExtension(str); + fileStr = PathFindExtensionW(str); // For the compability reason, if wParam is 0, then we assume the size of string buffer (lParam) is large enough. // otherwise we check if the string buffer size is enough for the string to copy. if (wParam != 0) { - if (strlen(fileStr) >= wParam) + if (wcslen(fileStr) >= wParam) { ::MessageBox(_hSelf, "Allocated buffer size is not enough to copy the string.", "NPPM error", MB_OK); return FALSE; } } - strcpy((char *)lParam, fileStr); + wcscpy((wchar_t *)lParam, fileStr); return TRUE; } @@ -6505,35 +6609,39 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } else //buffer large enough, perform safe copy { - lstrcpyn((char *)lParam, str, wParam); + wchar_t strW[strSize]; + char2wchar(str, strW); + lstrcpynW((wchar_t *)lParam, strW, wParam); return TRUE; } } - strcpy((char *)lParam, str); + wchar_t strW[strSize]; + char2wchar(str, strW); + wcscpy((wchar_t *)lParam, strW); return TRUE; } case NPPM_GETNPPDIRECTORY : { const int strSize = MAX_PATH; - char str[strSize]; + wchar_t str[strSize]; - ::GetModuleFileName(NULL, str, strSize); - PathRemoveFileSpec(str); + ::GetModuleFileNameW(NULL, str, strSize); + PathRemoveFileSpecW(str); // For the compability reason, if wParam is 0, then we assume the size of string buffer (lParam) is large enough. // otherwise we check if the string buffer size is enough for the string to copy. if (wParam != 0) { - if (strlen(str) >= wParam) + if (wcslen(str) >= wParam) { ::MessageBox(_hSelf, "Allocated buffer size is not enough to copy the string.", "NPPM_GETNPPDIRECTORY error", MB_OK); return FALSE; } } - strcpy((char *)lParam, str); + wcscpy((wchar_t *)lParam, str); return TRUE; } @@ -6657,7 +6765,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa activateNextDoc((GET_APPCOMMAND_LPARAM(lParam) == APPCOMMAND_BROWSER_FORWARD)?dirDown:dirUp); _linkTriggered = true; } - return ::DefWindowProc(hwnd, Message, wParam, lParam); + return ::DefWindowProcW(hwnd, Message, wParam, lParam); } case NPPM_GETNBSESSIONFILES : @@ -7131,7 +7239,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } } - return ::DefWindowProc(hwnd, Message, wParam, lParam); + return ::DefWindowProcW(hwnd, Message, wParam, lParam); } case WM_NOTIFY: @@ -7302,7 +7410,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _sysMenuEntering = true; } - return ::DefWindowProc(hwnd, Message, wParam, lParam); + return ::DefWindowProcW(hwnd, Message, wParam, lParam); } case WM_LBUTTONDBLCLK: @@ -7600,7 +7708,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return TRUE; } - return ::DefWindowProc(hwnd, Message, wParam, lParam); + return ::DefWindowProcW(hwnd, Message, wParam, lParam); } } @@ -7627,7 +7735,7 @@ LRESULT CALLBACK Notepad_plus::Notepad_plus_Proc(HWND hwnd, UINT Message, WPARAM default : { - return ((Notepad_plus *)::GetWindowLongPtr(hwnd, GWL_USERDATA))->runProc(hwnd, Message, wParam, lParam); + return ((Notepad_plus *)::GetWindowLongPtrW(hwnd, GWL_USERDATA))->runProc(hwnd, Message, wParam, lParam); } } } @@ -7830,7 +7938,7 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session) { BufferID bufID = _mainDocTab.getBufferByIndex(i); Buffer * buf = MainFileManager->getBufferByID(bufID); - if (!buf->isUntitled() && PathFileExists(buf->getFilePath())) + if (!buf->isUntitled() && PathFileExistsW(buf->getFilePathW())) { string languageName = getLangFromMenu( buf ); const char *langName = languageName.c_str(); @@ -7855,7 +7963,7 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session) { BufferID bufID = _subDocTab.getBufferByIndex(i); Buffer * buf = MainFileManager->getBufferByID(bufID); - if (!buf->isUntitled() && PathFileExists(buf->getFilePath())) + if (!buf->isUntitled() && PathFileExistsW(buf->getFilePathW())) { string languageName = getLangFromMenu( buf ); const char *langName = languageName.c_str(); @@ -7906,7 +8014,9 @@ bool Notepad_plus::fileLoadSession(const char *fn) } else { - if (PathFileExists(fn)) + wchar_t fnW[MAX_PATH]; + char2wchar(fn, fnW); + if (PathFileExistsW(fnW)) sessionFileName = fn; } @@ -7934,7 +8044,6 @@ const char * Notepad_plus::fileSaveSession(size_t nbFile, char ** fileNames, con Session currentSession; if ((nbFile) && (!fileNames)) { - for (size_t i = 0 ; i < nbFile ; i++) { if (PathFileExists(fileNames[i])) @@ -8001,6 +8110,37 @@ bool Notepad_plus::str2Cliboard(const char *str2cpy) return true; } +bool Notepad_plus::str2CliboardW(const wchar_t *str2cpy) +{ + if (!str2cpy) + return false; + + if (!::OpenClipboard(_hSelf)) + return false; + + ::EmptyClipboard(); + + int size = sizeof(wchar_t); + HGLOBAL hglbCopy = ::GlobalAlloc(GMEM_MOVEABLE, wcslen(str2cpy) * size + size); + + if (hglbCopy == NULL) + { + ::CloseClipboard(); + return false; + } + + // Lock the handle and copy the text to the buffer. + wchar_t *pStr = (wchar_t *)::GlobalLock(hglbCopy); + wcscpy(pStr, str2cpy); + ::GlobalUnlock(hglbCopy); + + // Place the handle on the clipboard. + ::SetClipboardData(CF_UNICODETEXT, hglbCopy); + ::CloseClipboard(); + return true; +} + + //ONLY CALL IN CASE OF EMERGENCY: EXCEPTION //This function is destructive bool Notepad_plus::emergency() { @@ -8153,9 +8293,9 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask) { if (mask & (BufferChangeDirty|BufferChangeFilename)) { checkDocState(); setTitle(); - char dir[MAX_PATH]; - strcpy(dir, buffer->getFilePath()); - PathRemoveFileSpec(dir); + wchar_t dir[MAX_PATH]; + wcscpy(dir, buffer->getFilePathW()); + PathRemoveFileSpecW(dir); setWorkingDir(dir); } if (mask & (BufferChangeLanguage)) { @@ -8198,9 +8338,9 @@ void Notepad_plus::notifyBufferActivated(BufferID bufid, int view) { setUniModeText(buf->getUnicodeMode()); setDisplayFormat(buf->getFormat()); enableConvertMenuItems(buf->getFormat()); - char dir[MAX_PATH]; - strcpy(dir, buf->getFilePath()); - PathRemoveFileSpec(dir); + wchar_t dir[MAX_PATH]; + wcscpy(dir, buf->getFilePathW()); + PathRemoveFileSpecW(dir); setWorkingDir(dir); setTitle(); //Make sure the colors of the tab controls match @@ -8210,12 +8350,12 @@ void Notepad_plus::notifyBufferActivated(BufferID bufid, int view) { _linkTriggered = true; } -void Notepad_plus::loadCommandlineParams(const char * commandLine, CmdLineParams * pCmdParams) { +void Notepad_plus::loadCommandlineParams(const wchar_t * commandLine, CmdLineParams * pCmdParams) { if (!commandLine || ! pCmdParams) return; FileNameStringSplitter fnss(commandLine); - const char *pFn = NULL; + const wchar_t *pFn = NULL; LangType lt = pCmdParams->_langType;//LangType(pCopyData->dwData & LASTBYTEMASK); int ln = pCmdParams->_line2go; @@ -8225,7 +8365,9 @@ void Notepad_plus::loadCommandlineParams(const char * commandLine, CmdLineParams for (int i = 0 ; i < fnss.size() ; i++) { pFn = fnss.getFileName(i); - BufferID bufID = doOpen(pFn, readOnly); + char fn[MAX_PATH]; + wchar2char(pFn, fn); + BufferID bufID = doOpen(fn, readOnly); if (bufID == BUFFER_INVALID) //cannot open file continue; diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 63adf06bd..00c9997cf 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -49,8 +49,11 @@ #include "AutoCompletion.h" #include "Buffer.h" #include "SmartHighlighter.h" +#include "UniConversion.h" +#include "UrlHighlighter.h" #define NOTEPAD_PP_CLASS_NAME "Notepad++" +#define NOTEPAD_PP_CLASS_NAME_W L"Notepad++" #define MENU 0x01 #define TOOLBAR 0x02 @@ -95,7 +98,7 @@ class Notepad_plus : public Window { public: Notepad_plus(); virtual inline ~Notepad_plus(); - void init(HINSTANCE, HWND, const char *cmdLine, CmdLineParams *cmdLineParams); + void init(HINSTANCE, HWND, const wchar_t *cmdLine, CmdLineParams *cmdLineParams); inline void killAllChildren(); virtual inline void destroy(); @@ -113,6 +116,7 @@ public: if (unicodeSupported?(::IsDialogMessageW(_hModelessDlgs[i], msg)):(::IsDialogMessageA(_hModelessDlgs[i], msg))) return true; } + return false; }; @@ -190,7 +194,9 @@ public: void notifyBufferChanged(Buffer * buffer, int mask); private: + void loadCommandlineParams(const wchar_t * commandLine, CmdLineParams * pCmdParams); static const char _className[32]; + static const wchar_t _classNameW[32]; char _nppPath[MAX_PATH]; Window *_pMainWindow; DockingManager _dockingManager; @@ -199,6 +205,7 @@ private: AutoCompletion _autoCompleteSub; //each Scintilla has its own autoComplete SmartHighlighter _smartHighlighter; + UrlHighlighter _urlHighlighter; TiXmlNode *_nativeLang, *_toolIcons; @@ -386,36 +393,44 @@ private: //END: Document management int doSaveOrNot(const char *fn) { - char pattern[64] = "Save file \"%s\" ?"; - char phrase[512]; - sprintf(phrase, pattern, fn); - return doActionOrNot("Save", phrase, MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL); + wchar_t fnW[MAX_PATH]; + char2wchar(fn, fnW); + wchar_t pattern[64] = L"Save file \"%s\" ?"; + wchar_t phrase[512]; + swprintf(phrase, pattern, fnW); + return doActionOrNot(L"Save", phrase, MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL); }; - int doReloadOrNot(const char *fn) { - char pattern[128] = "The file \"%s\" is modified by another program.\rReload this file?"; - char phrase[512]; - sprintf(phrase, pattern, fn); - return doActionOrNot("Reload", phrase, MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL); + wchar_t fnW[MAX_PATH]; + char2wchar(fn, fnW); + wchar_t pattern[128] = L"The file \"%s\" is modified by another program.\rReload this file?"; + wchar_t phrase[512]; + swprintf(phrase, pattern, fnW); + return doActionOrNot(L"Reload", phrase, MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL); }; int doCloseOrNot(const char *fn) { - char pattern[128] = "The file \"%s\" doesn't exist anymore.\rKeep this file in editor?"; - char phrase[512]; - sprintf(phrase, pattern, fn); - return doActionOrNot("Keep non existing file", phrase, MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL); + wchar_t fnW[MAX_PATH]; + char2wchar(fn, fnW); + wchar_t pattern[128] = L"The file \"%s\" doesn't exist anymore.\rKeep this file in editor?"; + wchar_t phrase[512]; + swprintf(phrase, pattern, fnW); + return doActionOrNot(L"Keep non existing file", phrase, MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL); }; int doDeleteOrNot(const char *fn) { - char pattern[128] = "The file \"%s\"\rwill be deleted from your disk and this document will be closed.\rContinue?"; - char phrase[512]; - sprintf(phrase, pattern, fn); - return doActionOrNot("Delete file", phrase, MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL); + wchar_t fnW[MAX_PATH]; + char2wchar(fn, fnW); + wchar_t pattern[128] = L"The file \"%s\"\rwill be deleted from your disk and this document will be closed.\rContinue?"; + wchar_t phrase[512]; + swprintf(phrase, pattern, fnW); + return doActionOrNot(L"Delete file", phrase, MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL); }; - int doActionOrNot(const char *title, const char *displayText, int type) { - return ::MessageBox(_hSelf, displayText, title, type); + int doActionOrNot(const wchar_t *title, const wchar_t *displayText, int type) { + return ::MessageBoxW(_hSelf, displayText, title, type); }; + void enableMenu(int cmdID, bool doEnable) const { int flag = doEnable?MF_ENABLED | MF_BYCOMMAND:MF_DISABLED | MF_GRAYED | MF_BYCOMMAND; ::EnableMenuItem(_mainMenuHandle, cmdID, flag); @@ -685,25 +700,26 @@ private: void getMatchedFileNames(const char *dir, const vector & patterns, vector & fileNames, bool isRecursive, bool isInHiddenDir); void doSynScorll(HWND hW); - void setWorkingDir(char *dir) { + void setWorkingDir(wchar_t *dir) { if (NppParameters::getInstance()->getNppGUI()._saveOpenKeepInSameDir) return; - if (!dir || !PathIsDirectory(dir)) + if (!dir || !PathIsDirectoryW(dir)) { //Non existing path, usually occurs when a new 1 file is open. //Set working dir to Notepad++' directory to prevent directory lock. - char nppDir[MAX_PATH]; + wchar_t nppDir[MAX_PATH]; //wParam set to max_path in case boundary checks will ever be made. - SendMessage(_hSelf, NPPM_GETNPPDIRECTORY, (WPARAM)MAX_PATH, (LPARAM)nppDir); - ::SetCurrentDirectory(nppDir); + ::SendMessage(_hSelf, NPPM_GETNPPDIRECTORY, (WPARAM)MAX_PATH, (LPARAM)nppDir); + ::SetCurrentDirectoryW(nppDir); return; } else - ::SetCurrentDirectory(dir); + ::SetCurrentDirectoryW(dir); } bool str2Cliboard(const char *str2cpy); + bool str2CliboardW(const wchar_t *str2cpy); bool bin2Cliboard(const unsigned char *uchar2cpy, size_t length); bool getIntegralDockingData(tTbData & dockData, int & iCont, bool & isVisible); @@ -771,8 +787,6 @@ private: bool dumpFiles(const char * outdir, const char * fileprefix = ""); //helper func void drawTabbarColoursFromStylerArray(); - - void loadCommandlineParams(const char * commandLine, CmdLineParams * pCmdParams); }; #endif //NOTEPAD_PLUS_H diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index a62602e69..1df0a031d 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -9,6 +9,7 @@ #include "Notepad_plus.h" #include "ScintillaEditView.h" +#include "UniConversion.h" FileManager * FileManager::_pSelf = new FileManager(); @@ -82,7 +83,7 @@ long Buffer::_recentTagCtr = 0; void Buffer::updateTimeStamp() { struct _stat buf; - time_t timeStamp = (_stat(_fullPathName, &buf)==0)?buf.st_mtime:0; + time_t timeStamp = (_wstat(_fullPathNameW, &buf)==0)?buf.st_mtime:0; if (timeStamp != _timeStamp) { _timeStamp = timeStamp; @@ -102,6 +103,8 @@ void Buffer::setFileName(const char *fn, LangType defaultLang) return; } strcpy(_fullPathName, fn); + char2wchar(_fullPathName, _fullPathNameW); + _fileNameW = PathFindFileNameW(_fullPathNameW); _fileName = PathFindFileName(_fullPathName); // for _lang @@ -148,19 +151,19 @@ bool Buffer::checkFileState() { //returns true if the status has been changed (i if (_currentStatus == DOC_UNNAMED) //unsaved document cannot change by environment return false; - if (_currentStatus != DOC_DELETED && !PathFileExists(_fullPathName)) //document has been deleted + if (_currentStatus != DOC_DELETED && !PathFileExistsW(_fullPathNameW)) //document has been deleted { _currentStatus = DOC_DELETED; _isFileReadOnly = false; - _isDirty = true; //dirty sicne no match with filesystem + _isDirty = true; //dirty since no match with filesystem _timeStamp = 0; doNotify(BufferChangeStatus | BufferChangeReadonly | BufferChangeTimestamp); return true; } - if (_currentStatus == DOC_DELETED && PathFileExists(_fullPathName)) + if (_currentStatus == DOC_DELETED && PathFileExistsW(_fullPathNameW)) { //document has returned from its grave - if (!_stat(_fullPathName, &buf)) + if (!_wstat(_fullPathNameW, &buf)) { _isFileReadOnly = (bool)(!(buf.st_mode & _S_IWRITE)); @@ -171,7 +174,7 @@ bool Buffer::checkFileState() { //returns true if the status has been changed (i } } - if (!_stat(_fullPathName, &buf)) + if (!_wstat(_fullPathNameW, &buf)) { int mask = 0; //status always 'changes', even if from modified to modified bool isFileReadOnly = (bool)(!(buf.st_mode & _S_IWRITE)); @@ -443,20 +446,22 @@ bool FileManager::reloadBufferDeferred(BufferID id) { bool FileManager::deleteFile(BufferID id) { Buffer * buf = getBufferByID(id); - const char *fileNamePath = buf->getFilePath(); - if (!PathFileExists(fileNamePath)) + const wchar_t *fileNamePath = buf->getFilePathW(); + if (!PathFileExistsW(fileNamePath)) return false; - return ::DeleteFile(fileNamePath) != 0; + return ::DeleteFileW(fileNamePath) != 0; } bool FileManager::moveFile(BufferID id, const char * newFileName) { Buffer * buf = getBufferByID(id); - const char *fileNamePath = buf->getFilePath(); - if (!PathFileExists(fileNamePath)) + const wchar_t *fileNamePath = buf->getFilePathW(); + if (!PathFileExistsW(fileNamePath)) return false; - if (::MoveFile(fileNamePath, newFileName) == 0) + wchar_t newFileNameW[MAX_PATH]; + char2wchar(newFileName, newFileNameW); + if (::MoveFileW(fileNamePath, newFileNameW) == 0) return false; buf->setFileName(newFileName); @@ -472,19 +477,21 @@ bool FileManager::saveBuffer(BufferID id, const char * filename, bool isCopy) { char fullpath[MAX_PATH]; ::GetFullPathName(filename, MAX_PATH, fullpath, NULL); ::GetLongPathName(fullpath, fullpath, MAX_PATH); - if (PathFileExists(fullpath)) + wchar_t fullpathW[MAX_PATH]; + char2wchar(fullpath, fullpathW); + if (PathFileExistsW(fullpathW)) { - attrib = ::GetFileAttributes(fullpath); + attrib = ::GetFileAttributesW(fullpathW); if (attrib != INVALID_FILE_ATTRIBUTES) { isHidden = (attrib & FILE_ATTRIBUTE_HIDDEN) != 0; if (isHidden) - ::SetFileAttributes(filename, attrib & ~FILE_ATTRIBUTE_HIDDEN); + ::SetFileAttributesW(fullpathW, attrib & ~FILE_ATTRIBUTE_HIDDEN); isSys = (attrib & FILE_ATTRIBUTE_SYSTEM) != 0; if (isSys) - ::SetFileAttributes(filename, attrib & ~FILE_ATTRIBUTE_SYSTEM); + ::SetFileAttributesW(fullpathW, attrib & ~FILE_ATTRIBUTE_SYSTEM); } } @@ -495,11 +502,12 @@ bool FileManager::saveBuffer(BufferID id, const char * filename, bool isCopy) { Utf8_16_Write UnicodeConvertor; UnicodeConvertor.setEncoding(mode); - FILE *fp = UnicodeConvertor.fopen(fullpath, "wb"); + FILE *fp = UnicodeConvertor.fopenW(fullpathW, L"wb"); if (fp) { _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, buffer->_doc); //generate new document + char data[blockSize + 1]; int lengthDoc = _pscratchTilla->getCurrentDocLen(); for (int i = 0; i < lengthDoc; i += blockSize) @@ -514,10 +522,10 @@ bool FileManager::saveBuffer(BufferID id, const char * filename, bool isCopy) { UnicodeConvertor.fclose(); if (isHidden) - ::SetFileAttributes(fullpath, attrib | FILE_ATTRIBUTE_HIDDEN); + ::SetFileAttributesW(fullpathW, attrib | FILE_ATTRIBUTE_HIDDEN); if (isSys) - ::SetFileAttributes(fullpath, attrib | FILE_ATTRIBUTE_SYSTEM); + ::SetFileAttributesW(fullpathW, attrib | FILE_ATTRIBUTE_SYSTEM); if (isCopy) { _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault); @@ -571,17 +579,20 @@ bool FileManager::loadFileData(Document doc, const char * filename, Utf8_16_Read const int blockSize = 128 * 1024; //128 kB char data[blockSize]; - __try { - FILE *fp = fopen(filename, "rb"); + WCHAR filenameW[MAX_PATH]; + char2wchar(filename, filenameW); + + FILE *fp = _wfopen(filenameW, L"rb"); if (!fp) return false; + __try { //Setup scratchtilla for new filedata _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, doc); bool ro = _pscratchTilla->execute(SCI_GETREADONLY) != 0; - if (ro) { + if (ro) { _pscratchTilla->execute(SCI_SETREADONLY, false); - } + } _pscratchTilla->execute(SCI_CLEARALL); if (language < L_EXTERNAL) { _pscratchTilla->execute(SCI_SETLEXER, ScintillaEditView::langNames[language].lexerID); @@ -610,6 +621,7 @@ bool FileManager::loadFileData(Document doc, const char * filename, Utf8_16_Read return true; }__except(filter(GetExceptionCode(), GetExceptionInformation())) { + printStr("File is too big to be opened by Notepad++"); return false; } @@ -634,7 +646,10 @@ BufferID FileManager::getBufferFromDocument(Document doc) { } bool FileManager::createEmptyFile(const char * path) { - FILE * file = fopen(path, "wb"); + WCHAR pathW[MAX_PATH]; + char2wchar(path, pathW); + + FILE * file = _wfopen(pathW, L"wb"); if (!file) return false; fclose(file); diff --git a/PowerEditor/src/ScitillaComponent/Buffer.h b/PowerEditor/src/ScitillaComponent/Buffer.h index 3dd3104c0..2df48bdbd 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.h +++ b/PowerEditor/src/ScitillaComponent/Buffer.h @@ -163,8 +163,12 @@ public : const char * getFilePath() const { return _fullPathName; }; + const wchar_t * getFilePathW() const { + return _fullPathNameW; + }; const char * getFileName() const { return _fileName; }; + const wchar_t * getFileNameW() const { return _fileNameW; }; BufferID getID() const { return _id; @@ -248,6 +252,10 @@ public : return _currentStatus; }; + time_t getTimeStamp() const { + return _timeStamp; + }; + Document getDocument() { return _doc; }; @@ -319,6 +327,13 @@ public : void setNeedReload(bool reload) { _needReloading = reload; } + + vector < pair > & getClickableStyles() { + return _clickableStyles; + }; + + + private : FileManager * _pManager; bool _canNotify; @@ -345,11 +360,14 @@ private : time_t _timeStamp; // 0 if it's a new doc bool _isFileReadOnly; char _fullPathName[MAX_PATH]; + wchar_t _fullPathNameW[MAX_PATH]; char * _fileName; //points to filename part in _fullPathName + wchar_t * _fileNameW; bool _needReloading; //True if Buffer needs to be reloaded on activation long _recentTag; static long _recentTagCtr; + vector < pair > _clickableStyles; void updateTimeStamp(); Lang * getCurrentLang() const; diff --git a/PowerEditor/src/ScitillaComponent/DocTabView.cpp b/PowerEditor/src/ScitillaComponent/DocTabView.cpp index 2d07c4507..ab01c1f73 100644 --- a/PowerEditor/src/ScitillaComponent/DocTabView.cpp +++ b/PowerEditor/src/ScitillaComponent/DocTabView.cpp @@ -23,6 +23,7 @@ #include #include +#include "UniConversion.h" bool DocTabView::_hideTabBarStatus = false; @@ -32,16 +33,18 @@ void DocTabView::addBuffer(BufferID buffer) { if (this->getIndexByBuffer(buffer) != -1) //no duplicates return; Buffer * buf = MainFileManager->getBufferByID(buffer); - TCITEM tie; + TCITEMW tie; tie.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; int index = -1; if (_hasImgLst) index = 0; tie.iImage = index; - tie.pszText = (LPSTR)buf->getFileName(); + tie.pszText = (LPWSTR)buf->getFileNameW(); + tie.cchTextMax = lstrlenW(tie.pszText); tie.lParam = (LPARAM)buffer; - ::SendMessage(_hSelf, TCM_INSERTITEM, _nbItem++, reinterpret_cast(&tie)); + + ::SendMessage(_hSelf, TCM_INSERTITEMW, _nbItem++, reinterpret_cast(&tie)); bufferUpdated(buf, BufferChangeMask); ::SendMessage(_hParent, WM_SIZE, 0, 0); @@ -108,7 +111,7 @@ void DocTabView::bufferUpdated(Buffer * buffer, int mask) { if (index == -1) return; - TCITEM tie; + TCITEMW tie; tie.lParam = -1; tie.mask = 0; @@ -123,10 +126,10 @@ void DocTabView::bufferUpdated(Buffer * buffer, int mask) { if (mask & BufferChangeFilename) { tie.mask |= TCIF_TEXT; - tie.pszText = (LPSTR)buffer->getFileName(); + tie.pszText = (LPWSTR)buffer->getFileNameW(); } - ::SendMessage(_hSelf, TCM_SETITEM, index, reinterpret_cast(&tie)); + ::SendMessage(_hSelf, TCM_SETITEMW, index, reinterpret_cast(&tie)); ::SendMessage(_hParent, WM_SIZE, 0, 0); } diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 7525dc2b2..ba02643c8 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -460,8 +460,11 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP doDialog((DIALOG_TYPE)indexClicked); if ((DIALOG_TYPE)indexClicked == FINDINFILES_DLG) { + wchar_t currentDirW[MAX_PATH]; + ::GetCurrentDirectoryW(MAX_PATH, currentDirW); char currentDir[MAX_PATH]; - ::GetCurrentDirectory(MAX_PATH, currentDir); + wchar2char(currentDirW, currentDir); + setFindInFilesDirFilter(currentDir, NULL); } } @@ -564,13 +567,17 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP if (_currentStatus == FINDINFILES_DLG) { char filters[256]; - char directory[MAX_PATH]; - ::GetDlgItemText(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filters, sizeof(filters)); - addText2Combo(filters, ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO)); + wchar_t filtersW[256]; + ::GetDlgItemTextW(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filtersW, sizeof(filtersW)); + wchar2char(filtersW, filters); + addText2Combo(filters, ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO), true); _filters = filters; - ::GetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, directory, sizeof(directory)); - addText2Combo(directory, ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO)); + char directory[MAX_PATH]; + wchar_t directoryW[MAX_PATH]; + ::GetDlgItemTextW(_hSelf, IDD_FINDINFILES_DIR_COMBO, directoryW, sizeof(directoryW)); + wchar2char(directoryW, directory); + addText2Combo(directory, ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO), true); _directory = directory; if ((strlen(directory) > 0) && (directory[strlen(directory)-1] != '\\')) @@ -877,13 +884,16 @@ bool FindReplaceDlg::processFindNext(const char *txt2find, FindOption *options) if (!pOptions->_isIncremental) { //incremental search doesnt trigger messages const char stringMaxSize = 64; char message[30 + stringMaxSize + 4]; //message, string, dots + wchar_t messageW[30 + stringMaxSize + 4]; //message, string, dots strcpy(message, "Can't find the text:\r\n\""); strncat(message, pText, stringMaxSize); strcat(message, "\""); if (strlen(pText) > stringMaxSize) { strcat(message, "..."); } - ::MessageBox(_hSelf, message, "Find", MB_OK); + + char2wchar(message, messageW); + ::MessageBoxW(_hSelf, messageW, L"Find", MB_OK); // if the dialog is not shown, pass the focus to his parent(ie. Notepad++) if (!::IsWindowVisible(_hSelf)) ::SetFocus((*_ppEditView)->getHSelf()); diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h index ca7f9291b..d2c9498f0 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h @@ -24,6 +24,7 @@ #include "ScintillaEditView.h" #include "StatusBar.h" #include "DockingDlgInterface.h" +#include "UniConversion.h" #define FIND_RECURSIVE 1 @@ -295,12 +296,18 @@ public : if (dir) { _directory = dir; - ::SetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, dir); + + wchar_t dirW[MAX_PATH]; + char2wchar(dir, dirW); + ::SetDlgItemTextW(_hSelf, IDD_FINDINFILES_DIR_COMBO, dirW); } if (filters) { _filters = filters; - ::SetDlgItemText(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filters); + + wchar_t filtersW[MAX_PATH]; + char2wchar(filters, filtersW); + ::SetDlgItemTextW(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filtersW); } }; diff --git a/PowerEditor/src/ScitillaComponent/Printer.cpp b/PowerEditor/src/ScitillaComponent/Printer.cpp index 2de3bf2a7..79a2cbf73 100644 --- a/PowerEditor/src/ScitillaComponent/Printer.cpp +++ b/PowerEditor/src/ScitillaComponent/Printer.cpp @@ -14,10 +14,10 @@ //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 "Printer.h" +#include "UniConversion.h" -void replaceStr(string & str, string str2BeReplaced, string replacement) +void replaceStr(wstring & str, wstring str2BeReplaced, wstring replacement) { size_t pos = str.find(str2BeReplaced); @@ -127,61 +127,65 @@ size_t Printer::doPrint(bool justDoIt) // Convert page size to logical units and we're done! DPtoLP(_pdlg.hDC, &ptPage, 1); - TEXTMETRIC tm; + TEXTMETRICW tm; int fontSize = nppGUI._printSettings._headerFontSize?nppGUI._printSettings._headerFontSize:9; int fontWeight = nppGUI._printSettings._headerFontStyle & FONTSTYLE_BOLD?FW_BOLD:FW_NORMAL; int isFontItalic = nppGUI._printSettings._headerFontStyle & FONTSTYLE_ITALIC?TRUE:FALSE; const char *fontFace = (nppGUI._printSettings._headerFontName != "")?nppGUI._printSettings._headerFontName.c_str():"Arial"; + wchar_t fontFaceW[LF_FACESIZE]; + char2wchar(fontFace, fontFaceW); + int headerLineHeight = ::MulDiv(fontSize, ptDpi.y, 72); //char toto[10]; - //::MessageBox(NULL, itoa(nppGUI._printSettings._headerFontStyle, toto, 10), "header", MB_OK); + //::MessageBox(NULL, itoa(nppGUI._printSettings._headerFontStyle, toto, 10), L"header", MB_OK); - HFONT fontHeader = ::CreateFont(headerLineHeight, + HFONT fontHeader = ::CreateFontW(headerLineHeight, 0, 0, 0, fontWeight, isFontItalic, FALSE, 0, 0, 0, 0, 0, 0, - fontFace); + fontFaceW); ::SelectObject(_pdlg.hDC, fontHeader); - ::GetTextMetrics(_pdlg.hDC, &tm); + ::GetTextMetricsW(_pdlg.hDC, &tm); headerLineHeight = tm.tmHeight + tm.tmExternalLeading; fontSize = nppGUI._printSettings._footerFontSize?nppGUI._printSettings._footerFontSize:9; fontWeight = nppGUI._printSettings._footerFontStyle & FONTSTYLE_BOLD?FW_BOLD:FW_NORMAL; isFontItalic = nppGUI._printSettings._footerFontStyle & FONTSTYLE_ITALIC?TRUE:FALSE; fontFace = (nppGUI._printSettings._footerFontName != "")?nppGUI._printSettings._footerFontName.c_str():"Arial"; - //::MessageBox(NULL, itoa(nppGUI._printSettings._footerFontStyle, , 10), "footer", MB_OK); + //::MessageBox(NULL, itoa(nppGUI._printSettings._footerFontStyle, , 10), L"footer", MB_OK); + char2wchar(fontFace, fontFaceW); int footerLineHeight = ::MulDiv(fontSize, ptDpi.y, 72); - HFONT fontFooter = ::CreateFont(footerLineHeight, + HFONT fontFooter = ::CreateFontW(footerLineHeight, 0, 0, 0, fontWeight, isFontItalic, FALSE, 0, 0, 0, 0, 0, 0, - fontFace); + fontFaceW); ::SelectObject(_pdlg.hDC, fontFooter); - ::GetTextMetrics(_pdlg.hDC, &tm); + ::GetTextMetricsW(_pdlg.hDC, &tm); footerLineHeight = tm.tmHeight + tm.tmExternalLeading; - ::GetTextMetrics(_pdlg.hDC, &tm); + ::GetTextMetricsW(_pdlg.hDC, &tm); int printMarge = tm.tmHeight + tm.tmExternalLeading; printMarge = printMarge + printMarge / 2; - DOCINFO docInfo; + DOCINFOW docInfo; docInfo.cbSize = sizeof(DOCINFO); - docInfo.lpszDocName = _pSEView->getCurrentBuffer()->getFilePath(); + docInfo.lpszDocName = _pSEView->getCurrentBuffer()->getFilePathW(); docInfo.lpszOutput = NULL; - if (::StartDoc(_pdlg.hDC, &docInfo) < 0) + if (::StartDocW(_pdlg.hDC, &docInfo) < 0) { MessageBox(NULL, "Can not start printer document.", 0, MB_OK); return 0; @@ -230,34 +234,33 @@ size_t Printer::doPrint(bool justDoIt) frPrint.rc.left += printMarge; frPrint.rc.right -= printMarge; - char headerL[256] = ""; - char headerM[256] = ""; - char headerR[256] = ""; - char footerL[256] = ""; - char footerM[256] = ""; - char footerR[256] = ""; + wchar_t headerL[256] = L""; + wchar_t headerM[256] = L""; + wchar_t headerR[256] = L""; + wchar_t footerL[256] = L""; + wchar_t footerM[256] = L""; + wchar_t footerR[256] = L""; + const wchar_t shortDateVar[] = L"$(SHORT_DATE)"; + const wchar_t longDateVar[] = L"$(LONG_DATE)"; + const wchar_t timeVar[] = L"$(TIME)"; - const char shortDateVar[] = "$(SHORT_DATE)"; - const char longDateVar[] = "$(LONG_DATE)"; - const char timeVar[] = "$(TIME)"; - - char shortDate[64]; - char longDate[64]; - char time[64]; + wchar_t shortDate[64]; + wchar_t longDate[64]; + wchar_t time[64]; SYSTEMTIME st; ::GetLocalTime(&st); - ::GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, shortDate, sizeof(shortDate)); - ::GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, longDate, sizeof(longDate)); - ::GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, time, sizeof(time)); + ::GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, shortDate, sizeof(shortDate)); + ::GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, longDate, sizeof(longDate)); + ::GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, time, sizeof(time)); if (nppGUI._printSettings.isHeaderPresent()) { frPrint.rc.top += headerLineHeight + headerLineHeight / 2; - string headerLeftPart = nppGUI._printSettings._headerLeft; - if (headerLeftPart != "") + wstring headerLeftPart = string2wstring(nppGUI._printSettings._headerLeft); + if (headerLeftPart != L"") { replaceStr(headerLeftPart, shortDateVar, shortDate); replaceStr(headerLeftPart, longDateVar, longDate); @@ -265,8 +268,8 @@ size_t Printer::doPrint(bool justDoIt) expandNppEnvironmentStrs(headerLeftPart.c_str(), headerL, sizeof(headerL), _pdlg.hwndOwner); } - string headerMiddlePart = nppGUI._printSettings._headerMiddle; - if (headerMiddlePart != "") + wstring headerMiddlePart = string2wstring(nppGUI._printSettings._headerMiddle); + if (headerMiddlePart != L"") { replaceStr(headerMiddlePart, shortDateVar, shortDate); replaceStr(headerMiddlePart, longDateVar, longDate); @@ -274,8 +277,8 @@ size_t Printer::doPrint(bool justDoIt) expandNppEnvironmentStrs(headerMiddlePart.c_str(), headerM, sizeof(headerM), _pdlg.hwndOwner); } - string headerRightPart = nppGUI._printSettings._headerRight; - if (headerRightPart != "") + wstring headerRightPart = string2wstring(nppGUI._printSettings._headerRight); + if (headerRightPart != L"") { replaceStr(headerRightPart, shortDateVar, shortDate); replaceStr(headerRightPart, longDateVar, longDate); @@ -289,8 +292,8 @@ size_t Printer::doPrint(bool justDoIt) { frPrint.rc.bottom -= footerLineHeight + footerLineHeight / 2; - string footerLeftPart = nppGUI._printSettings._footerLeft; - if (footerLeftPart != "") + wstring footerLeftPart = string2wstring(nppGUI._printSettings._footerLeft); + if (footerLeftPart != L"") { replaceStr(footerLeftPart, shortDateVar, shortDate); replaceStr(footerLeftPart, longDateVar, longDate); @@ -298,8 +301,8 @@ size_t Printer::doPrint(bool justDoIt) expandNppEnvironmentStrs(footerLeftPart.c_str(), footerL, sizeof(footerL), _pdlg.hwndOwner); } - string footerMiddlePart = nppGUI._printSettings._footerMiddle; - if (footerMiddlePart != "") + wstring footerMiddlePart = string2wstring(nppGUI._printSettings._footerMiddle); + if (footerMiddlePart != L"") { replaceStr(footerMiddlePart, shortDateVar, shortDate); replaceStr(footerMiddlePart, longDateVar, longDate); @@ -307,8 +310,8 @@ size_t Printer::doPrint(bool justDoIt) expandNppEnvironmentStrs(footerMiddlePart.c_str(), footerM, sizeof(footerM), _pdlg.hwndOwner); } - string footerRightPart = nppGUI._printSettings._footerRight; - if (footerRightPart != "") + wstring footerRightPart = string2wstring(nppGUI._printSettings._footerRight); + if (footerRightPart != L"") { replaceStr(footerRightPart, shortDateVar, shortDate); replaceStr(footerRightPart, longDateVar, longDate); @@ -324,7 +327,7 @@ size_t Printer::doPrint(bool justDoIt) size_t pageNum = 1; bool printPage; - const char pageVar[] = "$(CURRENT_PRINTING_PAGE)"; + const wchar_t pageVar[] = L"$(CURRENT_PRINTING_PAGE)"; while (lengthPrinted < lengthDoc) { @@ -334,8 +337,8 @@ size_t Printer::doPrint(bool justDoIt) if (!justDoIt) printPage = false; - char pageString[32]; - sprintf(pageString, "%0d", pageNum); + wchar_t pageString[32]; + wsprintfW(pageString, L"%0d", pageNum); if (printPage) { @@ -359,38 +362,38 @@ size_t Printer::doPrint(bool justDoIt) // Left part if (headerL[0] != '\0') { - string headerLeft(headerL); + wstring headerLeft(headerL); size_t pos = headerLeft.find(pageVar); if (pos != headerLeft.npos) - headerLeft.replace(pos, strlen(pageVar), pageString); + headerLeft.replace(pos, wcslen(pageVar), pageString); - ::ExtTextOut(_pdlg.hDC, frPrint.rc.left + 5, frPrint.rc.top - headerLineHeight / 2, + ::ExtTextOutW(_pdlg.hDC, frPrint.rc.left + 5, frPrint.rc.top - headerLineHeight / 2, ETO_OPAQUE, &rcw, headerLeft.c_str(), static_cast(headerLeft.length()), NULL); } // Middle part if (headerM != '\0') { - string headerMiddle(headerM); + wstring headerMiddle(headerM); size_t pos = headerMiddle.find(pageVar); if (pos != headerMiddle.npos) - headerMiddle.replace(pos, strlen(pageVar), pageString); + headerMiddle.replace(pos, wcslen(pageVar), pageString); - ::GetTextExtentPoint32(_pdlg.hDC, headerMiddle.c_str(), static_cast(headerMiddle.length()), &size); - ::ExtTextOut(_pdlg.hDC, ((frPrint.rc.right - frPrint.rc.left)/2 + frPrint.rc.left) - (size.cx/2), frPrint.rc.top - headerLineHeight / 2, + ::GetTextExtentPoint32W(_pdlg.hDC, headerMiddle.c_str(), static_cast(headerMiddle.length()), &size); + ::ExtTextOutW(_pdlg.hDC, ((frPrint.rc.right - frPrint.rc.left)/2 + frPrint.rc.left) - (size.cx/2), frPrint.rc.top - headerLineHeight / 2, ETO_CLIPPED, &rcw, headerMiddle.c_str(), static_cast(headerMiddle.length()), NULL); } // Right part if (headerR != '\0') { - string headerRight(headerR); + wstring headerRight(headerR); size_t pos = headerRight.find(pageVar); if (pos != headerRight.npos) - headerRight.replace(pos, strlen(pageVar), pageString); + headerRight.replace(pos, wcslen(pageVar), pageString); - ::GetTextExtentPoint32(_pdlg.hDC, headerRight.c_str(), static_cast(headerRight.length()), &size); - ::ExtTextOut(_pdlg.hDC, frPrint.rc.right - size.cx, frPrint.rc.top - headerLineHeight / 2, + ::GetTextExtentPoint32W(_pdlg.hDC, headerRight.c_str(), static_cast(headerRight.length()), &size); + ::ExtTextOutW(_pdlg.hDC, frPrint.rc.right - size.cx, frPrint.rc.top - headerLineHeight / 2, ETO_CLIPPED, &rcw, headerRight.c_str(), static_cast(headerRight.length()), NULL); } @@ -427,36 +430,37 @@ size_t Printer::doPrint(bool justDoIt) // Left part if (footerL[0] != '\0') { - string footerLeft(footerL); + wstring footerLeft(footerL); size_t pos = footerLeft.find(pageVar); if (pos != footerLeft.npos) - footerLeft.replace(pos, strlen(pageVar), pageString); + footerLeft.replace(pos, wcslen(pageVar), pageString); - ::ExtTextOut(_pdlg.hDC, frPrint.rc.left + 5, frPrint.rc.bottom + footerLineHeight / 2, + ::ExtTextOutW(_pdlg.hDC, frPrint.rc.left + 5, frPrint.rc.bottom + footerLineHeight / 2, ETO_OPAQUE, &rcw, footerLeft.c_str(), static_cast(footerLeft.length()), NULL); } // Middle part if (footerM[0] != '\0') { - string footerMiddle(footerM); + wstring footerMiddle(footerM); size_t pos = footerMiddle.find(pageVar); if (pos != footerMiddle.npos) - footerMiddle.replace(pos, strlen(pageVar), pageString); + footerMiddle.replace(pos, wcslen(pageVar), pageString); - ::GetTextExtentPoint32(_pdlg.hDC, footerMiddle.c_str(), static_cast(footerMiddle.length()), &size); - ::ExtTextOut(_pdlg.hDC, ((frPrint.rc.right - frPrint.rc.left)/2 + frPrint.rc.left) - (size.cx/2), frPrint.rc.bottom + footerLineHeight / 2, + ::GetTextExtentPoint32W(_pdlg.hDC, footerMiddle.c_str(), static_cast(footerMiddle.length()), &size); + ::ExtTextOutW(_pdlg.hDC, ((frPrint.rc.right - frPrint.rc.left)/2 + frPrint.rc.left) - (size.cx/2), frPrint.rc.bottom + footerLineHeight / 2, ETO_CLIPPED, &rcw, footerMiddle.c_str(), static_cast(footerMiddle.length()), NULL); } // Right part if (footerR[0] != '\0') { - string footerRight(footerR); + wstring footerRight(footerR); size_t pos = footerRight.find(pageVar); if (pos != footerRight.npos) - footerRight.replace(pos, strlen(pageVar), pageString); - ::GetTextExtentPoint32(_pdlg.hDC, footerRight.c_str(), static_cast(footerRight.length()), &size); - ::ExtTextOut(_pdlg.hDC, frPrint.rc.right - size.cx, frPrint.rc.bottom + footerLineHeight / 2, + footerRight.replace(pos, wcslen(pageVar), pageString); + + ::GetTextExtentPoint32W(_pdlg.hDC, footerRight.c_str(), static_cast(footerRight.length()), &size); + ::ExtTextOutW(_pdlg.hDC, frPrint.rc.right - size.cx, frPrint.rc.bottom + footerLineHeight / 2, ETO_CLIPPED, &rcw, footerRight.c_str(), static_cast(footerRight.length()), NULL); } diff --git a/PowerEditor/src/ScitillaComponent/Printer.h b/PowerEditor/src/ScitillaComponent/Printer.h index 461fedca1..72751a665 100644 --- a/PowerEditor/src/ScitillaComponent/Printer.h +++ b/PowerEditor/src/ScitillaComponent/Printer.h @@ -37,7 +37,7 @@ public : Printer(){}; void init(HINSTANCE hInst, HWND hwnd, ScintillaEditView *pSEView, bool showDialog, int startPos, int endPos); size_t Printer::doPrint() { - if (!::PrintDlg(&_pdlg)) + if (!::PrintDlgW(&_pdlg)) return 0; return doPrint(true); @@ -45,7 +45,7 @@ public : size_t doPrint(bool justDoIt); private : - PRINTDLG _pdlg; + PRINTDLGW _pdlg; ScintillaEditView *_pSEView; size_t _startPos; size_t _endPos; diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index 0d5469dc6..0351c1273 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -187,6 +187,11 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere) execute(SCI_INDICSETUNDER, SCE_UNIVERSAL_TAGMATCH, true); execute(SCI_INDICSETUNDER, SCE_UNIVERSAL_TAGATTR, true); + // URL highlighting + int activeFG = 0xFF0000; + execute(SCI_SETHOTSPOTACTIVEFORE, TRUE, activeFG); + execute(SCI_SETHOTSPOTSINGLELINE, FALSE); + _pParameter = NppParameters::getInstance(); _codepage = ::GetACP(); @@ -266,6 +271,47 @@ void ScintillaEditView::setSpecialIndicator(Style & styleToSet) execute(SCI_INDICSETFORE, styleToSet._styleID, styleToSet._bgColor); } +void ScintillaEditView::setHotspotStyle() +{ + vector< pair > clickableStyles = _currentBuffer->getClickableStyles(); + //printStr("getin"); + for (size_t i = 0 ; i < clickableStyles.size() ; i++) + { + + int styleID = clickableStyles[i].second; + + //if (execute(SCI_STYLEGETHOTSPOT, styleID) == FALSE) + { + Style styleToSet = clickableStyles[i].first; + //char toto[512]; + //sprintf(toto, start, end); + //writeLog("c:\npp.log", toto); + if ( styleToSet._colorStyle & COLORSTYLE_FOREGROUND ) + execute(SCI_STYLESETFORE, styleID, styleToSet._fgColor); + + if ( styleToSet._colorStyle & COLORSTYLE_BACKGROUND ) + execute(SCI_STYLESETBACK, styleID, styleToSet._bgColor); + + if ((!styleToSet._fontName)||(strcmp(styleToSet._fontName, ""))) + execute(SCI_STYLESETFONT, (WPARAM)styleID, (LPARAM)styleToSet._fontName); + + int fontStyle = styleToSet._fontStyle; + if (fontStyle != -1) + { + execute(SCI_STYLESETBOLD, (WPARAM)styleID, fontStyle & FONTSTYLE_BOLD); + execute(SCI_STYLESETITALIC, (WPARAM)styleID, fontStyle & FONTSTYLE_ITALIC); + execute(SCI_STYLESETUNDERLINE, (WPARAM)styleID, fontStyle & FONTSTYLE_UNDERLINE); + } + + if (styleToSet._fontSize > 0) + execute(SCI_STYLESETSIZE, styleID, styleToSet._fontSize); + + execute(SCI_STYLESETHOTSPOT, styleID, TRUE); + execute(SCI_SETHOTSPOTACTIVEFORE, TRUE, blue); + execute(SCI_SETHOTSPOTSINGLELINE, styleID, 0); + } + } +} void ScintillaEditView::setSpecialStyle(Style & styleToSet) { @@ -702,6 +748,7 @@ void ScintillaEditView::makeStyle(LangType language, const char **keywordArray) void ScintillaEditView::defineDocType(LangType typeDoc) { + //setHotspotStyle(); //setStyle(STYLE_DEFAULT, black, white, "Verdana", 0, 9); StyleArray & stylers = _pParameter->getMiscStylerArray(); int iStyleDefault = stylers.getStylerIndexByID(STYLE_DEFAULT); @@ -726,7 +773,6 @@ void ScintillaEditView::defineDocType(LangType typeDoc) if (iFind != -1) { Style & styleFind = stylers.getStyler(iFind); - //setSpecialStyle(styleFind); setSpecialIndicator(styleFind); } @@ -734,7 +780,6 @@ void ScintillaEditView::defineDocType(LangType typeDoc) if (iFind != -1) { Style & styleFind = stylers.getStyler(iFind); - //setSpecialStyle(styleFind); setSpecialIndicator(styleFind); } @@ -742,7 +787,6 @@ void ScintillaEditView::defineDocType(LangType typeDoc) if (iFind != -1) { Style & styleFind = stylers.getStyler(iFind); - //setSpecialStyle(styleFind); setSpecialIndicator(styleFind); } @@ -750,7 +794,6 @@ void ScintillaEditView::defineDocType(LangType typeDoc) if (iFind != -1) { Style & styleFind = stylers.getStyler(iFind); - //setSpecialStyle(styleFind); setSpecialIndicator(styleFind); } diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index 610332022..5f9c60ade 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -563,6 +563,7 @@ protected: inline void makeStyle(LangType langType, const char **keywordArray = NULL); void setStyle(Style styleToSet); //NOT by reference (style edited) void setSpecialStyle(Style & styleToSet); //by reference + void setHotspotStyle(); void setSpecialIndicator(Style & styleToSet); //Complex lexers (same lexer, different language) void setXmlLexer(LangType type); diff --git a/PowerEditor/src/ScitillaComponent/UserDefineLangReference.h b/PowerEditor/src/ScitillaComponent/UserDefineLangReference.h index 0975ea28f..9ec002814 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineLangReference.h +++ b/PowerEditor/src/ScitillaComponent/UserDefineLangReference.h @@ -18,7 +18,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef USER_DEFINE_LANG_REFERENCE_H - #define USER_DEFINE_LANG_REFERENCE_H const int langNameLenMax = 16; @@ -32,5 +31,3 @@ const int nbPrefixListAllowed = 4; #endif //USER_DEFINE_LANG_REFERENCE_H - - diff --git a/PowerEditor/src/TinyXml/tinyxml.cpp b/PowerEditor/src/TinyXml/tinyxml.cpp index 42d08b4a6..19a5a5194 100644 --- a/PowerEditor/src/TinyXml/tinyxml.cpp +++ b/PowerEditor/src/TinyXml/tinyxml.cpp @@ -24,6 +24,7 @@ distribution. #include #include "tinyxml.h" +#include "UniConversion.h" #ifdef TIXML_USE_STL #include @@ -713,7 +714,9 @@ bool TiXmlDocument::LoadFile( const char* filename ) // Fixed with the StringToBuffer class. value = filename; - FILE* file = fopen( value.c_str (), "r" ); + wchar_t filenameW[MAX_PATH]; + char2wchar(filename, filenameW); + FILE* file = _wfopen( filenameW, L"r" ); if ( file ) { @@ -758,7 +761,9 @@ bool TiXmlDocument::LoadFile( const char* filename ) bool TiXmlDocument::SaveFile( const char * filename ) const { // The old c stuff lives on... - FILE* fp = fopen( filename, "w" ); + wchar_t filenameW[MAX_PATH]; + char2wchar(filename, filenameW); + FILE* fp = _wfopen( filenameW, L"w" ); if ( fp ) { Print( fp, 0 ); diff --git a/PowerEditor/src/UniConversion.cpp b/PowerEditor/src/UniConversion.cpp index 9fd3d76f8..1d8e09449 100644 --- a/PowerEditor/src/UniConversion.cpp +++ b/PowerEditor/src/UniConversion.cpp @@ -7,6 +7,7 @@ #include #include +#include #include "UniConversion.h" unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) { @@ -133,3 +134,46 @@ int utf8_to_ascii(const char* pszUTF8, unsigned int lenUTF8, char* pszASCII) return nbByte; } +void char2wchar(const char* pszCHAR, wchar_t* pszWCHAR, UINT codepage) +{ + int len = MultiByteToWideChar(codepage, 0, pszCHAR, -1, pszWCHAR, 0); + if(len > 0) + MultiByteToWideChar(codepage, 0, pszCHAR, -1, pszWCHAR, len); + else + pszWCHAR[0] = 0; +} + +void wchar2char(const wchar_t* pszWCHAR, char* pszCHAR, UINT codepage) +{ + int len = WideCharToMultiByte(codepage, 0, pszWCHAR, -1, pszCHAR, 0, NULL, NULL); + if(len > 0) + WideCharToMultiByte(codepage, 0, pszWCHAR, -1, pszCHAR, len, NULL, NULL); + else + pszCHAR[0] = 0; +} + +std::wstring string2wstring(const std::string& rString, UINT codepage) +{ + int len = MultiByteToWideChar(codepage, 0, rString.c_str(), -1, NULL, 0); + if(len > 0) + { + std::vector vw(len); + MultiByteToWideChar(codepage, 0, rString.c_str(), -1, &vw[0], len); + return &vw[0]; + } + else + return L""; +} + +std::string wstring2string(const std::wstring& rwString, UINT codepage) +{ + int len = WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, NULL, 0, NULL, NULL); + if(len > 0) + { + std::vector vw(len); + WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, &vw[0], len, NULL, NULL); + return &vw[0]; + } + else + return ""; +} diff --git a/PowerEditor/src/UniConversion.h b/PowerEditor/src/UniConversion.h index 7ccc0e2c0..683e2ff8b 100644 --- a/PowerEditor/src/UniConversion.h +++ b/PowerEditor/src/UniConversion.h @@ -5,9 +5,23 @@ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. +#ifndef UNICONVERSION_H +#define UNICONVERSION_H + +#include +#include +#include + unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen); void UTF8FromUCS2(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len); unsigned int UCS2Length(const char *s, unsigned int len); unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen); unsigned int ascii_to_utf8(const char* pszASCII, unsigned int lenASCII, char* pszUTF8); int utf8_to_ascii(const char* pszUTF8, unsigned int lenUTF8, char* pszASCII); + +void char2wchar(const char* pszCHAR, wchar_t* pszWCHAR, UINT codepage = CP_UTF8); +void wchar2char(const wchar_t* pszWCHAR, char* pszCHAR, UINT codepage = CP_UTF8); +std::wstring string2wstring(const std::string& rString, UINT codepage = CP_UTF8); +std::string wstring2string(const std::wstring& rwString, UINT codepage = CP_UTF8); + +#endif //UNICONVERSION_H diff --git a/PowerEditor/src/Utf8_16.cpp b/PowerEditor/src/Utf8_16.cpp index 2e13723de..d94b8101e 100644 --- a/PowerEditor/src/Utf8_16.cpp +++ b/PowerEditor/src/Utf8_16.cpp @@ -21,6 +21,7 @@ #include #include #include "PluginInterface.h" +#include "UniConversion.h" const Utf8_16::utf8 Utf8_16::k_Boms[][3] = { {0x00, 0x00, 0x00}, // Unknown @@ -222,6 +223,15 @@ FILE * Utf8_16_Write::fopen(const char *_name, const char *_type) return m_pFile; } +FILE * Utf8_16_Write::fopenW(const wchar_t *_name, const wchar_t *_type) +{ + m_pFile = ::_wfopen(_name, _type); + + m_bFirstWrite = true; + + return m_pFile; +} + size_t Utf8_16_Write::fwrite(const void* p, size_t _size) { // no file open diff --git a/PowerEditor/src/Utf8_16.h b/PowerEditor/src/Utf8_16.h index e473f9e04..98846ce31 100644 --- a/PowerEditor/src/Utf8_16.h +++ b/PowerEditor/src/Utf8_16.h @@ -18,6 +18,10 @@ // - Removing UCS-Bug in Utf8_Iter // - Add convert function in Utf8_16_Write //////////////////////////////////////////////////////////////////////////////// + +#ifndef UTF8_16_H +#define UTF8_16_H + #pragma once #include @@ -135,6 +139,7 @@ public: void setEncoding(UniMode eType); FILE * fopen(const char *_name, const char *_type); + FILE * fopenW(const wchar_t *_name, const wchar_t *_type); size_t fwrite(const void* p, size_t _size); void fclose(); @@ -150,3 +155,5 @@ protected: size_t m_nBufSize; bool m_bFirstWrite; }; + +#endif //UTF8_16_H diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp index c5c87f7e3..54f67dade 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp @@ -62,14 +62,14 @@ BOOL CALLBACK ColourPopup::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA { ColourPopup *pColourPopup = (ColourPopup *)(lParam); pColourPopup->_hSelf = hwnd; - ::SetWindowLongPtr(hwnd, GWL_USERDATA, (long)lParam); + ::SetWindowLong(hwnd, GWL_USERDATA, (long)lParam); pColourPopup->run_dlgProc(message, wParam, lParam); return TRUE; } default : { - ColourPopup *pColourPopup = reinterpret_cast(::GetWindowLongPtr(hwnd, GWL_USERDATA)); + ColourPopup *pColourPopup = reinterpret_cast(::GetWindowLong(hwnd, GWL_USERDATA)); if (!pColourPopup) return FALSE; return pColourPopup->run_dlgProc(message, wParam, lParam); diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingCont.h b/PowerEditor/src/WinControls/DockingWnd/DockingCont.h index 9eea6cbea..deb7c69a0 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingCont.h +++ b/PowerEditor/src/WinControls/DockingWnd/DockingCont.h @@ -20,7 +20,7 @@ #define DOCKINGCONT #include "StaticDialog.h" -#include "Resource.h" +#include "resource.h" #include "Docking.h" #include #include diff --git a/PowerEditor/src/WinControls/DockingWnd/common_func.cpp b/PowerEditor/src/WinControls/DockingWnd/common_func.cpp index 338a9c94e..7b66f246d 100644 --- a/PowerEditor/src/WinControls/DockingWnd/common_func.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/common_func.cpp @@ -1,5 +1,6 @@ #include "common_func.h" #include +#include "UniConversion.h" using namespace std; @@ -52,22 +53,22 @@ void folderBrowser(HWND parent, int outputCtrlID) { // If we were able to get the shell malloc object, // then proceed by initializing the BROWSEINFO stuct - BROWSEINFO info; + BROWSEINFOW info; memset(&info, 0, sizeof(info)); info.hwndOwner = parent; info.pidlRoot = NULL; - char szDisplayName[MAX_PATH]; + wchar_t szDisplayName[MAX_PATH]; info.pszDisplayName = szDisplayName; - string title = "Select a folder to search from"; + wstring title = L"Select a folder to search from"; info.lpszTitle = title.c_str(); info.ulFlags = 0; info.lpfn = BrowseCallbackProc; - char directory[MAX_PATH]; - ::GetDlgItemText(parent, outputCtrlID, directory, sizeof(directory)); + wchar_t directory[MAX_PATH]; + ::GetDlgItemTextW(parent, outputCtrlID, directory, sizeof(directory)); info.lParam = reinterpret_cast(directory); // Execute the browsing dialog. - LPITEMIDLIST pidl = ::SHBrowseForFolder(&info); + LPITEMIDLIST pidl = ::SHBrowseForFolderW(&info); // pidl will be null if they cancel the browse dialog. // pidl will be not null when they select a folder. @@ -75,10 +76,10 @@ void folderBrowser(HWND parent, int outputCtrlID) { // Try to convert the pidl to a display string. // Return is true if success. - char szDir[MAX_PATH]; - if (::SHGetPathFromIDList(pidl, szDir)) + wchar_t szDirW[MAX_PATH]; + if (::SHGetPathFromIDListW(pidl, szDirW)) // Set edit control to the directory path. - ::SetDlgItemText(parent, outputCtrlID, szDir); + ::SetDlgItemTextW(parent, outputCtrlID, szDirW); pShellMalloc->Free(pidl); } pShellMalloc->Release(); diff --git a/PowerEditor/src/WinControls/Grid/BabyGrid.h b/PowerEditor/src/WinControls/Grid/BabyGrid.h index 3922a3b02..b52124f83 100644 --- a/PowerEditor/src/WinControls/Grid/BabyGrid.h +++ b/PowerEditor/src/WinControls/Grid/BabyGrid.h @@ -5,7 +5,8 @@ //Printed BABYGRID message reference and tutorial available. //email: mudcat@mis.net for more information. - +#ifndef BABYGRID_H +#define BABYGRID_H #include #include "resource.h" @@ -104,6 +105,4 @@ void SetCell(_BGCELL *cell,int row, int col); //global variables - - - +#endif //BABYGRID_H diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.h b/PowerEditor/src/WinControls/Grid/ShortcutMapper.h index 9c371b979..40866d320 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.h +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.h @@ -17,8 +17,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef SHORTCUTMAPPER -#define SHORTCUTMAPPER +#ifndef SHORTCUTMAPPER_H +#define SHORTCUTMAPPER_H #include "BabyGridWrapper.h" #include "ShortcutMapper_rc.h" @@ -77,4 +77,4 @@ private: void fillOutBabyGrid(); }; -#endif //SHORTCUTMAPPER +#endif //SHORTCUTMAPPER_H diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper_rc.h b/PowerEditor/src/WinControls/Grid/ShortcutMapper_rc.h index 405d095de..2ecf325f2 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper_rc.h +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper_rc.h @@ -16,9 +16,13 @@ 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 SHORTCUTMAPPERRC_H +#define SHORTCUTMAPPERRC_H #define IDD_SHORTCUTMAPPER_DLG 2600 #define IDD_BABYGRID_ID1 (IDD_SHORTCUTMAPPER_DLG + 1) #define IDM_BABYGRID_MODIFY (IDD_SHORTCUTMAPPER_DLG + 2) #define IDM_BABYGRID_DELETE (IDD_SHORTCUTMAPPER_DLG + 3) #define IDC_BABYGRID_TABBAR (IDD_SHORTCUTMAPPER_DLG + 4) + +#endif //SHORTCUTMAPPERRC_H diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp index 2ba66d893..044cbfebf 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp @@ -28,22 +28,24 @@ FileDialog::FileDialog(HWND hwnd, HINSTANCE hInst) for (int i = 0 ; i < nbExtMax ; i++) _extArray[i][0] = '\0'; - memset(_fileExt, 0x00, sizeof(_fileExt)); + memset(_fileExtW, 0x00, sizeof(_fileExtW)); _fileName[0] = '\0'; + _fileNameW[0] = '\0'; + _fileNameW[1] = '\0'; _winVersion = (NppParameters::getInstance())->getWinVersion(); _ofn.lStructSize = sizeof(_ofn); if (_winVersion < WV_W2K) - _ofn.lStructSize = sizeof(OPENFILENAME); + _ofn.lStructSize = sizeof(OPENFILENAMEW); _ofn.hwndOwner = hwnd; _ofn.hInstance = hInst; - _ofn.lpstrFilter = _fileExt; - _ofn.lpstrCustomFilter = (LPTSTR) NULL; + _ofn.lpstrFilter = _fileExtW; + _ofn.lpstrCustomFilter = (LPWSTR) NULL; _ofn.nMaxCustFilter = 0L; _ofn.nFilterIndex = 1L; - _ofn.lpstrFile = _fileName; - _ofn.nMaxFile = sizeof(_fileName); + _ofn.lpstrFile = _fileNameW; + _ofn.nMaxFile = sizeof(_fileNameW); _ofn.lpstrFileTitle = NULL; _ofn.nMaxFileTitle = 0; _ofn.lpstrInitialDir = NULL; @@ -101,13 +103,15 @@ void FileDialog::setExtFilter(const char *extText, const char *ext, ...) extFilter += " ("; extFilter += exts + ")"; - char *pFileExt = _fileExt + _nbCharFileExt; - memcpy(pFileExt, extFilter.c_str(), extFilter.length() + 1); - _nbCharFileExt += extFilter.length() + 1; + wchar_t *pFileExt = _fileExtW + _nbCharFileExt; + wstring extFilterW = string2wstring(extFilter); + wmemcpy(pFileExt, extFilterW.c_str(), extFilterW.length() + 1); + _nbCharFileExt += extFilterW.length() + 1; - pFileExt = _fileExt + _nbCharFileExt; - memcpy(pFileExt, exts.c_str(), exts.length() + 1); - _nbCharFileExt += exts.length() + 1; + pFileExt = _fileExtW + _nbCharFileExt; + wstring extsW = string2wstring(exts); + wmemcpy(pFileExt, extsW.c_str(), extsW.length() + 1); + _nbCharFileExt += extsW.length() + 1; } int FileDialog::setExtsFilter(const char *extText, const char *exts) @@ -122,63 +126,72 @@ int FileDialog::setExtsFilter(const char *extText, const char *exts) extFilter += exts; extFilter += ")"; - char *pFileExt = _fileExt + _nbCharFileExt; - memcpy(pFileExt, extFilter.c_str(), extFilter.length() + 1); - _nbCharFileExt += extFilter.length() + 1; + wchar_t *pFileExt = _fileExtW + _nbCharFileExt; + wstring extFilterW = string2wstring(extFilter); + wmemcpy(pFileExt, extFilterW.c_str(), extFilterW.length() + 1); + _nbCharFileExt += extFilterW.length() + 1; - pFileExt = _fileExt + _nbCharFileExt; - memcpy(pFileExt, exts, strlen(exts) + 1); - _nbCharFileExt += strlen(exts) + 1; + pFileExt = _fileExtW + _nbCharFileExt; + wchar_t extsW[MAX_PATH]; + char2wchar(exts, extsW); + wmemcpy(pFileExt, extsW, wcslen(extsW) + 1); + _nbCharFileExt += wcslen(extsW) + 1; return _nbExt; } char * FileDialog::doOpenSingleFileDlg() { - char dir[MAX_PATH]; - ::GetCurrentDirectory(sizeof(dir), dir); + WCHAR dir[MAX_PATH]; + ::GetCurrentDirectoryW(sizeof(dir), dir); _ofn.lpstrInitialDir = dir; _ofn.Flags |= OFN_FILEMUSTEXIST; - char *fn = NULL; + WCHAR *fnW = NULL; try { - fn = ::GetOpenFileName((OPENFILENAME*)&_ofn)?_fileName:NULL; + fnW = ::GetOpenFileNameW((OPENFILENAMEW*)&_ofn)?_fileNameW:NULL; + wchar2char(_fileNameW, _fileName); } catch(...) { ::MessageBox(NULL, "GetSaveFileName crashes!!!", "", MB_OK); } - return (fn); + return fnW?(_fileName):NULL; } stringVector * FileDialog::doOpenMultiFilesDlg() { - char dir[MAX_PATH]; - ::GetCurrentDirectory(sizeof(dir), dir); + WCHAR dir[MAX_PATH]; + ::GetCurrentDirectoryW(sizeof(dir), dir); _ofn.lpstrInitialDir = dir; _ofn.Flags |= OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT; - if (::GetOpenFileName((OPENFILENAME*)&_ofn)) + if (::GetOpenFileNameW((OPENFILENAMEW*)&_ofn)) { char fn[MAX_PATH]; - char *pFn = _fileName + strlen(_fileName) + 1; - if (!(*pFn)) + WCHAR fnW[MAX_PATH]; + WCHAR *pFnW = _fileNameW + wcslen(_fileNameW) + 1; + if (!(*pFnW)) + { + wchar2char(_fileNameW, _fileName); _fileNames.push_back(std::string(_fileName)); + } else { - strcpy(fn, _fileName); - if (fn[strlen(fn)-1] != '\\') - strcat(fn, "\\"); + wcscpy(fnW, _fileNameW); + if (fnW[wcslen(fnW)-1] != '\\') + wcscat(fnW, L"\\"); } - int term = int(strlen(fn)); + int term = int(wcslen(fnW)); - while (*pFn) + while (*pFnW) { - fn[term] = '\0'; - strcat(fn, pFn); + fnW[term] = '\0'; + wcscat(fnW, pFnW); + wchar2char(fnW, fn); _fileNames.push_back(std::string(fn)); - pFn += strlen(pFn) + 1; + pFnW += wcslen(pFnW) + 1; } return &_fileNames; @@ -189,10 +202,10 @@ stringVector * FileDialog::doOpenMultiFilesDlg() char * FileDialog::doSaveDlg() { - char dir[MAX_PATH]; - ::GetCurrentDirectory(sizeof(dir), dir); + WCHAR dirW[MAX_PATH]; + ::GetCurrentDirectoryW(sizeof(dirW), dirW); - _ofn.lpstrInitialDir = dir; + _ofn.lpstrInitialDir = dirW; _ofn.Flags |= OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_ENABLESIZING; @@ -200,13 +213,15 @@ char * FileDialog::doSaveDlg() _ofn.lpfnHook = OFNHookProc; char *fn = NULL; + WCHAR *fnW = NULL; try { - fn = ::GetSaveFileName((OPENFILENAME*)&_ofn)?_fileName:NULL; + fnW = ::GetSaveFileNameW((OPENFILENAMEW*)&_ofn)?_fileNameW:NULL; + wchar2char(_fileNameW, _fileName); } catch(...) { ::MessageBox(NULL, "GetSaveFileName crashes!!!", "", MB_OK); } - return (fn); + return fnW?(_fileName):NULL; } static HWND hFileDlg = NULL; @@ -301,7 +316,7 @@ UINT_PTR CALLBACK FileDialog::OFNHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, L default : { - FileDialog *pFileDialog = reinterpret_cast(::GetWindowLongPtr(hWnd, GWL_USERDATA)); + FileDialog *pFileDialog = reinterpret_cast(::GetWindowLong(hWnd, GWL_USERDATA)); if (!pFileDialog) { return FALSE; diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h index 782b4dbae..f9b54064c 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h @@ -26,6 +26,7 @@ #include #include "SysMsg.h" #include "Parameters.h" +#include "UniConversion.h" const int nbExtMax = 256; const int extLenMax = 64; @@ -40,29 +41,28 @@ struct OPENFILENAMENPP { DWORD lStructSize; HWND hwndOwner; HINSTANCE hInstance; - LPCTSTR lpstrFilter; - LPTSTR lpstrCustomFilter; + LPCWSTR lpstrFilter; + LPWSTR lpstrCustomFilter; DWORD nMaxCustFilter; DWORD nFilterIndex; - LPTSTR lpstrFile; + LPWSTR lpstrFile; DWORD nMaxFile; - LPTSTR lpstrFileTitle; + LPWSTR lpstrFileTitle; DWORD nMaxFileTitle; - LPCTSTR lpstrInitialDir; - LPCTSTR lpstrTitle; + LPCWSTR lpstrInitialDir; + LPCWSTR lpstrTitle; DWORD Flags; WORD nFileOffset; WORD nFileExtension; - LPCTSTR lpstrDefExt; + LPCWSTR lpstrDefExt; LPARAM lCustData; LPOFNHOOKPROC lpfnHook; - LPCTSTR lpTemplateName; + LPCWSTR lpTemplateName; void * pvReserved; DWORD dwReserved; DWORD FlagsEx; }; - static string changeExt(string fn, string ext) { if (ext == "") @@ -119,7 +119,7 @@ public: void setExtFilter(const char *, const char *, ...); int setExtsFilter(const char *extText, const char *exts); - void setDefFileName(const char *fn){strcpy(_fileName, fn);} + void setDefFileName(const char *fn){strcpy(_fileName, fn); char2wchar(fn, _fileNameW); } char * doSaveDlg(); stringVector * doOpenMultiFilesDlg(); @@ -133,8 +133,9 @@ protected : private: char _fileName[MAX_PATH*8]; + WCHAR _fileNameW[MAX_PATH*8]; - char _fileExt[MAX_PATH*10]; + WCHAR _fileExtW[MAX_PATH*10]; int _nbCharFileExt; stringVector _fileNames; diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp index 7a52bdbac..460d6880d 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp @@ -24,11 +24,11 @@ #include "Notepad_plus.h" -void Command::extractArgs(char *cmd2Exec, char *args, const char *cmdEntier) +void Command::extractArgs(wchar_t *cmd2Exec, wchar_t *args, const wchar_t *cmdEntier) { int i = 0; bool quoted = false; - for ( ; i < int(strlen(cmdEntier)) ; i++) + for ( ; i < int(wcslen(cmdEntier)) ; i++) { if ((cmdEntier[i] == ' ') && (!quoted)) break; @@ -39,18 +39,18 @@ void Command::extractArgs(char *cmd2Exec, char *args, const char *cmdEntier) } cmd2Exec[i] = '\0'; - if (i < int(strlen(cmdEntier))) + if (i < int(wcslen(cmdEntier))) { - for ( ; (i < int(strlen(cmdEntier))) && (cmdEntier[i] == ' ') ; i++); - if (i < int(strlen(cmdEntier))) + for ( ; (i < int(wcslen(cmdEntier))) && (cmdEntier[i] == ' ') ; i++); + if (i < int(wcslen(cmdEntier))) { - for (int k = 0 ; i <= int(strlen(cmdEntier)) ; i++, k++) + for (int k = 0 ; i <= int(wcslen(cmdEntier)) ; i++, k++) { args[k] = cmdEntier[i]; } } - int l = strlen(args); + int l = wcslen(args); if (args[l-1] == ' ') { for (l -= 2 ; (l > 0) && (args[l] == ' ') ; l--); @@ -63,42 +63,42 @@ void Command::extractArgs(char *cmd2Exec, char *args, const char *cmdEntier) } -int whichVar(char *str) +int whichVar(wchar_t *str) { - if (!strcmp(fullCurrentPath, str)) + if (!wcscmp(fullCurrentPath, str)) return FULL_CURRENT_PATH; - else if (!strcmp(currentDirectory, str)) + else if (!wcscmp(currentDirectory, str)) return CURRENT_DIRECTORY; - else if (!strcmp(onlyFileName, str)) + else if (!wcscmp(onlyFileName, str)) return FILE_NAME; - else if (!strcmp(fileNamePart, str)) + else if (!wcscmp(fileNamePart, str)) return NAME_PART; - else if (!strcmp(fileExtPart, str)) + else if (!wcscmp(fileExtPart, str)) return EXT_PART; - else if (!strcmp(currentWord, str)) + else if (!wcscmp(currentWord, str)) return CURRENT_WORD; - else if (!strcmp(nppDir, str)) + else if (!wcscmp(nppDir, str)) return NPP_DIRECTORY; - else if (!strcmp(currentLine, str)) + else if (!wcscmp(currentLine, str)) return CURRENT_LINE; - else if (!strcmp(currentColumn, str)) + else if (!wcscmp(currentColumn, str)) return CURRENT_COLUMN; return VAR_NOT_RECOGNIZED; } // Since I'm sure the length will be 256, I won't check the strlen : watch out! -void expandNppEnvironmentStrs(const char *strSrc, char *stringDest, size_t strDestLen, HWND hWnd) +void expandNppEnvironmentStrs(const wchar_t *strSrc, wchar_t *stringDest, size_t strDestLen, HWND hWnd) { size_t j = 0; - for (size_t i = 0 ; i < strlen(strSrc) ; i++) + for (size_t i = 0 ; i < wcslen(strSrc) ; i++) { int iBegin = -1; int iEnd = -1; if ((strSrc[i] == '$') && (strSrc[i+1] == '(')) { iBegin = i += 2; - for ( ; i < strlen(strSrc) ; i++) + for ( ; i < wcslen(strSrc) ; i++) { if (strSrc[i] == ')') { @@ -111,7 +111,7 @@ void expandNppEnvironmentStrs(const char *strSrc, char *stringDest, size_t strDe { if (iEnd != -1) { - char str[256]; + wchar_t str[256]; int m = 0; for (int k = iBegin ; k <= iEnd ; k++) str[m++] = strSrc[k]; @@ -125,16 +125,16 @@ void expandNppEnvironmentStrs(const char *strSrc, char *stringDest, size_t strDe } else { - char expandedStr[256]; + wchar_t expandedStr[256]; if (internalVar == CURRENT_LINE || internalVar == CURRENT_COLUMN) { int lineNumber = ::SendMessage(hWnd, RUNCOMMAND_USER + internalVar, 0, 0); - sprintf(expandedStr, "%d", lineNumber); + wsprintfW(expandedStr, L"%d", lineNumber); } else ::SendMessage(hWnd, RUNCOMMAND_USER + internalVar, MAX_PATH, (LPARAM)expandedStr); - for (size_t p = 0 ; p < strlen(expandedStr) ; p++) + for (size_t p = 0 ; p < wcslen(expandedStr) ; p++) stringDest[j++] = expandedStr[p]; } } @@ -152,20 +152,26 @@ void expandNppEnvironmentStrs(const char *strSrc, char *stringDest, size_t strDe HINSTANCE Command::run(HWND hWnd) { - char cmdPure[MAX_PATH]; - char cmdIntermediate[MAX_PATH]; - char cmd2Exec[MAX_PATH]; - char args[MAX_PATH]; - char argsIntermediate[MAX_PATH]; - char args2Exec[MAX_PATH]; + wchar_t cmdPure[MAX_PATH]; + wchar_t cmdIntermediate[MAX_PATH]; + wchar_t cmd2Exec[MAX_PATH]; + wchar_t args[MAX_PATH]; + wchar_t argsIntermediate[MAX_PATH]; + wchar_t args2Exec[MAX_PATH]; - extractArgs(cmdPure, args, _cmdLine.c_str()); - ::ExpandEnvironmentStrings(cmdPure, cmdIntermediate, sizeof(cmd2Exec)); - ::ExpandEnvironmentStrings(args, argsIntermediate, sizeof(args)); + wstring cmdLineW = string2wstring(_cmdLine); + extractArgs(cmdPure, args, cmdLineW.c_str()); + ::ExpandEnvironmentStringsW(cmdPure, cmdIntermediate, sizeof(cmd2Exec)); + ::ExpandEnvironmentStringsW(args, argsIntermediate, sizeof(args)); expandNppEnvironmentStrs(cmdIntermediate, cmd2Exec, sizeof(cmd2Exec), hWnd); expandNppEnvironmentStrs(argsIntermediate, args2Exec, sizeof(args2Exec), hWnd); - return ::ShellExecute(hWnd, "open", cmd2Exec, args2Exec, ".", SW_SHOW); + // cmd2Exec needs to be in UTF8 format for searches to work. + char temp[MAX_PATH]; + wchar2char(cmd2Exec, temp); + char2wchar(temp, cmd2Exec); + + return ::ShellExecuteW(hWnd, L"open", cmd2Exec, args2Exec, L".", SW_SHOW); } BOOL CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) @@ -190,18 +196,21 @@ BOOL CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) case IDOK : { char cmd[MAX_PATH]; - ::GetDlgItemText(_hSelf, IDC_COMBO_RUN_PATH, cmd, MAX_PATH); + wchar_t cmdW[MAX_PATH]; + ::GetDlgItemTextW(_hSelf, IDC_COMBO_RUN_PATH, cmdW, MAX_PATH); + wchar2char(cmdW, cmd); _cmdLine = cmd; + wstring cmdLineW = string2wstring(_cmdLine); HINSTANCE hInst = run(_hParent); if (int(hInst) > 32) { - addTextToCombo(_cmdLine.c_str()); + addTextToCombo(cmdLineW.c_str()); display(false); } else { - removeTextFromCombo(_cmdLine.c_str()); + removeTextFromCombo(cmdLineW.c_str()); } return TRUE; } @@ -213,7 +222,9 @@ BOOL CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) int cmdID = ID_USER_CMD + nbCmd; char cmd[MAX_PATH]; - ::GetDlgItemText(_hSelf, IDC_COMBO_RUN_PATH, cmd, MAX_PATH); + wchar_t cmdW[MAX_PATH]; + ::GetDlgItemTextW(_hSelf, IDC_COMBO_RUN_PATH, cmdW, MAX_PATH); + wchar2char(cmdW, cmd); UserCommand uc(Shortcut(), cmd, cmdID); uc.init(_hInst, _hSelf); @@ -238,7 +249,11 @@ BOOL CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) fd.setExtFilter("All files : ", ".*", NULL); if (const char *fn = fd.doOpenSingleFileDlg()) - addTextToCombo(fn); + { + wchar_t fnW[MAX_PATH]; + char2wchar(fn, fnW); + addTextToCombo(fnW); + } return TRUE; } @@ -250,18 +265,18 @@ BOOL CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) return FALSE; } -void RunDlg::addTextToCombo(const char *txt2Add) const +void RunDlg::addTextToCombo(const wchar_t *txt2Add) const { HWND handle = ::GetDlgItem(_hSelf, IDC_COMBO_RUN_PATH); - int i = ::SendMessage(handle, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)txt2Add); + int i = ::SendMessageW(handle, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)txt2Add); if (i == CB_ERR) - i = ::SendMessage(handle, CB_ADDSTRING, 0, (LPARAM)txt2Add); + i = ::SendMessageW(handle, CB_ADDSTRING, 0, (LPARAM)txt2Add); ::SendMessage(handle, CB_SETCURSEL, i, 0); } -void RunDlg::removeTextFromCombo(const char *txt2Remove) const +void RunDlg::removeTextFromCombo(const wchar_t *txt2Remove) const { HWND handle = ::GetDlgItem(_hSelf, IDC_COMBO_RUN_PATH); - int i = ::SendMessage(handle, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)txt2Remove); + int i = ::SendMessageW(handle, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)txt2Remove); if (i == CB_ERR) return; ::SendMessage(handle, CB_DELETESTRING, i, 0); diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h index c0b2f890c..109bf3c45 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h @@ -26,18 +26,18 @@ using namespace std; -const char fullCurrentPath[] = "FULL_CURRENT_PATH"; -const char currentDirectory[] = "CURRENT_DIRECTORY"; -const char onlyFileName[] = "FILE_NAME"; -const char fileNamePart[] = "NAME_PART"; -const char fileExtPart[] = "EXT_PART"; -const char currentWord[] = "CURRENT_WORD"; -const char nppDir[] = "NPP_DIRECTORY"; -const char currentLine[] = "CURRENT_LINE"; -const char currentColumn[] = "CURRENT_COLUMN"; +const wchar_t fullCurrentPath[] = L"FULL_CURRENT_PATH"; +const wchar_t currentDirectory[] = L"CURRENT_DIRECTORY"; +const wchar_t onlyFileName[] = L"FILE_NAME"; +const wchar_t fileNamePart[] = L"NAME_PART"; +const wchar_t fileExtPart[] = L"EXT_PART"; +const wchar_t currentWord[] = L"CURRENT_WORD"; +const wchar_t nppDir[] = L"NPP_DIRECTORY"; +const wchar_t currentLine[] = L"CURRENT_LINE"; +const wchar_t currentColumn[] = L"CURRENT_COLUMN"; -int whichVar(char *str); -void expandNppEnvironmentStrs(const char *strSrc, char *stringDest, size_t strDestLen, HWND hWnd); +int whichVar(wchar_t *str); +void expandNppEnvironmentStrs(const wchar_t *strSrc, wchar_t *stringDest, size_t strDestLen, HWND hWnd); class Command { public : @@ -49,7 +49,7 @@ public : protected : string _cmdLine; private : - void extractArgs(char *cmd2Exec, char *args, const char *cmdEntier); + void extractArgs(wchar_t *cmd2Exec, wchar_t *args, const wchar_t *cmdEntier); }; class RunDlg : public Command, public StaticDialog @@ -67,8 +67,8 @@ protected : virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); private : - void addTextToCombo(const char *txt2Add) const; - void removeTextFromCombo(const char *txt2Remove) const; + void addTextToCombo(const wchar_t *txt2Add) const; + void removeTextFromCombo(const wchar_t *txt2Remove) const; }; #endif //RUN_DLG_H diff --git a/PowerEditor/src/WinControls/StatusBar/StatusBar.h b/PowerEditor/src/WinControls/StatusBar/StatusBar.h index c486ca1e2..60dc8db76 100644 --- a/PowerEditor/src/WinControls/StatusBar/StatusBar.h +++ b/PowerEditor/src/WinControls/StatusBar/StatusBar.h @@ -17,6 +17,7 @@ #ifndef STATUS_BAR_H #define STATUS_BAR_H + #include "Window.h" #ifndef _WIN32_IE diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index b7d134ac0..f7b54f1bc 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -474,13 +474,13 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct) } bool isSelected = (nTab == ::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0)); - char label[MAX_PATH]; - TCITEM tci; + wchar_t label[MAX_PATH]; + TCITEMW tci; tci.mask = TCIF_TEXT|TCIF_IMAGE; tci.pszText = label; tci.cchTextMax = MAX_PATH-1; - if (!::SendMessage(_hSelf, TCM_GETITEM, nTab, reinterpret_cast(&tci))) + if (!::SendMessage(_hSelf, TCM_GETITEMW, nTab, reinterpret_cast(&tci))) { ::MessageBox(NULL, "! TCM_GETITEM", "", MB_OK); //return ::CallWindowProc(_tabBarDefaultProc, hwnd, Message, wParam, lParam); @@ -693,7 +693,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct) else Flags |= DT_BOTTOM; } - ::DrawText(hDC, label, strlen(label), &rect, Flags); + ::DrawTextW(hDC, label, wcslen(label), &rect, Flags); ::RestoreDC(hDC, nSavedDC); } @@ -736,37 +736,37 @@ void TabBarPlus::exchangeItemData(POINT point) ::SendMessage(_hSelf, TCM_SETCURSEL, nTab, 0); //2. shift their data, and insert the source - TCITEM itemData_nDraggedTab, itemData_shift; + TCITEMW itemData_nDraggedTab, itemData_shift; itemData_nDraggedTab.mask = itemData_shift.mask = TCIF_IMAGE | TCIF_TEXT | TCIF_PARAM; - char str1[256]; - char str2[256]; + wchar_t str1[MAX_PATH]; + wchar_t str2[MAX_PATH]; itemData_nDraggedTab.pszText = str1; - itemData_nDraggedTab.cchTextMax = (sizeof(str1)); + itemData_nDraggedTab.cchTextMax = (MAX_PATH-1); itemData_shift.pszText = str2; - itemData_shift.cchTextMax = (sizeof(str2)); + itemData_shift.cchTextMax = (MAX_PATH-1); - ::SendMessage(_hSelf, TCM_GETITEM, _nTabDragged, reinterpret_cast(&itemData_nDraggedTab)); + ::SendMessage(_hSelf, TCM_GETITEMW, _nTabDragged, reinterpret_cast(&itemData_nDraggedTab)); if (_nTabDragged > nTab) { for (int i = _nTabDragged ; i > nTab ; i--) { - ::SendMessage(_hSelf, TCM_GETITEM, i-1, reinterpret_cast(&itemData_shift)); - ::SendMessage(_hSelf, TCM_SETITEM, i, reinterpret_cast(&itemData_shift)); + ::SendMessage(_hSelf, TCM_GETITEMW, i-1, reinterpret_cast(&itemData_shift)); + ::SendMessage(_hSelf, TCM_SETITEMW, i, reinterpret_cast(&itemData_shift)); } } else { for (int i = _nTabDragged ; i < nTab ; i++) { - ::SendMessage(_hSelf, TCM_GETITEM, i+1, reinterpret_cast(&itemData_shift)); - ::SendMessage(_hSelf, TCM_SETITEM, i, reinterpret_cast(&itemData_shift)); + ::SendMessage(_hSelf, TCM_GETITEMW, i+1, reinterpret_cast(&itemData_shift)); + ::SendMessage(_hSelf, TCM_SETITEMW, i, reinterpret_cast(&itemData_shift)); } } // - ::SendMessage(_hSelf, TCM_SETITEM, nTab, reinterpret_cast(&itemData_nDraggedTab)); + ::SendMessage(_hSelf, TCM_SETITEMW, nTab, reinterpret_cast(&itemData_nDraggedTab)); //3. update the current index _nTabDragged = nTab; diff --git a/PowerEditor/src/WinControls/WindowsDlg/SizeableDlg.h b/PowerEditor/src/WinControls/WindowsDlg/SizeableDlg.h index 2d4f2c8a0..672dfdadc 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/SizeableDlg.h +++ b/PowerEditor/src/WinControls/WindowsDlg/SizeableDlg.h @@ -1,4 +1,5 @@ - +#ifndef SIZABLEDLG_H +#define SIZABLEDLG_H #include "StaticDialog.h" #include "WindowsDlgRc.h" @@ -18,3 +19,5 @@ protected: virtual void onGetMinMaxInfo(MINMAXINFO* lpMMI); virtual LRESULT onWinMgr(WPARAM wp, LPARAM lp); }; + +#endif //SIZABLEDLG_H diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp index b72a96f6e..cb651e761 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp @@ -5,6 +5,7 @@ #include #include #include +#include "UniConversion.h" #ifndef _countof #define _countof(x) (sizeof(x)/sizeof((x)[0])) @@ -14,7 +15,7 @@ #define LVS_EX_DOUBLEBUFFER 0x00010000 #endif -static const char *readonlyString = " [Read Only]"; +static const wchar_t *readonlyString = L" [Read Only]"; const UINT WDN_NOTIFY = RegisterWindowMessage("WDN_NOTIFY"); inline static DWORD GetStyle(HWND hWnd) { @@ -230,9 +231,9 @@ BOOL CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam if (wParam == IDC_WINDOWS_LIST) { NMHDR* pNMHDR = (NMHDR*)lParam; - if (pNMHDR->code == LVN_GETDISPINFO) + if (pNMHDR->code == LVN_GETDISPINFOW) { - NMLVDISPINFO *pLvdi = (NMLVDISPINFO *)pNMHDR; + NMLVDISPINFOW *pLvdi = (NMLVDISPINFOW *)pNMHDR; //if(pLvdi->item.mask & LVIF_IMAGE) // ; if(pLvdi->item.mask & LVIF_TEXT) @@ -249,10 +250,10 @@ BOOL CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam if (pLvdi->item.iSubItem == 0) // file name { int len = pLvdi->item.cchTextMax; - const char *fileName = buf->getFileName(); - strncpy(pLvdi->item.pszText, fileName, len-1); + const wchar_t *fileName = buf->getFileNameW(); + wcsncpy(pLvdi->item.pszText, fileName, len-1); pLvdi->item.pszText[len-1] = 0; - len = strlen(pLvdi->item.pszText); + len = wcslen(pLvdi->item.pszText); if (buf->isDirty()) { if (len < pLvdi->item.cchTextMax) @@ -263,23 +264,23 @@ BOOL CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam } else if (buf->isReadOnly()) { - len += strlen(readonlyString); + len += wcslen(readonlyString); if (len <= pLvdi->item.cchTextMax) - strcat(pLvdi->item.pszText, readonlyString); + wcscat(pLvdi->item.pszText, readonlyString); } } else if (pLvdi->item.iSubItem == 1) // directory { - const char *fullName = buf->getFilePath(); - const char *fileName = buf->getFileName(); - int len = strlen(fullName)-strlen(fileName); + const wchar_t *fullName = buf->getFilePathW(); + const wchar_t *fileName = buf->getFileNameW(); + int len = wcslen(fullName)-wcslen(fileName); if (!len) { len = 1; - fullName = ""; + fullName = L""; } if (pLvdi->item.cchTextMax < len) len = pLvdi->item.cchTextMax; - strncpy(pLvdi->item.pszText, fullName, len-1); + wcsncpy(pLvdi->item.pszText, fullName, len-1); pLvdi->item.pszText[len-1] = 0; } else if (pLvdi->item.iSubItem == 2) // Type @@ -289,7 +290,9 @@ BOOL CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam Lang *lang = pNppParameters->getLangFromID(buf->getLangType()); if (NULL != lang) { - strncpy(pLvdi->item.pszText, lang->getLangName(), len-1); + wchar_t langName[LANG_NAME_LEN]; + char2wchar(lang->getLangName(), langName); + wcsncpy(pLvdi->item.pszText, langName, len-1); } } } @@ -381,7 +384,7 @@ void WindowsDlg::updateButtonState() int WindowsDlg::doDialog(TiXmlNode *dlgNode) { _dlgNode = dlgNode; - return ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_WINDOWS), _hParent, (DLGPROC)dlgProc, (LPARAM)this); + return ::DialogBoxParamW(_hInst, MAKEINTRESOURCEW(IDD_WINDOWS), _hParent, (DLGPROC)dlgProc, (LPARAM)this); }; bool WindowsDlg::changeDlgLang() @@ -435,22 +438,22 @@ BOOL WindowsDlg::onInitDialog() GetClientRect(_hList, &rc); LONG width = rc.right - rc.left; - LVCOLUMN lvColumn; + LVCOLUMNW lvColumn; memset(&lvColumn, 0, sizeof(lvColumn)); lvColumn.mask = LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM|LVCF_FMT; lvColumn.fmt = LVCFMT_LEFT; - lvColumn.pszText = "Name"; + lvColumn.pszText = L"Name"; lvColumn.cx = width/4; - SendMessage(_hList, LVM_INSERTCOLUMN, 0, LPARAM(&lvColumn)); + SendMessage(_hList, LVM_INSERTCOLUMNW, 0, LPARAM(&lvColumn)); - lvColumn.pszText = "Path"; + lvColumn.pszText = L"Path"; lvColumn.cx = 300; - SendMessage(_hList, LVM_INSERTCOLUMN, 1, LPARAM(&lvColumn)); + SendMessage(_hList, LVM_INSERTCOLUMNW, 1, LPARAM(&lvColumn)); lvColumn.fmt = LVCFMT_CENTER; - lvColumn.pszText = "Type"; + lvColumn.pszText = L"Type"; lvColumn.cx = 40; - SendMessage(_hList, LVM_INSERTCOLUMN, 2, LPARAM(&lvColumn)); + SendMessage(_hList, LVM_INSERTCOLUMNW, 2, LPARAM(&lvColumn)); fitColumnsToSize(); @@ -749,15 +752,15 @@ void WindowsMenu::initPopupMenu(HMENU hMenu, DocTabView *pTab) int id, pos; for (id=IDM_WINDOW_MRU_FIRST, pos=0; idgetBufferByIndex(pos); Buffer * buf = MainFileManager->getBufferByID(bufID); - MENUITEMINFO mii; + MENUITEMINFOW mii; memset(&mii, 0, sizeof(mii)); mii.cbSize = sizeof(mii); mii.fMask = MIIM_STRING|MIIM_STATE|MIIM_ID; - mii.dwTypeData = buildFileName(buffer, 60, pos, buf->getFileName()); + mii.dwTypeData = buildFileName(buffer, 60, pos, buf->getFileNameW()); mii.fState &= ~(MF_GRAYED|MF_DISABLED|MF_CHECKED); if (pos == curDoc) mii.fState |= MF_CHECKED; @@ -765,9 +768,9 @@ void WindowsMenu::initPopupMenu(HMENU hMenu, DocTabView *pTab) UINT state = GetMenuState(hMenu, id, MF_BYCOMMAND); if (state == -1) - InsertMenuItem(hMenu, IDM_WINDOW_WINDOWS, FALSE, &mii); + InsertMenuItemW(hMenu, IDM_WINDOW_WINDOWS, FALSE, &mii); else - SetMenuItemInfo(hMenu, id, FALSE, &mii); + SetMenuItemInfoW(hMenu, id, FALSE, &mii); } for ( ; id<=IDM_WINDOW_MRU_LIMIT; ++id) { @@ -784,10 +787,10 @@ void WindowsMenu::uninitPopupMenu(HMENU hMenu, ScintillaEditView *pView) } } */ -static char* convertFileName(char *buffer, const char *filename) +static wchar_t* convertFileName(wchar_t *buffer, const wchar_t *filename) { - char *b = buffer; - const char *p = filename; + wchar_t *b = buffer; + const wchar_t *p = filename; while (*p) { if (*p == '&') *b++ = '&'; @@ -797,15 +800,15 @@ static char* convertFileName(char *buffer, const char *filename) return buffer; } -char *WindowsMenu::buildFileName(char *buffer, int len, int pos, const char *filename) +wchar_t *WindowsMenu::buildFileName(wchar_t *buffer, int len, int pos, const wchar_t *filename) { - char cwd[MAX_PATH]; + wchar_t cwd[MAX_PATH]; buffer[0] = 0; - GetCurrentDirectory(_countof(cwd), cwd); - strcat(cwd, "\\"); + GetCurrentDirectoryW(_countof(cwd), cwd); + wcscat(cwd, L"\\"); - char *itr = buffer; - char *end = buffer + len - 1; + wchar_t *itr = buffer; + wchar_t *end = buffer + len - 1; if (pos < 9) { *itr++ = '&'; @@ -819,33 +822,33 @@ char *WindowsMenu::buildFileName(char *buffer, int len, int pos, const char *fil } else { - itr = itoa(pos+1, itr, 10) + strlen(itr); + itr = _itow(pos+1, itr, 10) + wcslen(itr); } *itr++ = ':'; *itr++ = ' '; - if (0 == strnicmp(filename, cwd, strlen(cwd))) + if (0 == wcsnicmp(filename, cwd, wcslen(cwd))) { - char cnvName[MAX_PATH]; - const char *s1 = PathFindFileName(filename); - int len = strlen(s1); + wchar_t cnvName[MAX_PATH]; + const wchar_t *s1 = PathFindFileNameW(filename); + int len = wcslen(s1); if (len < (end-itr)) { - strcpy(cnvName, s1); + wcscpy(cnvName, s1); } else { int n = (len-3-(itr-buffer))/2; - strncpy(cnvName, s1, n); - strcpy(cnvName+n, "..."); - strcat(cnvName, s1 + strlen(s1) - n); + wcsncpy(cnvName, s1, n); + wcscpy(cnvName+n, L"..."); + wcscat(cnvName, s1 + wcslen(s1) - n); } convertFileName(itr, cnvName); } else { - char cnvName[MAX_PATH*2]; - const char *s1 = convertFileName(cnvName, filename); - PathCompactPathEx(itr, filename, len - (itr-buffer), 0); + wchar_t cnvName[MAX_PATH*2]; + const wchar_t *s1 = convertFileName(cnvName, filename); + PathCompactPathExW(itr, filename, len - (itr-buffer), 0); } return buffer; } \ No newline at end of file diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h index 9b70b37fb..61f3874cd 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h @@ -106,7 +106,7 @@ public: void initPopupMenu(HMENU hMenu, DocTabView *pTab); //void uninitPopupMenu(HMENU hMenu, ScintillaEditView *pView); private: - char *buildFileName(char *buffer, int len, int pos, const char *filename); + wchar_t *buildFileName(wchar_t *buffer, int len, int pos, const wchar_t *filename); HMENU _hMenu; }; diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlgRc.h b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlgRc.h index dbd183234..6d943275e 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlgRc.h +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlgRc.h @@ -1,3 +1,23 @@ +//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 WINDOWSDLG_RC_H +#define WINDOWSDLG_RC_H + #ifdef __GNUC__ #define _WIN32_IE 0x0600 @@ -17,3 +37,5 @@ #define IDM_WINDOW_WINDOWS (IDR_WINDOWS_MENU + 1) #define IDM_WINDOW_MRU_FIRST (IDR_WINDOWS_MENU + 20) #define IDM_WINDOW_MRU_LIMIT (IDR_WINDOWS_MENU + 29) + +#endif //WINDOWSDLG_RC_H diff --git a/PowerEditor/src/lastRecentFileList.cpp b/PowerEditor/src/lastRecentFileList.cpp index f2a3fcb7d..ecf10f28b 100644 --- a/PowerEditor/src/lastRecentFileList.cpp +++ b/PowerEditor/src/lastRecentFileList.cpp @@ -17,6 +17,7 @@ #include "lastRecentFileList.h" #include "menuCmdID.h" +#include "UniConversion.h" void LastRecentFileList::initMenu(HMENU hMenu, int idBase, int posBase) { @@ -65,7 +66,8 @@ void LastRecentFileList::updateMenu() { menuString += indexBuffer; menuString += " "; menuString += _lrfl.at(j)._name; - ::InsertMenu(_hMenu, _posBase + j, MF_BYPOSITION, _lrfl.at(j)._id, menuString.c_str()); + std::wstring menuStringW = string2wstring(menuString); + ::InsertMenuW(_hMenu, _posBase + j, MF_BYPOSITION, _lrfl.at(j)._id, menuStringW.c_str()); } } diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index 21bd11b44..12d0d001c 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -22,19 +22,19 @@ #include //default C++ exception #include "Win32Exception.h" //Win32 exception -typedef std::vector ParamVector; +typedef std::vector ParamVector; -bool checkSingleFile(const char * commandLine) { - char fullpath[MAX_PATH]; - ::GetFullPathName(commandLine, MAX_PATH, fullpath, NULL); - if (::PathFileExists(fullpath)) { +bool checkSingleFile(const wchar_t * commandLine) { + wchar_t fullpath[MAX_PATH]; + ::GetFullPathNameW(commandLine, MAX_PATH, fullpath, NULL); + if (::PathFileExistsW(fullpath)) { return true; } return false; } -void parseCommandLine(char * commandLine, ParamVector & paramVector) { +void parseCommandLine(wchar_t * commandLine, ParamVector & paramVector) { bool isFile = checkSingleFile(commandLine); //if the commandline specifies only a file, open it as such if (isFile) { paramVector.push_back(commandLine); @@ -43,7 +43,7 @@ void parseCommandLine(char * commandLine, ParamVector & paramVector) { bool isInFile = false; bool isInWhiteSpace = true; paramVector.clear(); - size_t commandLength = strlen(commandLine); + size_t commandLength = wcslen(commandLine); for(size_t i = 0; i < commandLength; i++) { switch(commandLine[i]) { case '\"': { //quoted filename, ignore any following whitespace @@ -72,12 +72,12 @@ void parseCommandLine(char * commandLine, ParamVector & paramVector) { //the commandline string is now a list of zero terminated strings concatenated, and the vector contains all the substrings } -bool isInList(const char *token2Find, ParamVector & params) { +bool isInList(const wchar_t *token2Find, ParamVector & params) { int nrItems = params.size(); for (int i = 0; i < nrItems; i++) { - if (!strcmp(token2Find, params.at(i))) { + if (!wcscmp(token2Find, params.at(i))) { params.erase(params.begin() + i); return true; } @@ -85,14 +85,14 @@ bool isInList(const char *token2Find, ParamVector & params) { return false; }; -bool getParamVal(char c, ParamVector & params, string & value) { - value = ""; +bool getParamVal(wchar_t c, ParamVector & params, wstring & value) { + value = L""; int nrItems = params.size(); for (int i = 0; i < nrItems; i++) { - const char * token = params.at(i); - if (token[0] == '-' && strlen(token) >= 2 && token[1] == c) { //dash, and enough chars + const wchar_t * token = params.at(i); + if (token[0] == '-' && wcslen(token) >= 2 && token[1] == c) { //dash, and enough chars value = (token+2); params.erase(params.begin() + i); return true; @@ -102,28 +102,30 @@ bool getParamVal(char c, ParamVector & params, string & value) { } LangType getLangTypeFromParam(ParamVector & params) { - string langStr; + wstring langStr; if (!getParamVal('l', params, langStr)) return L_EXTERNAL; - return NppParameters::getLangIDFromStr(langStr.c_str()); + char lang[MAX_PATH]; + wchar2char(langStr.c_str(), lang); + return NppParameters::getLangIDFromStr(lang); }; int getLn2GoFromParam(ParamVector & params) { - string lineNumStr; + wstring lineNumStr; if (!getParamVal('n', params, lineNumStr)) return -1; - return atoi(lineNumStr.c_str()); + return _wtoi(lineNumStr.c_str()); }; -const char FLAG_MULTI_INSTANCE[] = "-multiInst"; -const char FLAG_NO_PLUGIN[] = "-noPlugin"; -const char FLAG_READONLY[] = "-ro"; -const char FLAG_NOSESSION[] = "-nosession"; -const char FLAG_NOTABBAR[] = "-notabbar"; +const wchar_t FLAG_MULTI_INSTANCE[] = L"-multiInst"; +const wchar_t FLAG_NO_PLUGIN[] = L"-noPlugin"; +const wchar_t FLAG_READONLY[] = L"-ro"; +const wchar_t FLAG_NOSESSION[] = L"-nosession"; +const wchar_t FLAG_NOTABBAR[] = L"-notabbar"; void doException(Notepad_plus & notepad_plus_plus); -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdShow) +int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpszCmdLine, int nCmdShow) { bool TheFirstOne = true; ::SetLastError(NO_ERROR); @@ -152,24 +154,24 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdSh cmdLineParams._isNoSession = true; } - string quotFileName = ""; + wstring quotFileName = L""; // tell the running instance the FULL path to the new files to load size_t nrFilesToOpen = params.size(); - const char * currentFile; - char fullFileName[MAX_PATH]; + const wchar_t * currentFile; + wchar_t fullFileName[MAX_PATH]; //TODO: try merging the flenames and see if it exists, user may have typed a single spaced filename without quotes for(size_t i = 0; i < nrFilesToOpen; i++) { currentFile = params.at(i); //check if relative or full path. Relative paths dont have a colon for driveletter - BOOL isRelative = ::PathIsRelative(currentFile); - quotFileName += "\""; + BOOL isRelative = ::PathIsRelativeW(currentFile); + quotFileName += L"\""; if (isRelative) { - ::GetFullPathName(currentFile, MAX_PATH, fullFileName, NULL); + ::GetFullPathNameW(currentFile, MAX_PATH, fullFileName, NULL); quotFileName += fullFileName; } else { quotFileName += currentFile; } - quotFileName += "\" "; + quotFileName += L"\" "; } if ((!isMultiInst) && (!TheFirstOne)) { @@ -206,10 +208,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdSh COPYDATASTRUCT fileNamesData; fileNamesData.dwData = COPYDATA_FILENAMES; fileNamesData.lpData = (void *)quotFileName.c_str(); - fileNamesData.cbData = long(quotFileName.length() + 1); + fileNamesData.cbData = long((quotFileName.length() + 1) * sizeof(wchar_t)); - ::SendMessage(hNotepad_plus, WM_COPYDATA, (WPARAM)hInstance, (LPARAM)¶mData); - ::SendMessage(hNotepad_plus, WM_COPYDATA, (WPARAM)hInstance, (LPARAM)&fileNamesData); + ::SendMessageW(hNotepad_plus, WM_COPYDATA, (WPARAM)hInstance, (LPARAM)¶mData); + ::SendMessageW(hNotepad_plus, WM_COPYDATA, (WPARAM)hInstance, (LPARAM)&fileNamesData); } return 0; } diff --git a/PowerEditor/src/xpm_icons.h b/PowerEditor/src/xpm_icons.h index 9d89be89e..aa9e65e8b 100644 --- a/PowerEditor/src/xpm_icons.h +++ b/PowerEditor/src/xpm_icons.h @@ -15,6 +15,9 @@ //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +#ifndef XPMICONS_H +#define XPMICONS_H + static char * acTop_xpm[] = { "12 12 56 1", " c #FFFFFF", @@ -238,3 +241,5 @@ static char * bookmark_xpm[] = { " r*@s(tut(s@*r ", " v*w{x&x{w*v ", " l*yyy*l "}; + +#endif //XPMICONS_H diff --git a/PowerEditor/visual.net/no_ms_shit.vsprops b/PowerEditor/visual.net/no_ms_shit.vsprops index b19234ab3..32fa5ef65 100644 --- a/PowerEditor/visual.net/no_ms_shit.vsprops +++ b/PowerEditor/visual.net/no_ms_shit.vsprops @@ -6,6 +6,6 @@ > diff --git a/PowerEditor/visual.net/notepadPlus.vcproj b/PowerEditor/visual.net/notepadPlus.vcproj index 6afba25d0..0a93cbe7b 100644 --- a/PowerEditor/visual.net/notepadPlus.vcproj +++ b/PowerEditor/visual.net/notepadPlus.vcproj @@ -157,7 +157,8 @@ /> + + @@ -614,10 +619,6 @@ RelativePath="..\src\resource.h" > - - @@ -718,6 +719,10 @@ RelativePath="..\src\WinControls\AboutDlg\URLCtrl.h" > + +