Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3

Author Topic: Notepad++ syntax highlighting for DF raws  (Read 16141 times)

qwert

  • Bay Watcher
    • View Profile
Notepad++ syntax highlighting for DF raws
« on: December 19, 2008, 03:50:51 pm »

Just went through all the tags and tokens on the wiki, and created a custom language file for Notepad++

To use it copy the following into "%appdata%/Notepad++/userDefineLang.xml" with normal Windows Notepad (not Notepad++, that makes for weird errors). Then, with a DF raw file open, go to the languages menu, and pick 'DF Raw' at the bottom. Will now automagically associate txt files as DF raws, to change switch
Code: [Select]
    <UserLang name="DF Raw" ext="txt"> with
Code: [Select]
    <UserLang name="DF Raw" ext="">

Spoiler (click to show/hide)


Big tags like MATGLOSS, NAME, etc are bold and black, Location tags like IGNEOUS, ANY_DESERT, etc are bold and teal, Anything creature related like CAN_LEARN, GENPOWER, etc is bold and dark green, and everything else (materials and professions, mostly) is bold and dark red. Also, since tiles are in single quotes I was able to make them show with a dark blue background, and a light blue text color.


Post any missing tags/errors and comments please, and I will update as needed.

Note: I know that Vista handles program data different from XP, so anyone who can tell me the equivalent location in Vista would be appreciated.


For the unaware, "Notepad++ is a free (as in "free speech" and also as in "free beer") source code editor and Notepad replacement that supports several languages."


Edit: Added [BAR] to it, and preview screenie, from creature_other, reaction_standard, and matgloss_stone_layer:








EDIT2: Fixed some misplaced stone tokens, like METAL_ORE that were near tags like LAVA and updated the picture to reflect this.

EDIT3: Notepad++ will now automatically highlight all txt files as DF raws, and I made the  creature tags green instead of brown, forcing me to make the biom tags teal.
« Last Edit: September 27, 2009, 06:17:10 pm by qwert »
Logged

Warlord255

  • Bay Watcher
  • Master Building Designer
    • View Profile
Re: Notepad++ syntax highlighting for DF raws
« Reply #1 on: December 19, 2008, 03:52:02 pm »

<- on a Mac with TextEdit. :(
Logged
DF Vanilla-Spice Revised: Better balance, more !!fun!!
http://www.bay12forums.com/smf/index.php?topic=173907.msg7968772#msg7968772

LeadfootSlim on Steam, LeadfootSlim#1851 on Discord. Hit me up!

Deon

  • Bay Watcher
  • 💀 💀 💀 💀 💀
    • View Profile
Re: Notepad++ syntax highlighting for DF raws
« Reply #2 on: December 19, 2008, 03:57:04 pm »

Uhh so thanks :). I always use notepad++.
Logged
▬(ஜ۩۞۩ஜ)▬
✫ DF Wanderer ✫ - the adventure mode crafting and tweaks
✫ Cartographer's Lounge ✫ - a custom worldgen repository

Granite26

  • Bay Watcher
    • View Profile
Re: Notepad++ syntax highlighting for DF raws
« Reply #3 on: December 19, 2008, 04:35:07 pm »

thanks for the hard work!

Impaler[WrG]

  • Bay Watcher
  • Khazad Project Leader
    • View Profile
Re: Notepad++ syntax highlighting for DF raws
« Reply #4 on: December 19, 2008, 08:19:17 pm »

Nice work, I am a NP++ fan and will be using it even more now.
Logged
Khazad the Isometric Fortress Engine
Extract forts from DF, load and save them to file and view them in full 3D

Khazad Home Thread
Khazad v0.0.5 Download

Fieari

  • Bay Watcher
    • View Profile
Re: Notepad++ syntax highlighting for DF raws
« Reply #5 on: December 19, 2008, 10:45:12 pm »

Well, looking into Notepad++ has convinced me to switch out from TextPad, which I had been using.  (The Window Manager plugin is what I really needed to make the switch)  Now then, I can't find the userDefineLang.xml file.  There is a langs.model.xml and langs.xml, but they don't seem to have the same syntax.  Making a new userDefineLang.xml file doesn't seem to work...

I'm using v5.1.2 if it matters.
Logged

qwert

  • Bay Watcher
    • View Profile
Re: Notepad++ syntax highlighting for DF raws
« Reply #6 on: December 19, 2008, 11:29:11 pm »

Hmm, try sticking it into "C:\Program Files\Notepad++"

Depending on how you installed it, it might use that folder for configuration instead.
Logged

Vucar Fikodastesh

  • Bay Watcher
  • Grand Master Explorer
    • View Profile
Re: Notepad++ syntax highlighting for DF raws
« Reply #7 on: December 19, 2008, 11:33:56 pm »

I love you.
Logged
I think it's a vastly amusing thought that elephants are so afraid of heights that when Dwarves invented the Z-axis, they couldn't bear to face dwarves in combat anymore.

Captain Mayday

  • Bay Watcher
  • A Special Kind of Terrible
    • View Profile
Re: Notepad++ syntax highlighting for DF raws
« Reply #8 on: December 21, 2008, 11:12:41 pm »

This is extremely good, but I really need it to allow collapsing of sections in the same manner as the python language.
Logged
Why not join us on IRC? irc.newnet.net #bay12games

qwert

  • Bay Watcher
    • View Profile
Re: Notepad++ syntax highlighting for DF raws
« Reply #9 on: December 22, 2008, 01:10:23 am »

The way that collapsing works is that an opening and a closing character or phrase must be declared for each 'folding'. The way the raws work, the end of one entry is the beginning of the next, and it doesn't work just using, say, [CREATURE to both open and close the folding (notepad++ nests each entry inside the previous when you try that).

That is, there is no innate way to tell Notepad++ where to start and stop the folding. I suppose I could make it look for opening and closing characters like {} (assuming DF doesn't explode when it finds them). That will involve a long, annoying find and replace job for every raw file, and would have to be done for any existing mods that want character folding, though.  :-\

It's late, so I can't try genning a world with any attempts at getting around the problem, so I'll try tomorrow.
« Last Edit: December 22, 2008, 01:12:21 am by qwert »
Logged

Captain Mayday

  • Bay Watcher
  • A Special Kind of Terrible
    • View Profile
Re: Notepad++ syntax highlighting for DF raws
« Reply #10 on: December 22, 2008, 02:09:21 am »

The way that collapsing works is that an opening and a closing character or phrase must be declared for each 'folding'. The way the raws work, the end of one entry is the beginning of the next, and it doesn't work just using, say, [CREATURE to both open and close the folding (notepad++ nests each entry inside the previous when you try that).

That is, there is no innate way to tell Notepad++ where to start and stop the folding. I suppose I could make it look for opening and closing characters like {} (assuming DF doesn't explode when it finds them). That will involve a long, annoying find and replace job for every raw file, and would have to be done for any existing mods that want character folding, though.  :-\

It's late, so I can't try genning a world with any attempts at getting around the problem, so I'll try tomorrow.

Python apparently uses tabs.
Logged
Why not join us on IRC? irc.newnet.net #bay12games

qwert

  • Bay Watcher
    • View Profile
Re: Notepad++ syntax highlighting for DF raws
« Reply #11 on: December 22, 2008, 01:42:34 pm »

The problem is that since this is a user defined custom language, the only way for it to work is to have definite opening and closing strings (whitespace is the separator between strings). Also, it completely breaks if I try to use [CREATURE, etc as a string for folding anyway, because it doesn't see it as one until I tell it to not treat '[' as a symbol, which unhighlights everything immediately after a '[' in the entirety of the file.

It would be impossible to write folding for Python in a custom language as well, the developers had to cheat by hardcoding it.
Logged

Jurassiced

  • Bay Watcher
    • View Profile
Re: Notepad++ syntax highlighting for DF raws
« Reply #12 on: December 23, 2008, 11:45:56 am »

ownage tahnks mate note++ best
Logged
POKHOMME http://dffd.wimbli.com/file.php?id=84 Race mod im working on.

DJ_Muffinman

  • Bay Watcher
  • Awwwww...
    • View Profile
Re: Notepad++ syntax highlighting for DF raws
« Reply #13 on: December 23, 2008, 11:48:57 pm »

Hmm, try sticking it into "C:\Program Files\Notepad++"

Depending on how you installed it, it might use that folder for configuration instead.
I'm having the same problem. There's an API folder that has some, but not all, of the available languages in the Language Menu all in XML format. Do I make this into it's own XML file or what?
Logged
Kill a Bear

Live to Brag

qwert

  • Bay Watcher
    • View Profile
Re: Notepad++ syntax highlighting for DF raws
« Reply #14 on: December 24, 2008, 12:38:06 am »

I'm having the same problem. There's an API folder that has some, but not all, of the available languages in the Language Menu all in XML format. Do I make this into it's own XML file or what?

So far as I can tell, you just make one named userDefineLang.xml in the folder in the OP first, then try Program Files.

API folder  is for autocomplete, which I need to get around to doing.
Logged
Pages: [1] 2 3