Bytenik
Bytenik

Reputation:

Is there a syntax highlighting editor component for Mac OS X

I am looking for a syntax highlighting component that I can include in a Mac OS X XCode project to allow editing of Ruby, C++, Lua, etc.

I need a component that is open source or has the source included.

My Google searches didn't turn up much in the way of Mac OS X frameworks or components at all, let alone the type I am looking for.

Thanks for any pointers!

Upvotes: 2

Views: 2432

Answers (3)

Kyle
Kyle

Reputation: 17677

You could try using CodeMirror. I do this in my SQLite Professional app to highlight user editable queries. It's also fairly simple to setup:

  1. In your project, add the CodeMirror contents as a Folder rather than a group.
  2. Add the WebKit.Framework to your project.
  3. Add a WebView to your nib/xib.

Add the following code:

// Load our webview from our local CodeMirror path
NSURL * url = [NSURL fileURLWithPath: [NSString stringWithFormat:@"%@/CodeMirror/Demo/preview.html", [[NSBundle mainBundle] resourcePath]]];

NSString * html = [NSString stringWithContentsOfURL: url encoding:NSUTF8StringEncoding error:nil];

[webView.mainFrame loadHTMLString: html baseURL: url];

They also have lots of formats pre-defined, so it works quite well. The one issue I have found with this, is that the native Find dialog does not work when in the context of the WebView.

Upvotes: 0

Isaac
Isaac

Reputation: 10834

UKSyntaxColoredTextDocument (Mac-specific) or Scintilla (cross-platform and in use in a variety of editors, including Komodo) might be what you're looking for.

Upvotes: 3

osgx
osgx

Reputation: 94235

Try to use scintilla. http://www.scintilla.org/

Upvotes: 1

Related Questions