CMake syntax highlighting

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Zaippa
Posts: 9
Joined: Wed Oct 08, 2003 4:30 pm

CMake syntax highlighting

Post by Zaippa »

Hi! :wink:

I've started to use the marvelous CMake (http://www.cmake.org) for generating makefiles.
The files you create for telling CMake how to generate the makefiles are all called "CMakeLists.txt".

To make it a little easier for me to edit these files, i made a syntax highlighting file for textpad and a new document class for "CMakeLists.txt"-files.

The problem is (of course) that textpad will never use this document class. Whenever i open a CMakeLists.txt file, textpad uses the "Text" document class, since this document class is used for all filenames on the form "*.txt" - including CMakeLists.txt!

So is there a way to syntax highlight CMakeLists.txt files differently than other txt-files?

Thanx for any help!

(i currently use textpad 4.7.3 if that makes any difference)
User avatar
Bob Hansen
Posts: 1517
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Make a class for CmakeList files, perhaps use "cma" for the extension.
Make a syntax file for the "cma" class

Now, load the CmakeList.txt file,
Click on File/Rename to CmakeList.cma
Use the syntax file for cma class
Do the work.
Rename the file back to CMakeList.txt, save and exit.

You could make a macro to the rename from .txt to .cma and another macro to rename from .cma to .txt.
Hope this was helpful.............good luck,
Bob
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Re: CMake syntax highlighting

Post by MudGuard »

Zaippa wrote: The files you create for telling CMake how to generate the makefiles are all called "CMakeLists.txt".

To make it a little easier for me to edit these files, i made a syntax highlighting file for textpad and a new document class for "CMakeLists.txt"-files.

The problem is (of course) that textpad will never use this document class. Whenever i open a CMakeLists.txt file, textpad uses the "Text" document class, since this document class is used for all filenames on the form "*.txt" - including CMakeLists.txt!

So is there a way to syntax highlight CMakeLists.txt files differently than other txt-files?

Yes, there is a way.

When Textpad tries to find a document class for a file, it tries all document classes - in reverse alphabetic order (don't ask me why, it is just like that).

So create your document class with a name, that comes alphabetically after the "Text" class, e.g. "ZMake", and as a file filter, use "CMakeLists.txt" (or whatever pattern that matches your files but not generally all txt files)
Zaippa
Posts: 9
Joined: Wed Oct 08, 2003 4:30 pm

Post by Zaippa »

Thank you very much for that perfect solution!!!! :D

Thank you both for your answer!
(if it wasn't for madguard's insights into all the code of textpad, i would have tried out the macro method)
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

M_u_d, not Mad!

And I have never seen a single line of Textpad sourcecode ...
Post Reply