raspu / Highlightr

iOS & OSX Syntax Highlighter.
MIT License
1.67k stars 261 forks source link

Line numbers #46

Open brendand opened 6 years ago

brendand commented 6 years ago

Is there a function to display line numbers along the left side of the view? The syntax highlighting is great. Just needs line numbers.

raspu commented 6 years ago

This is not supported yet, and to be honest I don't currently have the time to implement it, but feel free to send a PR if you do so.

4np commented 6 years ago

Not going to happen: https://highlightjs.readthedocs.io/en/latest/line-numbers.html

RobertoMachorro commented 5 years ago

Highlightr just does the coloring using the highlightrjs library - it's an NSTextStorage, but the actual rendering is still done by Cocoa's NSLayoutManager and NSTextContainer.

I'm going to give this a shot using a vertical NSRuler, based on the information in the following links:

Displaying Line Numbers with NSTextView

NSTextView+LineNumberView

NSRulerView how to correctly align line numbers with main text

Flip NSRulerView

If you've achieved this already, please stop me and help a guy out ;)

Edit: Added another link.

adamwulf commented 1 year ago

Adding another link that has helped me with line numbers: https://github.com/alldritt/TextKit_LineNumbers

it's an old repo but still works like a charm