1. xmlUpdater now supports multiple models in one xml model file.
2. xmlUpdater now supports removing xml nodes (using action="remove" attribute).
3. combined stylesLexerModel.xml, and stylesGlobalModel.xml to stylesModel.xml.
4. added a new file "stylers_remove.xml" for removing old deprecated styles from stylers.xml when upgrading NPP.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@448 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
yniq 2009-04-12 16:29:37 +00:00
parent defd2ae4e0
commit 741cd58e61
5 changed files with 60 additions and 38 deletions

View File

@ -342,23 +342,24 @@ GLOBAL_INST:
SetOutPath "$TEMP\"
File "langsModel.xml"
File "configModel.xml"
File "stylesLexerModel.xml"
File "stylesGlobalModel.xml"
File "stylesModel.xml"
File "..\bin\langs.model.xml"
File "..\bin\config.model.xml"
File "..\bin\stylers.model.xml"
File "..\bin\stylers_remove.xml"
;UPGRATE $INSTDIR\langs.xml
nsExec::ExecToStack '"$TEMP\xmlUpdater.exe" "$TEMP\langsModel.xml" "$TEMP\langs.model.xml" "$INSTDIR\langs.xml"'
nsExec::ExecToStack '"$TEMP\xmlUpdater.exe" "$TEMP\configModel.xml" "$TEMP\config.model.xml" "$UPDATE_PATH\config.xml"'
nsExec::ExecToStack '"$TEMP\xmlUpdater.exe" "$TEMP\stylesLexerModel.xml" "$TEMP\stylers.model.xml" "$UPDATE_PATH\stylers.xml"'
nsExec::ExecToStack '"$TEMP\xmlUpdater.exe" "$TEMP\stylesGlobalModel.xml" "$TEMP\stylers.model.xml" "$UPDATE_PATH\stylers.xml"'
nsExec::ExecToStack '"$TEMP\xmlUpdater.exe" "$TEMP\stylesModel.xml" "$TEMP\stylers_remove.xml" "$UPDATE_PATH\stylers.xml"'
nsExec::ExecToStack '"$TEMP\xmlUpdater.exe" "$TEMP\stylesModel.xml" "$TEMP\stylers.model.xml" "$UPDATE_PATH\stylers.xml"'
SetOutPath "$INSTDIR\"
File "..\bin\langs.model.xml"
File "..\bin\config.model.xml"
File "..\bin\stylers.model.xml"
File "..\bin\stylers_remove.xml"
SetOverwrite off
File /oname=$INSTDIR\langs.xml "..\bin\langs.model.xml"
@ -972,6 +973,7 @@ Section Uninstall
Delete "$INSTDIR\langs.model.xml"
Delete "$INSTDIR\stylers.xml"
Delete "$INSTDIR\stylers.model.xml"
Delete "$INSTDIR\stylers_remove.xml"
Delete "$INSTDIR\contextMenu.xml"
Delete "$INSTDIR\shortcuts.xml"
Delete "$INSTDIR\nativeLang.xml"

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="Windows-1252" ?>
<NotepadPlus>
<LexerStyles>
<LexerType name="searchResult" desc="Search result" ext="">
<WordsStyle name="DEFAULT" action="remove" />
<WordsStyle name="HEARDER" action="remove" />
<WordsStyle name="NUMBER" action="remove" />
<WordsStyle name="HIT WORD" action="remove" />
<WordsStyle name="KEYWORD1" action="remove" />
<WordsStyle name="KEYWORD2" action="remove" />
<WordsStyle name="SEARCH HEADER" action="remove" />
<WordsStyle name="FILE HEADER" action="remove" />
<WordsStyle name="LINE NUMBER" action="remove" />
<WordsStyle name="SELECTED LINE" action="remove" />
</LexerType>
</LexerStyles>
</NotepadPlus>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="Windows-1252" ?>
<Node nodeName="NotepadPlus">
<Node nodeName="LexerStyles">
<Node nodeName="LexerType" name="name"/>
</Node>
</Node>

View File

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="Windows-1252" ?>
<Node nodeName="NotepadPlus">
<Node nodeName="LexerStyles">
<Node nodeName="LexerType" name="name">
<Node nodeName="WordsStyle" name="name"/>
</Node>
</Node>
<Node nodeName="GlobalStyles">
<Node nodeName="WidgetStyle" name="name" />
</Node>

View File

@ -64,33 +64,31 @@ static bool isInList(const char *token2Find, char *list2Clean) {
};
int update(TiXmlNode *modelNode, TiXmlNode *srcNode, TiXmlNode *destNode) {
void update(TiXmlNode *modelNode, TiXmlNode *srcNode, TiXmlNode *destNode) {
TiXmlNode *srcChildNode = NULL;
TiXmlNode *destChildNode = NULL;
TiXmlNode *modelChildNode = modelNode->FirstChild("Node");
if (!modelChildNode)
return 0;
if (!srcNode) return;
const char *nodeName = (modelChildNode->ToElement())->Attribute("nodeName");
const char *name = (modelChildNode->ToElement())->Attribute("name");
if (nodeName)
for (modelChildNode = modelNode->FirstChild("Node");
modelChildNode;
modelChildNode = modelChildNode->NextSibling("Node"))
{
if (!srcNode)
return 0;
srcChildNode = srcNode->FirstChild(nodeName);
if (!srcChildNode)
throw int(4);
const char *nodeName = (modelChildNode->ToElement())->Attribute("nodeName");
const char *name = (modelChildNode->ToElement())->Attribute("name");
if (nodeName)
{
srcChildNode = srcNode->FirstChild(nodeName);
if (!srcChildNode) continue;
destChildNode = destNode->FirstChild(nodeName);
if (!destChildNode)
{
//Insertion
destNode->InsertEndChild(*srcChildNode);
return 0;
}
else
{
destChildNode = destNode->FirstChild(nodeName);
if (!destChildNode)
{
//Insertion
destNode->InsertEndChild(*srcChildNode);
continue;
}
if (name && name[0])
{
srcChildNode = srcNode->FirstChild(nodeName);
@ -99,7 +97,13 @@ int update(TiXmlNode *modelNode, TiXmlNode *srcNode, TiXmlNode *destNode) {
const char *attrib = (srcChildNode->ToElement())->Attribute(name);
if (attrib)
{
const char *action = (srcChildNode->ToElement())->Attribute("action");
bool remove = false;
bool found = false;
if (action && !strcmp(action, "remove"))
remove = true;
destChildNode = destNode->FirstChild(nodeName);
while (destChildNode)
{
@ -111,23 +115,24 @@ int update(TiXmlNode *modelNode, TiXmlNode *srcNode, TiXmlNode *destNode) {
}
destChildNode = destChildNode->NextSibling(nodeName);
}
if (!found)
if (remove)
{
// Insertion
destNode->InsertEndChild(*srcChildNode);
//return 0;
if (found) destNode->RemoveChild(destChildNode);
}
else
{
update(modelChildNode, srcChildNode, destChildNode);
if (found)
update(modelChildNode, srcChildNode, destChildNode);
else
destNode->InsertEndChild(*srcChildNode);
}
}
srcChildNode = srcChildNode->NextSibling(nodeName);
}
} // while srcChildNode
}
}
update(modelChildNode, srcChildNode, destChildNode);
}
return update(modelChildNode, srcChildNode, destChildNode);
};