From 849ebb417d3de8ad161980f197521e4b8b05de4b Mon Sep 17 00:00:00 2001 From: donho Date: Fri, 6 Mar 2009 00:53:28 +0000 Subject: [PATCH] [NEW_FEATURE] drop (or open in dos command line) a directory in Notepad++ to open all files in the directory recursively. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@434 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 46 +++++++++++++------------- PowerEditor/src/Utf8_16.cpp | 55 +++++++++++++++----------------- 2 files changed, 48 insertions(+), 53 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 4a951108a..8a7e0953c 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -305,8 +305,6 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLine, CmdL getMatchedFileNames(localizationDir.c_str(), patterns, fileNames, false, false); for (size_t i = 0 ; i < fileNames.size() ; i++) { - //wchar_t fullpath[MAX_PATH]; - //lstrcpyW(fn, localizationDir[i]); localizationSwitcher.addLanguageFromXml(fileNames[i].c_str()); } #endif @@ -738,6 +736,26 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly) } else { + if (::PathIsDirectory(fileName)) + { + //::MessageBox(_hSelf, fileName, TEXT("Dir"), MB_OK); + vector fileNames; + vector patterns; + patterns.push_back(TEXT("*.*")); + + generic_string fileNameStr = fileName; + if (fileName[lstrlen(fileName) - 1] != '\\') + fileNameStr += TEXT("\\"); + + getMatchedFileNames(fileNameStr.c_str(), patterns, fileNames, true, false); + for (size_t i = 0 ; i < fileNames.size() ; i++) + { + //::MessageBox(_hSelf, fileNames[i].c_str(), TEXT("Dir"), MB_OK); + doOpen(fileNames[i].c_str()); + } + } + else + { TCHAR msg[MAX_PATH + 100]; lstrcpy(msg, TEXT("Can not open file \"")); //lstrcat(msg, fullPath); @@ -745,6 +763,7 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly) lstrcat(msg, TEXT("\".")); ::MessageBox(_hSelf, msg, TEXT("ERR"), MB_OK); _isFileOpening = false; + } return BUFFER_INVALID; } } @@ -1184,28 +1203,7 @@ bool Notepad_plus::fileRename(BufferID id, int curView) } return false; } -/* -bool Notepad_plus::fileDelete(BufferID id, int curView) -{ - BufferID bufferID = id; - if (id == BUFFER_INVALID) - bufferID = _pEditView->getCurrentBufferID(); - - Buffer * buf = MainFileManager->getBufferByID(bufferID); - const TCHAR *fileNamePath = buf->getFullPathName(); - if (PathFileExists(fileNamePath)) - return false; - - int res = doDeleteOrNot(fileNamePath); - if (res == IDYES && doDelete(fileNamePath)) - { - doClose(bufferID, currentView()); - return true; - } - return false; -} -*/ bool Notepad_plus::fileDelete(BufferID id, int curView) { @@ -7650,7 +7648,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_GETCURRENTWORD : { - const int strSize = MAX_PATH*4; + const int strSize = MAX_PATH*8; TCHAR str[strSize]; _pEditView->getGenericSelectedText((TCHAR *)str, strSize); diff --git a/PowerEditor/src/Utf8_16.cpp b/PowerEditor/src/Utf8_16.cpp index b0bb336b2..ad2357a30 100644 --- a/PowerEditor/src/Utf8_16.cpp +++ b/PowerEditor/src/Utf8_16.cpp @@ -186,35 +186,32 @@ void Utf8_16_Read::determineEncoding() m_eEncoding = uni8Bit; m_nSkip = 0; - if (m_nLen > 1) - { - if (m_pBuf[0] == k_Boms[uni16BE][0] && m_pBuf[1] == k_Boms[uni16BE][1]) - { - m_eEncoding = uni16BE; - m_nSkip = 2; - } - else if (m_pBuf[0] == k_Boms[uni16LE][0] && m_pBuf[1] == k_Boms[uni16LE][1]) - { - m_eEncoding = uni16LE; - m_nSkip = 2; - } - else if (m_nLen > 2 && m_pBuf[0] == k_Boms[uniUTF8][0] && - m_pBuf[1] == k_Boms[uniUTF8][1] && m_pBuf[2] == k_Boms[uniUTF8][2]) - { - m_eEncoding = uniUTF8; - m_nSkip = 3; - } - else - { - u78 detectedEncoding = utf8_7bits_8bits(); - if (detectedEncoding == utf8NoBOM) - m_eEncoding = uniCookie; - else if (detectedEncoding == ascii7bits) - m_eEncoding = uni7Bit; - else //(detectedEncoding == ascii8bits) - m_eEncoding = uni8Bit; - m_nSkip = 0; - } + if (m_nLen > 1 && m_pBuf[0] == k_Boms[uni16BE][0] && m_pBuf[1] == k_Boms[uni16BE][1]) + { + m_eEncoding = uni16BE; + m_nSkip = 2; + } + else if (m_nLen > 1 && m_pBuf[0] == k_Boms[uni16LE][0] && m_pBuf[1] == k_Boms[uni16LE][1]) + { + m_eEncoding = uni16LE; + m_nSkip = 2; + } + else if (m_nLen > 2 && m_pBuf[0] == k_Boms[uniUTF8][0] && + m_pBuf[1] == k_Boms[uniUTF8][1] && m_pBuf[2] == k_Boms[uniUTF8][2]) + { + m_eEncoding = uniUTF8; + m_nSkip = 3; + } + else + { + u78 detectedEncoding = utf8_7bits_8bits(); + if (detectedEncoding == utf8NoBOM) + m_eEncoding = uniCookie; + else if (detectedEncoding == ascii7bits) + m_eEncoding = uni7Bit; + else //(detectedEncoding == ascii8bits) + m_eEncoding = uni8Bit; + m_nSkip = 0; } }