Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

an objc syntax highlighting library that supports multiple language?

I come from the ruby and python worlds where we have many libraries that can syntax highlight arbitrary code from many languages. I am looking for something similar in the objc ecosystem, but i can't seem to find such, is there one available?

The equivalent libraries in Ruby would be CodeRay and Pygments for Python,

thanks in advance!

like image 916
horseyguy Avatar asked Apr 08 '12 10:04

horseyguy


2 Answers

Banister,

I myself have searched for a long time for a nice and robust Cocoa Syntax Highlighter, and since I'm currently building a code-oriented text editor myself, that would be a major part of the project.

So, I found out that there are plenty of Objective-C/Cocoa -friendly Syntax Highlighting libraries/components. For a starter (for something relatively basic, that is), I would suggest you have a look at :

  • OkudaKit (using CSS for styling)
  • UKSyntaxColoredTextDocument by Uli Kusterer (pretty nice try)

However, if you really need something POWERFUL, well-tested and still Cocoa-friendly, I would definitely suggest you to try the Scintilla component (for Cocoa). The code is great, and the community (at Scintilla-Interest Group) will gladly help you iron out any issues you may encounter.

In a few words :

I'm currently using on an about-to-be-release big project and it's working beautifully for me.


Scintilla

Scintilla is a free library that provides text-editing functions, with an emphasis on advanced features for source code editing. SciTE (cross-platform), Geany, Notepad++ (Windows), and Notepad2 (Windows) are examples of standalone editors based on Scintilla.

Scintilla Editing Component in use (SciTe)

Scintilla Editing Component

Features

Scintilla supports many features to make code editing easier in addition to syntax highlighting. The highlighting method allows the use of different fonts, colors, styles and background colors, and is not limited to fixed-width fonts. The control supports error indicators, line numbering in the margin, as well as line markers such as code breakpoints. Other features such as code folding and autocompletion can be added.


  • Download Scintilla (the Cocoa support has been integrated in the main project) : http://www.scintilla.org/SciTEDownload.html
  • Example project (integrating Scintilla with Cocoa) : http://bazaar.launchpad.net/~mike-lischke/scintilla-cocoa/trunk/files/head:/cocoa/ScintillaTest/
  • For complete documentation, have a look at : Scintilla Documentation
like image 181
Dr.Kameleon Avatar answered Sep 23 '22 18:09

Dr.Kameleon


Fragaria may be useful for future reference.

like image 23
user2067021 Avatar answered Sep 21 '22 18:09

user2067021