TextEditor update slows down after 1400 lines

the TextEditor update slows down after many lines. has been reported to me 1400+. Does insertTextAtCaret() repaint the entire TextEditor?

i guess it really depends on the number of characters per line and not the number of lines

I think the TextEditor stores its text as one long String so any operations on it are costly due to the internal shuffling around of the characters. If you need to store a large amount of text and edit it etc. take a look at the CodeEditorComponent which uses an Array of lines and is much quicker when dealing with large files. Just load a large file into the Introjucer as an example (my iTunes Library.xml is 11MB and is incredibly smooth).

I don’t know your particular use case but if its a large amount of lines you need, something closer to this would probably be better.

Thanks Dave. going to try it out

is there some other list component that i use that does not have editing. i don’t need to edit, i’m using as a display/monitor

Will a ListBox work?


There are other display types such as a ListBox that can efficiently display data but for that you would have to write your own model. If you’re just adding strings that you want to be displayed on a single line your storage method could just be a StringArray and you could display a line per list box row?

You might be able to use a CodeEditorComponent and just set “setMouseClickGrabsKeyboardFocus (false)” that might prevent users from being able to change the text.

can you set text color per line in textbox

There is no TextBox class so I presume you mean the ListBox idea. In short yes, you can store any kind of data and display it how you want. So you could store an Array of AttributedStrings or keep two arrays, a String and Colour one and have a method such as addLine (const String& newText, const Colour& textColour).

Then in your paintListBoxItem override you just look draw the AttributedString or the plain String from the Array in the corresponding colour.

Ok Thanks. yes I meant ListBox. However back when I started using the TextEditor that there was some reason I didn’t use a ListBox.
But i will look again.
Thanks for your speedy responses.

No worries. Yeh, there are a lot of options and each of the existing JUCE classes is tailored in some specific way. Of course if you need complete control over the display you could roll your own Component subclass from scratch, just depends on how much control you need vs how much time you want to spend on it.

Good luck.

Hi Dave,

Is there a way to change the text color per line for the CodeEditorComponent? With syntax highlighting disabled, If I set defaultTextColourId, the entire editor text changes to the color.


I don’t think so, its really designed for displaying code documents and to be honest I’ve never really used it. I just remember when Jules created it how there was a lot of talk about how fast it was when dealing with large amounts of text.

The problem is that TextEditor is quite generalised and CodeEditorDocument is quite specialised, what you need really is a specialised TextEditor. You might be best creating your own based on the CodeEditorDocument but having a similar interface to TextEditor. I don’t think TextEditor could be easily changed to use an array of lines because it uses a Value internally so you can register for changes etc.

Thanks Dave! Appreciate the response and guidance.
Do you know if ListBox should be better for speed in updating many many lines in the list.

thanks again.