Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Syntax highlighting for Telemac in Notepad++

Syntax highlighting for Telemac in Notepad++ 9 years 8 months ago #16252

  • j.lhomme
  • j.lhomme's Avatar
Hi All

I thought that having syntax highlighting in Notepad++ for TELEMAC steering files would be great. Here are the pros:
  • better readability of the files
  • verification of the keywords (i.e. they are not highlighted if incorrectly spelt)

We know that often new steering files are created from existing ones, so most keywords are already there, but errors can creep up, and syntax highlighting requires no effort and can only save time.

I have created a XML file that you can load into Notepad++ that sets up the syntax highlighting. This requires a recent version of Notepad++ (as the XML file syntax has changed not so long ago). All the keywords (English and French) have been included in the XML file.
There are 4 syntax setups contained in the XML file, one that works for all TELEMAC steering files (i.e. T2D, T3D and Sisyphe), and one set for each individual module.
The first one is nice with different colours for each module, but because some keywords are repeated between modules there are some steering files where colours get a bit mixed up. Hence why it can be good to use a setup for one individual module.

Here are a few limitations for now:
  • with French keywords, the syntax highlighting gets mixed up with the single quote.
  • ARTEMIS and Tomawac (or Mascaret) are not included yet.
  • with some keywords defined in multiple dico (cf. above), the colours can look a bit mixed-up and the order of the keyword groups matter (currently kw1 Sisyphe, kw2 T2D, kw3 T3D).

You can find the XML file in the attachments.
In Notepad++ v6.6.9, you need to go to Language > Define your own language, then click on Import and select the XML file.

I have also created a python script to generate the list of keywords automatically by reading the dico files. This script is also in the attachments, as well as the text file it generates.
In order to update the XML file or a future release of Telemac, the python script needs to point to the new tag and run. Then each linein the text file needs to be pasted in the XML at the following nodes <Keywords name="Keywords1"> <Keywords name="Keywords2"> <Keywords name="Keywords3"> <Keywords name="Keywords4"> <Keywords name="Keywords5">.

Hope you find this useful.

Julien
Attachments:
The administrator has disabled public write access.

Syntax highlighting for Telemac in Notepad++ 9 years 8 months ago #16253

  • j.lhomme
  • j.lhomme's Avatar
It turns out I can't upload a XML file, so I have changed the extension into .xml.txt.
Indeed you will need to remove the txt extension.
The administrator has disabled public write access.

Syntax highlighting for Telemac in Notepad++ 9 years 8 months ago #16254

  • cyamin
  • cyamin's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 997
  • Thank you received: 234
Hello Julien,

Excellent idea, it works fine. Looking forward for Artemis & Tomawac!

Many thanks,

Regards,
Costas
The administrator has disabled public write access.

Syntax highlighting for Telemac in Notepad++ 9 years 8 months ago #16255

  • j.lhomme
  • j.lhomme's Avatar
Hi Costas

Actually the syntax also works for Tomawac and Artemis (i.e. the keywords are in the XML file as well).

The description above was partly copied from and old internal email, I have done a few tweaks since then.

Julien
The administrator has disabled public write access.

Syntax highlighting for Telemac in Notepad++ 9 years 8 months ago #16256

  • cyamin
  • cyamin's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 997
  • Thank you received: 234
Indeed, it works. However there are some keywords that are not highlighted in some of my cas files:

Sisyphe:
SEDIMENT SLIDE (only SEDIMENT is highlighted)

Tomawac:
WINDS FILE FORMAT (only WINDS is highlighted)
WIND GENERATION (only WIND is highlighted)

It is not an issue of course, I am just mentioning it.

Regards,
Costas
The administrator has disabled public write access.

Syntax highlighting for Telemac in Notepad++ 9 years 8 months ago #16257

  • j.lhomme
  • j.lhomme's Avatar
Noted.

SEDIMENT SLIDE for example is in the XML file, but I think here it is Notepad++ that gets mixed up with the multi-words keywords, especially when a part of a multi-word keyword also exists as a keyword.

Have you tried to select the highlighting specific for Sisyphe or Tomawac ?

Julien
The administrator has disabled public write access.

Syntax highlighting for Telemac in Notepad++ 9 years 8 months ago #16260

  • cyamin
  • cyamin's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 997
  • Thank you received: 234
No, I didn't choose a specific highlighting. Every cas file I open, it gets automatically highlighted with the respective colors (there is some color mix up with cas files other than Telemac).

Update: I couldn't select an appropriate highlighting until I restarted Notepad++. Selecting the appropriate "Language" makes the highlighting color uniform and corrects the previously mentioned issues.

Costas
The administrator has disabled public write access.

Syntax highlighting for Telemac in Notepad++ 9 years 8 months ago #16261

  • j.lhomme
  • j.lhomme's Avatar
Yes the generic Telemac syntax is the default, but in many cases it is better to select the module specific syntax.
As you point, a restart of Notepad++ is recommended.

Cheers
Julien
The administrator has disabled public write access.

Syntax highlighting for Telemac in Notepad++ 9 years 8 months ago #16336

  • sebourban
  • sebourban's Avatar
  • OFFLINE
  • Administrator
  • Principal Scientist
  • Posts: 814
  • Thank you received: 219
Hello Julien,

This is very good work. Thank you for this contribution.

As such, I have now put it part of the TELEMAC system together with the other AddOns (such as TechPlot, etc.). It will be available to all in the next release of the system, and therefore maintained.

Kind regards, and good luck with your new employer !

Sébastien.
The administrator has disabled public write access.

Syntax highlighting for Telemac in Notepad++ 9 years 7 months ago #16426

  • Lux
  • Lux's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 96
  • Thank you received: 39
Thank you for this feature and the shared files. You will find below some suggestions.

For the French keywords handling, it is necessary to put telemac keywords in double quotation marks and keep the simple quote for the french apostrophe.
Find enclosed an xml file with the suggested modifications.

File Attachment:

File Name: UDL_Telemac_v7p0_v2.xml.txt
File Size: 161 KB


Moreover, there may be some confusions for the software in the syntax highlithing because some keywords can contain other(s) keyword(s). But this problem can be fixed in sorting the keywords. Indeed the order is relevant and larger keywords (which contain another other keyword) should be in first position.

I noticed also some "errors" in the keywords which are due to an error in the input dico files:
  • telemac2d.dico: CORIOLIS should be in quotation marks (line: NOM1 = CORIOLIS )
  • tomawac.dico : useless trailing space in quotation marks (NOM1 = 'SPECTRUM ENERGY THRESHOLD ' )

Best regards,
Luc
The administrator has disabled public write access.
  • Page:
  • 1
  • 2

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.