Posted 20 years ago
by painetraine
Well, I am trying to convert from v1 to v2 of SyntaxEditor and I have a couple of issues right now.
1. I had this same issue with v1 of the editor. If you have a state such as follows (any state will do) (this is a child state of the default state in sql language)
<State Key="UseState" Token="UseDefaultToken" Style="ReservedWordStyle">
<Scopes>
<Scope>
<RegexPatternGroup Type="StartScope" Token="UseStartToken" Style="ReservedWordStyle" PatternValue="[Uu][Ss][Ee]"/>
<RegexPatternGroup Type="EndScope" Token="UseEndToken" Style="DefaultStyle" PatternValue="[\w\s]"/>
</Scope>
</Scopes>
<PatternGroups>
<RegexPatternGroup Token="UseDefaultToken" PatternValue="\s" />
</PatternGroups>
</State>
and go to the end of the document and type "use" (so it should match the above state), the document never goes into the UseState. If you move to the next to the last character in the document, and type "use" then the editor will switch to the correct state (I am using the testeditor to test my states change correctly).
2. This one is a biggie since it causes the SyntaxEditor control to begin grabbing memory (when I checked it, the TestApp was up to 500MB and using 100% of the processor)
In v1 I had the following expressions:
<Regex Value="[Dd][Bb][Cc][Cc]" Token="DBCCStartToken">
<RegexValidStates>
<RegexValidState State="DefaultState" />
</RegexValidStates>
</Regex>
<Regex Value="[ ]+" Token="DBCCDefaultToken">
<RegexValidStates>
<RegexValidState State="DBCCState" />
</RegexValidStates>
</Regex>
<Regex Value="{LineTerminatorMacro}" Token="DBCCEndToken">
<RegexValidStates>
<RegexValidState State="DBCCState" />
</RegexValidStates>
</Regex>
<Regex Value="{WordMacro}" Token="DBCCProcStartToken">
<RegexValidStates>
<RegexValidState State="DBCCState" />
</RegexValidStates>
</Regex>
<Regex Value="\w*" Token="DBCCProcDefaultToken">
<RegexValidStates>
<RegexValidState State="DBCCProcState" />
</RegexValidStates>
</Regex>
<Regex Value="{LineTerminatorMacro}" Token="DBCCProcEndToken">
<RegexValidStates>
<RegexValidState State="DBCCProcState" />
</RegexValidStates>
</Regex>
In v2, I added the following states to the SQL language file you provide:
<State Key="DBCCState" Token="DBCCDefaultToken" Style="ReservedWordStyle">
<Scopes>
<Scope>
<RegexPatternGroup Type="StartScope" Token="DBCCStartToken" Style="ReservedWordStyle" PatternValue="[Dd][Bb][Cc][Cc]"/>
<RegexPatternGroup Type="EndScope" Token="DBCCEndToken" Style="DefaultStyle" PatternValue="{LineTerminatorMacro}"/>
</Scope>
</Scopes>
<PatternGroups>
<RegexPatternGroup Token="DBCCDefaultToken" PatternValue="[ ]+" />
</PatternGroups>
<ChildStates>
<ChildState Key="DBCCProcState"/>
</ChildStates>
</State>
<State Key="DBCCProcState" Token="DBCCProcDefaultToken" Style="ReservedWordStyle">
<Scopes>
<Scope>
<RegexPatternGroup Type="StartScope" Token="DBCCProcStartToken" Style="ReservedWordStyle" PatternValue="{WordMacro}"/>
<RegexPatternGroup Type="EndScope" Token="DBCCProcEndToken" Style="DefaultStyle" PatternValue="{LineTerminatorMacro}"/>
</Scope>
</Scopes>
<PatternGroups>
<RegexPatternGroup Token="DBCCProcDefaultToken" PatternValue="\w*" />
</PatternGroups>
</State>
In this example, I can type "dbcc" ok and it goes into DBCCState, however I then type any number of spaces and everything is ok, but when I try to type any other character, the control begins eating memory and processor and never comes back. In v1, the top language def worked by going into dbcc state and then when the user typed anything else, it would go into dbccprocstate and stay there until the next line. (Note: DBCCState above is a child of DefaultState)
Maybe I have just defined it wrong for the new language definition so if you could let me know if this is maybe an error in me defining the language elements (very possible) I would greatly appreciate it since I want to convert to SyntaxEditor 2.0 for my app for many of the other features.
Thanks
1. I had this same issue with v1 of the editor. If you have a state such as follows (any state will do) (this is a child state of the default state in sql language)
<State Key="UseState" Token="UseDefaultToken" Style="ReservedWordStyle">
<Scopes>
<Scope>
<RegexPatternGroup Type="StartScope" Token="UseStartToken" Style="ReservedWordStyle" PatternValue="[Uu][Ss][Ee]"/>
<RegexPatternGroup Type="EndScope" Token="UseEndToken" Style="DefaultStyle" PatternValue="[\w\s]"/>
</Scope>
</Scopes>
<PatternGroups>
<RegexPatternGroup Token="UseDefaultToken" PatternValue="\s" />
</PatternGroups>
</State>
and go to the end of the document and type "use" (so it should match the above state), the document never goes into the UseState. If you move to the next to the last character in the document, and type "use" then the editor will switch to the correct state (I am using the testeditor to test my states change correctly).
2. This one is a biggie since it causes the SyntaxEditor control to begin grabbing memory (when I checked it, the TestApp was up to 500MB and using 100% of the processor)
In v1 I had the following expressions:
<Regex Value="[Dd][Bb][Cc][Cc]" Token="DBCCStartToken">
<RegexValidStates>
<RegexValidState State="DefaultState" />
</RegexValidStates>
</Regex>
<Regex Value="[ ]+" Token="DBCCDefaultToken">
<RegexValidStates>
<RegexValidState State="DBCCState" />
</RegexValidStates>
</Regex>
<Regex Value="{LineTerminatorMacro}" Token="DBCCEndToken">
<RegexValidStates>
<RegexValidState State="DBCCState" />
</RegexValidStates>
</Regex>
<Regex Value="{WordMacro}" Token="DBCCProcStartToken">
<RegexValidStates>
<RegexValidState State="DBCCState" />
</RegexValidStates>
</Regex>
<Regex Value="\w*" Token="DBCCProcDefaultToken">
<RegexValidStates>
<RegexValidState State="DBCCProcState" />
</RegexValidStates>
</Regex>
<Regex Value="{LineTerminatorMacro}" Token="DBCCProcEndToken">
<RegexValidStates>
<RegexValidState State="DBCCProcState" />
</RegexValidStates>
</Regex>
In v2, I added the following states to the SQL language file you provide:
<State Key="DBCCState" Token="DBCCDefaultToken" Style="ReservedWordStyle">
<Scopes>
<Scope>
<RegexPatternGroup Type="StartScope" Token="DBCCStartToken" Style="ReservedWordStyle" PatternValue="[Dd][Bb][Cc][Cc]"/>
<RegexPatternGroup Type="EndScope" Token="DBCCEndToken" Style="DefaultStyle" PatternValue="{LineTerminatorMacro}"/>
</Scope>
</Scopes>
<PatternGroups>
<RegexPatternGroup Token="DBCCDefaultToken" PatternValue="[ ]+" />
</PatternGroups>
<ChildStates>
<ChildState Key="DBCCProcState"/>
</ChildStates>
</State>
<State Key="DBCCProcState" Token="DBCCProcDefaultToken" Style="ReservedWordStyle">
<Scopes>
<Scope>
<RegexPatternGroup Type="StartScope" Token="DBCCProcStartToken" Style="ReservedWordStyle" PatternValue="{WordMacro}"/>
<RegexPatternGroup Type="EndScope" Token="DBCCProcEndToken" Style="DefaultStyle" PatternValue="{LineTerminatorMacro}"/>
</Scope>
</Scopes>
<PatternGroups>
<RegexPatternGroup Token="DBCCProcDefaultToken" PatternValue="\w*" />
</PatternGroups>
</State>
In this example, I can type "dbcc" ok and it goes into DBCCState, however I then type any number of spaces and everything is ok, but when I try to type any other character, the control begins eating memory and processor and never comes back. In v1, the top language def worked by going into dbcc state and then when the user typed anything else, it would go into dbccprocstate and stay there until the next line. (Note: DBCCState above is a child of DefaultState)
Maybe I have just defined it wrong for the new language definition so if you could let me know if this is maybe an error in me defining the language elements (very possible) I would greatly appreciate it since I want to convert to SyntaxEditor 2.0 for my app for many of the other features.
Thanks