mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-23 13:54:54 +02:00
[BUG_FIXED] Fix the crash issue while the length of config.xml is zero.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@72 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
a89f6010de
commit
07c17d7c44
@ -5279,6 +5279,27 @@ bool Notepad_plus::doStreamComment()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Notepad_plus::saveScintillaParams(bool whichOne)
|
||||||
|
{
|
||||||
|
ScintillaViewParams svp;
|
||||||
|
ScintillaEditView *pView = (whichOne == SCIV_PRIMARY)?&_mainEditView:&_subEditView;
|
||||||
|
|
||||||
|
svp._lineNumberMarginShow = pView->hasMarginShowed(ScintillaEditView::_SC_MARGE_LINENUMBER);
|
||||||
|
svp._bookMarkMarginShow = pView->hasMarginShowed(ScintillaEditView::_SC_MARGE_SYBOLE);
|
||||||
|
svp._indentGuideLineShow = pView->isShownIndentGuide();
|
||||||
|
svp._folderStyle = pView->getFolderStyle();
|
||||||
|
svp._currentLineHilitingShow = pView->isCurrentLineHiLiting();
|
||||||
|
svp._wrapSymbolShow = pView->isWrapSymbolVisible();
|
||||||
|
svp._doWrap = pView->isWrap();
|
||||||
|
svp._edgeMode = int(pView->execute(SCI_GETEDGEMODE));
|
||||||
|
svp._edgeNbColumn = int(pView->execute(SCI_GETEDGECOLUMN));
|
||||||
|
svp._zoom = int(pView->execute(SCI_GETZOOM));
|
||||||
|
svp._whiteSpaceShow = pView->isInvisibleCharsShown();
|
||||||
|
svp._eolShow = pView->isEolVisible();
|
||||||
|
|
||||||
|
return (NppParameters::getInstance())->writeScintillaParams(svp, whichOne);
|
||||||
|
}
|
||||||
|
|
||||||
bool Notepad_plus::addCurrentMacro()
|
bool Notepad_plus::addCurrentMacro()
|
||||||
{
|
{
|
||||||
vector<MacroShortcut> & theMacros = (NppParameters::getInstance())->getMacroList();
|
vector<MacroShortcut> & theMacros = (NppParameters::getInstance())->getMacroList();
|
||||||
@ -6834,7 +6855,6 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||||||
_pluginsManager.notify(&scnN);
|
_pluginsManager.notify(&scnN);
|
||||||
|
|
||||||
_lastRecentFileList.saveLRFL();
|
_lastRecentFileList.saveLRFL();
|
||||||
|
|
||||||
saveScintillaParams(SCIV_PRIMARY);
|
saveScintillaParams(SCIV_PRIMARY);
|
||||||
saveScintillaParams(SCIV_SECOND);
|
saveScintillaParams(SCIV_SECOND);
|
||||||
saveGUIParams();
|
saveGUIParams();
|
||||||
|
@ -143,26 +143,9 @@ public:
|
|||||||
|
|
||||||
bool doReload(const char *fileName, bool alert = true);
|
bool doReload(const char *fileName, bool alert = true);
|
||||||
|
|
||||||
void saveScintillaParams(bool whichOne) {
|
bool saveScintillaParams(bool whichOne);
|
||||||
ScintillaViewParams svp;
|
|
||||||
ScintillaEditView *pView = (whichOne == SCIV_PRIMARY)?&_mainEditView:&_subEditView;
|
|
||||||
|
|
||||||
svp._lineNumberMarginShow = pView->hasMarginShowed(ScintillaEditView::_SC_MARGE_LINENUMBER);
|
bool saveGUIParams(){
|
||||||
svp._bookMarkMarginShow = pView->hasMarginShowed(ScintillaEditView::_SC_MARGE_SYBOLE);
|
|
||||||
svp._indentGuideLineShow = pView->isShownIndentGuide();
|
|
||||||
svp._folderStyle = pView->getFolderStyle();
|
|
||||||
svp._currentLineHilitingShow = pView->isCurrentLineHiLiting();
|
|
||||||
svp._wrapSymbolShow = pView->isWrapSymbolVisible();
|
|
||||||
svp._doWrap = pView->isWrap();
|
|
||||||
svp._edgeMode = int(pView->execute(SCI_GETEDGEMODE));
|
|
||||||
svp._edgeNbColumn = int(pView->execute(SCI_GETEDGECOLUMN));
|
|
||||||
svp._zoom = int(pView->execute(SCI_GETZOOM));
|
|
||||||
svp._whiteSpaceShow = pView->isInvisibleCharsShown();
|
|
||||||
svp._eolShow = pView->isEolVisible();
|
|
||||||
(NppParameters::getInstance())->writeScintillaParams(svp, whichOne);
|
|
||||||
};
|
|
||||||
|
|
||||||
void saveGUIParams(){
|
|
||||||
NppGUI & nppGUI = (NppGUI &)(NppParameters::getInstance())->getNppGUI();
|
NppGUI & nppGUI = (NppGUI &)(NppParameters::getInstance())->getNppGUI();
|
||||||
nppGUI._statusBarShow = _statusBar.isVisible();
|
nppGUI._statusBarShow = _statusBar.isVisible();
|
||||||
nppGUI._toolBarStatus = _toolBar.getState();
|
nppGUI._toolBarStatus = _toolBar.getState();
|
||||||
@ -193,7 +176,7 @@ public:
|
|||||||
|
|
||||||
saveDockingParams();
|
saveDockingParams();
|
||||||
|
|
||||||
(NppParameters::getInstance())->writeGUIParams();
|
return (NppParameters::getInstance())->writeGUIParams();
|
||||||
};
|
};
|
||||||
|
|
||||||
void saveDockingParams() {
|
void saveDockingParams() {
|
||||||
|
@ -1467,14 +1467,20 @@ void StyleArray::addStyler(int styleID, TiXmlNode *styleNode)
|
|||||||
_nbStyler++;
|
_nbStyler++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NppParameters::writeHistory(const char *fullpath)
|
bool NppParameters::writeHistory(const char *fullpath)
|
||||||
{
|
{
|
||||||
TiXmlNode *historyNode = (_pXmlUserDoc->FirstChild("NotepadPlus"))->FirstChildElement("History");
|
TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild("NotepadPlus");
|
||||||
|
if (!nppRoot) return false;
|
||||||
|
|
||||||
|
TiXmlNode *historyNode = nppRoot->FirstChildElement("History");
|
||||||
|
if (!historyNode) return false;
|
||||||
|
|
||||||
TiXmlElement recentFileNode("File");
|
TiXmlElement recentFileNode("File");
|
||||||
TiXmlText fileNameFullPath(fullpath);
|
TiXmlText fileNameFullPath(fullpath);
|
||||||
recentFileNode.InsertEndChild(fileNameFullPath);
|
recentFileNode.InsertEndChild(fileNameFullPath);
|
||||||
|
|
||||||
(historyNode->ToElement())->InsertEndChild(recentFileNode);
|
(historyNode->ToElement())->InsertEndChild(recentFileNode);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TiXmlNode * NppParameters::getChildElementByAttribut(TiXmlNode *pere, const char *childName,\
|
TiXmlNode * NppParameters::getChildElementByAttribut(TiXmlNode *pere, const char *childName,\
|
||||||
@ -2456,50 +2462,55 @@ void NppParameters::feedDockingManager(TiXmlNode *node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NppParameters::writeScintillaParams(const ScintillaViewParams & svp, bool whichOne)
|
bool NppParameters::writeScintillaParams(const ScintillaViewParams & svp, bool whichOne)
|
||||||
{
|
{
|
||||||
if (!_pXmlUserDoc) return;
|
if (!_pXmlUserDoc) return false;
|
||||||
|
|
||||||
const char *pViewName = (whichOne == SCIV_PRIMARY)?"ScintillaPrimaryView":"ScintillaSecondaryView";
|
const char *pViewName = (whichOne == SCIV_PRIMARY)?"ScintillaPrimaryView":"ScintillaSecondaryView";
|
||||||
TiXmlNode *configsRoot = (_pXmlUserDoc->FirstChild("NotepadPlus"))->FirstChildElement("GUIConfigs");
|
TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild("NotepadPlus");
|
||||||
|
if (!nppRoot) return false;
|
||||||
|
|
||||||
|
TiXmlNode *configsRoot = nppRoot->FirstChildElement("GUIConfigs");
|
||||||
|
if (!configsRoot) return false;
|
||||||
|
|
||||||
TiXmlNode *scintNode = getChildElementByAttribut(configsRoot, "GUIConfig", "name", pViewName);
|
TiXmlNode *scintNode = getChildElementByAttribut(configsRoot, "GUIConfig", "name", pViewName);
|
||||||
if (scintNode)
|
if (!scintNode) return false;
|
||||||
{
|
|
||||||
(scintNode->ToElement())->SetAttribute("lineNumberMargin", svp._lineNumberMarginShow?"show":"hide");
|
(scintNode->ToElement())->SetAttribute("lineNumberMargin", svp._lineNumberMarginShow?"show":"hide");
|
||||||
(scintNode->ToElement())->SetAttribute("bookMarkMargin", svp._bookMarkMarginShow?"show":"hide");
|
(scintNode->ToElement())->SetAttribute("bookMarkMargin", svp._bookMarkMarginShow?"show":"hide");
|
||||||
(scintNode->ToElement())->SetAttribute("indentGuideLine", svp._indentGuideLineShow?"show":"hide");
|
(scintNode->ToElement())->SetAttribute("indentGuideLine", svp._indentGuideLineShow?"show":"hide");
|
||||||
const char *pFolderStyleStr = (svp._folderStyle == FOLDER_STYLE_SIMPLE)?"simple":
|
const char *pFolderStyleStr = (svp._folderStyle == FOLDER_STYLE_SIMPLE)?"simple":
|
||||||
(svp._folderStyle == FOLDER_STYLE_ARROW)?"arrow":
|
(svp._folderStyle == FOLDER_STYLE_ARROW)?"arrow":
|
||||||
(svp._folderStyle == FOLDER_STYLE_CIRCLE)?"circle":"box";
|
(svp._folderStyle == FOLDER_STYLE_CIRCLE)?"circle":"box";
|
||||||
(scintNode->ToElement())->SetAttribute("folderMarkStyle", pFolderStyleStr);
|
(scintNode->ToElement())->SetAttribute("folderMarkStyle", pFolderStyleStr);
|
||||||
(scintNode->ToElement())->SetAttribute("currentLineHilitingShow", svp._currentLineHilitingShow?"show":"hide");
|
(scintNode->ToElement())->SetAttribute("currentLineHilitingShow", svp._currentLineHilitingShow?"show":"hide");
|
||||||
(scintNode->ToElement())->SetAttribute("wrapSymbolShow", svp._wrapSymbolShow?"show":"hide");
|
(scintNode->ToElement())->SetAttribute("wrapSymbolShow", svp._wrapSymbolShow?"show":"hide");
|
||||||
(scintNode->ToElement())->SetAttribute("Wrap", svp._doWrap?"yes":"no");
|
(scintNode->ToElement())->SetAttribute("Wrap", svp._doWrap?"yes":"no");
|
||||||
char *edgeStr = NULL;
|
char *edgeStr = NULL;
|
||||||
if (svp._edgeMode == EDGE_NONE)
|
if (svp._edgeMode == EDGE_NONE)
|
||||||
edgeStr = "no";
|
edgeStr = "no";
|
||||||
else if (svp._edgeMode == EDGE_LINE)
|
else if (svp._edgeMode == EDGE_LINE)
|
||||||
edgeStr = "line";
|
edgeStr = "line";
|
||||||
else
|
else
|
||||||
edgeStr = "background";
|
edgeStr = "background";
|
||||||
(scintNode->ToElement())->SetAttribute("edge", edgeStr);
|
(scintNode->ToElement())->SetAttribute("edge", edgeStr);
|
||||||
(scintNode->ToElement())->SetAttribute("edgeNbColumn", svp._edgeNbColumn);
|
(scintNode->ToElement())->SetAttribute("edgeNbColumn", svp._edgeNbColumn);
|
||||||
(scintNode->ToElement())->SetAttribute("zoom", svp._zoom);
|
(scintNode->ToElement())->SetAttribute("zoom", svp._zoom);
|
||||||
(scintNode->ToElement())->SetAttribute("whiteSpaceShow", svp._whiteSpaceShow?"show":"hide");
|
(scintNode->ToElement())->SetAttribute("whiteSpaceShow", svp._whiteSpaceShow?"show":"hide");
|
||||||
(scintNode->ToElement())->SetAttribute("eolShow", svp._eolShow?"show":"hide");
|
(scintNode->ToElement())->SetAttribute("eolShow", svp._eolShow?"show":"hide");
|
||||||
}
|
|
||||||
else {/*create one*/}
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NppParameters::writeGUIParams()
|
bool NppParameters::writeGUIParams()
|
||||||
{
|
{
|
||||||
if (!_pXmlUserDoc) return;
|
if (!_pXmlUserDoc) return false;
|
||||||
|
|
||||||
TiXmlNode *GUIRoot = (_pXmlUserDoc->FirstChild("NotepadPlus"))->FirstChildElement("GUIConfigs");
|
TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild("NotepadPlus");
|
||||||
if (!GUIRoot)
|
if (!nppRoot) return false;
|
||||||
{
|
|
||||||
return;
|
TiXmlNode *GUIRoot = nppRoot->FirstChildElement("GUIConfigs");
|
||||||
}
|
if (!GUIRoot) return false;
|
||||||
|
|
||||||
bool autoDetectionExist = false;
|
bool autoDetectionExist = false;
|
||||||
bool checkHistoryFilesExist = false;
|
bool checkHistoryFilesExist = false;
|
||||||
@ -2527,7 +2538,7 @@ void NppParameters::writeGUIParams()
|
|||||||
{
|
{
|
||||||
TiXmlElement *element = childNode->ToElement();
|
TiXmlElement *element = childNode->ToElement();
|
||||||
const char *nm = element->Attribute("name");
|
const char *nm = element->Attribute("name");
|
||||||
if (!nm) {return;}
|
if (!nm) continue;
|
||||||
|
|
||||||
if (!strcmp(nm, "ToolBar"))
|
if (!strcmp(nm, "ToolBar"))
|
||||||
{
|
{
|
||||||
@ -2908,7 +2919,7 @@ void NppParameters::writeGUIParams()
|
|||||||
}
|
}
|
||||||
|
|
||||||
insertDockingParamNode(GUIRoot);
|
insertDockingParamNode(GUIRoot);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NppParameters::insertDockingParamNode(TiXmlNode *GUIRoot)
|
void NppParameters::insertDockingParamNode(TiXmlNode *GUIRoot)
|
||||||
|
@ -796,22 +796,27 @@ public:
|
|||||||
return _svp[whichOne];
|
return _svp[whichOne];
|
||||||
};
|
};
|
||||||
|
|
||||||
void writeNbHistoryFile(int nb) {
|
bool writeNbHistoryFile(int nb) {
|
||||||
if (!_pXmlUserDoc) return;
|
if (!_pXmlUserDoc) return false;
|
||||||
|
|
||||||
TiXmlNode *historyNode = (_pXmlUserDoc->FirstChild("NotepadPlus"))->FirstChildElement("History");
|
TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild("NotepadPlus");
|
||||||
if (historyNode)
|
if (!nppRoot) return false;
|
||||||
(historyNode->ToElement())->SetAttribute("nbMaxFile", nb);
|
|
||||||
|
TiXmlNode *historyNode = nppRoot->FirstChildElement("History");
|
||||||
|
if (!historyNode) return false;
|
||||||
|
|
||||||
|
(historyNode->ToElement())->SetAttribute("nbMaxFile", nb);
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
void writeHistory(const char *fullpath);
|
bool writeHistory(const char *fullpath);
|
||||||
|
|
||||||
TiXmlNode * getChildElementByAttribut(TiXmlNode *pere, const char *childName,\
|
TiXmlNode * getChildElementByAttribut(TiXmlNode *pere, const char *childName,\
|
||||||
const char *attributName, const char *attributVal) const;
|
const char *attributName, const char *attributVal) const;
|
||||||
|
|
||||||
void writeScintillaParams(const ScintillaViewParams & svp, bool whichOne);
|
bool writeScintillaParams(const ScintillaViewParams & svp, bool whichOne);
|
||||||
|
|
||||||
void writeGUIParams();
|
bool writeGUIParams();
|
||||||
|
|
||||||
void writeStyles(LexerStylerArray & lexersStylers, StyleArray & globalStylers);
|
void writeStyles(LexerStylerArray & lexersStylers, StyleArray & globalStylers);
|
||||||
|
|
||||||
|
@ -99,18 +99,19 @@ public :
|
|||||||
|
|
||||||
void saveLRFL() const {
|
void saveLRFL() const {
|
||||||
NppParameters *pNppParams = NppParameters::getInstance();
|
NppParameters *pNppParams = NppParameters::getInstance();
|
||||||
pNppParams->writeNbHistoryFile(_userMax);
|
if (pNppParams->writeNbHistoryFile(_userMax))
|
||||||
|
|
||||||
// if user defined nb recent files smaller than the size of list,
|
|
||||||
// we just keep the newest ones
|
|
||||||
int decal = _lrfl.size() - _userMax;
|
|
||||||
decal = (decal >= 0)?decal:0;
|
|
||||||
stringList::const_iterator it = _lrfl.begin();
|
|
||||||
for (int i = 0 ; i < decal ; i++, it++);
|
|
||||||
|
|
||||||
for (int i = 0 ; it != _lrfl.end() && (i < _userMax) ; it++, i++)
|
|
||||||
{
|
{
|
||||||
pNppParams->writeHistory(((const std::string)*it).c_str());
|
// if user defined nb recent files smaller than the size of list,
|
||||||
|
// we just keep the newest ones
|
||||||
|
int decal = _lrfl.size() - _userMax;
|
||||||
|
decal = (decal >= 0)?decal:0;
|
||||||
|
stringList::const_iterator it = _lrfl.begin();
|
||||||
|
for (int i = 0 ; i < decal ; i++, it++);
|
||||||
|
|
||||||
|
for (int i = 0 ; it != _lrfl.end() && (i < _userMax) ; it++, i++)
|
||||||
|
{
|
||||||
|
pNppParams->writeHistory(((const std::string)*it).c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user