Improper Highlighting

SyntaxEditor for Windows Forms Forum

Posted 14 years ago by Tim Davis
Avatar
Hello,

I have another quick question. I have a key workd name 'key', it's style is blue.
If I type 'key' it turns blue. If I type 'keyblah' it's default which is good, but if I type 'keyblahkey' then the last instance of 'key' is highlighted which is bad. I've tested the same process on the sample project and it doesn't do it, i've compared and I can't find anything that you did that I didn't.

Here's my lang file.

<SyntaxLanguage Key="ISS" LanguageDefinitionVersion="2.0" Secure="False">

<Properties>
    <Property Key="Creator" Value="Tim Davis"/>
    <Property Key="Update" Value="3/20/2005"/>
</Properties>

<Triggers>
    <AutoReplaceTrigger Key="AutoReplaceTrigger">
        <AutoReplaceTriggerActivators>
            <AutoReplaceTriggerActivator Character="(" />
            <AutoReplaceTriggerActivator Character=")" />
        </AutoReplaceTriggerActivators>
        <AutoReplaceTriggerValidStates>
            <AutoReplaceTriggerValidState State="DefaultState" />
        </AutoReplaceTriggerValidStates>
    </AutoReplaceTrigger>
    
    <!-- <KeyPressTrigger Key="MemberListTrigger" Character=".">
        <KeyPressTriggerValidStates>
            <KeyPressTriggerValidState State="DefaultState" />
        </KeyPressTriggerValidStates>
    </KeyPressTrigger> -->
</Triggers>

<Styles>

    <Style Key="CollapsibleTextStyle" Name="Collapsible Text" ForeColor="Gray" BackColor="Default" Bold="False" Italic="False" Underline="False" />
    <Style Key="ReservedWordStyle" ForeColor="Blue" BackColor="Default" Bold="False" Italic="False" Underline="False" />
    <Style Key="CommentTextStyle" ForeColor="Green" BackColor="Default" Bold="False" Italic="True" Underline="False" />
    <Style Key="SectionHeaderStyle" ForeColor="Black" BackColor="Default" Bold="True" Italic="False" Underline="False" />
    <Style Key="ConstantStyle" ForeColor="Red" BackColor="Default" Bold="False" Italic="False" Underline="False"/>

</Styles>

<States>

    <State Key="DefaultState">
        
        <!-- Patterns Groups -->
        <PatternGroups>
            <!-- Whitespace -->
            <RegexPatternGroup Token="WhitespaceToken" PatternValue="{WhitespaceMacro}+" IsWhitespace="True" />
            <!-- Line Terminators -->
            <RegexPatternGroup Token="LineTerminatorToken" PatternValue="{LineTerminatorMacro}" IsWhitespace="True" />
            <!-- Brackets -->
            <ExplicitPatternGroup Key="OpenParenthesisPatternGroup" Token="OpenParenthesisToken" PatternValue="(" EndBracket="CloseParenthesisPatternGroup" />
            <ExplicitPatternGroup Key="CloseParenthesisPatternGroup" Token="CloseParenthesisToken" PatternValue=")" StartBracket="OpenParenthesisPatternGroup" />
            <!-- Reserved Words -->
            <ExplicitPatternGroup Token="ReservedWordToken" Style="ReservedWordStyle" LookAhead="{NonWordMacro}" StartsWith="[A-Ca-c]">
                <ExplicitPatterns>
                    AllowCancelDuringInstall AllowNoIcons AllowRootDirectory AllowUNCPath AlwaysRestart AlwaysShowComponentsList AlwaysShowDirOnReadyPage AlwaysShowGroupOnReadyPage AlwaysUsePersonalGroup AppComments AppContact AppCopyright AppendDefaultDirName AppendDefaultGroupName AppId AppModifyPath AppMutex AppName AppPublisher AppPublisherURL AppReadmeFile AppSupportURL AppUpdatesURL AppVerName AppVersion Attribs BackColor BackColor2 BackColorDirection BackSolid ChangesAssociations ChangesEnvironment Comment Components Compression CopyMode CreateAppDir CreateUninstallRegKey
                </ExplicitPatterns>
            </ExplicitPatternGroup>
            <ExplicitPatternGroup Token="ReservedWordToken" Style="ReservedWordStyle" LookAhead="{NonWordMacro}" StartsWith="[D-Fd-f]">
                <ExplicitPatterns>
                    DefaultDirName DefaultGroupName DefaultUserInfoName DefaultUserInfoOrg DefaultUserInfoSerial Description DestDir DestName DirExistsWarning dirifempty DisableDirPage DisableFinishedPage DisableProgramGroupPage DisableReadyMemo DisableReadyPage DisableStartupPrompt DiskClusterSize DiskSliceSize DiskSpanning EnableDirDoesntExistWarning Encryption Excludes ExtraDiskSpaceRequired Filename Flags FlatComponentsList FontInstall
                </ExplicitPatterns>
            </ExplicitPatternGroup>
            <ExplicitPatternGroup Token="ReservedWordToken" Style="ReservedWordStyle" LookAhead="{NonWordMacro}" StartsWith="[G-Rg-r]">
                <ExplicitPatterns>
                    GroupDescription HotKey IconFilename IconIndex InfoAfterFile InfoBeforeFile InternalCompressLevel Key LanguageDetectionMethod Languages LicenseFile MergeDuplicateFiles MessagesFile MinVersion Name OnlyBelowVersion OutputBaseFilename Parameters Password Permissions PrivilegesRequired ReserveBytes RestartIfNeededByRun Root RunOnceId
                </ExplicitPatterns>
            </ExplicitPatternGroup>
            <ExplicitPatternGroup Token="ReservedWordToken" Style="ReservedWordStyle" LookAhead="{NonWordMacro}" StartsWith="[S-Zs-z]">
                <ExplicitPatterns>
                    Section SetupIconFile ShowComponentSizes ShowLanguageDialog ShowTasksTreeLines SlicesPerDisk SolidCompression Source SourceDir StatusMsg String Subkey TimeStampRounding TimeStampsInUTC TouchDate TouchTime Type Types Uninstallable UninstallDisplayIcon UninstallDisplayName UninstallFilesDir UninstallLogMode UninstallRestartComputer UpdateUninstallLogAppName UsePreviousAppDir UsePreviousGroup UsePreviousSetupType UsePreviousTasks UsePreviousUserInfo UserInfoPage UseSetupLdr ValueData ValueName ValueType VersionInfoCompany VersionInfoDescription VersionInfoTextVersion VersionInfoVersion WindowResizable WindowShowCaption WindowStartMaximized WindowVisible WizardImageBackColor WizardImageFile WizardImageStretch WizardSmallImageFile WorkingDir
                </ExplicitPatterns>
            </ExplicitPatternGroup>
            <ExplicitPatternGroup Token="SectionHeaderToken" Style="SectionHeaderStyle" LookAhead="{NonWordMacro}">
                <ExplicitPatterns>
                    [Setup] [Types] [Components] [Tasks] [Dirs] [Files] [Icons] [INI] [InstallDelete] [Languages] [Messages] [CustomMessages] [LangOptions] [Registry] [Run] [UninstallDelete] [UninstallRun
                </ExplicitPatterns>
            </ExplicitPatternGroup>
        </PatternGroups>
        
        <!-- Child States -->
        <ChildStates>
            <ChildState Key="ConstantState"/>
            <ChildState Key="CodeState"/>
        </ChildStates>
    </State>
    
    <!-- State for using Constants in the Sections, Constant begins with { followed by any number of letters and ended by a } -->
    <State Key="ConstantState">
        <!-- Scopes -->
        <Scopes>
            <Scope>
                <ExplicitPatternGroup Type="StartScope" Token="ConstantStartToken" Style="ConstantStyle" PatternValue="{"/>
                <ExplicitPatternGroup Type="EndScope" Token="ConstantEndToken" Style="ConstantStyle" PatternValue="}"/>
            </Scope>
        </Scopes>
        <PatternGroups>
            <RegexPatternGroup Token="ConstantToken" PatternValue="{WordMacro}" Style="ConstantStyle" />
        </PatternGroups>
    </State>

    <State Key="CodeState">
        <!-- Scopes -->
    </State>

</States>

</SyntaxLanguage>

Comments (2)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Open your def up in our sample app. When you move over characters, the status bar indicates what token you are one. If there is an asterisk next to the token, the character you are on starts a token.

What you'll find is that you have nothing like an IdentifierToken to eat non-keywords. So the default token assignment is happening and probably is making one token for each character before your final "key" in that word. You need to make something like an IdentifierToken that will consume non-keywords.


Actipro Software Support

Posted 14 years ago by Tim Davis
Avatar
Ah, I found your example Identifier item in the VB syntax file. That fixed the problem!!!
The latest build of this product (v2018.1 build 0341) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.