Reputation:
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
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:
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
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