[BUG_FIXED] Revert remember folding states between session feature for a performance issue.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1032 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2013-04-02 16:25:04 +00:00
parent 45f9d6e13b
commit f03cac6706
9 changed files with 18 additions and 617 deletions

View File

@ -4217,44 +4217,6 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session)
sfi.marks.push_back(j);
}
}
//--FLS: xSaveFoldingStateSession:
// For all but the active document in the view, the folding states have to be retrieved from the buffer.
// For the active document, the folding state has to be retrieved directly from the view!
Buffer * viewCurrentBuf = _mainEditView.getCurrentBuffer();
if (buf != viewCurrentBuf) {
std::vector<HeaderLineState> lineStateVector;
lineStateVector = buf->getHeaderLineState(&_mainEditView);
int nbLineState = lineStateVector.size();
for (int i = 0 ; i < nbLineState ; i++)
{
const HeaderLineState & hls = lineStateVector.at(i);
//-- Store, if line is contracted
if (!hls._isExpanded)
sfi.foldedLines.push_back(hls._headerLineNumber);
}
} else {
//-- Development of saving Folding State to File Edit View History
//SCI_CONTRACTEDFOLDNEXT(int lineStart)
// Search efficiently for lines that are contracted fold headers.
// This is useful when saving the user's folding when switching documents or saving folding with a file.
// The search starts at line number lineStart and continues forwards to the end of the file.
// lineStart is returned if it is a contracted fold header otherwise the next contracted fold header is returned.
// If there are no more contracted fold headers then -1 is returned.
//-- Folding state is not copied to invisible view but only accessable in original view !!
int contractedFoldHeaderLine=0;
do {
contractedFoldHeaderLine = _mainEditView.execute(SCI_CONTRACTEDFOLDNEXT, contractedFoldHeaderLine);
if (contractedFoldHeaderLine != -1) {
//-- Store contracted line
sfi.foldedLines.push_back(contractedFoldHeaderLine);
//-- Start next search with next line
contractedFoldHeaderLine++;
}
} while (contractedFoldHeaderLine != -1);
} //-- else if (buf != viewCurrentBuf) --
//-- saving sfi in session --
session._mainViewFiles.push_back(sfi);
}
@ -4287,44 +4249,6 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session)
sfi.marks.push_back(j);
}
}
//--FLS: xSaveFoldingStateSession:
// For all but the active document in the view, the folding states have to be retrieved from the buffer.
// For the active document, the folding state has to be retrieved directly from the view!
Buffer * viewCurrentBuf = _subEditView.getCurrentBuffer();
if (buf != viewCurrentBuf) {
std::vector<HeaderLineState> lineStateVector;
lineStateVector = buf->getHeaderLineState(&_subEditView);
int nbLineState = lineStateVector.size();
for (int i = 0 ; i < nbLineState ; i++)
{
const HeaderLineState & hls = lineStateVector.at(i);
//-- Store, if line is contracted
if (!hls._isExpanded)
sfi.foldedLines.push_back(hls._headerLineNumber);
}
} else {
//-- Development of saving Folding State to File Edit View History
//SCI_CONTRACTEDFOLDNEXT(int lineStart)
// Search efficiently for lines that are contracted fold headers.
// This is useful when saving the user's folding when switching documents or saving folding with a file.
// The search starts at line number lineStart and continues forwards to the end of the file.
// lineStart is returned if it is a contracted fold header otherwise the next contracted fold header is returned.
// If there are no more contracted fold headers then -1 is returned.
//-- Folding state is not copied to invisible view but only accessable in original view !!
int contractedFoldHeaderLine=0;
do {
contractedFoldHeaderLine = _subEditView.execute(SCI_CONTRACTEDFOLDNEXT, contractedFoldHeaderLine);
if (contractedFoldHeaderLine != -1) {
//-- Store contracted line
sfi.foldedLines.push_back(contractedFoldHeaderLine);
//-- Start next search with next line
contractedFoldHeaderLine++;
}
} while (contractedFoldHeaderLine != -1);
} //-- else if (buf != viewCurrentBuf) --
//-- saving sfi in session --
session._subViewFiles.push_back(sfi);
}
}
@ -5196,7 +5120,7 @@ struct Quote{
const char *_quote;
};
const int nbQuote = 112;
const int nbQuote = 114;
Quote quotes[nbQuote] = {
{"Notepad++", "Good programmers use Notepad++ to code.\nExtreme programmers use MS Word to code, in Comic Sans, center aligned."},
{"Martin Golding", "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."},
@ -5303,6 +5227,8 @@ Quote quotes[nbQuote] = {
{"Anonymous #73", "If you try and don't succeed, cheat. Repeat until caught. Then lie."},
{"Anonymous #74", "Olympics is the stupidest thing.\nPeople are so proud to be competing for their country.\nThey play their stupid song and raise some dumb flags.\nI'd love to see no flags raised, no song, no mention of country.\nOnly people."},
{"Anonymous #75", "I think therefore I am\nnot religious."},
{"Anonymous #76", "Even if being gay were a choice, so what?\nPeople choose to be assholes and they can get married."},
{"Anonymous #77", "Governments are like diapers.\nThey should be changed often, and for the same reason."},
{"Apple fan boy", "I'll buy a second iPhone 5 and buy a lot of iOS applications so that Apple will be able to buy Samsung (this shitty company) to shut it down and all the Apple haters will be forced to have an iPhone. Muhahaha..."},
{"Motherf*cker", "Thousands of my potential children died on your mother's face last night."},
{"Hustle Man", "Politicians are like sperm.\nOne in a million turn out to be an actual human being."},
@ -5832,167 +5758,3 @@ bool Notepad_plus::undoStreamComment()
//return retVal;
} //----- undoStreamComment() -------------------------------
//--FLS: xFileEditViewHistory: new function addFileToFileEditViewSession()
void Notepad_plus::addFileToFileEditViewSession(Session * pSession, const TCHAR *fileNamePath, BufferID id, int whichOne)
{
//--FLS: Adds the edit-view parameters of the current file, which is closed by fileClose()
// into the FileEditViewHistory-Session.
// (see also code from _lastRecentFileList.add(fileNamePath) and getCurrentOpenedFiles(currentSession) )
//--FLS: Use _mainViewFiles for ALL session files, even for the sub-view files, because FileEditViewHistory does not distinguish.
TCHAR strFileName[MAX_PATH];
vector<sessionFileInfo>::iterator posIt;
//-- Get Pointer to Buffer and to _EditView --
Buffer * buf = MainFileManager->getBufferByID(id);
ScintillaEditView *_pEditView= whichOne==MAIN_VIEW?(&_mainEditView):(&_subEditView);
if (!buf->isUntitled())
{
// 1.) Search throught the session list and if an entry with fileNamePath is available, delete the entry
for (size_t i = 0 ; i < pSession->_mainViewFiles.size() ; i++)
{
lstrcpy(strFileName, pSession->_mainViewFiles[i]._fileName.c_str());
if (generic_stricmp((TCHAR*)&strFileName, fileNamePath)==0) {
posIt = pSession->_mainViewFiles.begin() + i;
pSession->_mainViewFiles.erase(posIt);
}
}
// 2.) Insert the edit-view parameters at the end of the session list.
// Code stolen from getCurrentOpenedFiles(currentSession) and doClose()
_pEditView->saveCurrentPos();
pSession->_activeMainIndex = _mainDocTab.getCurrentTabIndex();
//Use _invisibleEditView to temporarily open documents to retrieve markers
Document oldDoc = _invisibleEditView.execute(SCI_GETDOCPOINTER);
generic_string languageName = getLangFromMenu(buf);
const TCHAR *langName = languageName.c_str();
sessionFileInfo sfi(buf->getFullPathName(), langName, buf->getEncoding(), buf->getPosition(_pEditView));
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, buf->getDocument());
int maxLine = _invisibleEditView.execute(SCI_GETLINECOUNT);
for (int j = 0 ; j < maxLine ; j++)
{
if ((_invisibleEditView.execute(SCI_MARKERGET, j)&(1 << MARK_BOOKMARK)) != 0)
{
sfi.marks.push_back(j);
}
}
//--FLS: xSaveFoldingStateSession:
//-- Development of saving Folding State to File Edit View History
//SCI_CONTRACTEDFOLDNEXT(int lineStart)
// Search efficiently for lines that are contracted fold headers.
// This is useful when saving the user's folding when switching documents or saving folding with a file.
// The search starts at line number lineStart and continues forwards to the end of the file.
// lineStart is returned if it is a contracted fold header otherwise the next contracted fold header is returned.
// If there are no more contracted fold headers then -1 is returned.
//-- Folding state is not copied to invisible view but only accessable in original view !!
int contractedFoldHeaderLine=0;
do {
contractedFoldHeaderLine = _pEditView->execute(SCI_CONTRACTEDFOLDNEXT, contractedFoldHeaderLine);
if (contractedFoldHeaderLine != -1) {
//-- Store contracted line
sfi.foldedLines.push_back(contractedFoldHeaderLine);
//-- Start next search with next line
contractedFoldHeaderLine++;
}
} while (contractedFoldHeaderLine != -1);
//-- saving sfi in session --
pSession->_mainViewFiles.push_back(sfi);
//--FLS: Restore original saved document to invisibleEditView
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc);
} //-- if(!buf->isUntitled() )
} //-- addFileToFileEditViewSession() -----------------
//--FLS: xFileEditViewHistory: new function restoreFileEditView()
void Notepad_plus::restoreFileEditView(const TCHAR *longFileName, BufferID buffer)
{
//--FLS: FileEditViewHistory: restores edit-view settings (cursor position, marks, etc.) of files
// as they were when the file was closes the last time.
//--FLS: Use _mainViewFiles for ALL session files, even for the sub-view files, because FileEditViewHistory does not distinguish.
//-- Code partly stolen from loadSession() in NppIO.cpp
std::vector<HeaderLineState> lineStateVector;
//--Check, if FileEditViewHistoryRestore is Enabled
if ((NppParameters::getInstance())->getFileEditViewHistoryRestoreEnabled()) {
//--FLS: Save current view-Position and folding of current document into document buffer --
// Necessary to avoid drawback when doing SCI_SETDOCPOINTER below, because apparently SCI changes the SCI view-position
// and un-folds all foldings in some cases when applying SCI_SETDOCPOINTER!
// (see ScintillaEditView::activateBuffer()! )
_pEditView->saveCurrentPos();
//--FLS: get foldStateInfo of current doc and put the state into the buffer
_pEditView->getCurrentFoldStates(lineStateVector);
_pEditView->getCurrentBuffer()->setHeaderLineState(lineStateVector, _pEditView);
//--FLS: Restores the file edit-view (line position, window position, marks) of currently loaded file, if in FileEditViewSession list.
//--FLS: code stolen from init:..if (nppGUI._rememberLastSession)
Session lastSession = *(NppParameters::getInstance())->getPtrFileEditViewSession(); // _lastFileEditViewSession
for (size_t i = 0 ; i < lastSession._mainViewFiles.size() ; i++)
{
const TCHAR *pFn = lastSession._mainViewFiles[i]._fileName.c_str();
//-- searches through the list of FileEditViewSession for the recent FileName and restores the edit-view if found.
int res = generic_stricmp(longFileName,pFn);
if (res==0)
{
//--FLS: Compare restore actions with restore actions in loadSession() in NppIO.cpp - if (lastOpened)-case.!!
//showView(currentView()); //--- not needed, because view is not changed!
const TCHAR *pLn = lastSession._mainViewFiles[i]._langName.c_str();
int id = getLangFromMenuName(pLn);
LangType typeToSet = L_TEXT;
if (id != 0 && id != IDM_LANG_USER)
typeToSet = menuID2LangType(id);
if (typeToSet == L_EXTERNAL )
typeToSet = (LangType)(id - IDM_LANG_EXTERNAL + L_EXTERNAL);
Buffer * buf = MainFileManager->getBufferByID(buffer);
buf->setPosition(lastSession._mainViewFiles[i], _pEditView);
buf->setLangType(typeToSet, pLn);
if (lastSession._mainViewFiles[i]._encoding != -1)
buf->setEncoding(lastSession._mainViewFiles[i]._encoding);
//Force in the document so we can add the markers
//Dont use default methods because of performance
Document prevDoc = _pEditView->execute(SCI_GETDOCPOINTER);
_pEditView->execute(SCI_SETDOCPOINTER, 0, buf->getDocument());
for (size_t j = 0 ; j < lastSession._mainViewFiles[i].marks.size() ; j++)
{
_pEditView->execute(SCI_MARKERADD, lastSession._mainViewFiles[i].marks[j], MARK_BOOKMARK);
}
//--FLS: xSaveFoldingStateSession: restore fold levels
//- Bookmarks, selection marks and style marks are valid for a document in SCI (equal in all views of the same document in SCI)
//- But "folding" is a property of a view and not a document (different for the same document in two views)!
// So, if changing documents with SCI_SETDOCPOINTER, SCI un-folds all foldings!!
//- Therefore, the lexer needs first to do its work! But the lexer is not set at this stage (only for the first document replacing "new x" dummy document).
//- Set document language type and request lexter to style the document.
_pEditView->defineDocType(buf->getLangType());
_pEditView->execute(SCI_COLOURISE, 0, -1); // request the lexer to style the document.
for (size_t j = 0 ; j < lastSession._mainViewFiles[i].foldedLines.size() ; j++)
{
//-- Pre-Condition is that after file is opened NO lines are folded,
// but the Lexer has already styled the document so that the Folding-Header lines exist!!
_pEditView->execute(SCI_TOGGLEFOLD, lastSession._mainViewFiles[i].foldedLines[j]);
}
//-- Write folding state info also into current buffer for activation later in current view.
// get foldStateInfo of current doc
std::vector<HeaderLineState> lineStateVector;
_pEditView->getCurrentFoldStates(lineStateVector);
// put the state into the future ex buffer
buf->setHeaderLineState(lineStateVector, _pEditView);
//-- switch back the SCI-Buffer to the buffer of the current edit view.
_pEditView->execute(SCI_SETDOCPOINTER, 0, prevDoc);
} //-- if (res==0), when a File to restore EditView was found --
}
//--FLS: Restore saved view-Position and folding of original document from document buffer --
lineStateVector = _pEditView->getCurrentBuffer()->getHeaderLineState(_pEditView);
_pEditView->syncFoldStateWith(lineStateVector);
_pEditView->restoreCurrentPos();
}
return;
} //--restoreFileEditView()

View File

@ -219,8 +219,7 @@ public:
// fileOperations
//The doXXX functions apply to a single buffer and dont need to worry about views, with the excpetion of doClose, since closing one view doesnt have to mean the document is gone
//--FLS: xFileEditViewHistory: doOpen(fileName, isReadOnly, encoding) replaced by doOpen(fileName, isReadOnly, encoding, noRestoreFileEditView), due to reundancy of session-loading with RestoreFileEditView
BufferID doOpen(const TCHAR *fileName, bool isReadOnly = false, int encoding = -1, bool noRestoreFileEditView=false);
BufferID doOpen(const TCHAR *fileName, bool isReadOnly = false, int encoding = -1);
bool doReload(BufferID id, bool alert = true);
bool doSave(BufferID, const TCHAR * filename, bool isSaveCopy = false);
void doClose(BufferID, int whichOne);
@ -269,11 +268,6 @@ public:
};
void getCurrentOpenedFiles(Session & session);
//--FLS: xFileEditViewHistory: new function addFileToFileEditViewSession()
void addFileToFileEditViewSession(Session * pSession, const TCHAR *fileNamePath, BufferID id, int whichOne);
//--FLS: xFileEditViewHistory: new function declaration
void restoreFileEditView(const TCHAR *longFileName, BufferID buffer);
bool fileLoadSession(const TCHAR *fn = NULL);
const TCHAR * fileSaveSession(size_t nbFile, TCHAR ** fileNames, const TCHAR *sessionFile2save);

View File

@ -1461,9 +1461,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
saveScintillaParams(); //writeScintillaParams
saveGUIParams(); //writeGUIParams
saveProjectPanelsParams(); //writeProjectPanelsSettings
//--FLS: xFileEditViewHistory: write also FileEditViewHistory
Session lastSession = *(NppParameters::getInstance())->getPtrFileEditViewSession(); // _lastFileEditViewSession
(NppParameters::getInstance())->writeFileEditViewHistory(lastSession);
pNppParam->saveConfig_xml();

View File

@ -34,8 +34,7 @@
#include <TCHAR.h>
//--FLS: xFileEditViewHistory: Additional parameter "noRestoreFileEditView" to avoid redundancy when a session is loaded!
BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly, int encoding, bool noRestoreFileEditView)
BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly, int encoding)
{
NppParameters *pNppParam = NppParameters::getInstance();
TCHAR longFileName[MAX_PATH];
@ -167,9 +166,6 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly, int encodi
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
}
}
//--FLS: xFileEditViewHistory: File opened and now reset edit-view if file is in FileEditViewHistory and FileEditViewHistory is enabled!
if (!noRestoreFileEditView)
restoreFileEditView(longFileName, buffer);
PathRemoveFileSpec(longFileName);
_linkTriggered = true;
@ -353,10 +349,6 @@ void Notepad_plus::doClose(BufferID id, int whichOne)
if (PathFileExists(buf->getFullPathName()))
_lastRecentFileList.add(buf->getFullPathName());
//--FLS: xFileEditViewHistory: save current edit-view into list of FileEditViewHistory
Session *lastSession = (NppParameters::getInstance())->getPtrFileEditViewSession(); // returns pointer to _lastFileEditViewSession
addFileToFileEditViewSession(lastSession, buf->getFullPathName(), id, whichOne);
// We enable Wow64 system, if it was disabled
if (isWow64Off)
{
@ -1028,8 +1020,7 @@ bool Notepad_plus::loadSession(Session & session)
}
if (PathFileExists(pFn))
{
//--FLS: xFileEditViewHistory: Calling doOpen(..,noRestoreFileEditView=true), in order to suppress RestoreFileEditView() when a session is loading due to redundancy.
lastOpened = doOpen(pFn, false, session._mainViewFiles[i]._encoding, true);
lastOpened = doOpen(pFn, false, session._mainViewFiles[i]._encoding);
}
else
{
@ -1058,51 +1049,15 @@ bool Notepad_plus::loadSession(Session & session)
if (session._mainViewFiles[i]._encoding != -1)
buf->setEncoding(session._mainViewFiles[i]._encoding);
//--FLS: xSaveFoldingStateSession: The CurrentPos from the session has to be also activated
// in Scintilla document before activateBuffer() is called, because activateBuffer() saves
// CurrentPos from Scintilla document into the buffer!
// This is especially necessary for the first session file loaded into "New xx" buffer and view.
_mainEditView.restoreCurrentPos();
//--FLS: xSaveFoldingStateSession: To switch and style the new document, activateBuffer() is better than
// to do the whole buffer/view treatment manually using the low level SCI_SETDOCPOINTER approach.
// Furthermore, for some reason, the folding below does not work properly without activateBuffer().
activateBuffer(lastOpened, MAIN_VIEW);
//--FLS: xSaveFoldingStateSession: SCI_SETDOCPOINTER approach not necessary, if document is switched with activateBuffer() !!
//-- To be deleted afterwards --
//Force in the document so we can add the markers
//Dont use default methods because of performance
//Document prevDoc = _mainEditView.execute(SCI_GETDOCPOINTER);
//_mainEditView.execute(SCI_SETDOCPOINTER, 0, buf->getDocument());
//-- Add the bookmark markers.
Document prevDoc = _mainEditView.execute(SCI_GETDOCPOINTER);
_mainEditView.execute(SCI_SETDOCPOINTER, 0, buf->getDocument());
for (size_t j = 0 ; j < session._mainViewFiles[i].marks.size() ; j++)
{
_mainEditView.execute(SCI_MARKERADD, session._mainViewFiles[i].marks[j], MARK_BOOKMARK);
}
//--FLS: xSaveFoldingStateSession: Restore fold levels.
//- Bookmarks, selection marks and style marks are valid for a document in SCI (equal in all views of the same document in SCI)
//- But "folding" is a property of a view and not a document (different for the same document in two views)!
// So, if changing documents with SCI_SETDOCPOINTER, SCI un-folds all foldings!!
//- Therefore, the lexer needs first to do its work! But the lexer is not set at this stage
// (only for the first document replacing "new x" dummy document).
// So set document language type and request lexer to style the document.
//--FLS: xSaveFoldingStateSession: For some reason, the document has to be styled again here, whereas it should be already styled by activateBuffer().
// Otherwise, the folding below will not work !!??
_mainEditView.defineDocType(buf->getLangType());
//-- Following is equivalent to _mainEditView.restyleBuffer();
_mainEditView.execute(SCI_CLEARDOCUMENTSTYLE);
_mainEditView.execute(SCI_COLOURISE, 0, -1); // request the lexer to style the document.
for (size_t j = 0 ; j < session._mainViewFiles[i].foldedLines.size() ; j++)
{
//-- Pre-Condition is that after file is opened NO lines are folded,
// but the Lexer has already styled the document so that the Folding-Header lines exist!!
_mainEditView.execute(SCI_TOGGLEFOLD, session._mainViewFiles[i].foldedLines[j]);
}
//--FLS: xSaveFoldingStateSession: SCI_SETDOCPOINTER approach not necessary, if document is switched with activateBuffer() !!
//-- To be deleted afterwards --
//_mainEditView.execute(SCI_SETDOCPOINTER, 0, prevDoc);
_mainEditView.execute(SCI_SETDOCPOINTER, 0, prevDoc);
i++;
}
else
@ -1133,8 +1088,7 @@ bool Notepad_plus::loadSession(Session & session)
}
if (PathFileExists(pFn))
{
//--FLS: xFileEditViewHistory: Calling doOpen(..,noRestoreFileEditView=true), in order to suppress RestoreFileEditView() when a session is loading due to redundancy.
lastOpened = doOpen(pFn, false, session._subViewFiles[k]._encoding, true);
lastOpened = doOpen(pFn, false, session._subViewFiles[k]._encoding);
//check if already open in main. If so, clone
if (_mainDocTab.getIndexByBuffer(lastOpened) != -1) {
loadBufferIntoView(lastOpened, SUB_VIEW);
@ -1158,7 +1112,7 @@ bool Notepad_plus::loadSession(Session & session)
const TCHAR *pLn = session._subViewFiles[k]._langName.c_str();
int id = getLangFromMenuName(pLn);
LangType typeToSet = L_TEXT;
//-- FLS: Attention, handling of language-setting is different to the MAIN_VIEW code above !!??
if (id != 0)
typeToSet = menuID2LangType(id);
if (typeToSet == L_EXTERNAL )
@ -1174,41 +1128,15 @@ bool Notepad_plus::loadSession(Session & session)
buf->setLangType(typeToSet, pLn);
buf->setEncoding(session._subViewFiles[k]._encoding);
//--FLS: xSaveFoldingStateSession: Activate CurrentPos in Scintilla document.
// (for more detailed comments see at mainEditView part above)
_subEditView.restoreCurrentPos();
//--FLS: xSaveFoldingStateSession: Switch and style the new document using activateBuffer()
// (for more detailed comments see at mainEditView part above)
activateBuffer(lastOpened, SUB_VIEW);
//--FLS: xSaveFoldingStateSession: SCI_SETDOCPOINTER approach not necessary, if document is switched with activateBuffer() !!
//-- To be deleted afterwards --
//Force in the document so we can add the markers
//Dont use default methods because of performance
//Document prevDoc = _subEditView.execute(SCI_GETDOCPOINTER);
//_subEditView.execute(SCI_SETDOCPOINTER, 0, buf->getDocument());
//-- Add the bookmark markers.
Document prevDoc = _subEditView.execute(SCI_GETDOCPOINTER);
_subEditView.execute(SCI_SETDOCPOINTER, 0, buf->getDocument());
for (size_t j = 0 ; j < session._subViewFiles[k].marks.size() ; j++)
{
_subEditView.execute(SCI_MARKERADD, session._subViewFiles[k].marks[j], MARK_BOOKMARK);
}
//--FLS: xSaveFoldingStateSession: Restore fold levels
// (for more detailed comments see at mainEditView part above)
_subEditView.defineDocType(buf->getLangType());
//-- Following is equivalent to _subEditView.restyleBuffer();
_subEditView.execute(SCI_CLEARDOCUMENTSTYLE);
_subEditView.execute(SCI_COLOURISE, 0, -1); // request the lexer to style the document.
for (size_t j = 0 ; j < session._subViewFiles[k].foldedLines.size() ; j++)
{
//-- Pre-Condition is that after file is opened NO lines are folded,
// but the Lexer has already styled the document so that the Folding-Header lines exist!!
_subEditView.execute(SCI_TOGGLEFOLD, session._subViewFiles[k].foldedLines[j]);
}
//--FLS: xSaveFoldingStateSession: SCI_SETDOCPOINTER approach not necessary, if document is switched with activateBuffer() !!
//-- To be deleted afterwards --
//_subEditView.execute(SCI_SETDOCPOINTER, 0, prevDoc);
_subEditView.execute(SCI_SETDOCPOINTER, 0, prevDoc);
k++;
}
@ -1219,12 +1147,8 @@ bool Notepad_plus::loadSession(Session & session)
allSessionFilesLoaded = false;
}
}
//--FLS: xSaveFoldingStateSession: SCI_SETDOCPOINTER approach not necessary, if document is switched with activateBuffer() !!
//-- To be deleted afterwards --
//_mainEditView.restoreCurrentPos();
//_subEditView.restoreCurrentPos();
_mainEditView.restoreCurrentPos();
_subEditView.restoreCurrentPos();
if (session._activeMainIndex < (size_t)_mainDocTab.nbItem())//session.nbMainFiles())
activateBuffer(_mainDocTab.getBufferByIndex(session._activeMainIndex), MAIN_VIEW);

View File

@ -629,9 +629,7 @@ NppParameters::NppParameters() : _pXmlDoc(NULL),_pXmlUserDoc(NULL), _pXmlUserSty
_pXmlShortcutDoc(NULL), _pXmlContextMenuDocA(NULL), _pXmlSessionDoc(NULL), _pXmlBlacklistDoc(NULL),\
_nbUserLang(0), _nbExternalLang(0), _hUser32(NULL), _hUXTheme(NULL),\
_transparentFuncAddr(NULL), _enableThemeDialogTextureFuncAddr(NULL), _pNativeLangSpeaker(NULL),\
_isTaskListRBUTTONUP_Active(false), _fileSaveDlgFilterIndex(-1), _asNotepadStyle(false), _isFindReplacing(false),\
//--FLS: xFileEditViewHistory: Initialize parameter setting variables:
_nbMaxFileEditView(20), _blnFileEditViewHistoryRestoreEnabled(false)
_isTaskListRBUTTONUP_Active(false), _fileSaveDlgFilterIndex(-1), _asNotepadStyle(false), _isFindReplacing(false)
{
// init import UDL array
_nbImportedULD = 0;
@ -1249,9 +1247,6 @@ bool NppParameters::getUserParametersFromXmlTree()
//Get Find history parameters
feedFindHistoryParameters(root);
//--FLS: xFileEditViewHistory: new function feedFileEditViewHistoryParameters() to feed the parameters from config.xml
feedFileEditViewHistoryParameters(root);
//Get Project Panel parameters
feedProjectPanelsParameters(root);
@ -1659,18 +1654,6 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p
sfi.marks.push_back(lineNumber);
}
}
//--FLS: xSaveFoldingStateSession:
for (TiXmlNode *foldNode = childNode->FirstChildElement(TEXT("Fold"));
foldNode ;
foldNode = foldNode->NextSibling(TEXT("Fold")))
{
int lineNumber;
const TCHAR *lineNumberStr = (foldNode->ToElement())->Attribute(TEXT("line"), &lineNumber);
if (lineNumberStr)
{
sfi.foldedLines.push_back(lineNumber);
}
}
(*ptrSession)._mainViewFiles.push_back(sfi);
}
}
@ -1719,18 +1702,6 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p
sfi.marks.push_back(lineNumber);
}
}
//--FLS: xSaveFoldingStateSession:
for (TiXmlNode *foldNode = childNode->FirstChildElement(TEXT("Fold"));
foldNode ;
foldNode = foldNode->NextSibling(TEXT("Fold")))
{
int lineNumber;
const TCHAR *lineNumberStr = (foldNode->ToElement())->Attribute(TEXT("line"), &lineNumber);
if (lineNumberStr)
{
sfi.foldedLines.push_back(lineNumber);
}
}
(*ptrSession)._subViewFiles.push_back(sfi);
}
}
@ -2445,13 +2416,6 @@ void NppParameters::writeSession(const Session & session, const TCHAR *fileName)
TiXmlNode *markNode = fileNameNode->InsertEndChild(TiXmlElement(TEXT("Mark")));
markNode->ToElement()->SetAttribute(TEXT("line"), markLine);
}
//--FLS: xSaveFoldingStateSession:
for (size_t j = 0 ; j < session._mainViewFiles[i].foldedLines.size() ; j++)
{
size_t foldedLine = session._mainViewFiles[i].foldedLines[j];
TiXmlNode *markNode = fileNameNode->InsertEndChild(TiXmlElement(TEXT("Fold")));
markNode->ToElement()->SetAttribute(TEXT("line"), foldedLine);
}
}
TiXmlNode *subViewNode = sessionNode->InsertEndChild(TiXmlElement(TEXT("subView")));
@ -2476,13 +2440,6 @@ void NppParameters::writeSession(const Session & session, const TCHAR *fileName)
TiXmlNode *markNode = fileNameNode->InsertEndChild(TiXmlElement(TEXT("Mark")));
markNode->ToElement()->SetAttribute(TEXT("line"), markLine);
}
//--FLS: xSaveFoldingStateSession:
for (size_t j = 0 ; j < session._subViewFiles[i].foldedLines.size() ; j++)
{
size_t foldedLine = session._subViewFiles[i].foldedLines[j];
TiXmlNode *markNode = fileNameNode->InsertEndChild(TiXmlElement(TEXT("Fold")));
markNode->ToElement()->SetAttribute(TEXT("line"), foldedLine);
}
}
}
_pXmlSessionDoc->SaveFile();
@ -5531,153 +5488,3 @@ void NppParameters::safeWow64EnableWow64FsRedirection(BOOL Wow64FsEnableRedirect
}
}
//--FLS: xFileEditViewHistory: new function writeFileEditViewHistory()
void NppParameters::writeFileEditViewHistory(const Session & session)
{
//--FLS: Opens the XML-node of config.xml file and dumps the session. File is saved when notepad++ is exited.
//-- Code stolen from writeSession()
//--FLS: Use _mainViewFiles for ALL session files, even for the sub-view files, because FileEditViewHistory does not distinguish.
if (!_pXmlUserDoc) return; //otherwise, this will cause a system error!
TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild(TEXT("NotepadPlus"));
if (!nppRoot) return;
TiXmlNode *sessionNode;
sessionNode = nppRoot->FirstChildElement(TEXT("FileEditViewHistory"));
//--FLS: Erase always FileEditViewHistory node and re-insert it at the end.
if (sessionNode)
nppRoot->RemoveChild(sessionNode);
sessionNode = new TiXmlElement(TEXT("FileEditViewHistory"));
if (!sessionNode) return;
//--FLS: Write FileEditViewHistory to config.xml Document. Note: Document is only written to config.xml-file with _pXmlUserDoc->SaveFile()!
(sessionNode->ToElement())->SetAttribute(TEXT("FileEditViewHistoryRestoreEnabled"), _blnFileEditViewHistoryRestoreEnabled?TEXT("True"):TEXT("False"));
//--FLS: Write Attribute "nbMaxFile" and activeIndex
(sessionNode->ToElement())->SetAttribute(TEXT("nbMaxFile"), (int)_nbMaxFileEditView);
int actIndex = 0; // set default, if no file is present!!
if (session._mainViewFiles.size() != 0) actIndex = session._activeMainIndex;
(sessionNode->ToElement())->SetAttribute(TEXT("activeMainIndex"), actIndex);
//-- Only write last _nbMaxFileEditView elements from session.
int nAll = session._mainViewFiles.size();
size_t nStart = (nAll - _nbMaxFileEditView)>0?(nAll - _nbMaxFileEditView):0;
for (size_t i = nStart ; i < session._mainViewFiles.size() ; i++)
{
TiXmlNode *fileNameNode = sessionNode->InsertEndChild(TiXmlElement(TEXT("File")));
////--FLS: Don't save editViewIndex, because for file edit view history user wants to load the document allways into the current view.
(fileNameNode->ToElement())->SetAttribute(TEXT("firstVisibleLine"), session._mainViewFiles[i]._firstVisibleLine);
(fileNameNode->ToElement())->SetAttribute(TEXT("xOffset"), session._mainViewFiles[i]._xOffset);
(fileNameNode->ToElement())->SetAttribute(TEXT("scrollWidth"), session._mainViewFiles[i]._scrollWidth);
(fileNameNode->ToElement())->SetAttribute(TEXT("startPos"), session._mainViewFiles[i]._startPos);
(fileNameNode->ToElement())->SetAttribute(TEXT("endPos"), session._mainViewFiles[i]._endPos);
(fileNameNode->ToElement())->SetAttribute(TEXT("selMode"), session._mainViewFiles[i]._selMode);
(fileNameNode->ToElement())->SetAttribute(TEXT("lang"), session._mainViewFiles[i]._langName.c_str());
(fileNameNode->ToElement())->SetAttribute(TEXT("encoding"), session._mainViewFiles[i]._encoding);
(fileNameNode->ToElement())->SetAttribute(TEXT("filename"), session._mainViewFiles[i]._fileName.c_str());
for (size_t j = 0 ; j < session._mainViewFiles[i].marks.size() ; j++)
{
size_t markLine = session._mainViewFiles[i].marks[j];
TiXmlNode *markNode = fileNameNode->InsertEndChild(TiXmlElement(TEXT("Mark")));
markNode->ToElement()->SetAttribute(TEXT("line"), markLine);
}
//--FLS: xSaveFoldingStateSession:
for (size_t j = 0 ; j < session._mainViewFiles[i].foldedLines.size() ; j++)
{
size_t foldedLine = session._mainViewFiles[i].foldedLines[j];
TiXmlNode *markNode = fileNameNode->InsertEndChild(TiXmlElement(TEXT("Fold")));
markNode->ToElement()->SetAttribute(TEXT("line"), foldedLine);
}
}
//-- (Re)Insert the XML-node
(nppRoot->ToElement())->InsertEndChild(*sessionNode);
} //--- writeFileEditViewHistory() ----
//--FLS: xFileEditViewHistory: new function feedFileEditViewHistoryParameters()
// Reads the parameters from the config.xml file Node, after config.xml file is loaded.
void NppParameters::feedFileEditViewHistoryParameters(TiXmlNode *node)
{
const TCHAR *str;
//--FLS: Reads the FileEditViewHistory parameters out of according section in config.xml and stores them
// in a Session _lastFileEditViewSession.
//--FLS: Use _mainViewFiles for ALL session files, even for the sub-view files, because FileEditViewHistory does not distinguish.
//--FLS: Note: Don't use _nbMaxFile, which is directly assigned to the history _LRFileList,
// which is not really an independent class but a somehow directly linked class to _nbMaxFile variable!!
//--FLS: Code stolen from getSessionFromXmlTree().
//-- Set default values for variables, if there would be a reading error.
_nbMaxFileEditView = 20;
_blnFileEditViewHistoryRestoreEnabled = true;
//--FLS: Read FileEditViewHistory list into _lastFileEditViewSession. Same approach as used in getSessionFromXmlTree().
Session *ptrSession = &_lastFileEditViewSession;
TiXmlNode *sessionRoot = node->FirstChildElement(TEXT("FileEditViewHistory"));
if (!sessionRoot)
return;
TiXmlElement *actIndex = sessionRoot->ToElement();
size_t index;
str = actIndex->Attribute(TEXT("FileEditViewHistoryRestoreEnabled"), (int *)&index);
if (str) {
_blnFileEditViewHistoryRestoreEnabled = !generic_stricmp(TEXT("TRUE"), str);
}
//--FLS: Only one of the flags _fileEditViewHistoryRestoreEnabled or _rememberLastSession should be enabled!
// The GUI parameters have to be initialized before!!!
if (_nppGUI._rememberLastSession && _blnFileEditViewHistoryRestoreEnabled) _blnFileEditViewHistoryRestoreEnabled = false;
//--FLS: ->Attribute(const char *name, int *i) returns i=0, if a reading error occurs.
// Therefore, the code using "if (str)..." is not needed and is not the best, because it lets the ptrSession parameter uninitialized.
// read also activeYyIndex, which is not needed but just handled to set it in the session structure.
str = actIndex->Attribute(TEXT("activeView"), (int *)&(ptrSession->_activeView));
str = actIndex->Attribute(TEXT("activeMainIndex"), (int *)&(ptrSession->_activeMainIndex));
str = actIndex->Attribute(TEXT("activeSubIndex"), (int *)&(ptrSession->_activeSubIndex));
// read maximum list size
str = actIndex->Attribute(TEXT("nbMaxFile"), &_nbMaxFileEditView);
for (TiXmlNode *childNode = sessionRoot->FirstChildElement(TEXT("File"));
childNode ;
childNode = childNode->NextSibling(TEXT("File")) )
{
const TCHAR *fileName = (childNode->ToElement())->Attribute(TEXT("filename"));
if (fileName)
{
Position position;
(childNode->ToElement())->Attribute(TEXT("firstVisibleLine"), &position._firstVisibleLine);
(childNode->ToElement())->Attribute(TEXT("xOffset"), &position._xOffset);
(childNode->ToElement())->Attribute(TEXT("startPos"), &position._startPos);
(childNode->ToElement())->Attribute(TEXT("endPos"), &position._endPos);
(childNode->ToElement())->Attribute(TEXT("selMode"), &position._selMode);
(childNode->ToElement())->Attribute(TEXT("scrollWidth"), &position._scrollWidth);
const TCHAR *langName;
langName = (childNode->ToElement())->Attribute(TEXT("lang"));
int encoding = -1;
const TCHAR *encStr = (childNode->ToElement())->Attribute(TEXT("encoding"), &encoding);
sessionFileInfo sfi(fileName, langName, encStr?encoding:-1, position);
for (TiXmlNode *markNode = childNode->FirstChildElement(TEXT("Mark"));
markNode ;
markNode = markNode->NextSibling(TEXT("Mark")))
{
int lineNumber;
const TCHAR *lineNumberStr = (markNode->ToElement())->Attribute(TEXT("line"), &lineNumber);
if (lineNumberStr)
{
sfi.marks.push_back(lineNumber);
}
}
//--FLS: xSaveFoldingStateSession:
for (TiXmlNode *foldNode = childNode->FirstChildElement(TEXT("Fold"));
foldNode ;
foldNode = foldNode->NextSibling(TEXT("Fold")))
{
int lineNumber;
const TCHAR *lineNumberStr = (foldNode->ToElement())->Attribute(TEXT("line"), &lineNumber);
if (lineNumberStr)
{
sfi.foldedLines.push_back(lineNumber);
}
}
(*ptrSession)._mainViewFiles.push_back(sfi);
}
}
return;
} //---feedFileEditViewHistoryParameters()-----

View File

@ -155,8 +155,6 @@ struct sessionFileInfo : public Position {
generic_string _fileName;
generic_string _langName;
vector<size_t> marks;
//--FLS: xSaveFoldingStateSession: additional vector for saving folding state.
vector<size_t> foldedLines;
int _encoding;
};
@ -1307,9 +1305,6 @@ public:
void writeShortcuts();
void writeSession(const Session & session, const TCHAR *fileName = NULL);
bool writeFindHistory();
//--FLS: xFileEditViewHistory: new function writeFileEditViewHistory()
void writeFileEditViewHistory(const Session & session);
bool isExistingUserLangName(const TCHAR *newName) const {
if ((!newName) || (!newName[0]))
@ -1406,13 +1401,6 @@ public:
vector<MenuItemUnit> & getContextMenuItems() {return _contextMenuItems;};
const Session & getSession() const {return _session;};
//--FLS: xFileEditViewHistory: new functions for EditViewPerFileHistory
Session * getPtrFileEditViewSession() {return &_lastFileEditViewSession;};
bool getFileEditViewHistoryRestoreEnabled() const {return _blnFileEditViewHistoryRestoreEnabled;};
void setFileEditViewHistoryRestoreEnabled(bool en) { _blnFileEditViewHistoryRestoreEnabled=en;};
int getNbMaxFileEditView() const {return _nbMaxFileEditView;};
void setNbMaxFileEditView(int nb) { _nbMaxFileEditView = nb;};
bool hasCustomContextMenu() const {return !_contextMenuItems.empty();};
void setAccelerator(Accelerator *pAccel) {_pAccelerator = pAccel;};
@ -1580,12 +1568,6 @@ private:
vector<MenuItemUnit> _contextMenuItems;
Session _session;
//--FLS: xFileEditViewHistory: _lastFileEditViewList for (FileEditViewHistory)
Session _lastFileEditViewSession;
int _nbMaxFileEditView;
//--FLS: xFileEditViewHistory: Parameter setting control for FileEditViewHistory (restores last EditView of files, if true)
bool _blnFileEditViewHistoryRestoreEnabled;
generic_string _shortcutsPath;
generic_string _contextMenuPath;
generic_string _sessionPath;
@ -1643,8 +1625,6 @@ private:
void feedGUIParameters(TiXmlNode *node);
void feedKeyWordsParameters(TiXmlNode *node);
void feedFileListParameters(TiXmlNode *node);
//--FLS: xFileEditViewHistory: new function feedFileEditViewHistoryParameters()
void feedFileEditViewHistoryParameters(TiXmlNode *node);
void feedScintillaParam(TiXmlNode *node);
void feedDockingManager(TiXmlNode *node);
void feedFindHistoryParameters(TiXmlNode *node);

View File

@ -269,11 +269,6 @@ void Buffer::setPosition(const Position & pos, ScintillaEditView * identifier) {
Position & Buffer::getPosition(ScintillaEditView * identifier) {
int index = indexOfReference(identifier);
//--FLS: xFileEditViewHistory: Crashes if index is -1 when buffer is not within given EditView! Therefore, check and return default Position.
if (index == -1) {
static Position pos; // 'static' because of warning returning local value!
return pos;
}
return _positions.at(index);
}

View File

@ -717,22 +717,6 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
::SendDlgItemMessage(_hSelf, IDC_CHECK_REMEMBERSESSION, BM_SETCHECK, nppGUI._rememberLastSession, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_AUTOUPDATE, BM_SETCHECK, nppGUI._autoUpdateOpt._doAutoUpdate, 0);
//--FLS: xFileEditViewHistoryParameterGUI: Initialize Checkbox for enabling the history for restoring the edit view per file.
bool boolItem = (pNppParam->getFileEditViewHistoryRestoreEnabled());
//--FLS: Only one of the flags _fileEditViewHistoryRestoreEnabled or _rememberLastSession should be enabled!
if (boolItem && nppGUI._rememberLastSession)
{
boolItem = false;
(pNppParam->setFileEditViewHistoryRestoreEnabled(boolItem));
}
::SendDlgItemMessage(_hSelf, IDC_CHECK_REMEMBEREDITVIEWPERFILE, BM_SETCHECK, boolItem, 0);
//--FLS: xFileEditViewHistoryParameterGUI: Initializing number of files for edit view history per file
::SetDlgItemInt(_hSelf, IDC_EDIT_REMEMBEREDITVIEWPERFILE, pNppParam->getNbMaxFileEditView(), FALSE);
_nbFileEditViewHistoryVal.init(_hInst, _hSelf);
_nbFileEditViewHistoryVal.create(::GetDlgItem(_hSelf, IDC_EDIT_REMEMBEREDITVIEWPERFILE), IDC_EDIT_REMEMBEREDITVIEWPERFILE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_CHECK_AUTOUPDATE), nppGUI._doesExistUpdater?SW_SHOW:SW_HIDE);
BOOL linkEnable = FALSE;
@ -863,45 +847,8 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
case IDC_CHECK_REMEMBERSESSION:
//::SendMessage(_hParent, WM_COMMAND, IDM_SETTING_REMEMBER_LAST_SESSION, 0);
nppGUI._rememberLastSession = isCheckedOrNot(wParam);
//--FLS: xFileEditViewHistoryParameterGUI: Only one of the flags _fileEditViewHistoryRestoreEnabled or _rememberLastSession should be enabled!
if (nppGUI._rememberLastSession) {
//-- disable IDC_CHECK_REMEMBEREDITVIEWPERFILE
(pNppParam->setFileEditViewHistoryRestoreEnabled(false));
::SendDlgItemMessage(_hSelf, IDC_CHECK_REMEMBEREDITVIEWPERFILE, BM_SETCHECK, false, 0);
}
return TRUE;
//--FLS: xFileEditViewHistoryParameterGUI: Checkbox for enabling the history for restoring the edit view per file.
case IDC_CHECK_REMEMBEREDITVIEWPERFILE:
{
bool isChecked = isCheckedOrNot(wParam);
(pNppParam->setFileEditViewHistoryRestoreEnabled(isChecked));
//--FLS: Only one of the flags _fileEditViewHistoryRestoreEnabled or _rememberLastSession should be enabled!
if (isChecked) {
//-- disable IDM_SETTING_REMEMBER_LAST_SESSION
nppGUI._rememberLastSession = false;
::SendDlgItemMessage(_hSelf, IDC_CHECK_REMEMBERSESSION, BM_SETCHECK, false, 0);
}
return TRUE;
}
//--FLS: xFileEditViewHistoryParameterGUI: Handle number of files for edit view history per file
case IDC_EDIT_REMEMBEREDITVIEWPERFILE:
{
ValueDlg nbFileMaxDlg;
nbFileMaxDlg.init(NULL, _hSelf, pNppParam->getNbMaxFileEditView(), TEXT("Max File: "));
POINT p;
::GetCursorPos(&p);
int nbMaxFile = nbFileMaxDlg.doDialog(p);
if (nbMaxFile != -1)
{
pNppParam->setNbMaxFileEditView(nbMaxFile);
::SetDlgItemInt(_hSelf, IDC_EDIT_REMEMBEREDITVIEWPERFILE, nbMaxFile, FALSE);
}
return TRUE;
}
case IDC_CHECK_ENABLEDOCSWITCHER :
{
nppGUI._doTaskList = !nppGUI._doTaskList;

View File

@ -57,13 +57,8 @@ class SettingsDlg : public StaticDialog
{
public :
SettingsDlg() {};
//--FLS: xFileEditViewHistoryParameterGUI: Number of files in file edit view history list.
virtual void destroy() {
_nbFileEditViewHistoryVal.destroy();
}
private :
//--FLS: xFileEditViewHistoryParameterGUI: Number of files in file edit view history list.
URLCtrl _nbFileEditViewHistoryVal;
BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
};