This project is a simple (syntax) highlighting
UITextView for Cocoa and iOS. I wanted to create a simple, easy to use and extendable highlighter entirely based on regular expressions (regex, regexp). Existing projects aimed to cover a specific highlighting or purpose. I wanted to create a versatile class to be used for any purpose.
The class uses the
CoreText framework and
NSAttributedString to highlight the text based on defined regular expressions. Expressions as well as colors can be defined using
NSDictionary or plist files. Build-in highlighting Themes allow to beautifully highlight text out of the box. All XCode themes are supported:
- Low Key
The highlighting themes and colors can be easily changed and adapted. Define your own highlighting by defining own regular expressions. Anyways the project comes bundled with predefined highlight definitions for the following programming languages:
Please give support so I can continue to make RegexHighlightView even more awesome!
Your help is much appreciated. Please send pull requests for useful additions you make or ask me what work is required.
It is open source and covered by a standard MIT license. That means you have to mention Kristian Kraljic (dikrypt.com, ksquared.de) as the original author of this code. You can purchase a Non-Attribution-License from me.
RegexHighlightView needs a minimum iOS deployment target of 4.3 because of:
The best way to use RegexHighlightView with Xcode 4.2 is to add the source files to your Xcode project with the following steps.
- Download RegexHighlightView as a subfolder of your project folder
- Open the destination project and drag the folder as a subordinate item in the Project Navigator (Copy all classes and headers)
In your prefix.pch file add:
In your application target's Build Phases add the following framework to the Link Binary With Libraries phase (you can also do this from the Target's Summary view in the Linked Frameworks and Libraries):
Go to File: Project Settings… and change the derived data location to project-relative.
- Add the DerivedData folder to your git ignore.
- In your application's target Build Settings:
- If your app does not use ARC yet (but RegexHighlightView does) then you need to add the the -fobjc-arc linker flag to the app target's "Other Linker Flags".
If you do not want to deal with Git submodules simply add RegexHighlightView to your project's git ignore file and pull updates to RegexHighlightView as its own independent Git repository. Otherwise you are free to add RegexHighlightView as a submodule.
None, so far… Yay!
If you find an issue then you are welcome to fix it and contribute your fix via a GitHub pull request.