0

I am new to OS X and using TextMate as an editor. In TextMate, i am using Mac Classic theme which provides the syntax coloring for std C++'s.

Questions: How can i configure Textmate so that it can provide the syntax coloring to OpenCV datatypes also like 'Mat' etc.

PS: I just want to use Textmate as an editor because i want to compile and run my code through terminal.

skm
  • 5,015
  • 8
  • 43
  • 104
  • @DownVoter: Kindly let me know the reason for downvote so that i can improve the question. – skm Feb 16 '15 at 19:37

1 Answers1

0

I could not find an existing bundle for OpenCV, so you'll have to create your own language grammar:

Textmate Manual - Language Grammars

So there are 2 suggestions;

The first is to hack your C++ language:

  • Bundles-> Bundle Editor-> C->Language Grammars->C++
  • insert this code, perhaps after the {include= 'source.c';}, line

    {name = 'keyword.control.c++'; match = '\b(Mat|Range|Rect)\b'; },

  • You then include all of the keywords you want recognized, just as I've demonstrated with Mat, Range, and Rect.

Or

You could create your own language bundle. Following the above manual, this is an untested grammar that might work.

{
  scopeName = 'source.opencv';
  fileTypes = ( );
  foldingStartMarker = '\{\s*$';
  foldingStopMarker = '^\s*\}';
  patterns = (
      { 
        name = 'meta.function';
        match = '\b(Mat|Range|Rect)\b';
      },
   );
}

Mind you, a proper bundle would create a new language with the correct the scope selector.

One perk here, is if you create the bundle successfully you could have it added to the official bundles list, saving others the effort. If you get that far, reachout to the mailing list to have it officially added.

Graham P Heath
  • 7,009
  • 3
  • 31
  • 45