This is the beginning of a syntax highlighting UITextView
for iOS. Currently it only knows about Obj-C. Previously Chromatism used a combination of CoreText
and UITableView
for performance, but luckily that is not needed anymore.
Chromatism is currently unstable, changing quickly and without test-coverage.
MIT, see LICENSE.txt. If you develop Chromatism further, sharing your improvements are encouraged.
- Drag and drop
Chromatism.xcodeproj
to your project. - Add
Chromatism
as a target dependency and link tolibChromatism.a
- Make sure you have the
-ObjC
flag on theOther Linker Flags
build setting. - Add
"$(BUILT_PRODUCTS_DIR)/../../Headers"
to theHeader Search Paths
build setting.
JLTextView
is a textView with a syntaxTokenixer property to aJLTokenizer
JLTokenizer
is the work horse of Chromatism. It uses scopes and tokenPatterns to appropriately tokenize a textStorage or a string. It is a delegate ofNSTextStorage
andUITextView
.JLScope
has aNSMutableIndexSet
-property that corresponds to ranges in the textStorage. Scopes can be arranged in a complex hierarchy, especially since it is a subclass ofNSOperation
.JLTokenPattern
is a subclass ofJLScope
. It has a regex-pattern that in-perform
searches through the ranges of its parent scope.
- Subclass
JLTokenizer
. - Checkout
JLObjectiveCTokenizer
to see what to do next. - (Optional) Be awesome and submit a PR.