Crimson Editor syntax highlighting

The place to post your WML questions and answers.

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.
Post Reply
floodbud
Posts: 23
Joined: August 23rd, 2007, 5:40 pm

Crimson Editor syntax highlighting

Post by floodbud »

(drumroll please)
***TEXT HIGHLIGHTER***
Here is my first real contribution to BfW.

I have made a text-highlighting feature for Wesnoth WML. This may or may not be helpful; however, I have found in using it that: 1)It helps me to remember to close my tags. 2)I can scroll through my WML files faster and find what I want quicker because of the different colors.

If you want it, do the following:
A. Download Crimson Editor
-Crimson Editor is a free text editor made especially to double as a programming environment for an infinite number of programming languages. Several are already built in.

B. Download my spec files for Crimson Editor.
-Go to my file server.
-Right click "firstline.cfg", then click "Save link as". Put it in the "Crimson Editor/link" folder.
-Get "wesnoth.key" and "wesnoth.spc". Put them in the "Crimson Editor/spec" folder

C. Set up Crimson Editor to use Wesnoth WML.
-Once all of the above are completed, open Crimson Editor. On the menu, click Tools->Preferences. On the left side of the window that pops up, click File->Syntax type.
-In the "Syntax type" window (on top) go to the first "-Empty-" slot and click on it. In the blank "Description" box below, type "Wesnoth WML" or a description of your choice. Then click the three dots button by the "Lang Spec" box. Find "wesnoth.spc" and choose it. Then click the three dots button by the "Keywords" box. Find "wesnoth.key" and choose it.

D. Open any Wesnoth WML file (this includes scenarios, units, _main files, and even maps)
-If the file's first line says "wesnoth" in it somewhere, text highlighting will automatically be applied.
-If text highlighting does not turn on automatically, then on the menu click Document->Syntax type->Wesnoth WML. This should unconditionally turn on the text highlighting.


DEFAULT COLORS:
Light blue: "id", the most important variable, found in almost every file
Dark blue: RESERVED COMMAND IN {} BRACKETS, like "{SPECIAL_NOTES_MARKSMAN}"
Light red: VARIABLE NAME, like "description", "alignment", or "damage"
Dark red: RESERVED COMMAND IN {} BRACKETS DEALING WITH SOUND OR IMAGES, like "{DEFENSE_ANIM}"
Light yellow: BUILT-IN VALUE, like "yes", "melee", or "Ww"
Dark yellow: LOGICAL/CONTROL OPERATOR, like "If", "or", or "not"
Light purple: VARIABLE DEALING WITH SOUND OR IMAGES, like "die_sound" or "image"
Dark purple: START/END TAGS INSIDE OF [] BRACKETS, like "[attack]" or "[side]"
Blue-green: START/END TAGS IN [] BRACKETS THAT DEAL WITH SOUND OR IMAGES, like "[frame]"
Green: LINE STARTING WITH #, like a #define statement or a comment

You can change these colors by going to Tools->Preferences->General->Colors->Keyword Colors.

NOTE: When there is a conflict between a variable name(red) and a start/end tag(Dark purple) I have favored the start/end tag, so some variables that you would think should be red will not be. A common one is the "village" variable.

Disclaimer: I do not believe this setup is perfect. You will probably find some variables I forgot to highlight, or something that is the wrong color. Let me know and I will fix it and release it again. Or if you would rather, use Crimson's help file to decipher the "wesnoth.key" file and fix the problem yourself.
However, in the making of this environment, I looked through nearly every unit, _main, scenario, and map file. To see the product of my several hours of manual labor, open "wesnoth.key" with a regular text editor. Yeah. I typed all that. Manually. For most purposes, this feature should work fine.

You don't have to like this text-highlighter. It might bug you. What the crap, stop griping. I like it, so I shared it. It's not hard to uninstall. And if you insult me, you will really hurt my pride 'cause I worked on this for a long, long time. Not only typing in hundreds of keywords, but bug-testing and error-checking and glitch-killing. I know, I know, I need to get a life. But this is more fun...

Sorry this post is so long! If you read it all, kudos to you.
BTW, this feature is issued without any warranty...blah blah blah...but I know it works fine because I've used it.

Have fun!
--floodbud
User avatar
Ken_Oh
Moderator Emeritus
Posts: 2178
Joined: February 6th, 2006, 4:03 am
Location: Baltimore, Maryland, USA

Post by Ken_Oh »

Cool. I use Crimson Editor so I'll be using this. I just set it up and it works good.

Of course it's not complete, since I'm doing a lot of funky stuff like putting variables inside of variables, but it works well enough to be helpful.

Thanks for releasing it.
floodbud
Posts: 23
Joined: August 23rd, 2007, 5:40 pm

thx

Post by floodbud »

I know it isn't complete. However, it mostly works. I am constantly fixing and patching it. A new version will come out soon.
I am trying to work out a way around the [] tag vs. variable name problem. If I fix it there will be a new release.
You're welcome :D
--floodbud
User avatar
DDR
Posts: 558
Joined: March 23rd, 2007, 4:56 pm
Location: Vancouver, Canada
Contact:

Post by DDR »

Nice! I will use this for WML from now on! - thanks a lot!
I have noticed that a lot of error come from unclosed quotation marks, like:
message= _ "Hey. I'm trying to work here.
Would it be much trouble to highlight, unobtrusively, the quote's contents?
message= _ "Hey. I'm trying to work here."
Thanks! :D
Post Reply