UDL 3 different colors for 3 similar delimiters
-
Hi, I am a writer, not a coder.
Context
My world is Chapters and Sections and Subsections.
In Word, it corresponds to Heading1, Heading2, Heading3.
NPP is awesome fast on my old Surface and UDL supplies some of that Word stuff I miss.Question
I want this color scheme in NPP:
#- to show as blue until EOL i.e. Heading1
#-- to show as green until EOL i.e. Heading2
#— to show as orange until EOL i.e. Heading3I can get #- and #-- to work.
But #— keeps showing as green, not orange.
Can #— be orange with blue #- and green #-- ?More Info
(note1: three dashes is autocorrrecting into an emdash inside this forum’s editor but it looks like #- - - without the spaces)
(note2: I use #- to macro-build a “Navigation Pane” in NPP’s Search Results Find All pane)To get the first two to work, i had to make #- a delimiter, and #-- as a comment
I have tried putting #— in probably every field available in the UDL tool that comes with NPP but i can’t get #— to show as orange. I have cleared out every other field in the UDL tool.
I perused the good UDL docs (ivan-radic) but nothing was immediately apparent to me. I also scanned a UDL repository on github but all those are for programming languages.
-
@joShu001
I was able to make it work with the following settings:
Delimiter 1 style:
Open =#---
Close =((EOL))
foreground color = orangeDelimiter 2 style:
Open =#--
Close =((EOL))
foreground color = greenDelimiter 3 style:
Open =#-
Close =((EOL))
foreground color = blue
The order in which I assigned those delimiters is important. The UDL lexer will colorize Delimiter 1 before Delimiter 2, and Delimiter 2 before Delimiter 3. Since
#-
and#--
are prefixes of#---
,#---
needs to be the last Delimiter.Note that this approach isn’t perfect; if you only want these headings to be colorized if the headers are at the beginning of a line, you probably want to use EnhanceAnyLexer.
Here’s the XML I got.
<NotepadPlus> <UserLang name="blahblahblah" ext="" udlVersion="2.1"> <Settings> <Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" /> <Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" /> </Settings> <KeywordLists> <Keywords name="Comments"></Keywords> <Keywords name="Numbers, prefix1"></Keywords> <Keywords name="Numbers, prefix2"></Keywords> <Keywords name="Numbers, extras1"></Keywords> <Keywords name="Numbers, extras2"></Keywords> <Keywords name="Numbers, suffix1"></Keywords> <Keywords name="Numbers, suffix2"></Keywords> <Keywords name="Numbers, range"></Keywords> <Keywords name="Operators1"></Keywords> <Keywords name="Operators2"></Keywords> <Keywords name="Folders in code1, open"></Keywords> <Keywords name="Folders in code1, middle"></Keywords> <Keywords name="Folders in code1, close"></Keywords> <Keywords name="Folders in code2, open"></Keywords> <Keywords name="Folders in code2, middle"></Keywords> <Keywords name="Folders in code2, close"></Keywords> <Keywords name="Folders in comment, open"></Keywords> <Keywords name="Folders in comment, middle"></Keywords> <Keywords name="Folders in comment, close"></Keywords> <Keywords name="Keywords1"></Keywords> <Keywords name="Keywords2"></Keywords> <Keywords name="Keywords3"></Keywords> <Keywords name="Keywords4"></Keywords> <Keywords name="Keywords5"></Keywords> <Keywords name="Keywords6"></Keywords> <Keywords name="Keywords7"></Keywords> <Keywords name="Keywords8"></Keywords> <Keywords name="Delimiters">00#--- 01 02((EOL)) 03#-- 04 05((EOL)) 06#- 07 08((EOL)) 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords> </KeywordLists> <Styles> <WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="COMMENTS" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="LINE COMMENTS" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="NUMBERS" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS1" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS2" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS3" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS4" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS5" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS6" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS8" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="OPERATORS" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="FOLDER IN CODE1" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="FOLDER IN CODE2" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS1" fgColor="FF8040" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS2" fgColor="808000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS3" fgColor="0000FF" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" /> </Styles> </UserLang> </NotepadPlus>
-
@Mark-Olson , you solved it and it works great.
It did not occur to me that the order would matter.
Thanks for sharing your cleverness!