Posted 19 years ago
by Joris Koster
-
Paragon Decision Technology
Hi,
I think I found a bug in loading the SyntaxLanguage object from an encoded XML stream.
Consider the following relevant language spec:when loading this language from a file- or memorystream, the bracket-highligting will fail if (and only if) the stream is encoded. When loading using a filename there seems to be no problem.
Small example code to demonstrate the problem; syntaxEditor1 and 2 both have the BracketHighlightingVisible property set to true, but nevertheless syntaxEditor2 will not show the brackethighlighting.I'm not sure if the problem is in my language-spec, but nevertheless I would expect both cases to be correct xor incorrect.
I think I found a bug in loading the SyntaxLanguage object from an encoded XML stream.
Consider the following relevant language spec:
<SyntaxLanguage Key="BracketHLTest" LanguageDefinitionVersion="3.0" Secure="True"
xmlns="http://ActiproSoftware/SyntaxEditor/3.0/LanguageDefinition">
<!-- States -->
<States>
<!-- Code -->
<State Key="DefaultState">
<Scopes>
<Scope BracketHighlight="True">
<ExplicitPatternGroup Type="StartScope" TokenKey="BracketStartToken" PatternValue="(" />
<ExplicitPatternGroup Type="EndScope" TokenKey="BracketEndToken" PatternValue=")" />
</Scope>
</Scopes>
<ChildStates>
<ChildState Key="DefaultState" />
</ChildStates>
</State>
</States>
</SyntaxLanguage>
Small example code to demonstrate the problem; syntaxEditor1 and 2 both have the BracketHighlightingVisible property set to true, but nevertheless syntaxEditor2 will not show the brackethighlighting.
private void Form1_Load(object sender, System.EventArgs e)
{
System.Int32 encodeKey = 1234;
System.String plainFilename = "../../test.xml";
System.String encodedFilename = "../../test.enc";
// create an encoded xml file
ActiproSoftware.SyntaxEditor.SyntaxLanguage thePlainLanguage =
ActiproSoftware.SyntaxEditor.SyntaxLanguage.LoadFromXml( plainFilename, 0 );
thePlainLanguage.SaveToXml(encodedFilename, encodeKey);
// open the plain text stream
System.IO.FileStream streamPlain =
new System.IO.FileStream(plainFilename,
System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
// load the language from the plain text stream
ActiproSoftware.SyntaxEditor.SyntaxLanguage languagePlain =
ActiproSoftware.SyntaxEditor.SyntaxLanguage.LoadFromXml(
streamPlain, 0);
// set the syntax-language for the first editor
syntaxEditor1.Document.Language = languagePlain;
// open the encoded text stream
System.IO.FileStream streamEncoded =
new System.IO.FileStream(encodedFilename,
System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
// load the language from the encoded text stream
ActiproSoftware.SyntaxEditor.SyntaxLanguage languageEncoded =
ActiproSoftware.SyntaxEditor.SyntaxLanguage.LoadFromXml(
streamEncoded, encodeKey);
// set the syntax-language for the second editor
syntaxEditor2.Document.Language = languageEncoded;
}