Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [Utility] Syntax Highlighting for DF raws  (Read 10703 times)

Frizzil

  • Bay Watcher
  • Programmer, Guitarist, and Squirrel
    • View Profile
[Utility] Syntax Highlighting for DF raws
« on: January 28, 2013, 12:49:29 am »

Hello one and all,

I just created a very simple package for Sublime Text that syntax highlights the DF raws.  If you don't already have an IDE (ie, a text editor for programmers), I strongly recommend downloading Sublime, as it'll make those raws a thousand times easier to look at :)

Should I mention that this IDE is both fantastic, fully-featured, and free?  Hehe.

Images:
Spoiler (click to show/hide)

Download and Instructions:
Spoiler (click to show/hide)

Once installed, you can select DFML in Sublime by clicking the bottom-right of the window where the current syntax is displayed.

Happy modding!
« Last Edit: January 28, 2013, 01:25:39 am by Frizzil »
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: [Utility] Syntax Highlighting for DF raws
« Reply #1 on: January 28, 2013, 12:57:17 am »

Ah, nice. I expanded an old one from 40d for Notepad++ a little while back, but it only has creature raws for now, so I'm probably not releasing it. Also, it also has this annoying thing with apostrophes, which is why you'll see stray apostrophes in my code :P.'

Frizzil

  • Bay Watcher
  • Programmer, Guitarist, and Squirrel
    • View Profile
Re: [Utility] Syntax Highlighting for DF raws
« Reply #2 on: January 28, 2013, 01:08:16 am »

Ah, nice. I expanded an old one from 40d for Notepad++ a little while back, but it only has creature raws for now, so I'm probably not releasing it. Also, it also has this annoying thing with apostrophes, which is why you'll see stray apostrophes in my code :P.'

Thanks, it's fairly simple, really :P

Only creature raws?  Oh dear, you didn't hard-code in every token did you???  That sounds like a nightmare XD  I basically just treat the first component of a token as the "type", then further components as parameters.  Anything not in between brackets is considered a comment.  It's all Regex magic in Sublime, no validation of token types or anything.

Though that does give me an idea... just make a web scraper for the token lists on the wiki, build a table, then you have validation :)  I don't think you'd be able to reference your own created types, however.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: [Utility] Syntax Highlighting for DF raws
« Reply #3 on: January 28, 2013, 01:09:54 am »

Nope, hehe. This should work much better for me. Besides, Notepad++ was getting annoying with needing admin permission to run.

Frizzil

  • Bay Watcher
  • Programmer, Guitarist, and Squirrel
    • View Profile
Re: [Utility] Syntax Highlighting for DF raws
« Reply #4 on: January 28, 2013, 01:20:55 am »

Nope, hehe. This should work much better for me. Besides, Notepad++ was getting annoying with needing admin permission to run.

*whew* You had me going there, heh.

I don't think Sublime requires admin, but there's a good chance manual installation of the package does, since you'd be fiddling inside the AppData which is hidden by default.  Package Control would probably work, but it's still getting set up by the devs on their end :P  Should be up tomorrow or the day after, hopefully.
Logged

CLA

  • Bay Watcher
    • View Profile
Re: [Utility] Syntax Highlighting for DF raws
« Reply #5 on: January 28, 2013, 12:49:59 pm »

Notepad++ needing admin permission to run.

Huh? What system do you run that on? I never had that problem. I have a portable install on win7, somewhere outside of program files.
Logged
CLA - an ASCII-like Graphic Pack with simplified letter-like creature graphics. The simple and clean looks of ASCII with distinct creature graphics - best of both worlds!

http://www.bay12forums.com/smf/index.php?topic=105376.0

Vherid

  • Bay Watcher
  • [CREATURE:SLARK]
    • View Profile
Re: [Utility] Syntax Highlighting for DF raws
« Reply #6 on: January 28, 2013, 02:59:33 pm »

Damn this is a sexy program.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: [Utility] Syntax Highlighting for DF raws
« Reply #7 on: January 28, 2013, 06:17:52 pm »

Notepad++ needing admin permission to run.

Huh? What system do you run that on? I never had that problem. I have a portable install on win7, somewhere outside of program files.

it doesn't need it to run, I just have it set up to require admin permission to start for easier cfg editing and such in steam, which is in the program files folder.

Dragoon209

  • Bay Watcher
    • View Profile
Re: [Utility] Syntax Highlighting for DF raws
« Reply #8 on: February 06, 2013, 04:57:35 pm »

I've started using this, and found it very handy!  I wasn't aware that something like Sublime Text existed!  I was using notepad++, but this seems to have taken over for now.  I like that its multiplatform, and the default theme is really nice and readable.

Do you have any plans on expanding on this?  For instance, different colors for different tag types? (Tools, Items, Reactions, etc.)
Logged
Check out my mini-mods:
Upgradable Leather Tiers
Block Crafting Workshop

Have you played Webfort yet?  It's a way to play Dwarf Fortress in a web browser with your friends!  Come check it out at:
Community Web Fortress

Itnetlolor

  • Bay Watcher
    • View Profile
    • Steam ID
Re: [Utility] Syntax Highlighting for DF raws
« Reply #9 on: February 06, 2013, 05:14:49 pm »

Although not intended for this use, I always considered the Smalltalk syntax highlight language in Notepad++ to work well for DF raws in most cases. Then again, I'm also looking at 40d raws with it.

It actually has a decent highlighting scheme to it.

For example it displays something like this (mind my labeling):
[RAW:#Value:#Value]
[
RAW:STRING_VALUE/FLAG]
[PREFSTRING:string value/flag]
[
BENIGN]

It does a pretty good job on it's own.
« Last Edit: February 06, 2013, 08:31:47 pm by Itnetlolor »
Logged

zwei

  • Bay Watcher
  • [ECHO][MENDING]
    • View Profile
    • Fate of Heroes
Re: [Utility] Syntax Highlighting for DF raws
« Reply #10 on: November 24, 2017, 06:45:11 am »

Thank you for this tool! I was about to make my own highlighter for Sublime Text 3 - and your works perfectly.

jaked122

  • Bay Watcher
  • [PREFSTRING:Lurker tendancies]
    • View Profile
Re: [Utility] Syntax Highlighting for DF raws
« Reply #11 on: November 24, 2017, 10:22:52 am »

Only creature raws?  Oh dear, you didn't hard-code in every token did you???  That sounds like a nightmare XD  I basically just treat the first component of a token as the "type", then further components as parameters.  Anything not in between brackets is considered a comment.  It's all Regex magic in Sublime, no validation of token types or anything.
That's the wimpy approach.

We don't have optimizing regex engines these days for naught. Go out and send a python script rummaging through all your raws and take all the tags, put them into the sublime syntax, and watch in amazement as it performs reasonably well, against all odds and hopes.