regex - Format a string using Xcode's Code Highlighting Colours -
i have app exports objective-c , swift code.
in preview window auto generated code format text same colours default theme of xcode uses i.e. green comments, blue numbers, red strings purple class names etc.
apps such paintcode manage achieve this. know of library or other means of producing this.

you need lexer split text parts: identifiers, symbols, string , number literals, comments, etc. further reading lexers on wikipedia.
then have know color apply on them, including identifiers of different kind: keywords, functions, variables, types, etc. those, can manage kind of lists , them.
for parsing, place start nsscanner or go on text character character. that’s how in paintcode.
for coloring itself, use nsattributedstring , nsforegroundcolorattributename. there’s no need go core text.
Comments
Post a Comment