Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Notepad++ highlighting mod remade v1.2 "Comments and dark mode improved"  (Read 6311 times)

Sirmaril

  • Bay Watcher
  • I'm from Poland, so sorry for my bad english.
    • View Profile

Hi everyone!

This is my first utility mod for Dwarf Fortress. This is expanded version of "Notepad++ raw file highlighting mode" made by Kazimuth, since he seems to have abandoned it, and the Bay12Forums, his post can be found here: http://www.bay12forums.com/smf/index.php?topic=130510

What does it do?

This file can be used by Notepad++ editor to highlight syntax used in Dwarf Fortress moding. You can change the default colours I chose by following the instructions down below or in the download file. You can see how it looks here:

Spoiler (click to show/hide)

What's new?

Spoiler (click to show/hide)

How to use it?

A simple how-to guide is included in with the download or you can check the spoiler here:

Spoiler (click to show/hide)

Download

Mod file and how-to guide can be downloaded here: http://dffd.bay12games.com/file.php?id=12053

Progress so far.

So far I've managed to give it a basic functionality I wanted. You can open any file like d_init.txt in data folder or entity_default.txt in raw folder and get a helpful highlighting. I'm not sure if i have included all the tokens so if anything is missing please let me know.

Known issues.

Some tokens are used differently in different files so sometimes some odd words may be highlighted, event though they shouldn't be highlighted here, but they are useful elsewhere.
Comments, highlighted blue, are highlighted black after colon, ":", there is nothing I can do about that, it's just a limitation imposed by Notepad++.

Found any errors, missing tokens, etc.?

If you do please comment here.

ArchbishopDave

  • Escaped Lunatic
    • View Profile
Re: Notepad++ highlighting mod remade
« Reply #1 on: May 22, 2016, 04:25:38 pm »

Hi there!

I saw the post with the old language file the other day and was really hoping for a new one! I fiddled around, but could not find a good example for writing my own. This though is pretty spot on and extremely helpful!

Some things I noticed during the few files I've poked through with it.


1. The only a single ATTRIBUTE_TAG is included in the ruleset. STRENGTH is the only one that is color coded (and in group 4). Below is a link to the page that lists them all, but it doesn't seem to actually have the tags associated with them. I took what I found quickly in creature_standard though.

http://dwarffortresswiki.org/index.php/DF2014:Attribute

Spoiler (click to show/hide)

2. A Couple of high level CREATURE_TOKEN seem to be missing.

STRANGE_MOODS and OUTSIDER_CONTROLLABLE are ones I immediately saw.
The CREATURE_TOKEN (Caste) MULTIPART_FULL_VISION is as well.
Should probably be level 3 with the rest of the high level tags.

3. The rules for comments causes some strange tagging to occur in some strings. See spoiler for examples. Looks like the comma is really the only one that would be used regularly and cause this problem, but DF doesn't need to escape it. Where is that used as a separator in the modding language? In any case, very small problem.

Spoiler (click to show/hide)

4. Really Small Issue
SET_SCHOLARS_ON_VALUES_AND_JOBS appears to be a high level ENTITY_TOKEN but is set to a different level than all of the others? It is 4, while most others are 3. ( [MERCENARY] for example is Green, while it is Orange)



Other Comments

At some point, it might be good to split the different high level tags (Group 3-Green) into another, one that accepts arguments and one that does not. So something like WOOD_WEAPONS and PERMITTED_JOB, while being the same kind of token have different rules. Perhaps the color difference could be subtle in this case.

This note is a slippery slope, but perhaps tags that expect nested values could have their own color as well? For example, the POSITION ENTITY_TOKEN. Truth be told, I have no idea how DF decides that the next tag is not a part of it when reading the raws. Maybe just the first time it runs into something non-valid? In any case, someone messing with the raws I'm sure knows, but it still might be a good feature to have.

I use a different standard color set for my text viewing (dark mode). When using the language, the background color for all tokens is set to white instead of translucent.


All in all, awesome work! As I said at the beginning, this is really helpful with just letting me scan something and immediately find what I'm looking for. Thanks!
Logged

Dirst

  • Bay Watcher
  • [EASILY_DISTRA
    • View Profile
Re: Notepad++ highlighting mod remade
« Reply #2 on: May 22, 2016, 05:58:31 pm »

Other Comments

At some point, it might be good to split the different high level tags (Group 3-Green) into another, one that accepts arguments and one that does not. So something like WOOD_WEAPONS and PERMITTED_JOB, while being the same kind of token have different rules. Perhaps the color difference could be subtle in this case.

This note is a slippery slope, but perhaps tags that expect nested values could have their own color as well? For example, the POSITION ENTITY_TOKEN. Truth be told, I have no idea how DF decides that the next tag is not a part of it when reading the raws. Maybe just the first time it runs into something non-valid? In any case, someone messing with the raws I'm sure knows, but it still might be a good feature to have.
This would be awesome, but DF structures only have an "open tag" and simply close when the next "open tag" or end-of-file occur.  Notepad++ language files, to my knowledge, only understand structures with an "open tag" and a "close tag".

We could make up a close tag that DF sees as a comment, but then it would only work on specially-made raws.
Logged
Just got back, updating:
(0.42 & 0.43) The Earth Strikes Back! v2.15 - Pay attention...  It's a mine!  It's-a not yours!
(0.42 & 0.43) Appearance Tweaks v1.03 - Tease those hippies about their pointy ears.
(0.42 & 0.43) Accessibility Utility v1.04 - Console tools to navigate the map

Thundercraft

  • Bay Watcher
    • View Profile
Re: Notepad++ highlighting mod remade
« Reply #3 on: May 22, 2016, 06:39:48 pm »

[snip]...perhaps tags that expect nested values could have their own color as well? For example, the POSITION ENTITY_TOKEN. Truth be told, I have no idea how DF decides that the next tag is not a part of it when reading the raws...
This would be awesome, but DF structures only have an "open tag" and simply close when the next "open tag" or end-of-file occur.  Notepad++ language files, to my knowledge, only understand structures with an "open tag" and a "close tag".

We could make up a close tag that DF sees as a comment, but then it would only work on specially-made raws.

In terms of making up a fake close tag for this highlighting mod to interpret as a close: Is there anything to prevent Notepad++ from interpreting, say, the next "]" or ":" or other punctuation as a close? But then, is it possible for Notepad++ to use the same combination of letters and symbols as the close tag for multiple, different tokens? Worth a shot?
Logged

Sirmaril

  • Bay Watcher
  • I'm from Poland, so sorry for my bad english.
    • View Profile
Re: Notepad++ highlighting mod remade
« Reply #4 on: May 23, 2016, 03:46:11 am »

Hi folks!

Thanks for all your input. I will try to implement your suggestions ASAP, although I won't be able to work on it this week since I need to finish my project for my university class.

About comments in DF files. I cannot make them any better than they are right now. Problem is that when you put colon, ":", anywhere in the comment it will interpret is as an operator, and then it will highlight the rest of the line accordingly. I've managed to work around it by making any other punctuation character an operator stopper. I wanted to set whitespace as such, but sadly it's impossible. If DF files had a designated comment operator, like say Java has "//" it would be mush easier, but ATM I cannot do anything about it.

Sirmaril

  • Bay Watcher
  • I'm from Poland, so sorry for my bad english.
    • View Profile
Re: Notepad++ highlighting mod remade v1.1 "New tokens and dark mode"
« Reply #5 on: May 24, 2016, 01:34:06 pm »

Hi Folks!

I come with and update. I added some missing tokens and added a dark mode as an option. Tell me what you think and tell me if I missed something again.

Sirmaril

  • Bay Watcher
  • I'm from Poland, so sorry for my bad english.
    • View Profile
Re: Notepad++ highlighting mod remade
« Reply #6 on: May 25, 2016, 02:57:56 am »

Hi ArchbishopDave!

Sorry for answering so late, but I've been quite busy lately.

1. The only a single ATTRIBUTE_TAG is included in the ruleset. STRENGTH is the only one that is color coded (and in group 4). Below is a link to the page that lists them all, but it doesn't seem to actually have the tags associated with them. I took what I found quickly in creature_standard though.

http://dwarffortresswiki.org/index.php/DF2014:Attribute

Spoiler (click to show/hide)

2. A Couple of high level CREATURE_TOKEN seem to be missing.

STRANGE_MOODS and OUTSIDER_CONTROLLABLE are ones I immediately saw.
The CREATURE_TOKEN (Caste) MULTIPART_FULL_VISION is as well.
Should probably be level 3 with the rest of the high level tags.

Thanks for that info, it really helped me to find my mistakes.


3. The rules for comments causes some strange tagging to occur in some strings. See spoiler for examples. Looks like the comma is really the only one that would be used regularly and cause this problem, but DF doesn't need to escape it. Where is that used as a separator in the modding language? In any case, very small problem.

Spoiler (click to show/hide)

Yes, it's quite a problem when it comes to comments. Actually comma was my way of trying to help out with the comment highlighting, but it didn't help. Problem is that some comments begin or contain a colon, ":" somewhere in it and Notepad++ interprets that as an operator and then it highlights whole string black. It looks bad in comments, but it causes problem other way around when as you pointed out it highlights DESCRIPTION tokens incorrectly. I think that I will remove this rule that treats comma as an operation breaker, maybe it'll look a bit better.


4. Really Small Issue
SET_SCHOLARS_ON_VALUES_AND_JOBS appears to be a high level ENTITY_TOKEN but is set to a different level than all of the others? It is 4, while most others are 3. ( [MERCENARY] for example is Green, while it is Orange)

This will be fixed in version 1.2, I forgot to do it in this release.


Other Comments

At some point, it might be good to split the different high level tags (Group 3-Green) into another, one that accepts arguments and one that does not. So something like WOOD_WEAPONS and PERMITTED_JOB, while being the same kind of token have different rules. Perhaps the color difference could be subtle in this case.

This note is a slippery slope, but perhaps tags that expect nested values could have their own color as well? For example, the POSITION ENTITY_TOKEN. Truth be told, I have no idea how DF decides that the next tag is not a part of it when reading the raws. Maybe just the first time it runs into something non-valid? In any case, someone messing with the raws I'm sure knows, but it still might be a good feature to have.

I use a different standard color set for my text viewing (dark mode). When using the language, the background color for all tokens is set to white instead of translucent.

As it was pointed out already your idea is great, but it'll not work with how Dwarf Fortress's language is build up. When it comes to dark mode I couldn't find a solution to make background of highlights transparent, I will look more into this later, but for now I've made a separate version where background is set to black.


All in all, awesome work! As I said at the beginning, this is really helpful with just letting me scan something and immediately find what I'm looking for. Thanks!

Thanks a lot, I'm happy that it helps you.

ArchbishopDave

  • Escaped Lunatic
    • View Profile
Re: Notepad++ highlighting mod remade v1.1 "New tokens and dark mode"
« Reply #7 on: May 25, 2016, 10:16:57 am »

Replying by mobile so I apologize for the short and terse post.

I wasn't suggesting that the nested tags be collapsible or anything, just that they're their own color, signifying that subsequent tags are probably related. I think DF just looks for the next unrelated / unexpected tag, and that would be a nightmare to replicate. As for the transparency thing, right clicking the color box sets it as transparent. Not home, or I'd just paste the export of mine as example.

Thanks again!
Logged

Sirmaril

  • Bay Watcher
  • I'm from Poland, so sorry for my bad english.
    • View Profile
Re: Notepad++ highlighting mod remade v1.1 "New tokens and dark mode"
« Reply #8 on: May 25, 2016, 10:22:53 am »

Hi ArchbishopDave!

Replying by mobile so I apologize for the short and terse post.

I wasn't suggesting that the nested tags be collapsible or anything, just that they're their own color, signifying that subsequent tags are probably related. I think DF just looks for the next unrelated / unexpected tag, and that would be a nightmare to replicate. As for the transparency thing, right clicking the color box sets it as transparent. Not home, or I'd just paste the export of mine as example.

Thanks again!

Sorry I wasn't clear enough, but I understood what you wanted, but I cannot do it. I tried and searched on the internet but without any success. What you want is a pretty nice idea but as far as I know I cannot do it.

Thanks for the information about setting the colour to transparent. I tried looking for it but all I found was info on how to make the editor window transparent. I didn't found info in documentation for UDL either, so thanks for the tip, it'll make things easier for me.

With best regards,
Daniel.

Repseki

  • Bay Watcher
    • View Profile
Re: Notepad++ highlighting mod remade v1.1 "New tokens and dark mode"
« Reply #9 on: May 27, 2016, 05:29:06 am »

Quick question, doesn't actually have to do with the highlighting specifically, which is wonderfully helpful.

Is there any way to set the user defined Notepad++ language as default?

In the settings you can set a default, but the imported DF one doesn't seem to be in the list, just wondering if I'm missing something obvious.
Logged

Sirmaril

  • Bay Watcher
  • I'm from Poland, so sorry for my bad english.
    • View Profile
Re: Notepad++ highlighting mod remade v1.1 "New tokens and dark mode"
« Reply #10 on: May 27, 2016, 05:58:02 am »

Hi Repseki!

Thanks a lot, and to answer your question. You can set it to default, but it'll be a bit special. Since Dwarf Fortress uses normal txt files for modding it's a bit problematic to set the language highlight to default to special extension. It much easier with Java for example since all of it's file have .java as extension.

You can set my highlight to default to txt files, but then it will hilghlight also normal txt files. If you are ok with this here's how to do it:

Spoiler (click to show/hide)

Dirst

  • Bay Watcher
  • [EASILY_DISTRA
    • View Profile
Re: Notepad++ highlighting mod remade v1.1 "New tokens and dark mode"
« Reply #11 on: May 27, 2016, 09:49:41 am »

Came up with a better way to differentiate comments.

First, make sure there are no "line comment" delimiters, and make sure that comments are allowed "anywhere".

Second, make the open comment character into a ]
Third, make the close comment character into a [

This will miss comments before the first tag and after the last tag, but those are pretty obvious anyway.
Logged
Just got back, updating:
(0.42 & 0.43) The Earth Strikes Back! v2.15 - Pay attention...  It's a mine!  It's-a not yours!
(0.42 & 0.43) Appearance Tweaks v1.03 - Tease those hippies about their pointy ears.
(0.42 & 0.43) Accessibility Utility v1.04 - Console tools to navigate the map

Sirmaril

  • Bay Watcher
  • I'm from Poland, so sorry for my bad english.
    • View Profile

Thanks Dirst for your idea. I implemented it and uploaded a new version for all to try out, let me hear what you all think of it.

Kazimuth

  • Bay Watcher
  • [ARTIFICIAL_HIVEABLE]
    • View Profile
    • github

I've updated the ancient project thread, by the way. Thanks for keeping this up to date :)
Logged
I'm not sure this was a good idea