Syntax highlighting of Celestia Catalogs in Notepad++

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

Chuft-Captain
Topic author
Avatar
Chuft-Captain
Topic author
Posts: 1725
With us: 11 years 7 months

#1by Chuft-Captain » 12.01.2012, 22:18

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


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 25.05.2012, 22:04, 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

Andy74 M
Andy74 M
Age: 43
Posts: 115
With us: 13 years
Location: Regensburg, Germany

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#2by Andy74 » 12.01.2012, 23:37

Thanks, CC!

Very good idea indeed, I will definitely use it.

Regards

Andy

MiR
MiR
Posts: 247
With us: 7 years 5 months
Location: Germany

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#3by MiR » 13.01.2012, 04:44

Yes, thank you :)

Michael

Chuft-Captain
Topic author
Avatar
Chuft-Captain
Topic author
Posts: 1725
With us: 11 years 7 months

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#4by Chuft-Captain » 13.01.2012, 06:11

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

selden
Avatar
selden
Posts: 10010
With us: 14 years 10 months
Location: NY, USA

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#5by selden » 13.01.2012, 13:00

CC,

I don't see anything in your posts that can be downloaded -- neither an attachment nor a link to another site.
Selden

Chuft-Captain
Topic author
Avatar
Chuft-Captain
Topic author
Posts: 1725
With us: 11 years 7 months

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#6by Chuft-Captain » 13.01.2012, 13:09

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

selden
Avatar
selden
Posts: 10010
With us: 14 years 10 months
Location: NY, USA

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#7by selden » 13.01.2012, 14:28

Thanks!
Selden

Fenerit M
Avatar
Fenerit M
Posts: 1864
With us: 10 years 3 months
Location: Thyrrenian sea

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#8by Fenerit » 14.01.2012, 15:06

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

piellepi M
Avatar
piellepi M
Age: 61
Posts: 125
With us: 13 years 9 months
Location: Rome, Italy

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#9by piellepi » 15.01.2012, 18:46

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.

Chuft-Captain
Topic author
Avatar
Chuft-Captain
Topic author
Posts: 1725
With us: 11 years 7 months

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#10by Chuft-Captain » 17.01.2012, 13:38

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 18.01.2012, 04:40, 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

Fenerit M
Avatar
Fenerit M
Posts: 1864
With us: 10 years 3 months
Location: Thyrrenian sea

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#11by Fenerit » 17.01.2012, 17:10

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

Chuft-Captain
Topic author
Avatar
Chuft-Captain
Topic author
Posts: 1725
With us: 11 years 7 months

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#12by Chuft-Captain » 17.01.2012, 22:59

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

Chuft-Captain
Topic author
Avatar
Chuft-Captain
Topic author
Posts: 1725
With us: 11 years 7 months

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#13by Chuft-Captain » 18.01.2012, 04:24

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

selden
Avatar
selden
Posts: 10010
With us: 14 years 10 months
Location: NY, USA

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#14by selden » 18.01.2012, 13:28

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

Chuft-Captain
Topic author
Avatar
Chuft-Captain
Topic author
Posts: 1725
With us: 11 years 7 months

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#15by Chuft-Captain » 18.01.2012, 14:48

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

Fenerit M
Avatar
Fenerit M
Posts: 1864
With us: 10 years 3 months
Location: Thyrrenian sea

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#16by Fenerit » 19.01.2012, 02:04

Chuft-Captain wrote:
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

My fault Chuft: read "style". FYI my custom colors like Perl language
np++_1.jpg

np++_2.jpg

userDefineLang.zip

In the zip there are all the CMOD directives. Maybe it can help you.
Never at rest.
Massimo

Chuft-Captain
Topic author
Avatar
Chuft-Captain
Topic author
Posts: 1725
With us: 11 years 7 months

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#17by Chuft-Captain » 20.01.2012, 12:49

Graci Massimo,

Very retro theme. You must have done some change to your preferences in Notepad++ as well, in order to have a black background?

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

O'NEILL COLONY
LAGRANGE POINTS

Fenerit M
Avatar
Fenerit M
Posts: 1864
With us: 10 years 3 months
Location: Thyrrenian sea

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#18by Fenerit » 20.01.2012, 14:09

Chuft-Captain wrote:Graci Massimo,

Very retro theme. You must have done some change to your preferences in Notepad++ as well, in order to have a black background?

CC
Yes. It can comes with the "obsidian" theme. Menu: "Settings" > "Style Configurator" > "Select theme" > "obsidian". You must check/uncheck the "Enable global background colour" checkbox whether you want to hold/reject your language's background. As "experiment" it has been assigned like global background into the xml above just to see what should be happened.
With your Celestia's language colours it doesn't looks bad, apart the black, red and blue strings which are either too faints or too "in your face".

EDIT LATER:
Just a question I wonder now: what Notepad++ version do you use? Mine is the 5.9.
Never at rest.
Massimo

Fenerit M
Avatar
Fenerit M
Posts: 1864
With us: 10 years 3 months
Location: Thyrrenian sea

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#19by Fenerit » 20.01.2012, 17:41

Celestia language Perl-like VERSION 2
Fixes:
- All string backgrounds are now white. Choose "bespin, blackboard,choco, deepblack, obsidian etc." themes for the dark background.
- Changed colours from green to cyan for "array/hashes" alike directives (Atmosphere, UniformRotation, EllipticalOrbit, Galaxy, Globular, etc)
- (SSC) Add LunarLambert CloudNormalMap Source DoublePrecision Interpolation Kernel Origin Beginning BoundingRadius SpiceOrbit SpiceRotation Base BaseFrame Observer Vector Freeze;

- (STC) Fixed the comment lines' wrong colour from green to gray;
- (STC) Removed the "CustomOrbit" directive;
- (STC) add BoloCorrection GlobularCluster Mesh Position

- (CMOD) Add up to ten texture[0] (texture0... texture10) and color[0] (color0... color10) for redundant purpose;
- (CMOD) Add "f4", which was lacking;

np++_1_1.png

np++_1_2.png


EDIT LATER:

- Added support for CMS (CMOD), CFG, XYZ, XYZV (SSC) formats;
- Changed colours for SpiceOrbit/SpiceRotation (Source, Kernel, Origin, Frame, BaseFrame) ScriptedOrbit (Module, Function): now cyan:
- Changed colours for Add, Modify, Replace in maroon, like Perl's regex
- Changed color for [ ], now they are white like { }

userDefineLang-v2.zip


This is definitely a customization for people who like to write on the black background.
Never at rest.
Massimo

Fenerit M
Avatar
Fenerit M
Posts: 1864
With us: 10 years 3 months
Location: Thyrrenian sea

Re: Syntax highlighting of Celestia Catalogs in Notepad++

#20by Fenerit » 22.01.2012, 16:37

Celestia language Perl-like VERSION 3

- Added: FixedPosition Planetographic FixedAttitude Heading LabelColor's directives;
- All the directives are listed in alphabetical order; check it through "user-defined dialogue..."'s menu for a better view.
- Removed "prefix" and "ignore case" options for syntax lightning purpose; words without capitals and uncorrect directives are not lightened even whether the typing is continued after the right word.
- Minor fixes;

userDefineLang-v3.zip
Never at rest.
Massimo


Return to “Utilities”

Who is online (over the past 5 minutes)

Users browsing this forum: 1 guest