WML syntax hiliting for TextWrangler/BBEdit
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
- Celtic_Minstrel
- Developer
- Posts: 2343
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
WML syntax hiliting for TextWrangler/BBEdit
For Mac users, I made a TextWrangler/BBEdit syntax highlighter (with limited support for the function menu as well). The plist file in the download is generated by a simple Python script so that it hilites full tags rather than just the tag-name (thus preventing tag-names from being hilited in other contexts); the source for that script is also available, which could be useful if someone else wanted to update it for newer tags. It's probable that I've missed a tag or two, and there may be one or two tags in the list that don't exist. Preprocessor commands are also considered identifiers and hilited as such, while still supporting comment hiliting.
Download
Source
I didn't include a license file in the download, but it can be considered to be available under a Simplified BSD license.
If I had the time (and motivation) I would do it properly and write a C++ module to interface with TextWrangler for the syntax hiliting; there's an API provided for that, and it would make a lot of things nicer (eg, ability to hilite inline Lua). Maybe someday I'll do that.
Download
Source
I didn't include a license file in the download, but it can be considered to be available under a Simplified BSD license.
If I had the time (and motivation) I would do it properly and write a C++ module to interface with TextWrangler for the syntax hiliting; there's an API provided for that, and it would make a lot of things nicer (eg, ability to hilite inline Lua). Maybe someday I'll do that.
Last edited by Celtic_Minstrel on April 6th, 2023, 12:52 am, edited 2 times in total.
- Celtic_Minstrel
- Developer
- Posts: 2343
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: WML syntax hiliting for TextWrangler
Updated this with a bunch of missing tags, and also added a FAI.plist as a hiliter for FormulaAI (automatically applies to files with a .fai extension). I don't use much FormulaAI, so I'm not sure how good this is.
This version considers #wmllint to be a preprocessor directive. Unfortunately this won't work if there's a space, ie "# wmllint".
The new version overwrites the old, so use the same links in the first post.
This version considers #wmllint to be a preprocessor directive. Unfortunately this won't work if there's a space, ie "# wmllint".
The new version overwrites the old, so use the same links in the first post.
Re: WML syntax hiliting for TextWrangler
Thanks for coding this up- I'm new to Textwrangler and can't seem to figure how to make this work- can you do a quick write up? Most text editors I've use in the past have a simple pulldown to select the highlight mode.
- Celtic_Minstrel
- Developer
- Posts: 2343
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: WML syntax hiliting for TextWrangler
There are three pull-downs at the bottom of the window, which from left to right are language, encoding, newline style. You need to put the WML.plist where TextWrangler can find it (which is "~/Application Support/TextWrangler/Language Modules" if I recall correctly), and if it's running you need to restart it.
- Celtic_Minstrel
- Developer
- Posts: 2343
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: WML syntax hiliting for TextWrangler
Unless TextWrangler allows you to colour "line comments" and "block comments" in different colours, I don't think you can change the macro colour. The thing is, this is just a set of configuration parameters for TextWrangler's basic syntax highlighter, and I set it up to count macros as comments. There's only a limited amount of customizability in the basic highlighter, so I believe that was the best I could manage.
Adding additional tags to the recognized list is easy, though. If you open the plist file in an appropriate editor (you can even open it in TextWrangler itself if there are no better editors installed), you can find the list of recognized keywords and add whatever you want. There's probably a lot more missing than just
[elseif]
.Re: WML syntax hiliting for TextWrangler
In TextWrangler's Preferences section is a tab for "colors." I clicked it and saw a list of codes, which included General, HTML, Markdown, etc, and under each code was a list of elements and their colors. It seems to me that if WML were in that list, changing colors of a macro would be possible. I don't know how hard that would be, though. All this stuff may as well be atomic science as far as my comprehension is concerned. Or magnets. But maybe...you could...add..........................it?Celtic_Minstrel wrote: ↑November 16th, 2020, 1:00 am Unless TextWrangler allows you to colour "line comments" and "block comments" in different colours, I don't think you can change the macro colour. The thing is, this is just a set of configuration parameters for TextWrangler's basic syntax highlighter, and I set it up to count macros as comments. There's only a limited amount of customizability in the basic highlighter, so I believe that was the best I could manage.
Oh! Would it be possible to color macros differently if macros were categorized as something else beside a comment block? Such as predefined symbols? Or even something inaccurate, like XML Processing Instructions or even Misspelled Words? I don't know, but maybe there's a quick workaround.
I shocked myself. I addedCeltic_Minstrel wrote: ↑November 16th, 2020, 1:00 am Adding additional tags to the recognized list is easy, though. If you open the plist file in an appropriate editor (you can even open it in TextWrangler itself if there are no better editors installed), you can find the list of recognized keywords and add whatever you want. There's probably a lot more missing than just[elseif]
.
[elseif]
to the syntax highlighter and it works. Yay.Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
- Celtic_Minstrel
- Developer
- Posts: 2343
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: WML syntax hiliting for TextWrangler
I have no control over that screen where you set the colours. The only colours available for the basic syntax highlighter are the ones you see in the Source Code section (and not even all of those, I think).Helmet wrote: ↑November 16th, 2020, 3:46 am In TextWrangler's Preferences section is a tab for "colors." I clicked it and saw a list of codes, which included General, HTML, Markdown, etc, and under each code was a list of elements and their colors. It seems to me that if WML were in that list, changing colors of a macro would be possible. I don't know how hard that would be, though. All this stuff may as well be atomic science as far as my comprehension is concerned. Or magnets. But maybe...you could...add..........................it?
It's possible to set them as XML Processing Instructions, but not when using a plist file. It would require writing C/C++ code to implement the syntax highlighting… I did give it a try awhile back but it's pretty buggy and I don't even think the plugin I built would work on a newer Mac. Since I don't use TextWrangler for WML anymore, I don't have much motivation to fix it.Helmet wrote: ↑November 16th, 2020, 3:46 am Oh! Would it be possible to color macros differently if macros were categorized as something else beside a comment block? Such as predefined symbols? Or even something inaccurate, like XML Processing Instructions or even Misspelled Words? I don't know, but maybe there's a quick workaround.
Re: WML syntax hiliting for TextWrangler
I understand. I have a custom sprite in my campaign that could be better, but it works and I have other sprites that I need to work on instead. The syntax highlighter is still very useful for writing WML, so thanks for making it.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
- Celtic_Minstrel
- Developer
- Posts: 2343
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: WML syntax hiliting for TextWrangler
I updated the links in the opening post.
Re: WML syntax hiliting for TextWrangler
Thanks!
Wesnoth-related GitHub repos:
General mods collection, SotBEEE, AToTBWaTD, The Earth's Gut, A Little Adventure, FtF
Social media: Mastodon: @egallager@treehouse.systems, Steam: egallager
General mods collection, SotBEEE, AToTBWaTD, The Earth's Gut, A Little Adventure, FtF
Social media: Mastodon: @egallager@treehouse.systems, Steam: egallager