简体   繁体   English

Mac OS X是否有语法突出显示编辑器组件

[英]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. 我正在寻找可以在Mac OS X XCode项目中包含的语法突出显示组件,以允许编辑Ruby,C ++,Lua等。

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. 我的Google搜索完全没有以Mac OS X框架或组件的方式出现,更不用说我正在寻找的类型了。

Thanks for any pointers! 感谢您的指导!

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

Try to use scintilla. 尝试使用闪烁。 http://www.scintilla.org/ http://www.scintilla.org/

You could try using CodeMirror . 您可以尝试使用CodeMirror I do this in my SQLite Professional app to highlight user editable queries. 我在SQLite Professional应用程序中执行此操作,以突出显示用户可编辑的查询。 It's also fairly simple to setup: 设置也很简单:

  1. In your project, add the CodeMirror contents as a Folder rather than a group. 在您的项目中,将CodeMirror内容添加为文件夹而不是组。
  2. Add the WebKit.Framework to your project. 将WebKit.Framework添加到您的项目。
  3. Add a WebView to your nib/xib. 将WebView添加到您的笔尖/ 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. 我发现的一个问题是,在WebView上下文中,本机的“查找”对话框不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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