[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
This commit is contained in:
donho 2009-03-06 00:53:28 +00:00
parent b006afab7d
commit 849ebb417d
2 changed files with 48 additions and 53 deletions

View File

@ -305,8 +305,6 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLine, CmdL
getMatchedFileNames(localizationDir.c_str(), patterns, fileNames, false, false); getMatchedFileNames(localizationDir.c_str(), patterns, fileNames, false, false);
for (size_t i = 0 ; i < fileNames.size() ; i++) for (size_t i = 0 ; i < fileNames.size() ; i++)
{ {
//wchar_t fullpath[MAX_PATH];
//lstrcpyW(fn, localizationDir[i]);
localizationSwitcher.addLanguageFromXml(fileNames[i].c_str()); localizationSwitcher.addLanguageFromXml(fileNames[i].c_str());
} }
#endif #endif
@ -737,6 +735,26 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly)
return buffer; return buffer;
} }
else else
{
if (::PathIsDirectory(fileName))
{
//::MessageBox(_hSelf, fileName, TEXT("Dir"), MB_OK);
vector<generic_string> fileNames;
vector<wstring> 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]; TCHAR msg[MAX_PATH + 100];
lstrcpy(msg, TEXT("Can not open file \"")); lstrcpy(msg, TEXT("Can not open file \""));
@ -745,6 +763,7 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly)
lstrcat(msg, TEXT("\".")); lstrcat(msg, TEXT("\"."));
::MessageBox(_hSelf, msg, TEXT("ERR"), MB_OK); ::MessageBox(_hSelf, msg, TEXT("ERR"), MB_OK);
_isFileOpening = false; _isFileOpening = false;
}
return BUFFER_INVALID; return BUFFER_INVALID;
} }
} }
@ -1184,28 +1203,7 @@ bool Notepad_plus::fileRename(BufferID id, int curView)
} }
return false; 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) 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 : case NPPM_GETCURRENTWORD :
{ {
const int strSize = MAX_PATH*4; const int strSize = MAX_PATH*8;
TCHAR str[strSize]; TCHAR str[strSize];
_pEditView->getGenericSelectedText((TCHAR *)str, strSize); _pEditView->getGenericSelectedText((TCHAR *)str, strSize);

View File

@ -186,14 +186,12 @@ void Utf8_16_Read::determineEncoding()
m_eEncoding = uni8Bit; m_eEncoding = uni8Bit;
m_nSkip = 0; m_nSkip = 0;
if (m_nLen > 1) if (m_nLen > 1 && m_pBuf[0] == k_Boms[uni16BE][0] && m_pBuf[1] == k_Boms[uni16BE][1])
{
if (m_pBuf[0] == k_Boms[uni16BE][0] && m_pBuf[1] == k_Boms[uni16BE][1])
{ {
m_eEncoding = uni16BE; m_eEncoding = uni16BE;
m_nSkip = 2; m_nSkip = 2;
} }
else if (m_pBuf[0] == k_Boms[uni16LE][0] && m_pBuf[1] == k_Boms[uni16LE][1]) else if (m_nLen > 1 && m_pBuf[0] == k_Boms[uni16LE][0] && m_pBuf[1] == k_Boms[uni16LE][1])
{ {
m_eEncoding = uni16LE; m_eEncoding = uni16LE;
m_nSkip = 2; m_nSkip = 2;
@ -216,7 +214,6 @@ void Utf8_16_Read::determineEncoding()
m_nSkip = 0; m_nSkip = 0;
} }
} }
}
// ================================================================== // ==================================================================