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\" SetOutPath "$TEMP\"
File "langsModel.xml" File "langsModel.xml"
File "configModel.xml" File "configModel.xml"
File "stylesLexerModel.xml" File "stylesModel.xml"
File "stylesGlobalModel.xml"
File "..\bin\langs.model.xml" File "..\bin\langs.model.xml"
File "..\bin\config.model.xml" File "..\bin\config.model.xml"
File "..\bin\stylers.model.xml" File "..\bin\stylers.model.xml"
File "..\bin\stylers_remove.xml"
;UPGRATE $INSTDIR\langs.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\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\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\stylesModel.xml" "$TEMP\stylers_remove.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.model.xml" "$UPDATE_PATH\stylers.xml"'
SetOutPath "$INSTDIR\" SetOutPath "$INSTDIR\"
File "..\bin\langs.model.xml" File "..\bin\langs.model.xml"
File "..\bin\config.model.xml" File "..\bin\config.model.xml"
File "..\bin\stylers.model.xml" File "..\bin\stylers.model.xml"
File "..\bin\stylers_remove.xml"
SetOverwrite off SetOverwrite off
File /oname=$INSTDIR\langs.xml "..\bin\langs.model.xml" File /oname=$INSTDIR\langs.xml "..\bin\langs.model.xml"
@ -972,6 +973,7 @@ Section Uninstall
Delete "$INSTDIR\langs.model.xml" Delete "$INSTDIR\langs.model.xml"
Delete "$INSTDIR\stylers.xml" Delete "$INSTDIR\stylers.xml"
Delete "$INSTDIR\stylers.model.xml" Delete "$INSTDIR\stylers.model.xml"
Delete "$INSTDIR\stylers_remove.xml"
Delete "$INSTDIR\contextMenu.xml" Delete "$INSTDIR\contextMenu.xml"
Delete "$INSTDIR\shortcuts.xml" Delete "$INSTDIR\shortcuts.xml"
Delete "$INSTDIR\nativeLang.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" ?> <?xml version="1.0" encoding="Windows-1252" ?>
<Node nodeName="NotepadPlus"> <Node nodeName="NotepadPlus">
<Node nodeName="LexerStyles">
<Node nodeName="LexerType" name="name">
<Node nodeName="WordsStyle" name="name"/>
</Node>
</Node>
<Node nodeName="GlobalStyles"> <Node nodeName="GlobalStyles">
<Node nodeName="WidgetStyle" name="name" /> <Node nodeName="WidgetStyle" name="name" />
</Node> </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 *srcChildNode = NULL;
TiXmlNode *destChildNode = NULL; TiXmlNode *destChildNode = NULL;
TiXmlNode *modelChildNode = modelNode->FirstChild("Node"); TiXmlNode *modelChildNode = modelNode->FirstChild("Node");
if (!modelChildNode) if (!srcNode) return;
return 0;
const char *nodeName = (modelChildNode->ToElement())->Attribute("nodeName"); for (modelChildNode = modelNode->FirstChild("Node");
const char *name = (modelChildNode->ToElement())->Attribute("name"); modelChildNode;
if (nodeName) modelChildNode = modelChildNode->NextSibling("Node"))
{ {
if (!srcNode) const char *nodeName = (modelChildNode->ToElement())->Attribute("nodeName");
return 0; const char *name = (modelChildNode->ToElement())->Attribute("name");
srcChildNode = srcNode->FirstChild(nodeName); if (nodeName)
if (!srcChildNode) {
throw int(4); srcChildNode = srcNode->FirstChild(nodeName);
if (!srcChildNode) continue;
destChildNode = destNode->FirstChild(nodeName); destChildNode = destNode->FirstChild(nodeName);
if (!destChildNode) if (!destChildNode)
{ {
//Insertion //Insertion
destNode->InsertEndChild(*srcChildNode); destNode->InsertEndChild(*srcChildNode);
return 0; continue;
} }
else
{
if (name && name[0]) if (name && name[0])
{ {
srcChildNode = srcNode->FirstChild(nodeName); srcChildNode = srcNode->FirstChild(nodeName);
@ -99,7 +97,13 @@ int update(TiXmlNode *modelNode, TiXmlNode *srcNode, TiXmlNode *destNode) {
const char *attrib = (srcChildNode->ToElement())->Attribute(name); const char *attrib = (srcChildNode->ToElement())->Attribute(name);
if (attrib) if (attrib)
{ {
const char *action = (srcChildNode->ToElement())->Attribute("action");
bool remove = false;
bool found = false; bool found = false;
if (action && !strcmp(action, "remove"))
remove = true;
destChildNode = destNode->FirstChild(nodeName); destChildNode = destNode->FirstChild(nodeName);
while (destChildNode) while (destChildNode)
{ {
@ -111,23 +115,24 @@ int update(TiXmlNode *modelNode, TiXmlNode *srcNode, TiXmlNode *destNode) {
} }
destChildNode = destChildNode->NextSibling(nodeName); destChildNode = destChildNode->NextSibling(nodeName);
} }
if (!found) if (remove)
{ {
// Insertion if (found) destNode->RemoveChild(destChildNode);
destNode->InsertEndChild(*srcChildNode);
//return 0;
} }
else else
{ {
update(modelChildNode, srcChildNode, destChildNode); if (found)
update(modelChildNode, srcChildNode, destChildNode);
else
destNode->InsertEndChild(*srcChildNode);
} }
} }
srcChildNode = srcChildNode->NextSibling(nodeName); srcChildNode = srcChildNode->NextSibling(nodeName);
} } // while srcChildNode
} }
} }
update(modelChildNode, srcChildNode, destChildNode);
} }
return update(modelChildNode, srcChildNode, destChildNode);
}; };