Change find in files/replace etc to use invisible view.
Also fix bug where replace in files didnt trigger save point git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@241 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
fe67fabc7c
commit
a06816432b
@ -1236,15 +1236,16 @@ bool Notepad_plus::fileCloseAllButCurrent()
|
|||||||
|
|
||||||
bool Notepad_plus::replaceAllFiles() {
|
bool Notepad_plus::replaceAllFiles() {
|
||||||
|
|
||||||
BufferID mainID = _mainEditView.getCurrentBufferID();
|
|
||||||
BufferID subID = _subEditView.getCurrentBufferID();
|
|
||||||
ScintillaEditView *pOldView = _pEditView;
|
ScintillaEditView *pOldView = _pEditView;
|
||||||
|
_pEditView = &_invisibleEditView;
|
||||||
|
Document oldDoc = _invisibleEditView.execute(SCI_GETDOCPOINTER);
|
||||||
|
Buffer * oldBuf = _invisibleEditView.getCurrentBuffer(); //for manually setting the buffer, so notifications can be handled properly
|
||||||
|
|
||||||
Buffer * pBuf = NULL;
|
Buffer * pBuf = NULL;
|
||||||
|
|
||||||
int nbTotal = 0;
|
int nbTotal = 0;
|
||||||
const bool isEntireDoc = true;
|
const bool isEntireDoc = true;
|
||||||
|
|
||||||
_pEditView = &_mainEditView;
|
|
||||||
if (_mainWindowStatus & WindowMainActive)
|
if (_mainWindowStatus & WindowMainActive)
|
||||||
{
|
{
|
||||||
for (int i = 0 ; i < _mainDocTab.nbItem() ; i++)
|
for (int i = 0 ; i < _mainDocTab.nbItem() ; i++)
|
||||||
@ -1252,18 +1253,14 @@ bool Notepad_plus::replaceAllFiles() {
|
|||||||
pBuf = MainFileManager->getBufferByID(_mainDocTab.getBufferByIndex(i));
|
pBuf = MainFileManager->getBufferByID(_mainDocTab.getBufferByIndex(i));
|
||||||
if (pBuf->isReadOnly())
|
if (pBuf->isReadOnly())
|
||||||
continue;
|
continue;
|
||||||
bool oldStyle = pBuf->getNeedsLexing();
|
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
|
||||||
pBuf->setNeedsLexing(false);
|
_invisibleEditView._currentBuffer = pBuf;
|
||||||
_mainEditView.activateBuffer(pBuf->getID());
|
_invisibleEditView.execute(SCI_BEGINUNDOACTION);
|
||||||
_mainEditView.execute(SCI_BEGINUNDOACTION);
|
|
||||||
nbTotal += _findReplaceDlg.processAll(ProcessReplaceAll, NULL, NULL, isEntireDoc, NULL);
|
nbTotal += _findReplaceDlg.processAll(ProcessReplaceAll, NULL, NULL, isEntireDoc, NULL);
|
||||||
_mainEditView.execute(SCI_ENDUNDOACTION);
|
_invisibleEditView.execute(SCI_ENDUNDOACTION);
|
||||||
pBuf->setNeedsLexing(oldStyle);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_mainEditView.activateBuffer(mainID);
|
|
||||||
|
|
||||||
_pEditView = &_subEditView;
|
|
||||||
if (_mainWindowStatus & WindowSubActive)
|
if (_mainWindowStatus & WindowSubActive)
|
||||||
{
|
{
|
||||||
for (int i = 0 ; i < _subDocTab.nbItem() ; i++)
|
for (int i = 0 ; i < _subDocTab.nbItem() ; i++)
|
||||||
@ -1271,17 +1268,16 @@ bool Notepad_plus::replaceAllFiles() {
|
|||||||
pBuf = MainFileManager->getBufferByID(_subDocTab.getBufferByIndex(i));
|
pBuf = MainFileManager->getBufferByID(_subDocTab.getBufferByIndex(i));
|
||||||
if (pBuf->isReadOnly())
|
if (pBuf->isReadOnly())
|
||||||
continue;
|
continue;
|
||||||
bool oldStyle = pBuf->getNeedsLexing();
|
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
|
||||||
pBuf->setNeedsLexing(false);
|
_invisibleEditView._currentBuffer = pBuf;
|
||||||
_subEditView.activateBuffer(pBuf->getID());
|
_invisibleEditView.execute(SCI_BEGINUNDOACTION);
|
||||||
_subEditView.execute(SCI_BEGINUNDOACTION);
|
|
||||||
nbTotal += _findReplaceDlg.processAll(ProcessReplaceAll, NULL, NULL, isEntireDoc, NULL);
|
nbTotal += _findReplaceDlg.processAll(ProcessReplaceAll, NULL, NULL, isEntireDoc, NULL);
|
||||||
_subEditView.execute(SCI_ENDUNDOACTION);
|
_invisibleEditView.execute(SCI_ENDUNDOACTION);
|
||||||
pBuf->setNeedsLexing(oldStyle);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_subEditView.activateBuffer(subID);
|
|
||||||
|
|
||||||
|
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc);
|
||||||
|
_invisibleEditView._currentBuffer = oldBuf;
|
||||||
_pEditView = pOldView;
|
_pEditView = pOldView;
|
||||||
|
|
||||||
char result[64];
|
char result[64];
|
||||||
@ -1427,7 +1423,9 @@ void Notepad_plus::getMatchedFileNames(const char *dir, const vector<string> & p
|
|||||||
bool Notepad_plus::findInFiles(bool isRecursive, bool isInHiddenDir)
|
bool Notepad_plus::findInFiles(bool isRecursive, bool isInHiddenDir)
|
||||||
{
|
{
|
||||||
int nbTotal = 0;
|
int nbTotal = 0;
|
||||||
BufferID oldBufID = _pEditView->getCurrentBufferID();
|
ScintillaEditView *pOldView = _pEditView;
|
||||||
|
_pEditView = &_invisibleEditView;
|
||||||
|
Document oldDoc = _invisibleEditView.execute(SCI_GETDOCPOINTER);
|
||||||
|
|
||||||
if (!_findReplaceDlg.isFinderEmpty())
|
if (!_findReplaceDlg.isFinderEmpty())
|
||||||
_findReplaceDlg.clearFinder();
|
_findReplaceDlg.clearFinder();
|
||||||
@ -1457,31 +1455,28 @@ bool Notepad_plus::findInFiles(bool isRecursive, bool isInHiddenDir)
|
|||||||
}
|
}
|
||||||
if (id != BUFFER_INVALID) {
|
if (id != BUFFER_INVALID) {
|
||||||
Buffer * pBuf = MainFileManager->getBufferByID(id);
|
Buffer * pBuf = MainFileManager->getBufferByID(id);
|
||||||
bool oldLex = pBuf->getNeedsLexing();
|
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
|
||||||
pBuf->setNeedsLexing(false);
|
|
||||||
MainFileManager->addBufferReference(id, _pEditView);
|
|
||||||
_pEditView->activateBuffer(id);
|
|
||||||
nbTotal += _findReplaceDlg.processAll(ProcessFindAll, NULL, NULL, true, fileNames.at(i).c_str());
|
nbTotal += _findReplaceDlg.processAll(ProcessFindAll, NULL, NULL, true, fileNames.at(i).c_str());
|
||||||
_pEditView->activateBuffer(oldBufID);
|
|
||||||
if (!dontClose)
|
if (!dontClose)
|
||||||
MainFileManager->closeBuffer(id, _pEditView);
|
MainFileManager->closeBuffer(id, _pEditView);
|
||||||
else
|
|
||||||
pBuf->setNeedsLexing(oldLex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc);
|
||||||
|
_pEditView = pOldView;
|
||||||
|
|
||||||
_findReplaceDlg.putFindResult(nbTotal);
|
_findReplaceDlg.putFindResult(nbTotal);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Notepad_plus::findInOpenedFiles() {
|
bool Notepad_plus::findInOpenedFiles() {
|
||||||
|
int nbTotal = 0;
|
||||||
BufferID mainID = _mainEditView.getCurrentBufferID();
|
|
||||||
BufferID subID = _subEditView.getCurrentBufferID();
|
|
||||||
ScintillaEditView *pOldView = _pEditView;
|
ScintillaEditView *pOldView = _pEditView;
|
||||||
|
_pEditView = &_invisibleEditView;
|
||||||
|
Document oldDoc = _invisibleEditView.execute(SCI_GETDOCPOINTER);
|
||||||
|
|
||||||
Buffer * pBuf = NULL;
|
Buffer * pBuf = NULL;
|
||||||
|
|
||||||
int nbTotal = 0;
|
|
||||||
const bool isEntireDoc = true;
|
const bool isEntireDoc = true;
|
||||||
|
|
||||||
if (!_findReplaceDlg.isFinderEmpty())
|
if (!_findReplaceDlg.isFinderEmpty())
|
||||||
@ -1489,40 +1484,27 @@ bool Notepad_plus::findInOpenedFiles() {
|
|||||||
|
|
||||||
_findReplaceDlg.setSearchWord2Finder();
|
_findReplaceDlg.setSearchWord2Finder();
|
||||||
|
|
||||||
_pEditView = &_mainEditView;
|
|
||||||
if (_mainWindowStatus & WindowMainActive)
|
if (_mainWindowStatus & WindowMainActive)
|
||||||
{
|
{
|
||||||
for (int i = 0 ; i < _mainDocTab.nbItem() ; i++)
|
for (int i = 0 ; i < _mainDocTab.nbItem() ; i++)
|
||||||
{
|
{
|
||||||
pBuf = MainFileManager->getBufferByID(_mainDocTab.getBufferByIndex(i));
|
pBuf = MainFileManager->getBufferByID(_mainDocTab.getBufferByIndex(i));
|
||||||
bool oldStyle = pBuf->getNeedsLexing();
|
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
|
||||||
pBuf->setNeedsLexing(false);
|
|
||||||
_mainEditView.activateBuffer(pBuf->getID());
|
|
||||||
_mainEditView.execute(SCI_BEGINUNDOACTION);
|
|
||||||
nbTotal += _findReplaceDlg.processAll(ProcessFindAll, NULL, NULL, isEntireDoc, pBuf->getFilePath());
|
nbTotal += _findReplaceDlg.processAll(ProcessFindAll, NULL, NULL, isEntireDoc, pBuf->getFilePath());
|
||||||
_mainEditView.execute(SCI_ENDUNDOACTION);
|
|
||||||
pBuf->setNeedsLexing(oldStyle);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_mainEditView.activateBuffer(mainID);
|
|
||||||
|
|
||||||
_pEditView = &_subEditView;
|
|
||||||
if (_mainWindowStatus & WindowSubActive)
|
if (_mainWindowStatus & WindowSubActive)
|
||||||
{
|
{
|
||||||
for (int i = 0 ; i < _subDocTab.nbItem() ; i++)
|
for (int i = 0 ; i < _subDocTab.nbItem() ; i++)
|
||||||
{
|
{
|
||||||
pBuf = MainFileManager->getBufferByID(_subDocTab.getBufferByIndex(i));
|
pBuf = MainFileManager->getBufferByID(_subDocTab.getBufferByIndex(i));
|
||||||
bool oldStyle = pBuf->getNeedsLexing();
|
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
|
||||||
pBuf->setNeedsLexing(false);
|
|
||||||
_subEditView.activateBuffer(pBuf->getID());
|
|
||||||
_subEditView.execute(SCI_BEGINUNDOACTION);
|
|
||||||
nbTotal += _findReplaceDlg.processAll(ProcessFindAll, NULL, NULL, isEntireDoc, pBuf->getFilePath());
|
nbTotal += _findReplaceDlg.processAll(ProcessFindAll, NULL, NULL, isEntireDoc, pBuf->getFilePath());
|
||||||
_subEditView.execute(SCI_ENDUNDOACTION);
|
|
||||||
pBuf->setNeedsLexing(oldStyle);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_subEditView.activateBuffer(subID);
|
|
||||||
|
|
||||||
|
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc);
|
||||||
_pEditView = pOldView;
|
_pEditView = pOldView;
|
||||||
|
|
||||||
_findReplaceDlg.putFindResult(nbTotal);
|
_findReplaceDlg.putFindResult(nbTotal);
|
||||||
@ -1726,9 +1708,14 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
buf = _mainEditView.getCurrentBuffer();
|
buf = _mainEditView.getCurrentBuffer();
|
||||||
} else if (isFromSecondary) {
|
} else if (isFromSecondary) {
|
||||||
buf = _subEditView.getCurrentBuffer();
|
buf = _subEditView.getCurrentBuffer();
|
||||||
|
} else {
|
||||||
|
//Done by invisibleEditView?
|
||||||
|
if (notification->nmhdr.hwndFrom == _invisibleEditView.getHSelf()) {
|
||||||
|
buf = _invisibleEditView.getCurrentBuffer();
|
||||||
} else {
|
} else {
|
||||||
break; //wrong scintilla
|
break; //wrong scintilla
|
||||||
}
|
}
|
||||||
|
}
|
||||||
buf->setDirty(notification->nmhdr.code == SCN_SAVEPOINTLEFT);
|
buf->setDirty(notification->nmhdr.code == SCN_SAVEPOINTLEFT);
|
||||||
break; }
|
break; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user