Author Topic: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!  (Read 8783 times)

0 Members and 1 Guest are viewing this topic.

Offline Sesquipedalian

  • Atankharz'ythi
  • 211
Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
I've created syntax highlighting modules for FreeSpace 2 mission and table files to use in modern text editors like TextMate, Sublime Text, and Atom. Syntax highlighting makes it so much nicer and easier to edit mission and table files by hand.

Syntax highlighting is much prettier to look at, of course. But more importantly, syntax highlighting makes it immediately easier to see and understand what is happening in the file when you read it. For those times when you need to fire up a text editor and mess around with the guts of your mission and table files, this is much better than using Notepad.

Check it out:

More examples with different themes:

(Click to enlarge)

Section headings, keywords, SEXP names, numeric values, string values, variables, colour control codes in XSTR text, etc., all receive unique formatting. The section headings will populate the quick navigation features of TextMate and Sublime Text, making it easy to get to the section that you need to deal with.


I've created versions of the FreeSpace 2 syntax highlighting module for the three text editors mentioned above. To use one, do the following:

  • Choose one of the three text editors and install it.
    • TextMate is the best all around, but it is for Macs only. Get it here.
    • Sublime Text is the best for Windows and Linux, but not as user friendly as the others. Get it here.
    • Atom is slightly less powerful than the first two, but more user friendly than Sublime Text. Get it here.
  • Install the FreeSpace 2 module for your application
    • For TextMate and SublimeText, go to https://github.com/Sesquipedalian/freespace2.tmbundle and follow the simple installation instructions to get the FreeSpace 2 bundle up and running in no time.
    • For Atom, just go to the Install section of the application's settings, search for "language-fs2", and click the install button once it finds the package for you.

Supported file types:
  • .fs2 (mission files)
  • .fc2 (campaign files)
  • .tbl (table files)
  • .tbm (modular table files)

All three of these text editors let you choose your favourite theme, so you can choose whichever colour scheme you prefer. I personally like the one in the top picture, but there are many options available.

Changelog:
  • 0.3.3
    • Detect SEXP operators correctly even when not separated by whitespace from parentheses
  • 0.3.2
    • Allow space between digit and closing parenthesis in XSTR construct
  • 0.3.1
    • Derp...
  • 0.3.0
    • Redefines some language elements (again) because Atom's default themes ignored a rather important one
    • Fine tunes a couple of the regular expressions
  • 0.2.1
    • Adjusts SEXP detection to work around a bug in Sublime Text
  • 0.2.0
    • Restructures SEXP handling to be much more robust
    • Better differentiates some language elements
  • 0.1.0
    • Initial release
« Last Edit: February 07, 2016, 10:30:37 pm by Sesquipedalian »
Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

The Scroll of Atankharzim | FS2 syntax highlighting

 

Offline niffiwan

  • 211
  • Eluder Class
Re: FS2 syntax highlighting in your text editor
Neat! I don't suppose you have a language/syntax file for vim?   ;7

Also seems like a good time/place to link in Mjn's similar efforts for notepad++

http://www.hard-light.net/forums/index.php?topic=84887.0 (TBL/TBM)
http://www.hard-light.net/forums/index.php?topic=84905.0 (debug log)
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Re: FS2 syntax highlighting in your text editor
Oh, sweet. I've always preferred Sublime Text; one of these days, I was going to try to make my own syntax highlighting for it. It looks like you've saved me the trouble! :yes:

I don't suppose you could add debug log support...?
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

 

Offline Sesquipedalian

  • Atankharz'ythi
  • 211
Re: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
Neat! I don't suppose you have a language/syntax file for vim?   ;7
:lol:

Quote
Also seems like a good time/place to link in Mjn's similar efforts for notepad++

http://www.hard-light.net/forums/index.php?topic=84887.0 (TBL/TBM)
http://www.hard-light.net/forums/index.php?topic=84905.0 (debug log)

Cool. Well, now we have more options, and not just for one editor on Windows. :)


I don't suppose you could add debug log support...?

Probably. Might be a while before I can get around to it, though. :)
Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

The Scroll of Atankharzim | FS2 syntax highlighting

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
I'll move this to tools in a couple of days. Let the FREDders see it first. :D
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Online Bryan See

  • Has anyone really been far as decided to use even go want to do look more like?
  • 210
  • Trying to redeem.
    • Skype
    • Steam
    • Twitter
Re: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
I don't see any FreeSpace-related extensions in the link: http://docs.notepad-plus-plus.org/index.php/User_Defined_Language_Files.

However, can I create them by myself?

EDIT: I'm using Notepad++.
Bryan See - My FreeSpace Wiki User Page (Talk, Contributions)

Campaigns:
FreeSpace: Reunited - Shattered Stars

Ships:
GTS Hygeia, GTT Argo, SC Raguel

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Re: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
I don't see any FreeSpace-related extensions in the link: http://docs.notepad-plus-plus.org/index.php/User_Defined_Language_Files.

However, can I create them by myself?

EDIT: I'm using Notepad++.
Niffiwan just linked to them in the very first reply:
Also seems like a good time/place to link in Mjn's similar efforts for notepad++

http://www.hard-light.net/forums/index.php?topic=84887.0 (TBL/TBM)
http://www.hard-light.net/forums/index.php?topic=84905.0 (debug log)
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

 

Offline coffeesoft

  • 28
  • Bip Bip
Re: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
This is incredibly useful , as well i didn't  know the thread of Notepad ++ .

My eyes are very grateful , thanks :p

 

Offline Sesquipedalian

  • Atankharz'ythi
  • 211
Re: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
You are welcome. :yes:
Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

The Scroll of Atankharzim | FS2 syntax highlighting

 
Re: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
i won't be happy until we have an emacs major mode that can interface with a running FSO process
The good Christian should beware of mathematicians, and all those who make empty prophecies. The danger already exists that the mathematicians have made a covenant with the devil to darken the spirit and to confine man in the bonds of Hell.

 

Offline Sesquipedalian

  • Atankharz'ythi
  • 211
Re: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
i won't be happy until we have an emacs major mode that can interface with a running FSO process
Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

The Scroll of Atankharzim | FS2 syntax highlighting

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
Works great on my Sublime Text 3 on my Mac.  However, it does seem to be acting like it's running some very long loops between actions, so far I noticed it just on opening and closing the files.  It hangs the program for a couple of seconds.  None of my other syntax highlighted files have an issue like that.

Edit:  Or it may have been that the nightly build process had just started running in the background, that does tend to consume a lot of my CPU cycles.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline Sesquipedalian

  • Atankharz'ythi
  • 211
Re: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
Works great on my Sublime Text 3 on my Mac.  However, it does seem to be acting like it's running some very long loops between actions, so far I noticed it just on opening and closing the files.  It hangs the program for a couple of seconds.  None of my other syntax highlighted files have an issue like that.

Edit:  Or it may have been that the nightly build process had just started running in the background, that does tend to consume a lot of my CPU cycles.

I have not seen that on my machine at all. Have you had a chance to try it again since?
Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

The Scroll of Atankharzim | FS2 syntax highlighting

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
Yeah running much better when not simultaneously trying to compile 9 C++ files at a time.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline Sesquipedalian

  • Atankharz'ythi
  • 211
Re: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
I've made some updates. Now at version 0.2.1. See original post for changelog.
« Last Edit: January 05, 2016, 03:39:51 pm by Sesquipedalian »
Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

The Scroll of Atankharzim | FS2 syntax highlighting

 

Offline Sesquipedalian

  • Atankharz'ythi
  • 211
Re: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
Version 0.3.0 is available now. See original post for changelog.
Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

The Scroll of Atankharzim | FS2 syntax highlighting

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Re: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
Version 0.3.0 is available now. See original post for changelog.
Changelog:
  • 0.3.0
    • Refinements and improvements
...That's not a changelog; that's a placeholder. :P
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

 

Offline Sesquipedalian

  • Atankharz'ythi
  • 211
Re: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
...That's not a changelog; that's a placeholder. :P

Fair criticism. Happy now? ;)
Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

The Scroll of Atankharzim | FS2 syntax highlighting

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Re: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
...That's not a changelog; that's a placeholder. :P

Fair criticism. Happy now? ;)
Yes! :)
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Re: Make hand editing missions and tables easier with SYNTAX HIGHLIGHTING!
I opened up some Blue Planet TBMs and noticed something odd:


I scratched my head for a while wondering what could be going wrong, and then I finally had an idea and did a quick find&replace...


The space between the -1 and the closing parenthesis appears to be confounding the syntax highlighting. I'm guessing a regular expression probably just needs "\s*" added?
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.