コード例 #1
0
ファイル: NppIO.cpp プロジェクト: Oldes/npp-community
void Notepad_plus::doClose(BufferID id, int whichOne)
{
	assert(_mainDocTab);
	assert(_subDocTab);
	Buffer * buf = MainFileManager->getBufferByID(id);

	// Notify plugins that current file is about to be closed
	SCNotification scnN;
	scnN.nmhdr.code = NPPN_FILEBEFORECLOSE;
	scnN.nmhdr.hwndFrom = _pPublicInterface->getHSelf();
	scnN.nmhdr.idFrom = (uptr_t)id;
	_pluginsManager->notify(&scnN);

	//add to recent files if its an existing file
	if (!buf->isUntitled() && PathFileExists(buf->getFullPathName()))
	{
		_lastRecentFileList->add(buf->getFullPathName());
	}

	int nrDocs = whichOne==MAIN_VIEW?(_mainDocTab->nbItem()):(_subDocTab->nbItem());

	//Do all the works
	removeBufferFromView(id, whichOne);
	if (nrDocs == 1 && canHideView(whichOne))
	{	//close the view if both visible
		hideView(whichOne);
	}

	// Notify plugins that current file is closed
	scnN.nmhdr.code = NPPN_FILECLOSED;
	_pluginsManager->notify(&scnN);

	return;
}
コード例 #2
0
void Notepad_plus::doClose(BufferID id, int whichOne) {
	Buffer * buf = MainFileManager->getBufferByID(id);

	// Notify plugins that current file is about to be closed
	SCNotification scnN;
	scnN.nmhdr.code = NPPN_FILEBEFORECLOSE;
	scnN.nmhdr.hwndFrom = getMainWindowHandle();
	scnN.nmhdr.idFrom = (uptr_t)id;
	_pluginsManager.notify(&scnN);

	//add to recent files if its an existing file
	if (!buf->isUntitled())
	{
		// if the file doesn't exist, it could be redirected
		// So we turn Wow64 off
		bool isWow64Off = false;
		NppParameters *pNppParam = NppParameters::getInstance();
		const TCHAR *fn = buf->getFullPathName();
		if (!PathFileExists(fn))
		{
			pNppParam->safeWow64EnableWow64FsRedirection(FALSE);
			isWow64Off = true;
		}

		if (PathFileExists(buf->getFullPathName()))
			_lastRecentFileList.add(buf->getFullPathName());

		// We enable Wow64 system, if it was disabled
		if (isWow64Off)
		{
			pNppParam->safeWow64EnableWow64FsRedirection(TRUE);
			isWow64Off = false;
		}
	}

	int nrDocs = whichOne==MAIN_VIEW?(_mainDocTab.nbItem()):(_subDocTab.nbItem());

	//Do all the works
	bool isBufRemoved = removeBufferFromView(id, whichOne);
	int hiddenBufferID = -1;
	if (nrDocs == 1 && canHideView(whichOne))
	{	//close the view if both visible
		hideView(whichOne);

		// if the current activated buffer is in this view, 
		// then get buffer ID to remove the entry from File Switcher Pannel
		hiddenBufferID = ::SendMessage(getMainWindowHandle(), NPPM_GETBUFFERIDFROMPOS, 0, whichOne);
	}

	// Notify plugins that current file is closed
	if (isBufRemoved)
	{
		scnN.nmhdr.code = NPPN_FILECLOSED;
		_pluginsManager.notify(&scnN);

		// The document could be clonned.
		// if the same buffer ID is not found then remove the entry from File Switcher Pannel
		if (_pFileSwitcherPanel)
		{
			//int posInfo = ::SendMessage(getMainWindowHandle(), NPPM_GETPOSFROMBUFFERID, (WPARAM)id ,0);
				
			_pFileSwitcherPanel->closeItem((int)id, whichOne);

			if (hiddenBufferID != -1)
				_pFileSwitcherPanel->closeItem((int)hiddenBufferID, whichOne);
		}
	}
	return;
}