Page 1 of 2

Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 12.01.2012, 22:18
by Chuft-Captain
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++, you're tired of this plain look :
npp.jpg

and you'd rather see something more helpful like this:
npp-celestia-4.jpg


... then you might find this tool useful.

VERSION 5 DOWNLOAD:
(added CELX script handler as requested.)

INSTALLATION:
Find the existing userDefineLang.XML file in your installation.
in XP: "...\Documents and Settings\...[User]...l\Application Data\Notepad++"
in Win7: "%APPDATA%\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

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 12.01.2012, 23:37
by Andy74
Thanks, CC!

Very good idea indeed, I will definitely use it.

Regards

Andy

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 13.01.2012, 04:44
by MiR
Yes, thank you :)

Michael

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 13.01.2012, 06:11
by Chuft-Captain
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.

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 13.01.2012, 13:00
by selden
CC,

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

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 13.01.2012, 13:09
by Chuft-Captain
Should be there now Selden. (I was updating the post as you looked at it).

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 13.01.2012, 14:28
by selden
Thanks!

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 14.01.2012, 15:06
by Fenerit
Thanks Chuft. 8) This is ought to be definitely adopted by the Notepad++ team, imho.

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 15.01.2012, 18:46
by piellepi
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.

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 17.01.2012, 13:38
by Chuft-Captain
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++.

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 17.01.2012, 17:10
by Fenerit
Hi Chuft: I use the "obsidian" theme and your layouts looks like a charm.

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 17.01.2012, 22:59
by Chuft-Captain
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

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 18.01.2012, 04:24
by Chuft-Captain
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

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 18.01.2012, 13:28
by selden
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.

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 18.01.2012, 14:48
by Chuft-Captain
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".

:)

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 19.01.2012, 02:04
by Fenerit
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.

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 20.01.2012, 12:49
by Chuft-Captain
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

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 20.01.2012, 14:09
by Fenerit
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.

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 20.01.2012, 17:41
by Fenerit
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.

Re: Syntax highlighting of Celestia Catalogs in Notepad++

Posted: 22.01.2012, 16:37
by Fenerit
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