raspu / Highlightr

iOS & OSX Syntax Highlighter.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Highlightr in a collection view

qin-guan opened this issue · comments

How would u put highlightr in a collection view? my idea is that you can give a live preview of a document however due to the collectionview having to dequeue cells the entire code highlighting is re rendered and takes up way too much system resources. Is there a more efficient way to do this? Also, isit possible to take a snapshot of the view of the highlighted code, for now the snapshot captures the text only and not the code.

Maybe you can have an independent highlighting service, and each item of the collection view just has a NSAttributedString, and then when the item is going to be displayed you then send the text-code to the highlighting service and when is ready (do this asynchronously of course) you replace the text on the corresponding item. This way you display the code without highlighting first, and then when the highlighting is done you update it.

Also, you should cache the highlighting, just store the NSAttributedStrings somewhere in memory in order to avoid highlighting the same code twice.

200-300 what? kb? Also, what are you caching and how are caching?

my bad the 200-300 was supposed to be for another project

ill go try out ur suggestion! TYSM!