Search code examples
nsisavalonedit

AvalonEdit - How do i color variables inside of a string


Is there a way to add a rule in AvalonEdit to color all variables inside of a string to something different? Kind of like how NSIS does (HM NIS Edit for example)

In this case, i'd need to have "$SmPrograms" (a constant) and "${AppName}" (a variable) standout from the rest of the string.

Section "Start Menu Shortcuts" SecStartMenuShortcuts
  SectionIn 1 2
  CreateDirectory "$SMPROGRAMS\MyApp"
  CreateShortCut "$SMPROGRAMS\MyApp\Uninstall-${AppName}.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  Delete "$SMPROGRAMS\MyApp\MyApp.lnk" ; Delete older link if exists
  CreateShortCut "$SMPROGRAMS\MyApp\MyApp2.lnk" "$INSTDIR\MyApp.exe" "" "$INSTDIR\MyApp.exe" 0
SectionEnd

Many thanks if anyone can assist


Solution

  • You can nest a ruleset within a span:

        <Span color="String">
            <Begin>"</Begin>
            <End>"</End>
            <RuleSet>
                <Rule foreground="#FF993366">
                    \$[\w\d_]+
                </Span>
            </RuleSet>
        </Span>