简体   繁体   中英

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!

UKSyntaxColoredTextDocument (Mac专用)或Scintilla (跨平台,并在包括Komodo在内的各种编辑器中使用)可能是您想要的。

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM