[NEW_FEATURE] (Author: Loreia) Add widecard capacity for command line arguments.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1192 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
fd800dcf20
commit
b63c4a0f6c
|
@ -37,201 +37,212 @@
|
||||||
|
|
||||||
BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly, int encoding)
|
BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly, int encoding)
|
||||||
{
|
{
|
||||||
NppParameters *pNppParam = NppParameters::getInstance();
|
NppParameters *pNppParam = NppParameters::getInstance();
|
||||||
TCHAR longFileName[MAX_PATH];
|
TCHAR longFileName[MAX_PATH];
|
||||||
|
|
||||||
::GetFullPathName(fileName, MAX_PATH, longFileName, NULL);
|
::GetFullPathName(fileName, MAX_PATH, longFileName, NULL);
|
||||||
::GetLongPathName(longFileName, longFileName, MAX_PATH);
|
::GetLongPathName(longFileName, longFileName, MAX_PATH);
|
||||||
|
|
||||||
_lastRecentFileList.remove(longFileName);
|
_lastRecentFileList.remove(longFileName);
|
||||||
|
|
||||||
const TCHAR * fileName2Find;
|
const TCHAR * fileName2Find;
|
||||||
generic_string gs_fileName = fileName;
|
generic_string gs_fileName = fileName;
|
||||||
size_t res = gs_fileName.find_first_of(UNTITLED_STR);
|
size_t res = gs_fileName.find_first_of(UNTITLED_STR);
|
||||||
|
|
||||||
if (res != string::npos && res == 0)
|
if (res != string::npos && res == 0)
|
||||||
{
|
{
|
||||||
fileName2Find = fileName;
|
fileName2Find = fileName;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fileName2Find = longFileName;
|
fileName2Find = longFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferID test = MainFileManager->getBufferFromName(fileName2Find);
|
BufferID test = MainFileManager->getBufferFromName(fileName2Find);
|
||||||
if (test != BUFFER_INVALID)
|
if (test != BUFFER_INVALID)
|
||||||
{
|
{
|
||||||
//switchToFile(test);
|
//switchToFile(test);
|
||||||
//Don't switch, not responsibility of doOpen, but of caller
|
//Dont switch, not responsibility of doOpen, but of caller
|
||||||
if (_pTrayIco)
|
if (_pTrayIco)
|
||||||
{
|
{
|
||||||
if (_pTrayIco->isInTray())
|
if (_pTrayIco->isInTray())
|
||||||
{
|
{
|
||||||
::ShowWindow(_pPublicInterface->getHSelf(), SW_SHOW);
|
::ShowWindow(_pPublicInterface->getHSelf(), SW_SHOW);
|
||||||
if (!_pPublicInterface->isPrelaunch())
|
if (!_pPublicInterface->isPrelaunch())
|
||||||
_pTrayIco->doTrayIcon(REMOVE);
|
_pTrayIco->doTrayIcon(REMOVE);
|
||||||
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
|
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFileSession(longFileName) && PathFileExists(longFileName))
|
if (isFileSession(longFileName) && PathFileExists(longFileName))
|
||||||
{
|
{
|
||||||
fileLoadSession(longFileName);
|
fileLoadSession(longFileName);
|
||||||
return BUFFER_INVALID;
|
return BUFFER_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isWow64Off = false;
|
bool isWow64Off = false;
|
||||||
if (!PathFileExists(longFileName))
|
if (!PathFileExists(longFileName))
|
||||||
{
|
{
|
||||||
pNppParam->safeWow64EnableWow64FsRedirection(FALSE);
|
pNppParam->safeWow64EnableWow64FsRedirection(FALSE);
|
||||||
isWow64Off = true;
|
isWow64Off = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PathFileExists(longFileName))
|
bool globbing = wcsrchr(longFileName, TCHAR('*')) || wcsrchr(longFileName, TCHAR('?'));
|
||||||
{
|
if (!PathFileExists(longFileName) && !globbing)
|
||||||
TCHAR str2display[MAX_PATH*2];
|
{
|
||||||
generic_string longFileDir(longFileName);
|
TCHAR str2display[MAX_PATH*2];
|
||||||
PathRemoveFileSpec(longFileDir);
|
generic_string longFileDir(longFileName);
|
||||||
|
PathRemoveFileSpec(longFileDir);
|
||||||
|
|
||||||
bool isCreateFileSuccessful = false;
|
bool isCreateFileSuccessful = false;
|
||||||
if (PathFileExists(longFileDir.c_str()))
|
if (PathFileExists(longFileDir.c_str()))
|
||||||
{
|
{
|
||||||
wsprintf(str2display, TEXT("%s doesn't exist. Create it?"), longFileName);
|
wsprintf(str2display, TEXT("%s doesn't exist. Create it?"), longFileName);
|
||||||
if (::MessageBox(_pPublicInterface->getHSelf(), str2display, TEXT("Create new file"), MB_YESNO) == IDYES)
|
if (::MessageBox(_pPublicInterface->getHSelf(), str2display, TEXT("Create new file"), MB_YESNO) == IDYES)
|
||||||
{
|
{
|
||||||
bool res = MainFileManager->createEmptyFile(longFileName);
|
bool res = MainFileManager->createEmptyFile(longFileName);
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
isCreateFileSuccessful = true;
|
isCreateFileSuccessful = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wsprintf(str2display, TEXT("Cannot create the file \"%s\""), longFileName);
|
wsprintf(str2display, TEXT("Cannot create the file \"%s\""), longFileName);
|
||||||
::MessageBox(_pPublicInterface->getHSelf(), str2display, TEXT("Create new file"), MB_OK);
|
::MessageBox(_pPublicInterface->getHSelf(), str2display, TEXT("Create new file"), MB_OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isCreateFileSuccessful)
|
if (!isCreateFileSuccessful)
|
||||||
{
|
{
|
||||||
if (isWow64Off)
|
if (isWow64Off)
|
||||||
{
|
{
|
||||||
pNppParam->safeWow64EnableWow64FsRedirection(TRUE);
|
pNppParam->safeWow64EnableWow64FsRedirection(TRUE);
|
||||||
isWow64Off = false;
|
isWow64Off = false;
|
||||||
}
|
}
|
||||||
return BUFFER_INVALID;
|
return BUFFER_INVALID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify plugins that current file is about to load
|
// Notify plugins that current file is about to load
|
||||||
// Plugins can should use this notification to filter SCN_MODIFIED
|
// Plugins can should use this notification to filter SCN_MODIFIED
|
||||||
SCNotification scnN;
|
SCNotification scnN;
|
||||||
scnN.nmhdr.code = NPPN_FILEBEFORELOAD;
|
scnN.nmhdr.code = NPPN_FILEBEFORELOAD;
|
||||||
scnN.nmhdr.hwndFrom = _pPublicInterface->getHSelf();
|
scnN.nmhdr.hwndFrom = _pPublicInterface->getHSelf();
|
||||||
scnN.nmhdr.idFrom = NULL;
|
scnN.nmhdr.idFrom = NULL;
|
||||||
_pluginsManager.notify(&scnN);
|
_pluginsManager.notify(&scnN);
|
||||||
|
|
||||||
if (encoding == -1)
|
if (encoding == -1)
|
||||||
{
|
{
|
||||||
encoding = getHtmlXmlEncoding(longFileName);
|
encoding = getHtmlXmlEncoding(longFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferID buffer = MainFileManager->loadFile(longFileName, NULL, encoding);
|
BufferID buffer = MainFileManager->loadFile(longFileName, NULL, encoding);
|
||||||
|
|
||||||
if (buffer != BUFFER_INVALID)
|
if (buffer != BUFFER_INVALID)
|
||||||
{
|
{
|
||||||
_isFileOpening = true;
|
_isFileOpening = true;
|
||||||
|
|
||||||
Buffer * buf = MainFileManager->getBufferByID(buffer);
|
Buffer * buf = MainFileManager->getBufferByID(buffer);
|
||||||
// if file is read only, we set the view read only
|
// if file is read only, we set the view read only
|
||||||
if (isReadOnly)
|
if (isReadOnly)
|
||||||
buf->setUserReadOnly(true);
|
buf->setUserReadOnly(true);
|
||||||
|
|
||||||
// Notify plugins that current file is about to open
|
// Notify plugins that current file is about to open
|
||||||
scnN.nmhdr.code = NPPN_FILEBEFOREOPEN;
|
scnN.nmhdr.code = NPPN_FILEBEFOREOPEN;
|
||||||
scnN.nmhdr.idFrom = (uptr_t)buffer;
|
scnN.nmhdr.idFrom = (uptr_t)buffer;
|
||||||
_pluginsManager.notify(&scnN);
|
_pluginsManager.notify(&scnN);
|
||||||
|
|
||||||
|
|
||||||
loadBufferIntoView(buffer, currentView());
|
loadBufferIntoView(buffer, currentView());
|
||||||
|
|
||||||
if (_pTrayIco)
|
if (_pTrayIco)
|
||||||
{
|
{
|
||||||
if (_pTrayIco->isInTray())
|
if (_pTrayIco->isInTray())
|
||||||
{
|
{
|
||||||
::ShowWindow(_pPublicInterface->getHSelf(), SW_SHOW);
|
::ShowWindow(_pPublicInterface->getHSelf(), SW_SHOW);
|
||||||
if (!_pPublicInterface->isPrelaunch())
|
if (!_pPublicInterface->isPrelaunch())
|
||||||
_pTrayIco->doTrayIcon(REMOVE);
|
_pTrayIco->doTrayIcon(REMOVE);
|
||||||
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
|
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PathRemoveFileSpec(longFileName);
|
||||||
|
_linkTriggered = true;
|
||||||
|
_isFileOpening = false;
|
||||||
|
|
||||||
PathRemoveFileSpec(longFileName);
|
// Notify plugins that current file is just opened
|
||||||
_linkTriggered = true;
|
scnN.nmhdr.code = NPPN_FILEOPENED;
|
||||||
_isFileOpening = false;
|
_pluginsManager.notify(&scnN);
|
||||||
|
if (_pFileSwitcherPanel)
|
||||||
|
_pFileSwitcherPanel->newItem((int)buf, currentView());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (globbing || ::PathIsDirectory(fileName))
|
||||||
|
{
|
||||||
|
vector<generic_string> fileNames;
|
||||||
|
vector<generic_string> patterns;
|
||||||
|
if (globbing)
|
||||||
|
{
|
||||||
|
const TCHAR * substring = wcsrchr(fileName, TCHAR('\\'));
|
||||||
|
size_t pos = substring - fileName;
|
||||||
|
|
||||||
// Notify plugins that current file is just opened
|
patterns.push_back(substring + 1);
|
||||||
scnN.nmhdr.code = NPPN_FILEOPENED;
|
generic_string dir(fileName, pos + 1);
|
||||||
_pluginsManager.notify(&scnN);
|
getMatchedFileNames(dir.c_str(), patterns, fileNames, true, false);
|
||||||
if (_pFileSwitcherPanel)
|
}
|
||||||
_pFileSwitcherPanel->newItem((int)buf, currentView());
|
else
|
||||||
}
|
{
|
||||||
else
|
generic_string fileNameStr = fileName;
|
||||||
{
|
if (fileName[lstrlen(fileName) - 1] != '\\')
|
||||||
if (::PathIsDirectory(fileName))
|
fileNameStr += TEXT("\\");
|
||||||
{
|
|
||||||
vector<generic_string> fileNames;
|
|
||||||
vector<generic_string> patterns;
|
|
||||||
patterns.push_back(TEXT("*.*"));
|
|
||||||
|
|
||||||
generic_string fileNameStr = fileName;
|
patterns.push_back(TEXT("*"));
|
||||||
if (fileName[lstrlen(fileName) - 1] != '\\')
|
getMatchedFileNames(fileNameStr.c_str(), patterns, fileNames, true, false);
|
||||||
fileNameStr += TEXT("\\");
|
}
|
||||||
|
|
||||||
|
bool ok2Open = true;
|
||||||
|
size_t nbFiles2Open = fileNames.size();
|
||||||
|
|
||||||
getMatchedFileNames(fileNameStr.c_str(), patterns, fileNames, true, false);
|
if (nbFiles2Open > 200)
|
||||||
size_t nbFiles2Open = fileNames.size();
|
{
|
||||||
|
ok2Open = IDYES == _nativeLangSpeaker.messageBox("NbFileToOpenImportantWarning",
|
||||||
|
_pPublicInterface->getHSelf(),
|
||||||
|
TEXT("$INT_REPLACE$ files are about to be opened.\rAre you sure to open them?"),
|
||||||
|
TEXT("Amount of files to open is too large"),
|
||||||
|
MB_YESNO|MB_APPLMODAL,
|
||||||
|
nbFiles2Open);
|
||||||
|
}
|
||||||
|
|
||||||
bool ok2Open = true;
|
if (ok2Open)
|
||||||
if (nbFiles2Open > 200)
|
{
|
||||||
{
|
for (size_t i = 0 ; i < nbFiles2Open ; ++i)
|
||||||
int answer = _nativeLangSpeaker.messageBox("NbFileToOpenImportantWarning",
|
{
|
||||||
_pPublicInterface->getHSelf(),
|
doOpen(fileNames[i].c_str());
|
||||||
TEXT("$INT_REPLACE$ files are about to be opened.\rAre you sure to open them?"),
|
}
|
||||||
TEXT("Amount of files to open is too large"),
|
}
|
||||||
MB_YESNO|MB_APPLMODAL,
|
}
|
||||||
nbFiles2Open);
|
else
|
||||||
ok2Open = answer == IDYES;
|
{
|
||||||
}
|
generic_string msg = TEXT("Can not open file \"");
|
||||||
|
msg += longFileName;
|
||||||
|
msg += TEXT("\".");
|
||||||
|
::MessageBox(_pPublicInterface->getHSelf(), msg.c_str(), TEXT("ERROR"), MB_OK);
|
||||||
|
_isFileOpening = false;
|
||||||
|
|
||||||
if (ok2Open)
|
scnN.nmhdr.code = NPPN_FILELOADFAILED;
|
||||||
{
|
_pluginsManager.notify(&scnN);
|
||||||
for (size_t i = 0 ; i < nbFiles2Open ; ++i)
|
}
|
||||||
{
|
}
|
||||||
doOpen(fileNames[i].c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
generic_string msg = TEXT("Can not open file \"");
|
|
||||||
msg += longFileName;
|
|
||||||
msg += TEXT("\".");
|
|
||||||
::MessageBox(_pPublicInterface->getHSelf(), msg.c_str(), TEXT("ERROR"), MB_OK);
|
|
||||||
_isFileOpening = false;
|
|
||||||
|
|
||||||
scnN.nmhdr.code = NPPN_FILELOADFAILED;
|
if (isWow64Off)
|
||||||
_pluginsManager.notify(&scnN);
|
{
|
||||||
}
|
pNppParam->safeWow64EnableWow64FsRedirection(TRUE);
|
||||||
}
|
isWow64Off = false;
|
||||||
|
}
|
||||||
if (isWow64Off)
|
return buffer;
|
||||||
{
|
|
||||||
pNppParam->safeWow64EnableWow64FsRedirection(TRUE);
|
|
||||||
isWow64Off = false;
|
|
||||||
}
|
|
||||||
return buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Notepad_plus::doReload(BufferID id, bool alert)
|
bool Notepad_plus::doReload(BufferID id, bool alert)
|
||||||
|
|
Loading…
Reference in New Issue