Syntax highlighting of Celestia Catalogs in Notepad++

Here you find pointers to utilities that help you create addons for Celestia.

Moderator: selden

Syntax highlighting of Celestia Catalogs in Notepad++

Postby Chuft-Captain » Thu Jan 12, 2012 3:18 pm

For a long time now NOTEPAD++ has been my editor of choice when working with Celestia catalog files (or other files) because, well to put it simply, it's just a great editor. Simple to use, yet powerful and extensible.

Celestia's catalog language is NOT included in the long list of common languages recognized automatically by NOTEPAD++, HOWEVER, like any good editor, NOTEPAD++ can be extended to recognize custom languages by creating a "user-defined language".
I've been meaning to do this for ages, and finally made a start on this last night.

So, if you use NOTEPAD++, and are tired of seeing this:
npp.jpg

and would rather see something like this:
npp-celestia-2.jpg
then you might find this useful.

VERSION 5: added CELX script handler as requested.
Celestia-NPP-Styles_v5.zip
VERSION 5 - Adds CELX handler
(4.31 KiB) Downloaded 111 times


INSTALLATION:
Find the existing userDefineLang.XML file in your installation.
(in XP, it should be in "...\Documents and Settings\...[User]...l\Application Data\Notepad++".)

If you haven't already made any other user defined languages for NOTEPAD++, then you can simply replace the existing (empty) XML file with this one. (Take a backup if you're not sure).
WARNING: If you do have other user defined languages, then you'll need to cut and paste from this one into the existing one, rather than just replacing it.

Now open any Celestia ssc, ctx, stc, dsc, dat, cfg, or celx file and you should see the syntax highlighted automatically.
If not, you can select the language manually from the Language menu.
-- Down the bottom...
CelSSC (for ssc, ctx, dat, or cfg files),
CelSTC (for stc, dsc),
CelX (for celx).

Hope someone finds this useful. Any feedback welcome.
(Please let me know of any omissions.)

I have done nothing for CELX files as they are probably reasonably well serviced by the LUA language syntax already provided with NOTEPAD++. However it might be worth adding specific celX keywords in the future (ie. the non LUA elements)

UPDATE:VERSION 5 now adds this functionality.

CC
Last edited by Chuft-Captain on Fri May 25, 2012 3:04 pm, edited 31 times in total.
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

O'NEILL COLONY
LAGRANGE POINTS
User avatar
Chuft-Captain
 
Posts: 1668
Joined: Sun Dec 18, 2005 1:26 am

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Postby Andy74 » Thu Jan 12, 2012 4:37 pm

Thanks, CC!

Very good idea indeed, I will definitely use it.

Regards

Andy
Andy74
 
Posts: 113
Joined: Wed Jul 21, 2004 5:51 am
Location: Regensburg, Germany

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Postby MiR » Thu Jan 12, 2012 9:44 pm

Yes, thank you :)

Michael
User avatar
MiR
 
Posts: 247
Joined: Sun Jan 31, 2010 8:22 pm
Location: Germany

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Postby Chuft-Captain » Thu Jan 12, 2012 11:11 pm

Version 2 upgrade is available.

This version...
    * changes the colors to be a bit less "in your face"
    * enables the "Treat keyword as symbol" option on the comment symbol #, to make sure all comments are recognized correctly
    * implements "syntax folding" on braces {}

DOWNLOAD and INSTALL INSTRUCTIONS: in first post.
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

O'NEILL COLONY
LAGRANGE POINTS
User avatar
Chuft-Captain
 
Posts: 1668
Joined: Sun Dec 18, 2005 1:26 am

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Postby selden » Fri Jan 13, 2012 6:00 am

CC,

I don't see anything in your posts that can be downloaded -- neither an attachment nor a link to another site.
Selden
User avatar
selden
 
Posts: 9902
Joined: Tue Sep 03, 2002 7:21 pm
Location: NY, USA

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Postby Chuft-Captain » Fri Jan 13, 2012 6:09 am

Should be there now Selden. (I was updating the post as you looked at it).
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

O'NEILL COLONY
LAGRANGE POINTS
User avatar
Chuft-Captain
 
Posts: 1668
Joined: Sun Dec 18, 2005 1:26 am

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Postby selden » Fri Jan 13, 2012 7:28 am

Thanks!
Selden
User avatar
selden
 
Posts: 9902
Joined: Tue Sep 03, 2002 7:21 pm
Location: NY, USA

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Postby Fenerit » Sat Jan 14, 2012 8:06 am

Thanks Chuft. 8) This is ought to be definitely adopted by the Notepad++ team, imho.
Never at rest.
Massimo

Mirror site
User avatar
Fenerit
 
Posts: 1793
Joined: Mon Mar 26, 2007 1:43 pm
Location: Tuscany, Thyrrenian sea

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Postby piellepi » Sun Jan 15, 2012 11:46 am

thanks a lot,Chuft-Captain!
it's very useful!!

Ciao
Pierluigi

PS
I have added
- the filetype "ctx" (used for VTs) to ext
- the keyword "VirtualTexture" to Words1
- the keywords "ImageDirectory BaseSplit TileSize TileType" to Words3
this way also ctx files have syntax coloring!

Perhaps there is a typo in the words from DELIMINER1 to 3: I think they should be DELIMITER1 to 3.
User avatar
piellepi
 
Posts: 124
Joined: Thu Sep 25, 2003 6:33 am
Location: Rome, Italy

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Postby Chuft-Captain » Tue Jan 17, 2012 6:38 am

Graci Pierluigi,

I had forgotton about the CTX files, so thank you for that.
I have now included your CTX additions and made some other changes, including:
    * Keywords I had overlooked. eg. ScriptedRotation.
    * Language handlers are now case-insensitive.
    * Most keywords are now treated as symbols.
    (The reason for this, is that braces {} often can follow keywords without an intervening space, depending on the individuals style of writing code (although that's not my style). This ensures that they are recognized in all circumstances.

In addition, given that the syntax differences between SSC and STC files are far greater than the similarities, I decided it would be more useful to have 2 separate language handlers. So the original CelestiaCC language is replaced by:
    CelSSC which handles SSC, CTX, DAT, and CFG files,
    and
    CelSTC which takes care of STC, and DSC files.

When keywords are common to both SSC and STC syntaxes, then this separation of handlers gives more freedom to handle them in the style most appropriate to the context.
For example, in a DSC file "Axis" is a first-order attribute of a Galaxy, so I want it to be blue, however in an SSC file "Axis" is a keyword associated with a ReferenceFrame, so I want it to be a dark red color.
This is just my preference. Feel free however to [EDIT] re-design my scheme, or come up with your own layout/colors to your liking, and if you do, please share it here in this thread as well. (Just zip up your userDefineLang.xml and upload it)

Version 3 (has now been superseded by VERSION 4). DOWNLOAD: in first post

Cheers
CC

PS. Pink Floyd fans are always welcome here! :)

piellepi wrote:Perhaps there is a typo in the words from DELIMINER1 to 3: I think they should be DELIMITER1 to 3.
I agree, but don't change that. That's a tag that is defined and used by the UDL dialog. (Probably a typo by some rather hasty Notepad++ developer, but that is how it is defined and used.)
In fact, for making changes to your UDL themes, I recommend that you use the "View-->User-Defined Dialog" tool within Notepad++, rather than editing the XML file directly:
UDL-Dialog.jpg
... you can see the effect on any open files immediately, and no danger of accidentally damaging the TAG structure. Any changes you make in this dialog are saved to the userDefineLang.xml file, each time you close Notepad++.
Last edited by Chuft-Captain on Tue Jan 17, 2012 9:40 pm, edited 3 times in total.
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

O'NEILL COLONY
LAGRANGE POINTS
User avatar
Chuft-Captain
 
Posts: 1668
Joined: Sun Dec 18, 2005 1:26 am

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Postby Fenerit » Tue Jan 17, 2012 10:10 am

Hi Chuft: I use the "obsidian" theme and your layouts looks like a charm.
Never at rest.
Massimo

Mirror site
User avatar
Fenerit
 
Posts: 1793
Joined: Mon Mar 26, 2007 1:43 pm
Location: Tuscany, Thyrrenian sea

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Postby Chuft-Captain » Tue Jan 17, 2012 3:59 pm

Fenerit wrote:Hi Chuft: I use the "obsidian" theme and your layouts looks like a charm.

I may have misled you Fenerit. When I referred to "theme"'s I was merely referring to the design and color scheme of the Notepad++ UDL handler(s) created by me. I think you're talking however about a windows "theme". I wasn't talking about windows "themes" at all. -- (Perhaps "theme" was an unfortunate choice of words on my part.) -- I've edited the post above to make it less ambiguous.
eg. The use of green italic comments, blue for main keywords, crimson for ReferenceFrame stuff, and purple for secondary attributes could be thought of as a Notepad++ "theme". If you perhaps didn't like the colors I've chosen, you could easily change them, or any other aspect of the UDL handler and your version could then be known as the "Fenerit" theme, or the "Italian" theme if everything was Ferrari red. :wink:

Cheers
CC
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

O'NEILL COLONY
LAGRANGE POINTS
User avatar
Chuft-Captain
 
Posts: 1668
Joined: Sun Dec 18, 2005 1:26 am

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Postby Chuft-Captain » Tue Jan 17, 2012 9:24 pm

Yet another update! (Every time I look at another catalog file, I seem to discover something I've missed. :roll: )

Added some keywords which I had overlooked in the STC handler, which can in fact be present in .STC's or .DSC's. Namely:
    CustomOrbit
    CustomTemplate
    UniformRotation
    Obliquity
    EquatorAscendingNode
    RotationPeriod
    Temperature

Also, the comment delimiter # wasn't being treated as a symbol in the CelSTC handler, so some comment lines were not displayed with the correct color. FIXED.

VERSION 4 DOWNLOAD: in first post
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

O'NEILL COLONY
LAGRANGE POINTS
User avatar
Chuft-Captain
 
Posts: 1668
Joined: Sun Dec 18, 2005 1:26 am

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Postby selden » Wed Jan 18, 2012 6:28 am

A quibble: the keyword CustomOrbit should never be present in an STC. It is used to select a Solar System planet or moon orbit function which is hard-coded within Celestia. No star orbits are known to a precision which would justify Chris (or another Celestia developer) having written the appropriate C++ functions.
Selden
User avatar
selden
 
Posts: 9902
Joined: Tue Sep 03, 2002 7:21 pm
Location: NY, USA

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Postby Chuft-Captain » Wed Jan 18, 2012 7:48 am

A very good point Selden, however there is one star whose "orbit" is very precisely known...

8)

CustomOrbit.jpg


... reminds me of the classic quiz show question:
Q: "Name the closest star to Earth"
A: "Alpha Centauri".

:)
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

O'NEILL COLONY
LAGRANGE POINTS
User avatar
Chuft-Captain
 
Posts: 1668
Joined: Sun Dec 18, 2005 1:26 am

Next

Return to Utilities

Who is online

Users browsing this forum: No registered users and 1 guest