diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index 34407a3b..f6d8e712 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -16,6 +16,7 @@ //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //#include "Common.h" //use force include +#include #include #include #include "Common.h" @@ -375,3 +376,70 @@ std::string wstring2string(const std::wstring & rwString, UINT codepage) else return ""; } + +static TCHAR* convertFileName(TCHAR *buffer, const TCHAR *filename) +{ + TCHAR *b = buffer; + const TCHAR *p = filename; + while (*p) + { + if (*p == '&') *b++ = '&'; + *b++ = *p++; + } + *b = 0; + return buffer; +} + +TCHAR *BuildMenuFileName(TCHAR *buffer, int len, int pos, const TCHAR *filename) +{ + TCHAR cwd[MAX_PATH]; + buffer[0] = 0; + GetCurrentDirectory(_countof(cwd), cwd); + lstrcat(cwd, TEXT("\\")); + + TCHAR *itr = buffer; + TCHAR *end = buffer + len - 1; + if (pos < 9) + { + *itr++ = '&'; + *itr++ = '1' + pos; + } + else if (pos == 9) + { + *itr++ = '1'; + *itr++ = '&'; + *itr++ = '0'; + } + else + { + wsprintf(itr, TEXT("%d"), pos+1); + itr = itr + lstrlen(itr); + } + *itr++ = ':'; + *itr++ = ' '; + if (0 == generic_strnicmp(filename, cwd, lstrlen(cwd))) + { + TCHAR cnvName[MAX_PATH]; + const TCHAR *s1 = PathFindFileName(filename); + int len = lstrlen(s1); + if (len < (end-itr)) + { + lstrcpy(cnvName, s1); + } + else + { + int n = (len-3-(itr-buffer))/2; + generic_strncpy(cnvName, s1, n); + lstrcpy(cnvName+n, TEXT("...")); + lstrcat(cnvName, s1 + lstrlen(s1) - n); + } + convertFileName(itr, cnvName); + } + else + { + TCHAR cnvName[MAX_PATH*2]; + const TCHAR *s1 = convertFileName(cnvName, filename); + PathCompactPathEx(itr, filename, len - (itr-buffer), 0); + } + return buffer; +} diff --git a/PowerEditor/src/MISC/Common/Common.h b/PowerEditor/src/MISC/Common/Common.h index 3b25eb90..ec2604dc 100644 --- a/PowerEditor/src/MISC/Common/Common.h +++ b/PowerEditor/src/MISC/Common/Common.h @@ -103,6 +103,8 @@ void ScreenRectToClientRect(HWND hWnd, RECT* rect); std::wstring string2wstring(const std::string & rString, UINT codepage); std::string wstring2string(const std::wstring & rwString, UINT codepage); +TCHAR *BuildMenuFileName(TCHAR *buffer, int len, int pos, const TCHAR *filename); + class WcharMbcsConvertor { public: static WcharMbcsConvertor * getInstance() {return _pSelf;}; diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 85631312..5b05d219 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -7206,14 +7206,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa for (int i = 0 ; i < nbLRFile ; i++) { generic_string * stdStr = pNppParam->getLRFile(i); - if (nppGUI._checkHistoryFiles) - { - if (PathFileExists(stdStr->c_str())) - { - _lastRecentFileList.add(stdStr->c_str()); - } - } - else + if (!nppGUI._checkHistoryFiles || PathFileExists(stdStr->c_str())) { _lastRecentFileList.add(stdStr->c_str()); } diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp index 1ac32fb8..2eea8146 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp @@ -787,7 +787,7 @@ void WindowsMenu::initPopupMenu(HMENU hMenu, DocTabView *pTab) 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 = BuildMenuFileName(buffer, 60, pos, buf->getFileName()); mii.fState &= ~(MF_GRAYED|MF_DISABLED|MF_CHECKED); if (pos == curDoc) mii.fState |= MF_CHECKED; @@ -814,69 +814,3 @@ void WindowsMenu::uninitPopupMenu(HMENU hMenu, ScintillaEditView *pView) } } */ -static TCHAR* convertFileName(TCHAR *buffer, const TCHAR *filename) -{ - TCHAR *b = buffer; - const TCHAR *p = filename; - while (*p) - { - if (*p == '&') *b++ = '&'; - *b++ = *p++; - } - *b = 0; - return buffer; -} - -TCHAR *WindowsMenu::buildFileName(TCHAR *buffer, int len, int pos, const TCHAR *filename) -{ - TCHAR cwd[MAX_PATH]; - buffer[0] = 0; - GetCurrentDirectory(_countof(cwd), cwd); - lstrcat(cwd, TEXT("\\")); - - TCHAR *itr = buffer; - TCHAR *end = buffer + len - 1; - if (pos < 9) - { - *itr++ = '&'; - *itr++ = '1' + pos; - } - else if (pos == 9) - { - *itr++ = '1'; - *itr++ = '&'; - *itr++ = '0'; - } - else - { - wsprintf(itr, TEXT("%d"), pos+1); - itr = itr + lstrlen(itr); - } - *itr++ = ':'; - *itr++ = ' '; - if (0 == generic_strnicmp(filename, cwd, lstrlen(cwd))) - { - TCHAR cnvName[MAX_PATH]; - const TCHAR *s1 = PathFindFileName(filename); - int len = lstrlen(s1); - if (len < (end-itr)) - { - lstrcpy(cnvName, s1); - } - else - { - int n = (len-3-(itr-buffer))/2; - generic_strncpy(cnvName, s1, n); - lstrcpy(cnvName+n, TEXT("...")); - lstrcat(cnvName, s1 + lstrlen(s1) - n); - } - convertFileName(itr, cnvName); - } - else - { - TCHAR cnvName[MAX_PATH*2]; - const TCHAR *s1 = convertFileName(cnvName, filename); - PathCompactPathEx(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 1580804e..1717704c 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h @@ -106,7 +106,6 @@ public: void initPopupMenu(HMENU hMenu, DocTabView *pTab); //void uninitPopupMenu(HMENU hMenu, ScintillaEditView *pView); private: - TCHAR *buildFileName(TCHAR *buffer, int len, int pos, const TCHAR *filename); HMENU _hMenu; }; diff --git a/PowerEditor/src/lastRecentFileList.cpp b/PowerEditor/src/lastRecentFileList.cpp index 65a83afd..faeb7940 100644 --- a/PowerEditor/src/lastRecentFileList.cpp +++ b/PowerEditor/src/lastRecentFileList.cpp @@ -65,17 +65,10 @@ void LastRecentFileList::updateMenu() { ::RemoveMenu(_hMenu, _lrfl.at(i)._id, MF_BYCOMMAND); } //Then readd them, so everything stays in sync - TCHAR indexBuffer[4]; + TCHAR buffer[MAX_PATH]; for(int j = 0; j < _size; j++) { - std::generic_string menuString = TEXT(""); - if (j < 9) { //first 9 have accelerator (0 unused) - menuString += TEXT("&"); - } - wsprintf(indexBuffer, TEXT("%d"), j+1);//one based numbering - menuString += indexBuffer; - menuString += TEXT(" "); - menuString += _lrfl.at(j)._name; - ::InsertMenu(_hMenu, _posBase + j, MF_BYPOSITION, _lrfl.at(j)._id, menuString.c_str()); + BuildMenuFileName(buffer, 100, j, _lrfl.at(j)._name.c_str()); + ::InsertMenu(_hMenu, _posBase + j, MF_BYPOSITION, _lrfl.at(j)._id, buffer); } }