Code improvement for FileManager
This commit is contained in:
parent
48f83a9d0f
commit
2c764d7221
@ -219,7 +219,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
||||
_subEditView.init(_pPublicInterface->getHinst(), hwnd);
|
||||
|
||||
_fileEditView.init(_pPublicInterface->getHinst(), hwnd);
|
||||
MainFileManager->init(this, &_fileEditView); //get it up and running asap.
|
||||
MainFileManager.init(this, &_fileEditView); //get it up and running asap.
|
||||
|
||||
pNppParam->setFontList(hwnd);
|
||||
|
||||
@ -1084,7 +1084,7 @@ bool Notepad_plus::replaceInOpenedFiles() {
|
||||
{
|
||||
for (size_t i = 0, len = _mainDocTab.nbItem(); i < len ; ++i)
|
||||
{
|
||||
pBuf = MainFileManager->getBufferByID(_mainDocTab.getBufferByIndex(i));
|
||||
pBuf = MainFileManager.getBufferByID(_mainDocTab.getBufferByIndex(i));
|
||||
if (pBuf->isReadOnly())
|
||||
continue;
|
||||
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
|
||||
@ -1101,7 +1101,7 @@ bool Notepad_plus::replaceInOpenedFiles() {
|
||||
{
|
||||
for (size_t i = 0, len = _subDocTab.nbItem(); i < len; ++i)
|
||||
{
|
||||
pBuf = MainFileManager->getBufferByID(_subDocTab.getBufferByIndex(i));
|
||||
pBuf = MainFileManager.getBufferByID(_subDocTab.getBufferByIndex(i));
|
||||
if (pBuf->isReadOnly())
|
||||
continue;
|
||||
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
|
||||
@ -1543,16 +1543,16 @@ bool Notepad_plus::replaceInFiles()
|
||||
|
||||
bool closeBuf = false;
|
||||
|
||||
BufferID id = MainFileManager->getBufferFromName(fileNames.at(i).c_str());
|
||||
BufferID id = MainFileManager.getBufferFromName(fileNames.at(i).c_str());
|
||||
if (id == BUFFER_INVALID)
|
||||
{
|
||||
id = MainFileManager->loadFile(fileNames.at(i).c_str());
|
||||
id = MainFileManager.loadFile(fileNames.at(i).c_str());
|
||||
closeBuf = true;
|
||||
}
|
||||
|
||||
if (id != BUFFER_INVALID)
|
||||
{
|
||||
Buffer * pBuf = MainFileManager->getBufferByID(id);
|
||||
Buffer * pBuf = MainFileManager.getBufferByID(id);
|
||||
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
|
||||
auto cp = _invisibleEditView.execute(SCI_GETCODEPAGE);
|
||||
_invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8);
|
||||
@ -1564,11 +1564,11 @@ bool Notepad_plus::replaceInFiles()
|
||||
nbTotal += nbReplaced;
|
||||
if (nbReplaced)
|
||||
{
|
||||
MainFileManager->saveBuffer(id, pBuf->getFullPathName());
|
||||
MainFileManager.saveBuffer(id, pBuf->getFullPathName());
|
||||
}
|
||||
|
||||
if (closeBuf)
|
||||
MainFileManager->closeBuffer(id, _pEditView);
|
||||
MainFileManager.closeBuffer(id, _pEditView);
|
||||
}
|
||||
if (i == updateOnCount)
|
||||
{
|
||||
@ -1639,16 +1639,16 @@ bool Notepad_plus::findInFinderFiles(FindersInfo *findInFolderInfo)
|
||||
if (progress.isCancelled()) break;
|
||||
|
||||
bool closeBuf = false;
|
||||
BufferID id = MainFileManager->getBufferFromName(fileNames.at(i).c_str());
|
||||
BufferID id = MainFileManager.getBufferFromName(fileNames.at(i).c_str());
|
||||
if (id == BUFFER_INVALID)
|
||||
{
|
||||
id = MainFileManager->loadFile(fileNames.at(i).c_str());
|
||||
id = MainFileManager.loadFile(fileNames.at(i).c_str());
|
||||
closeBuf = true;
|
||||
}
|
||||
|
||||
if (id != BUFFER_INVALID)
|
||||
{
|
||||
Buffer * pBuf = MainFileManager->getBufferByID(id);
|
||||
Buffer * pBuf = MainFileManager.getBufferByID(id);
|
||||
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
|
||||
auto cp = _invisibleEditView.execute(SCI_GETCODEPAGE);
|
||||
_invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8);
|
||||
@ -1656,7 +1656,7 @@ bool Notepad_plus::findInFinderFiles(FindersInfo *findInFolderInfo)
|
||||
findInFolderInfo->_pFileName = fileNames.at(i).c_str();
|
||||
nbTotal += _findReplaceDlg.processAll(ProcessFindInFinder, &(findInFolderInfo->_findOption), true, findInFolderInfo);
|
||||
if (closeBuf)
|
||||
MainFileManager->closeBuffer(id, _pEditView);
|
||||
MainFileManager.closeBuffer(id, _pEditView);
|
||||
}
|
||||
if (i == updateOnCount)
|
||||
{
|
||||
@ -1724,16 +1724,16 @@ bool Notepad_plus::findInFiles()
|
||||
if (progress.isCancelled()) break;
|
||||
|
||||
bool closeBuf = false;
|
||||
BufferID id = MainFileManager->getBufferFromName(fileNames.at(i).c_str());
|
||||
BufferID id = MainFileManager.getBufferFromName(fileNames.at(i).c_str());
|
||||
if (id == BUFFER_INVALID)
|
||||
{
|
||||
id = MainFileManager->loadFile(fileNames.at(i).c_str());
|
||||
id = MainFileManager.loadFile(fileNames.at(i).c_str());
|
||||
closeBuf = true;
|
||||
}
|
||||
|
||||
if (id != BUFFER_INVALID)
|
||||
{
|
||||
Buffer * pBuf = MainFileManager->getBufferByID(id);
|
||||
Buffer * pBuf = MainFileManager.getBufferByID(id);
|
||||
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
|
||||
auto cp = _invisibleEditView.execute(SCI_GETCODEPAGE);
|
||||
_invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8);
|
||||
@ -1741,7 +1741,7 @@ bool Notepad_plus::findInFiles()
|
||||
findersInfo._pFileName = fileNames.at(i).c_str();
|
||||
nbTotal += _findReplaceDlg.processAll(ProcessFindAll, FindReplaceDlg::_env, true, &findersInfo);
|
||||
if (closeBuf)
|
||||
MainFileManager->closeBuffer(id, _pEditView);
|
||||
MainFileManager.closeBuffer(id, _pEditView);
|
||||
}
|
||||
if (i == updateOnCount)
|
||||
{
|
||||
@ -1787,7 +1787,7 @@ bool Notepad_plus::findInOpenedFiles()
|
||||
{
|
||||
for (size_t i = 0, len = _mainDocTab.nbItem(); i < len ; ++i)
|
||||
{
|
||||
pBuf = MainFileManager->getBufferByID(_mainDocTab.getBufferByIndex(i));
|
||||
pBuf = MainFileManager.getBufferByID(_mainDocTab.getBufferByIndex(i));
|
||||
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
|
||||
auto cp = _invisibleEditView.execute(SCI_GETCODEPAGE);
|
||||
_invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8);
|
||||
@ -1801,7 +1801,7 @@ bool Notepad_plus::findInOpenedFiles()
|
||||
{
|
||||
for (size_t i = 0, len2 = _subDocTab.nbItem(); i < len2 ; ++i)
|
||||
{
|
||||
pBuf = MainFileManager->getBufferByID(_subDocTab.getBufferByIndex(i));
|
||||
pBuf = MainFileManager.getBufferByID(_subDocTab.getBufferByIndex(i));
|
||||
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
|
||||
auto cp = _invisibleEditView.execute(SCI_GETCODEPAGE);
|
||||
_invisibleEditView.execute(SCI_SETCODEPAGE, pBuf->getUnicodeMode() == uni8Bit ? cp : SC_CP_UTF8);
|
||||
@ -1967,9 +1967,9 @@ void Notepad_plus::checkDocState()
|
||||
bool isFileExisting = PathFileExists(curBuf->getFullPathName()) != FALSE;
|
||||
if (!isCurrentDirty)
|
||||
{
|
||||
for (size_t i = 0; i < MainFileManager->getNbBuffers(); ++i)
|
||||
for (size_t i = 0; i < MainFileManager.getNbBuffers(); ++i)
|
||||
{
|
||||
if (MainFileManager->getBufferByIndex(i)->isDirty())
|
||||
if (MainFileManager.getBufferByIndex(i)->isDirty())
|
||||
{
|
||||
isSeveralDirty = true;
|
||||
break;
|
||||
@ -3325,7 +3325,7 @@ void Notepad_plus::dropFiles(HDROP hdrop)
|
||||
void Notepad_plus::checkModifiedDocument(bool bCheckOnlyCurrentBuffer)
|
||||
{
|
||||
//this will trigger buffer updates. If the status changes, Notepad++ will be informed and can do its magic
|
||||
MainFileManager->checkFilesystemChanges(bCheckOnlyCurrentBuffer);
|
||||
MainFileManager.checkFilesystemChanges(bCheckOnlyCurrentBuffer);
|
||||
}
|
||||
|
||||
void Notepad_plus::getMainClientRect(RECT &rc) const
|
||||
@ -3419,7 +3419,7 @@ bool Notepad_plus::canHideView(int whichOne)
|
||||
if (!bothActive())
|
||||
return false; //cannot hide only window
|
||||
DocTabView * tabToCheck = (whichOne == MAIN_VIEW)?&_mainDocTab:&_subDocTab;
|
||||
Buffer * buf = MainFileManager->getBufferByID(tabToCheck->getBufferByIndex(0));
|
||||
Buffer * buf = MainFileManager.getBufferByID(tabToCheck->getBufferByIndex(0));
|
||||
bool canHide = ((tabToCheck->nbItem() == 1) && !buf->isDirty() && buf->isUntitled());
|
||||
return canHide;
|
||||
}
|
||||
@ -3430,7 +3430,7 @@ bool Notepad_plus::isEmpty()
|
||||
|
||||
DocTabView * tabToCheck = (_mainWindowStatus & WindowMainActive) ? &_mainDocTab : &_subDocTab;
|
||||
|
||||
Buffer * buf = MainFileManager->getBufferByID(tabToCheck->getBufferByIndex(0));
|
||||
Buffer * buf = MainFileManager.getBufferByID(tabToCheck->getBufferByIndex(0));
|
||||
bool isEmpty = ((tabToCheck->nbItem() == 1) && !buf->isDirty() && buf->isUntitled());
|
||||
return isEmpty;
|
||||
}
|
||||
@ -3450,21 +3450,21 @@ void Notepad_plus::loadBufferIntoView(BufferID id, int whichOne, bool dontClose)
|
||||
if (!dontClose && tabToOpen->nbItem() == 1)
|
||||
{
|
||||
idToClose = tabToOpen->getBufferByIndex(0);
|
||||
Buffer * buf = MainFileManager->getBufferByID(idToClose);
|
||||
Buffer * buf = MainFileManager.getBufferByID(idToClose);
|
||||
if (buf->isDirty() || !buf->isUntitled())
|
||||
{
|
||||
idToClose = BUFFER_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
MainFileManager->addBufferReference(id, viewToOpen);
|
||||
MainFileManager.addBufferReference(id, viewToOpen);
|
||||
|
||||
//close clean doc. Use special logic to prevent flicker of tab showing then hiding
|
||||
if (idToClose != BUFFER_INVALID)
|
||||
{
|
||||
tabToOpen->setBuffer(0, id); //index 0 since only one open
|
||||
activateBuffer(id, whichOne); //activate. DocTab already activated but not a problem
|
||||
MainFileManager->closeBuffer(idToClose, viewToOpen); //delete the buffer
|
||||
MainFileManager.closeBuffer(idToClose, viewToOpen); //delete the buffer
|
||||
if (_pFileSwitcherPanel)
|
||||
_pFileSwitcherPanel->closeItem(idToClose, whichOne);
|
||||
}
|
||||
@ -3484,7 +3484,7 @@ bool Notepad_plus::removeBufferFromView(BufferID id, int whichOne)
|
||||
if (index == -1) //doesn't exist, done
|
||||
return false;
|
||||
|
||||
Buffer * buf = MainFileManager->getBufferByID(id);
|
||||
Buffer * buf = MainFileManager.getBufferByID(id);
|
||||
|
||||
//Cannot close doc if last and clean
|
||||
if (tabToClose->nbItem() == 1)
|
||||
@ -3500,8 +3500,8 @@ bool Notepad_plus::removeBufferFromView(BufferID id, int whichOne)
|
||||
{
|
||||
if (tabToClose->nbItem() == 1) //need alternative doc, add new one. Use special logic to prevent flicker of adding new tab then closing other
|
||||
{
|
||||
BufferID newID = MainFileManager->newEmptyDocument();
|
||||
MainFileManager->addBufferReference(newID, viewToClose);
|
||||
BufferID newID = MainFileManager.newEmptyDocument();
|
||||
MainFileManager.addBufferReference(newID, viewToClose);
|
||||
tabToClose->setBuffer(0, newID); //can safely use id 0, last (only) tab open
|
||||
activateBuffer(newID, whichOne); //activate. DocTab already activated but not a problem
|
||||
}
|
||||
@ -3528,7 +3528,7 @@ bool Notepad_plus::removeBufferFromView(BufferID id, int whichOne)
|
||||
tabToClose->deletItemAt((size_t)index);
|
||||
}
|
||||
|
||||
MainFileManager->closeBuffer(id, viewToClose);
|
||||
MainFileManager.closeBuffer(id, viewToClose);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3560,7 +3560,7 @@ int Notepad_plus::switchEditViewTo(int gid)
|
||||
if (NppParameters::getInstance()->getNppGUI().isSnapshotMode())
|
||||
{
|
||||
// Before switching off, synchronize backup file
|
||||
MainFileManager->backupCurrentBuffer();
|
||||
MainFileManager.backupCurrentBuffer();
|
||||
}
|
||||
|
||||
notifyBufferActivated(_pEditView->getCurrentBufferID(), currentView());
|
||||
@ -3615,7 +3615,7 @@ void Notepad_plus::undockUserDlg()
|
||||
void Notepad_plus::docOpenInNewInstance(FileTransferMode mode, int x, int y)
|
||||
{
|
||||
BufferID bufferID = _pEditView->getCurrentBufferID();
|
||||
Buffer * buf = MainFileManager->getBufferByID(bufferID);
|
||||
Buffer * buf = MainFileManager.getBufferByID(bufferID);
|
||||
if (buf->isUntitled() || buf->isDirty())
|
||||
return;
|
||||
|
||||
@ -3704,7 +3704,7 @@ void Notepad_plus::docGotoAnotherEditView(FileTransferMode mode)
|
||||
}
|
||||
|
||||
loadBufferIntoView(current, viewToGo);
|
||||
Buffer *buf = MainFileManager->getBufferByID(current);
|
||||
Buffer *buf = MainFileManager.getBufferByID(current);
|
||||
_pEditView->saveCurrentPos(); //allow copying of position
|
||||
buf->setPosition(buf->getPosition(_pEditView), _pNonEditView);
|
||||
_pNonEditView->restoreCurrentPos(); //set position
|
||||
@ -3723,7 +3723,7 @@ void Notepad_plus::docGotoAnotherEditView(FileTransferMode mode)
|
||||
//Close the document if we transfered the document instead of cloning it
|
||||
if (mode == TransferMove)
|
||||
{
|
||||
Buffer *buf = MainFileManager->getBufferByID(current);
|
||||
Buffer *buf = MainFileManager.getBufferByID(current);
|
||||
monitoringWasOn = buf->isMonitoringOn();
|
||||
|
||||
//just close the activate document, since thats the one we moved (no search)
|
||||
@ -3745,13 +3745,13 @@ bool Notepad_plus::activateBuffer(BufferID id, int whichOne)
|
||||
if (isSnapshotMode)
|
||||
{
|
||||
// Before switching off, synchronize backup file
|
||||
MainFileManager->backupCurrentBuffer();
|
||||
MainFileManager.backupCurrentBuffer();
|
||||
}
|
||||
Buffer * pBuf = MainFileManager->getBufferByID(id);
|
||||
Buffer * pBuf = MainFileManager.getBufferByID(id);
|
||||
bool reload = pBuf->getNeedReload();
|
||||
if (reload)
|
||||
{
|
||||
MainFileManager->reloadBuffer(id);
|
||||
MainFileManager.reloadBuffer(id);
|
||||
pBuf->setNeedReload(false);
|
||||
}
|
||||
if (whichOne == MAIN_VIEW)
|
||||
@ -4488,14 +4488,14 @@ void Notepad_plus::getTaskListInfo(TaskListInfo *tli)
|
||||
for (int i = 0 ; i < currentNbDoc ; ++i)
|
||||
{
|
||||
BufferID bufID = _pDocTab->getBufferByIndex(i);
|
||||
Buffer * b = MainFileManager->getBufferByID(bufID);
|
||||
Buffer * b = MainFileManager.getBufferByID(bufID);
|
||||
int status = b->isReadOnly()?tb_ro:(b->isDirty()?tb_unsaved:tb_saved);
|
||||
tli->_tlfsLst.push_back(TaskLstFnStatus(currentView(), i, b->getFullPathName(), status, (void *)bufID));
|
||||
}
|
||||
for (int i = 0 ; i < nonCurrentNbDoc ; ++i)
|
||||
{
|
||||
BufferID bufID = _pNonDocTab->getBufferByIndex(i);
|
||||
Buffer * b = MainFileManager->getBufferByID(bufID);
|
||||
Buffer * b = MainFileManager.getBufferByID(bufID);
|
||||
int status = b->isReadOnly()?tb_ro:(b->isDirty()?tb_unsaved:tb_saved);
|
||||
tli->_tlfsLst.push_back(TaskLstFnStatus(otherView(), i, b->getFullPathName(), status, (void *)bufID));
|
||||
}
|
||||
@ -4980,7 +4980,7 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session, bool includUntitledD
|
||||
size_t activeIndex = k == 0 ? session._activeMainIndex : session._activeSubIndex;
|
||||
vector<sessionFileInfo> *viewFiles = (vector<sessionFileInfo> *)(k == 0?&(session._mainViewFiles):&(session._subViewFiles));
|
||||
|
||||
Buffer * buf = MainFileManager->getBufferByID(bufID);
|
||||
Buffer * buf = MainFileManager.getBufferByID(bufID);
|
||||
|
||||
if (buf->isUntitled() && buf->docLength() == 0)
|
||||
continue;
|
||||
@ -5041,9 +5041,9 @@ bool Notepad_plus::dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix) {
|
||||
TCHAR savePath[MAX_PATH] = {0};
|
||||
|
||||
//rescue primary
|
||||
for (size_t i = 0; i < MainFileManager->getNbBuffers(); ++i)
|
||||
for (size_t i = 0; i < MainFileManager.getNbBuffers(); ++i)
|
||||
{
|
||||
Buffer * docbuf = MainFileManager->getBufferByIndex(i);
|
||||
Buffer * docbuf = MainFileManager.getBufferByIndex(i);
|
||||
if (!docbuf->isDirty()) //skip saved documents
|
||||
continue;
|
||||
else
|
||||
@ -5052,7 +5052,7 @@ bool Notepad_plus::dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix) {
|
||||
const TCHAR * unitext = (docbuf->getUnicodeMode() != uni8Bit)?TEXT("_utf8"):TEXT("");
|
||||
wsprintf(savePath, TEXT("%s\\%s%03d%s.dump"), outdir, fileprefix, i, unitext);
|
||||
|
||||
bool res = MainFileManager->saveBuffer(docbuf->getID(), savePath);
|
||||
bool res = MainFileManager.saveBuffer(docbuf->getID(), savePath);
|
||||
|
||||
somethingsaved |= res;
|
||||
}
|
||||
@ -5277,7 +5277,7 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask)
|
||||
|
||||
void Notepad_plus::notifyBufferActivated(BufferID bufid, int view)
|
||||
{
|
||||
Buffer * buf = MainFileManager->getBufferByID(bufid);
|
||||
Buffer * buf = MainFileManager.getBufferByID(bufid);
|
||||
buf->increaseRecentTag();
|
||||
|
||||
if (view == MAIN_VIEW)
|
||||
@ -5382,7 +5382,7 @@ std::vector<generic_string> Notepad_plus::loadCommandlineParams(const TCHAR * co
|
||||
|
||||
if (lt != L_EXTERNAL && lt < nppParams->L_END)
|
||||
{
|
||||
Buffer * pBuf = MainFileManager->getBufferByID(bufID);
|
||||
Buffer * pBuf = MainFileManager.getBufferByID(bufID);
|
||||
pBuf->setLangType(lt);
|
||||
}
|
||||
|
||||
@ -5638,7 +5638,7 @@ bool Notepad_plus::noOpenedDoc() const
|
||||
if (_pDocTab->nbItem() == 1)
|
||||
{
|
||||
BufferID buffer = _pDocTab->getBufferByIndex(0);
|
||||
Buffer * buf = MainFileManager->getBufferByID(buffer);
|
||||
Buffer * buf = MainFileManager.getBufferByID(buffer);
|
||||
if (!buf->isDirty() && buf->isUntitled())
|
||||
return true;
|
||||
}
|
||||
|
@ -58,8 +58,8 @@ struct SortTaskListPred final
|
||||
bool operator()(const TaskLstFnStatus &l, const TaskLstFnStatus &r) const {
|
||||
BufferID lID = _views[l._iView]->getBufferByIndex(l._docIndex);
|
||||
BufferID rID = _views[r._iView]->getBufferByIndex(r._docIndex);
|
||||
Buffer * bufL = MainFileManager->getBufferByID(lID);
|
||||
Buffer * bufR = MainFileManager->getBufferByID(rID);
|
||||
Buffer * bufL = MainFileManager.getBufferByID(lID);
|
||||
Buffer * bufR = MainFileManager.getBufferByID(rID);
|
||||
return bufL->getRecentTag() > bufR->getRecentTag();
|
||||
}
|
||||
};
|
||||
@ -171,9 +171,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
generic_string name{userLangName};
|
||||
|
||||
//loop through buffers and reset the language (L_USER, TEXT("")) if (L_USER, name)
|
||||
for (size_t i = 0; i < MainFileManager->getNbBuffers(); ++i)
|
||||
for (size_t i = 0; i < MainFileManager.getNbBuffers(); ++i)
|
||||
{
|
||||
Buffer* buf = MainFileManager->getBufferByIndex(i);
|
||||
Buffer* buf = MainFileManager.getBufferByIndex(i);
|
||||
if (buf->getLangType() == L_USER && name == buf->getUserDefineLangName())
|
||||
buf->setLangType(L_USER, TEXT(""));
|
||||
}
|
||||
@ -189,9 +189,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
generic_string newName{ reinterpret_cast<TCHAR *>(wParam) };
|
||||
|
||||
//loop through buffers and reset the language (L_USER, newName) if (L_USER, oldName)
|
||||
for (size_t i = 0; i < MainFileManager->getNbBuffers(); ++i)
|
||||
for (size_t i = 0; i < MainFileManager.getNbBuffers(); ++i)
|
||||
{
|
||||
Buffer* buf = MainFileManager->getBufferByIndex(i);
|
||||
Buffer* buf = MainFileManager.getBufferByIndex(i);
|
||||
if (buf->getLangType() == L_USER && oldName == buf->getUserDefineLangName())
|
||||
buf->setLangType(L_USER, newName.c_str());
|
||||
}
|
||||
@ -296,7 +296,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
if (!lParam && !wParam)
|
||||
return FALSE;
|
||||
BufferID id = (BufferID)wParam;
|
||||
Buffer * b = MainFileManager->getBufferByID(id);
|
||||
Buffer * b = MainFileManager.getBufferByID(id);
|
||||
if (b && b->getStatus() == DOC_UNNAMED) {
|
||||
b->setFileName(reinterpret_cast<const TCHAR*>(lParam));
|
||||
return TRUE;
|
||||
@ -309,7 +309,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
if (!wParam)
|
||||
return -1;
|
||||
BufferID id = (BufferID)wParam;
|
||||
Buffer * b = MainFileManager->getBufferByID(id);
|
||||
Buffer * b = MainFileManager.getBufferByID(id);
|
||||
return b->getLangType();
|
||||
}
|
||||
|
||||
@ -321,7 +321,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
return FALSE;
|
||||
|
||||
BufferID id = (BufferID)wParam;
|
||||
Buffer * b = MainFileManager->getBufferByID(id);
|
||||
Buffer * b = MainFileManager.getBufferByID(id);
|
||||
b->setLangType((LangType)lParam);
|
||||
return TRUE;
|
||||
}
|
||||
@ -331,7 +331,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
if (!wParam)
|
||||
return -1;
|
||||
BufferID id = (BufferID)wParam;
|
||||
Buffer * b = MainFileManager->getBufferByID(id);
|
||||
Buffer * b = MainFileManager.getBufferByID(id);
|
||||
return b->getUnicodeMode();
|
||||
}
|
||||
|
||||
@ -343,7 +343,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
return FALSE;
|
||||
|
||||
BufferID id = (BufferID)wParam;
|
||||
Buffer * b = MainFileManager->getBufferByID(id);
|
||||
Buffer * b = MainFileManager.getBufferByID(id);
|
||||
if (b->getStatus() != DOC_UNNAMED || b->isDirty()) //do not allow to change the encoding if the file has any content
|
||||
return FALSE;
|
||||
b->setUnicodeMode((UniMode)lParam);
|
||||
@ -355,7 +355,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
if (!wParam)
|
||||
return -1;
|
||||
BufferID id = (BufferID)wParam;
|
||||
Buffer * b = MainFileManager->getBufferByID(id);
|
||||
Buffer * b = MainFileManager.getBufferByID(id);
|
||||
return static_cast<LRESULT>(b->getEolFormat());
|
||||
}
|
||||
|
||||
@ -372,7 +372,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
}
|
||||
|
||||
BufferID id = (BufferID)wParam;
|
||||
Buffer * b = MainFileManager->getBufferByID(id);
|
||||
Buffer * b = MainFileManager.getBufferByID(id);
|
||||
b->setEolFormat(newFormat);
|
||||
return TRUE;
|
||||
}
|
||||
@ -407,7 +407,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
|
||||
case NPPM_RELOADFILE:
|
||||
{
|
||||
BufferID id = MainFileManager->getBufferFromName(reinterpret_cast<const TCHAR *>(lParam));
|
||||
BufferID id = MainFileManager.getBufferFromName(reinterpret_cast<const TCHAR *>(lParam));
|
||||
if (id != BUFFER_INVALID)
|
||||
doReload(id, wParam != 0);
|
||||
break;
|
||||
@ -415,7 +415,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
|
||||
case NPPM_SWITCHTOFILE :
|
||||
{
|
||||
BufferID id = MainFileManager->getBufferFromName(reinterpret_cast<const TCHAR *>(lParam));
|
||||
BufferID id = MainFileManager.getBufferFromName(reinterpret_cast<const TCHAR *>(lParam));
|
||||
if (id != BUFFER_INVALID)
|
||||
return switchToFile(id);
|
||||
return false;
|
||||
@ -632,7 +632,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
{
|
||||
if (NppParameters::getInstance()->getNppGUI().isSnapshotMode())
|
||||
{
|
||||
MainFileManager->backupCurrentBuffer();
|
||||
MainFileManager.backupCurrentBuffer();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -874,7 +874,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
for (size_t i = 0; i < _mainDocTab.nbItem() && j < nbFileNames; ++i)
|
||||
{
|
||||
BufferID id = _mainDocTab.getBufferByIndex(i);
|
||||
Buffer * buf = MainFileManager->getBufferByID(id);
|
||||
Buffer * buf = MainFileManager.getBufferByID(id);
|
||||
lstrcpy(fileNames[j++], buf->getFullPathName());
|
||||
}
|
||||
}
|
||||
@ -884,7 +884,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
for (size_t i = 0; i < _subDocTab.nbItem() && j < nbFileNames; ++i)
|
||||
{
|
||||
BufferID id = _subDocTab.getBufferByIndex(i);
|
||||
Buffer * buf = MainFileManager->getBufferByID(id);
|
||||
Buffer * buf = MainFileManager.getBufferByID(id);
|
||||
lstrcpy(fileNames[j++], buf->getFullPathName());
|
||||
}
|
||||
}
|
||||
@ -1615,7 +1615,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
|
||||
case NPPM_GETFULLPATHFROMBUFFERID:
|
||||
{
|
||||
return MainFileManager->getFileNameFromBuffer(reinterpret_cast<BufferID>(wParam), reinterpret_cast<TCHAR *>(lParam));
|
||||
return MainFileManager.getFileNameFromBuffer(reinterpret_cast<BufferID>(wParam), reinterpret_cast<TCHAR *>(lParam));
|
||||
}
|
||||
|
||||
case NPPM_INTERNAL_ENABLECHECKDOCOPT:
|
||||
@ -1752,7 +1752,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
if (isSnapshotMode)
|
||||
{
|
||||
::LockWindowUpdate(hwnd);
|
||||
MainFileManager->backupCurrentBuffer();
|
||||
MainFileManager.backupCurrentBuffer();
|
||||
}
|
||||
|
||||
Session currentSession;
|
||||
|
@ -3166,7 +3166,7 @@ void Notepad_plus::command(int id)
|
||||
NppGUI & nppGUI = const_cast<NppGUI &>((NppParameters::getInstance())->getNppGUI());
|
||||
::ShowWindow(_pPublicInterface->getHSelf(), nppGUI._isMaximized?SW_MAXIMIZE:SW_SHOW);
|
||||
BufferID bufferID = _pEditView->getCurrentBufferID();
|
||||
Buffer * buf = MainFileManager->getBufferByID(bufferID);
|
||||
Buffer * buf = MainFileManager.getBufferByID(bufferID);
|
||||
if (!buf->isUntitled() || buf->docLength() != 0)
|
||||
{
|
||||
fileNew();
|
||||
|
@ -164,14 +164,14 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
|
||||
// 3. a file name with relative path to open or create
|
||||
|
||||
// Search case 1 & 2 firstly
|
||||
BufferID foundBufID = MainFileManager->getBufferFromName(fileName.c_str());
|
||||
BufferID foundBufID = MainFileManager.getBufferFromName(fileName.c_str());
|
||||
|
||||
if (foundBufID == BUFFER_INVALID)
|
||||
fileName2Find = longFileName;
|
||||
|
||||
// if case 1 & 2 not found, search case 3
|
||||
if (foundBufID == BUFFER_INVALID)
|
||||
foundBufID = MainFileManager->getBufferFromName(fileName2Find.c_str());
|
||||
foundBufID = MainFileManager.getBufferFromName(fileName2Find.c_str());
|
||||
|
||||
// If we found the document, then we don't open the existing doc. We return the found buffer ID instead.
|
||||
if (foundBufID != BUFFER_INVALID && !isSnapshotMode)
|
||||
@ -231,7 +231,7 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
|
||||
|
||||
if (res == IDYES)
|
||||
{
|
||||
bool isOK = MainFileManager->createEmptyFile(longFileName);
|
||||
bool isOK = MainFileManager.createEmptyFile(longFileName);
|
||||
if (isOK)
|
||||
{
|
||||
isCreateFileSuccessful = true;
|
||||
@ -286,7 +286,7 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
|
||||
BufferID buffer;
|
||||
if (isSnapshotMode)
|
||||
{
|
||||
buffer = MainFileManager->loadFile(longFileName, NULL, encoding, backupFileName, fileNameTimestamp);
|
||||
buffer = MainFileManager.loadFile(longFileName, NULL, encoding, backupFileName, fileNameTimestamp);
|
||||
|
||||
if (buffer != BUFFER_INVALID)
|
||||
{
|
||||
@ -306,14 +306,14 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = MainFileManager->loadFile(longFileName, NULL, encoding);
|
||||
buffer = MainFileManager.loadFile(longFileName, NULL, encoding);
|
||||
}
|
||||
|
||||
if (buffer != BUFFER_INVALID)
|
||||
{
|
||||
_isFileOpening = true;
|
||||
|
||||
Buffer * buf = MainFileManager->getBufferByID(buffer);
|
||||
Buffer * buf = MainFileManager.getBufferByID(buffer);
|
||||
|
||||
// if file is read only, we set the view read only
|
||||
if (isReadOnly)
|
||||
@ -455,11 +455,11 @@ bool Notepad_plus::doReload(BufferID id, bool alert)
|
||||
|
||||
if (!mainVisisble && !subVisisble)
|
||||
{
|
||||
return MainFileManager->reloadBufferDeferred(id);
|
||||
return MainFileManager.reloadBufferDeferred(id);
|
||||
}
|
||||
|
||||
bool res = MainFileManager->reloadBuffer(id);
|
||||
Buffer * pBuf = MainFileManager->getBufferByID(id);
|
||||
bool res = MainFileManager.reloadBuffer(id);
|
||||
Buffer * pBuf = MainFileManager.getBufferByID(id);
|
||||
if (mainVisisble)
|
||||
{
|
||||
_mainEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
|
||||
@ -480,7 +480,7 @@ bool Notepad_plus::doReload(BufferID id, bool alert)
|
||||
|
||||
bool Notepad_plus::doSave(BufferID id, const TCHAR * filename, bool isCopy)
|
||||
{
|
||||
const int index = MainFileManager->getBufferIndexByID(id);
|
||||
const int index = MainFileManager.getBufferIndexByID(id);
|
||||
if (index == -1)
|
||||
{
|
||||
_nativeLangSpeaker.messageBox("BufferInvalidWarning",
|
||||
@ -504,7 +504,7 @@ bool Notepad_plus::doSave(BufferID id, const TCHAR * filename, bool isCopy)
|
||||
}
|
||||
|
||||
generic_string error_msg;
|
||||
bool res = MainFileManager->saveBuffer(id, filename, isCopy, &error_msg);
|
||||
bool res = MainFileManager.saveBuffer(id, filename, isCopy, &error_msg);
|
||||
|
||||
if (!isCopy)
|
||||
{
|
||||
@ -567,7 +567,7 @@ bool Notepad_plus::doSave(BufferID id, const TCHAR * filename, bool isCopy)
|
||||
::GetModuleFileName(NULL, nppFullPath, MAX_PATH);
|
||||
|
||||
BufferID bufferID = _pEditView->getCurrentBufferID();
|
||||
Buffer * buf = MainFileManager->getBufferByID(bufferID);
|
||||
Buffer * buf = MainFileManager.getBufferByID(bufferID);
|
||||
|
||||
//process the fileNamePath into LRF
|
||||
generic_string fileNamePath = buf->getFullPathName();
|
||||
@ -631,9 +631,9 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup)
|
||||
((_mainWindowStatus & WindowSubActive) == WindowSubActive ? _subDocTab.nbItem() : 0);
|
||||
|
||||
if (doDeleteBackup)
|
||||
MainFileManager->deleteBufferBackup(id);
|
||||
MainFileManager.deleteBufferBackup(id);
|
||||
|
||||
Buffer * buf = MainFileManager->getBufferByID(id);
|
||||
Buffer * buf = MainFileManager.getBufferByID(id);
|
||||
|
||||
// Notify plugins that current file is about to be closed
|
||||
SCNotification scnN;
|
||||
@ -707,7 +707,7 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup)
|
||||
}
|
||||
|
||||
// Add to recent file only if file is removed and does not exist in any of the views
|
||||
BufferID buffID = MainFileManager->getBufferFromName(fileFullPath.c_str());
|
||||
BufferID buffID = MainFileManager.getBufferFromName(fileFullPath.c_str());
|
||||
if (buffID == BUFFER_INVALID && fileFullPath.length() > 0)
|
||||
_lastRecentFileList.add(fileFullPath.c_str());
|
||||
}
|
||||
@ -855,7 +855,7 @@ bool Notepad_plus::fileClose(BufferID id, int curView)
|
||||
BufferID bufferID = id;
|
||||
if (id == BUFFER_INVALID)
|
||||
bufferID = _pEditView->getCurrentBufferID();
|
||||
Buffer * buf = MainFileManager->getBufferByID(bufferID);
|
||||
Buffer * buf = MainFileManager.getBufferByID(bufferID);
|
||||
|
||||
int res;
|
||||
|
||||
@ -904,7 +904,7 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isSnapshotMode)
|
||||
for (size_t i = 0; i < _mainDocTab.nbItem() && !noSaveToAll; ++i)
|
||||
{
|
||||
BufferID id = _mainDocTab.getBufferByIndex(i);
|
||||
Buffer * buf = MainFileManager->getBufferByID(id);
|
||||
Buffer * buf = MainFileManager.getBufferByID(id);
|
||||
if (buf->isUntitled() && buf->docLength() == 0)
|
||||
{
|
||||
// Do nothing
|
||||
@ -982,7 +982,7 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isSnapshotMode)
|
||||
for (size_t i = 0; i < _subDocTab.nbItem() && !noSaveToAll; ++i)
|
||||
{
|
||||
BufferID id = _subDocTab.getBufferByIndex(i);
|
||||
Buffer * buf = MainFileManager->getBufferByID(id);
|
||||
Buffer * buf = MainFileManager.getBufferByID(id);
|
||||
if (buf->isUntitled() && buf->docLength() == 0)
|
||||
{
|
||||
// Do nothing
|
||||
@ -1087,7 +1087,7 @@ bool Notepad_plus::fileCloseAllGiven(const std::vector<int> &krvecBufferIndexes)
|
||||
for (std::vector<int>::const_iterator itIndex = krvecBufferIndexes.begin(); itIndex != itIndexesEnd; ++itIndex)
|
||||
{
|
||||
BufferID id = _pDocTab->getBufferByIndex(*itIndex);
|
||||
Buffer * buf = MainFileManager->getBufferByID(id);
|
||||
Buffer * buf = MainFileManager.getBufferByID(id);
|
||||
|
||||
if (buf->isUntitled() && buf->docLength() == 0)
|
||||
{
|
||||
@ -1182,7 +1182,7 @@ bool Notepad_plus::fileCloseAllUnchanged()
|
||||
for (int i = int(_pDocTab->nbItem()) - 1; i >= 0; i--)
|
||||
{
|
||||
BufferID id = _mainDocTab.getBufferByIndex(i);
|
||||
Buffer* buf = MainFileManager->getBufferByID(id);
|
||||
Buffer* buf = MainFileManager.getBufferByID(id);
|
||||
if ((buf->isUntitled() && buf->docLength() == 0) || !buf->isDirty())
|
||||
{
|
||||
vecIndexesToClose.push_back(i);
|
||||
@ -1208,7 +1208,7 @@ bool Notepad_plus::fileCloseAllButCurrent()
|
||||
BufferID id = _mainDocTab.getBufferByIndex(i);
|
||||
if (id == current)
|
||||
continue;
|
||||
Buffer * buf = MainFileManager->getBufferByID(id);
|
||||
Buffer * buf = MainFileManager.getBufferByID(id);
|
||||
if (buf->isUntitled() && buf->docLength() == 0)
|
||||
{
|
||||
// Do nothing
|
||||
@ -1254,7 +1254,7 @@ bool Notepad_plus::fileCloseAllButCurrent()
|
||||
for (size_t i = 0; i < _subDocTab.nbItem() && !noSaveToAll; ++i)
|
||||
{
|
||||
BufferID id = _subDocTab.getBufferByIndex(i);
|
||||
Buffer * buf = MainFileManager->getBufferByID(id);
|
||||
Buffer * buf = MainFileManager.getBufferByID(id);
|
||||
if (id == current)
|
||||
continue;
|
||||
if (buf->isUntitled() && buf->docLength() == 0)
|
||||
@ -1335,7 +1335,7 @@ bool Notepad_plus::fileSave(BufferID id)
|
||||
BufferID bufferID = id;
|
||||
if (id == BUFFER_INVALID)
|
||||
bufferID = _pEditView->getCurrentBufferID();
|
||||
Buffer * buf = MainFileManager->getBufferByID(bufferID);
|
||||
Buffer * buf = MainFileManager.getBufferByID(bufferID);
|
||||
|
||||
if (!buf->getFileReadOnly() && buf->isDirty()) //cannot save if readonly
|
||||
{
|
||||
@ -1479,7 +1479,7 @@ bool Notepad_plus::fileSaveAs(BufferID id, bool isSaveCopy)
|
||||
BufferID bufferID = id;
|
||||
if (id == BUFFER_INVALID)
|
||||
bufferID = _pEditView->getCurrentBufferID();
|
||||
Buffer * buf = MainFileManager->getBufferByID(bufferID);
|
||||
Buffer * buf = MainFileManager.getBufferByID(bufferID);
|
||||
|
||||
FileDialog fDlg(_pPublicInterface->getHSelf(), _pPublicInterface->getHinst());
|
||||
|
||||
@ -1535,7 +1535,7 @@ bool Notepad_plus::fileRename(BufferID id)
|
||||
BufferID bufferID = id;
|
||||
if (id == BUFFER_INVALID)
|
||||
bufferID = _pEditView->getCurrentBufferID();
|
||||
Buffer * buf = MainFileManager->getBufferByID(bufferID);
|
||||
Buffer * buf = MainFileManager.getBufferByID(bufferID);
|
||||
|
||||
SCNotification scnN;
|
||||
scnN.nmhdr.code = NPPN_FILEBEFORERENAME;
|
||||
@ -1556,7 +1556,7 @@ bool Notepad_plus::fileRename(BufferID id)
|
||||
TCHAR *pfn = fDlg.doSaveDlg();
|
||||
|
||||
if (pfn)
|
||||
success = MainFileManager->moveFile(bufferID, pfn);
|
||||
success = MainFileManager.moveFile(bufferID, pfn);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1588,7 +1588,7 @@ bool Notepad_plus::fileRename(BufferID id)
|
||||
|
||||
// Create new backup
|
||||
buf->setModifiedStatus(true);
|
||||
bool bRes = MainFileManager->backupCurrentBuffer();
|
||||
bool bRes = MainFileManager.backupCurrentBuffer();
|
||||
|
||||
// Delete old backup
|
||||
if (bRes)
|
||||
@ -1610,7 +1610,7 @@ bool Notepad_plus::fileDelete(BufferID id)
|
||||
if (id == BUFFER_INVALID)
|
||||
bufferID = _pEditView->getCurrentBufferID();
|
||||
|
||||
Buffer * buf = MainFileManager->getBufferByID(bufferID);
|
||||
Buffer * buf = MainFileManager.getBufferByID(bufferID);
|
||||
const TCHAR *fileNamePath = buf->getFullPathName();
|
||||
|
||||
winVer winVersion = (NppParameters::getInstance())->getWinVersion();
|
||||
@ -1629,7 +1629,7 @@ bool Notepad_plus::fileDelete(BufferID id)
|
||||
scnN.nmhdr.idFrom = (uptr_t)bufferID;
|
||||
_pluginsManager.notify(&scnN);
|
||||
|
||||
if (!MainFileManager->deleteFile(bufferID))
|
||||
if (!MainFileManager.deleteFile(bufferID))
|
||||
{
|
||||
_nativeLangSpeaker.messageBox("DeleteFileFailed",
|
||||
_pPublicInterface->getHSelf(),
|
||||
@ -1680,7 +1680,7 @@ void Notepad_plus::fileOpen()
|
||||
|
||||
void Notepad_plus::fileNew()
|
||||
{
|
||||
BufferID newBufID = MainFileManager->newEmptyDocument();
|
||||
BufferID newBufID = MainFileManager.newEmptyDocument();
|
||||
|
||||
loadBufferIntoView(newBufID, currentView(), true); //true, because we want multiple new files if possible
|
||||
activateBuffer(newBufID, currentView());
|
||||
@ -1812,7 +1812,7 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode)
|
||||
if (typeToSet == L_EXTERNAL )
|
||||
typeToSet = (LangType)(id - IDM_LANG_EXTERNAL + L_EXTERNAL);
|
||||
|
||||
Buffer *buf = MainFileManager->getBufferByID(lastOpened);
|
||||
Buffer *buf = MainFileManager.getBufferByID(lastOpened);
|
||||
|
||||
if (session._mainViewFiles[i]._foldStates.size() > 0)
|
||||
{
|
||||
@ -1921,7 +1921,7 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode)
|
||||
if (typeToSet == L_EXTERNAL )
|
||||
typeToSet = (LangType)(id - IDM_LANG_EXTERNAL + L_EXTERNAL);
|
||||
|
||||
Buffer * buf = MainFileManager->getBufferByID(lastOpened);
|
||||
Buffer * buf = MainFileManager.getBufferByID(lastOpened);
|
||||
|
||||
// Set fold states
|
||||
if (session._subViewFiles[k]._foldStates.size() > 0)
|
||||
@ -2034,8 +2034,8 @@ bool Notepad_plus::fileLoadSession(const TCHAR *fn)
|
||||
bool isEmptyNpp = false;
|
||||
if (_mainDocTab.nbItem() == 1 && _subDocTab.nbItem() == 1)
|
||||
{
|
||||
Buffer * buf1 = MainFileManager->getBufferByID(_mainDocTab.getBufferByIndex(0));
|
||||
Buffer * buf2 = MainFileManager->getBufferByID(_subDocTab.getBufferByIndex(0));
|
||||
Buffer * buf1 = MainFileManager.getBufferByID(_mainDocTab.getBufferByIndex(0));
|
||||
Buffer * buf2 = MainFileManager.getBufferByID(_subDocTab.getBufferByIndex(0));
|
||||
isEmptyNpp = (!buf1->isDirty() && buf1->isUntitled() && !buf2->isDirty() && buf2->isUntitled());
|
||||
}
|
||||
if (!isEmptyNpp && (nppGUI._multiInstSetting == multiInstOnSession || nppGUI._multiInstSetting == multiInst))
|
||||
|
@ -109,18 +109,18 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
BufferID id = BUFFER_INVALID;
|
||||
if (notification->nmhdr.hwndFrom == _invisibleEditView.getHSelf())
|
||||
{
|
||||
id = MainFileManager->getBufferFromDocument(_invisibleEditView.execute(SCI_GETDOCPOINTER));
|
||||
id = MainFileManager.getBufferFromDocument(_invisibleEditView.execute(SCI_GETDOCPOINTER));
|
||||
}
|
||||
else if (notification->nmhdr.hwndFrom == _fileEditView.getHSelf())
|
||||
{
|
||||
id = MainFileManager->getBufferFromDocument(_fileEditView.execute(SCI_GETDOCPOINTER));
|
||||
id = MainFileManager.getBufferFromDocument(_fileEditView.execute(SCI_GETDOCPOINTER));
|
||||
}
|
||||
else
|
||||
break; //wrong scintilla
|
||||
|
||||
if (id != BUFFER_INVALID)
|
||||
{
|
||||
buf = MainFileManager->getBufferByID(id);
|
||||
buf = MainFileManager.getBufferByID(id);
|
||||
}
|
||||
else
|
||||
break;
|
||||
@ -164,7 +164,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
if (pTabDocView)
|
||||
{
|
||||
BufferID id = pTabDocView->getBufferByIndex(tbHdr->_tabOrigin);
|
||||
Buffer *pBuf = MainFileManager->getBufferByID(id);
|
||||
Buffer *pBuf = MainFileManager.getBufferByID(id);
|
||||
|
||||
Buffer *currentBufMain = _mainEditView.getCurrentBuffer();
|
||||
Buffer *currentBufSub = _subEditView.getCurrentBuffer();
|
||||
@ -194,7 +194,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
if (pTabDocView)
|
||||
{
|
||||
BufferID id = pTabDocView->getBufferByIndex(tbHdr->_tabOrigin);
|
||||
Buffer *pBuf = MainFileManager->getBufferByID(id);
|
||||
Buffer *pBuf = MainFileManager.getBufferByID(id);
|
||||
|
||||
Buffer *currentBufMain = _mainEditView.getCurrentBuffer();
|
||||
Buffer *currentBufSub = _subEditView.getCurrentBuffer();
|
||||
@ -294,7 +294,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
{
|
||||
int index = _pDocTab->getCurrentTabIndex();
|
||||
BufferID bufferToClose = notifyDocTab->getBufferByIndex(index);
|
||||
Buffer * buf = MainFileManager->getBufferByID(bufferToClose);
|
||||
Buffer * buf = MainFileManager.getBufferByID(bufferToClose);
|
||||
int iView = isFromPrimary?MAIN_VIEW:SUB_VIEW;
|
||||
if (buf->isDirty())
|
||||
{
|
||||
@ -332,7 +332,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
{
|
||||
int index = tabNotification->_tabOrigin;
|
||||
BufferID bufferToClose = notifyDocTab->getBufferByIndex(index);
|
||||
Buffer * buf = MainFileManager->getBufferByID(bufferToClose);
|
||||
Buffer * buf = MainFileManager.getBufferByID(bufferToClose);
|
||||
int iView = isFromPrimary?MAIN_VIEW:SUB_VIEW;
|
||||
if (buf->isDirty())
|
||||
{
|
||||
@ -392,7 +392,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
if (isSnapshotMode)
|
||||
{
|
||||
// Before switching off, synchronize backup file
|
||||
MainFileManager->backupCurrentBuffer();
|
||||
MainFileManager.backupCurrentBuffer();
|
||||
}
|
||||
// Switch off
|
||||
switchEditViewTo(MAIN_VIEW);
|
||||
@ -403,7 +403,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
if (isSnapshotMode)
|
||||
{
|
||||
// Before switching off, synchronize backup file
|
||||
MainFileManager->backupCurrentBuffer();
|
||||
MainFileManager.backupCurrentBuffer();
|
||||
}
|
||||
// Switch off
|
||||
switchEditViewTo(SUB_VIEW);
|
||||
@ -886,7 +886,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
else if (hWin == _mainDocTab.getHSelf())
|
||||
{
|
||||
BufferID idd = _mainDocTab.getBufferByIndex(id);
|
||||
Buffer * buf = MainFileManager->getBufferByID(idd);
|
||||
Buffer * buf = MainFileManager.getBufferByID(idd);
|
||||
tipTmp = buf->getFullPathName();
|
||||
|
||||
if (tipTmp.length() >= tipMaxLen)
|
||||
@ -898,7 +898,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
else if (hWin == _subDocTab.getHSelf())
|
||||
{
|
||||
BufferID idd = _subDocTab.getBufferByIndex(id);
|
||||
Buffer * buf = MainFileManager->getBufferByID(idd);
|
||||
Buffer * buf = MainFileManager.getBufferByID(idd);
|
||||
tipTmp = buf->getFullPathName();
|
||||
|
||||
if (tipTmp.length() >= tipMaxLen)
|
||||
|
@ -106,9 +106,9 @@ public:
|
||||
bool deleteFile(BufferID id);
|
||||
bool moveFile(BufferID id, const TCHAR * newFilename);
|
||||
bool createEmptyFile(const TCHAR * path);
|
||||
static FileManager * getInstance() {
|
||||
static FileManager& getInstance() {
|
||||
static FileManager instance;
|
||||
return &instance;
|
||||
return instance;
|
||||
};
|
||||
int getFileNameFromBuffer(BufferID id, TCHAR * fn2copy);
|
||||
int docLength(Buffer * buffer) const;
|
||||
|
@ -43,7 +43,7 @@ void DocTabView::addBuffer(BufferID buffer)
|
||||
return;
|
||||
if (this->getIndexByBuffer(buffer) != -1) //no duplicates
|
||||
return;
|
||||
Buffer * buf = MainFileManager->getBufferByID(buffer);
|
||||
Buffer * buf = MainFileManager.getBufferByID(buffer);
|
||||
TCITEM tie;
|
||||
tie.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM;
|
||||
|
||||
@ -95,7 +95,7 @@ BufferID DocTabView::findBufferByName(const TCHAR * fullfilename) //-1 if not fo
|
||||
{
|
||||
::SendMessage(_hSelf, TCM_GETITEM, i, reinterpret_cast<LPARAM>(&tie));
|
||||
BufferID id = reinterpret_cast<BufferID>(tie.lParam);
|
||||
Buffer * buf = MainFileManager->getBufferByID(id);
|
||||
Buffer * buf = MainFileManager.getBufferByID(id);
|
||||
if (OrdinalIgnoreCaseCompareStrings(fullfilename, buf->getFullPathName()) == 0)
|
||||
{
|
||||
return id;
|
||||
@ -204,7 +204,7 @@ void DocTabView::setBuffer(size_t index, BufferID id)
|
||||
tie.mask = TCIF_PARAM;
|
||||
::SendMessage(_hSelf, TCM_SETITEM, index, reinterpret_cast<LPARAM>(&tie));
|
||||
|
||||
bufferUpdated(MainFileManager->getBufferByID(id), BufferChangeMask); //update tab, everything has changed
|
||||
bufferUpdated(MainFileManager.getBufferByID(id), BufferChangeMask); //update tab, everything has changed
|
||||
|
||||
::SendMessage(_hParent, WM_SIZE, 0, 0);
|
||||
}
|
||||
|
@ -1524,7 +1524,7 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
|
||||
setSpecialStyle(nfoStyle);
|
||||
execute(SCI_STYLECLEARALL);
|
||||
|
||||
Buffer * buf = MainFileManager->getBufferByID(_currentBufferID);
|
||||
Buffer * buf = MainFileManager.getBufferByID(_currentBufferID);
|
||||
|
||||
if (buf->getEncoding() != NPP_CP_DOS_437)
|
||||
{
|
||||
@ -1762,10 +1762,10 @@ BufferID ScintillaEditView::attachDefaultDoc()
|
||||
// get the doc pointer attached (by default) on the view Scintilla
|
||||
Document doc = execute(SCI_GETDOCPOINTER, 0, 0);
|
||||
execute(SCI_ADDREFDOCUMENT, 0, doc);
|
||||
BufferID id = MainFileManager->bufferFromDocument(doc, false, true);//true, true); //keep counter on 1
|
||||
Buffer * buf = MainFileManager->getBufferByID(id);
|
||||
BufferID id = MainFileManager.bufferFromDocument(doc, false, true);//true, true); //keep counter on 1
|
||||
Buffer * buf = MainFileManager.getBufferByID(id);
|
||||
|
||||
MainFileManager->addBufferReference(id, this); //add a reference. Notepad only shows the buffer in tabbar
|
||||
MainFileManager.addBufferReference(id, this); //add a reference. Notepad only shows the buffer in tabbar
|
||||
|
||||
_currentBufferID = id;
|
||||
_currentBuffer = buf;
|
||||
@ -1781,7 +1781,7 @@ void ScintillaEditView::saveCurrentPos()
|
||||
int32_t docLine = static_cast<int32_t>(execute(SCI_DOCLINEFROMVISIBLE, displayedLine)); //linenumber of the line displayed in the top
|
||||
//int offset = displayedLine - execute(SCI_VISIBLEFROMDOCLINE, docLine); //use this to calc offset of wrap. If no wrap this should be zero
|
||||
|
||||
Buffer * buf = MainFileManager->getBufferByID(_currentBufferID);
|
||||
Buffer * buf = MainFileManager.getBufferByID(_currentBufferID);
|
||||
|
||||
Position pos;
|
||||
// the correct visible line number
|
||||
@ -1797,7 +1797,7 @@ void ScintillaEditView::saveCurrentPos()
|
||||
|
||||
void ScintillaEditView::restoreCurrentPos()
|
||||
{
|
||||
Buffer * buf = MainFileManager->getBufferByID(_currentBufferID);
|
||||
Buffer * buf = MainFileManager.getBufferByID(_currentBufferID);
|
||||
Position & pos = buf->getPosition(this);
|
||||
|
||||
execute(SCI_GOTOPOS, 0); //make sure first line visible by setting caret there, will scroll to top of document
|
||||
@ -1834,7 +1834,7 @@ void ScintillaEditView::activateBuffer(BufferID buffer)
|
||||
return;
|
||||
if (buffer == _currentBuffer)
|
||||
return;
|
||||
Buffer * newBuf = MainFileManager->getBufferByID(buffer);
|
||||
Buffer * newBuf = MainFileManager.getBufferByID(buffer);
|
||||
|
||||
// before activating another document, we get the current position
|
||||
// from the Scintilla view then save it to the current document
|
||||
|
@ -159,8 +159,8 @@ struct BufferEquivalent
|
||||
{
|
||||
BufferID bid1 = _pTab->getBufferByIndex(i1);
|
||||
BufferID bid2 = _pTab->getBufferByIndex(i2);
|
||||
Buffer * b1 = MainFileManager->getBufferByID(bid1);
|
||||
Buffer * b2 = MainFileManager->getBufferByID(bid2);
|
||||
Buffer * b1 = MainFileManager.getBufferByID(bid1);
|
||||
Buffer * b2 = MainFileManager.getBufferByID(bid2);
|
||||
|
||||
if (_iColumn == 0)
|
||||
{
|
||||
@ -321,7 +321,7 @@ INT_PTR CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa
|
||||
|
||||
//const Buffer& buffer = _pView->getBufferAt(index);
|
||||
BufferID bufID = _pTab->getBufferByIndex(index);
|
||||
Buffer * buf = MainFileManager->getBufferByID(bufID);
|
||||
Buffer * buf = MainFileManager.getBufferByID(bufID);
|
||||
if (pLvdi->item.iSubItem == 0) // file name
|
||||
{
|
||||
int len = pLvdi->item.cchTextMax;
|
||||
@ -888,7 +888,7 @@ void WindowsMenu::initPopupMenu(HMENU hMenu, DocTabView *pTab)
|
||||
for (id = IDM_WINDOW_MRU_FIRST, pos = 0; id < IDM_WINDOW_MRU_FIRST + static_cast<int32_t>(nDoc); ++id, ++pos)
|
||||
{
|
||||
BufferID bufID = pTab->getBufferByIndex(pos);
|
||||
Buffer * buf = MainFileManager->getBufferByID(bufID);
|
||||
Buffer * buf = MainFileManager.getBufferByID(bufID);
|
||||
|
||||
MENUITEMINFO mii;
|
||||
memset(&mii, 0, sizeof(mii));
|
||||
|
Loading…
Reference in New Issue
Block a user