Is BBLMRunColors only a coded language module feature.

126 views
Skip to first unread message

Christopher Waterman

unread,
Aug 23, 2021, 4:05:22 PM8/23/21
to bbe...@googlegroups.com
Hello,

I’m curious about BBLMRunColors.

I imagine it would be implemented something like this:

<key>BBLMRunColors</key>
<array>
<string>com.run.kind.name</string>
</array> 

But this crashes BBEdit.


The BBLMKeywords key is an array of dictionaries. In each dictionary, there is a RunKindkey that specifies the run kind to be used (one of the factory-supplied run kinds, or one defined in your language module's BBLMRunColors array),...
...
The run kinds you can use are not limited to the built-in ones; you can define your own run kinds and color mappings using a BBLMRunColors key, as previously described. You must also add a BBLMRunNames key which maps those run kinds to human-readable names, so that users can adjust the color settings.

This isn’t explicit as to whether this BBLMRunColors is a “coded” only language module feature or if it works with the codeless variety.

The only example I could find was in the built in Python module, where it was mapping built in run kinds to custom ones.

- Does it work with codeless language modules?

- If it does, does anyone have an example?

Thanks
—C. Waterman



jj

unread,
Aug 24, 2021, 4:43:17 AM8/24/21
to BBEdit Talk

Hi Christopher,

Here is a minimal Codeless Language Module for an hypothetical "Christopher" language that demonstrates the use of color runs.
Save it as Christopher.plist in ~/Library/Application Support/BBEdit/Language Modules.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>BBEditDocumentType</key>
    <string>CodelessLanguageModule</string>
    <key>BBLMColorsSyntax</key>
    <true/>
    <key>BBLMIsCaseSensitive</key>
    <false/>
    <key>BBLMLanguageCode</key>
    <string>Chri</string>
    <key>BBLMLanguageDisplayName</key>
    <string>Christopher</string>
    <key>BBLMSuffixMap</key>
    <array>
        <dict>
        <key>BBLMLanguageSuffix</key>
        <string>.chris</string>
        </dict>
    </array>
    <key>BBLMRunColors</key>
    <dict>
        <key>com.christopher.preferred_color</key>
        <string>hsla(1.000, 1.000, 1.000, 1.000)</string>
    </dict>
    <key>BBLMRunNames</key>
    <dict>
        <key>com.christopher.preferred_color</key>
        <string>Christorpher's preferred color</string>
    </dict>
    <key>BBLMKeywordPatterns</key>
    <array>
        <dict>
            <key>RunKind</key>
            <string>com.christopher.preferred_color</string>
            <key>Pattern</key>
            <string>Chris(topher)?</string>
        </dict>
    </array>
    <key>Language Features</key>
    <dict>
        <key>Identifier and Keyword Character Class</key>
        <string>\p{L}\p{N}\-</string>
    </dict>
</dict>
</plist>

After restarting BBEdit and selecting the "Christopher" language, any instances of "Chris" or "Christopher" should be colored in red.

"Christopher's preferred color" is configurable in BBEdit > Preferences > Text Colors > Christopher > Christopher's preferred color.

For more information about "Keywords, Run Kind Patterns, and More" see:

HTH

Jean Jourdain

Christopher Waterman

unread,
Aug 24, 2021, 7:25:43 PM8/24/21
to bbe...@googlegroups.com
Jean,

Fantastic example.

Thank you.
— Chris(topher)?

> Here is a minimal Codeless Language Module for an hypothetical "Christopher” language ...

Christopher Waterman

unread,
Aug 24, 2021, 8:27:29 PM8/24/21
to bbe...@googlegroups.com
Ya know what? I think that is my signature going forward.

> Chris(topher)?


Christopher Waterman

unread,
Aug 26, 2021, 2:47:40 AM8/26/21
to bbe...@googlegroups.com
Jean

Again thanks for the help with BBLMRunColors. That really got me off of the right foot.
I’ve discover how you can map them to each other and to builtin RunKinds. Pretty neat.

I have a question regarding BBLMKeywordPatterns. Do you know if you can make it match a named sub-pattern for coloring? 
Similar to the way Function Pattern works. Maybe there is a magic name or something. 😉 

Thanks,
— Chris(topher)?



On Aug 24, 2021, at 1:43 AM, jj <goo...@mixio.com> wrote:


Hi Christopher,

Here is a minimal Codeless Language Module for an hypothetical "Christopher" language that demonstrates the use of color runs.
Save it as Christopher.plist in ~/Library/Application Support/BBEdit/Language Modules.

...

jj

unread,
Aug 26, 2021, 12:09:00 PM8/26/21
to BBEdit Talk
Christopher,

For what I know Function Patterns use named subpatterns in order to capture function names and ranges for the navigation bar Functions menu and for the code folding.

It is not clear to me what will be the use of keyword subpattern captures.

If you don't find an answer to your question in the documentation, you should send an mail to the BBEdit support team (sup...@barebones.com) with a clear description of your question and what you intend to do, including examples, expected results, etc.

Codeless Language Modules documentation is available here:

Best regards,

Jean 

Chris

unread,
Aug 26, 2021, 2:33:54 PM8/26/21
to bbe...@googlegroups.com
Yeah I am likely in the weeds and the problem worked out another way. 

The reason I was wondering if you could target a sub-pattern with Keyword Pattern was that I had a list of keywords: variables, and a list of keywords: commands. It turns out a couple keywords appear in both lists. 

I realized that I only care about the variables keywords in particular contexts, so a larger pattern. But I’d still like the keyword colored as a variable, the sub-pattern. 

Now with a clearer head I realize that doesn’t really make sense. So yeah, I got way way in the weeds and simplified what I was doing. 



On Aug 26, 2021, at 9:09 AM, jj <goo...@mixio.com> wrote:


--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/770e89c3-91bc-44b6-8b83-021f92b9e388n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages