[NEW] Add NPPN_FILEBEFORELOAD and NPPN_FILELOADFAILED messages.
[BUG_FIXED] Fix New document not be switched while db clicking in Find in files result panel. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@446 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
4826c0b011
commit
91b9b03ff7
@ -329,7 +329,6 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
|
||||
// INT NPPM_GETCURRENTCOLUMN(0, 0)
|
||||
// return the caret current position column
|
||||
|
||||
|
||||
#define VAR_NOT_RECOGNIZED 0
|
||||
#define FULL_CURRENT_PATH 1
|
||||
#define CURRENT_DIRECTORY 2
|
||||
@ -416,4 +415,14 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
|
||||
// UCHAR _key;
|
||||
//};
|
||||
|
||||
#define NPPN_FILEBEFORELOAD (NPPN_FIRST + 14) // To notify plugins that the current file is about to be loaded
|
||||
//scnNotification->nmhdr.code = NPPN_FILEBEFOREOPEN;
|
||||
//scnNotification->nmhdr.hwndFrom = hwndNpp;
|
||||
//scnNotification->nmhdr.idFrom = NULL;
|
||||
|
||||
#define NPPN_FILELOADFAILED (NPPN_FIRST + 15) // To notify plugins that file open operation failed
|
||||
//scnNotification->nmhdr.code = NPPN_FILEOPENFAILED;
|
||||
//scnNotification->nmhdr.hwndFrom = hwndNpp;
|
||||
//scnNotification->nmhdr.idFrom = BufferID;
|
||||
|
||||
#endif //NOTEPAD_PLUS_MSGS_H
|
||||
|
@ -633,12 +633,26 @@ bool Notepad_plus::loadSession(Session & session)
|
||||
BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly)
|
||||
{
|
||||
TCHAR longFileName[MAX_PATH];
|
||||
|
||||
::GetFullPathName(fileName, MAX_PATH, longFileName, NULL);
|
||||
::GetLongPathName(longFileName, longFileName, MAX_PATH);
|
||||
|
||||
_lastRecentFileList.remove(longFileName);
|
||||
|
||||
BufferID test = MainFileManager->getBufferFromName(longFileName);
|
||||
const TCHAR * fileName2Find;
|
||||
generic_string gs_fileName = fileName;
|
||||
size_t res = gs_fileName.find_first_of(UNTITLED_STR);
|
||||
|
||||
if (res != string::npos && res == 0)
|
||||
{
|
||||
fileName2Find = fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName2Find = longFileName;
|
||||
}
|
||||
|
||||
BufferID test = MainFileManager->getBufferFromName(fileName2Find);
|
||||
if (test != BUFFER_INVALID)
|
||||
{
|
||||
//switchToFile(test);
|
||||
@ -655,11 +669,14 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly)
|
||||
return test;
|
||||
}
|
||||
|
||||
if (isFileSession(longFileName) && PathFileExists(longFileName)) {
|
||||
if (isFileSession(longFileName) && PathFileExists(longFileName))
|
||||
{
|
||||
fileLoadSession(longFileName);
|
||||
return BUFFER_INVALID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!PathFileExists(longFileName))
|
||||
{
|
||||
TCHAR str2display[MAX_PATH*2];
|
||||
@ -693,6 +710,14 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly)
|
||||
}
|
||||
}
|
||||
|
||||
// Notify plugins that current file is about to load
|
||||
// Plugins can should use this notification to filter SCN_MODIFIED
|
||||
SCNotification scnN;
|
||||
scnN.nmhdr.code = NPPN_FILEBEFORELOAD;
|
||||
scnN.nmhdr.hwndFrom = _hSelf;
|
||||
scnN.nmhdr.idFrom = NULL;
|
||||
_pluginsManager.notify(&scnN);
|
||||
|
||||
BufferID buffer = MainFileManager->loadFile(longFileName);
|
||||
if (buffer != BUFFER_INVALID)
|
||||
{
|
||||
@ -703,10 +728,8 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly)
|
||||
if (isReadOnly)
|
||||
buf->setUserReadOnly(true);
|
||||
|
||||
// Notify plugins that current file is just opened
|
||||
SCNotification scnN;
|
||||
// Notify plugins that current file is about to open
|
||||
scnN.nmhdr.code = NPPN_FILEBEFOREOPEN;
|
||||
scnN.nmhdr.hwndFrom = _hSelf;
|
||||
scnN.nmhdr.idFrom = (uptr_t)buffer;
|
||||
_pluginsManager.notify(&scnN);
|
||||
|
||||
@ -756,13 +779,16 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly)
|
||||
}
|
||||
else
|
||||
{
|
||||
TCHAR msg[MAX_PATH + 100];
|
||||
lstrcpy(msg, TEXT("Can not open file \""));
|
||||
//lstrcat(msg, fullPath);
|
||||
lstrcat(msg, longFileName);
|
||||
lstrcat(msg, TEXT("\"."));
|
||||
::MessageBox(_hSelf, msg, TEXT("ERR"), MB_OK);
|
||||
_isFileOpening = false;
|
||||
TCHAR msg[MAX_PATH + 100];
|
||||
lstrcpy(msg, TEXT("Can not open file \""));
|
||||
//lstrcat(msg, fullPath);
|
||||
lstrcat(msg, longFileName);
|
||||
lstrcat(msg, TEXT("\"."));
|
||||
::MessageBox(_hSelf, msg, TEXT("ERR"), MB_OK);
|
||||
_isFileOpening = false;
|
||||
|
||||
scnN.nmhdr.code = NPPN_FILELOADFAILED;
|
||||
_pluginsManager.notify(&scnN);
|
||||
}
|
||||
return BUFFER_INVALID;
|
||||
}
|
||||
|
@ -13,7 +13,6 @@
|
||||
FileManager * FileManager::_pSelf = new FileManager();
|
||||
|
||||
const int blockSize = 128 * 1024 + 4;
|
||||
const TCHAR UNTITLED_STR[] = TEXT("new ");
|
||||
|
||||
// Ordre important!! Ne le changes pas!
|
||||
//SC_EOL_CRLF (0), SC_EOL_CR (1), or SC_EOL_LF (2).
|
||||
@ -173,7 +172,6 @@ bool Buffer::checkFileState() { //returns true if the status has been changed (i
|
||||
doNotify(BufferChangeStatus | BufferChangeReadonly | BufferChangeTimestamp);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!generic_stat(_fullPathName, &buf))
|
||||
|
@ -55,6 +55,7 @@ struct HeaderLineState {
|
||||
};
|
||||
|
||||
const int userLangNameMax = 16;
|
||||
const TCHAR UNTITLED_STR[] = TEXT("new ");
|
||||
|
||||
//File manager class maintains all buffers
|
||||
class Buffer;
|
||||
|
Loading…
Reference in New Issue
Block a user