Any plans to add text/line wrapping to the CodeEditorComponent?
It would be a surprising amount of work to do that, as it’s all very much designed around lines being the same height, so no current plans, sorry!
Gotcha, thanks for the speedy reply!
I’m using CodeEditorComponent
for quite a few tasks other than coding (e.g. log windows) where line-wrapping would be nice. So I’ve been working on this for the last couple of days, and I’m making quite good progress. It has involved a heavy refactor of the CodeEditorComponent
though, as Jules suggested it would.
Is this something that might be accepted into JUCE provided the code is of high enough quality?
At present the only way I’ve found to do it is to create a TextLayout for every line in the document, which lets us find the line’s height with wrapping enabled. I’m doing this on a background thread, so it doesn’t stall the editor. However, it’s still relatively slow and might take a few seconds for a very large document (I’m testing with War & Peace).
Might there be a faster way to find a line’s height with wrapping enabled? Then I could create layouts only for the lines that are in view. On the Mac it seems we might be able to use NSAttributedString:boundingRectWithSize
- does anyone know if there are there similar APIs for Windows?
Update on this: I’ve added word-wrapping to CodeEditorComponent
and also another feature I want: prettified symbols. This changes how certain symbols are displayed in the document without changing the underlying text. Here’s an example with a bit of Lua code (prettifying function
to fn
and return
to =>
).
A side effect of what I’ve been doing means that CodeEditorComponent can handle non-monospace fonts or fonts with ligatures.