Logger window component

I’ve tried to make a logging window (for a serial port) using the TextEditor component.

I have some problems though:
Each time I receive new text I add it to the end of the existing using something like this:

This is a very expensove approach I think, but for now I can live with it.

Upon each update I call myEditor.moveCaretToEnd() causing the editor to always scroll down to newest text.

But here comes my major concern: I want the user to be able to stay at a specific line by moving the dragging the scollbar. I.e. basically I only want the ‘show newest’ to be active if the scrollbar is already at the end. Unfortunately I can’t see how to get feedback from the scrollbar.
Any ideas ?
Alternative solutions?
Existing components to use?

I’ve made a similar thing in the past and I think you’ll find the TextEditor component will get quite slow once you have pages worth of logging information. I ended up using a ListBox. (TableListBox to be exact because that suited my data better) I can’t remember the exact reason of the speed difference but from memory the TextEditor checks the whole body of the text when calculating drawing positions while ListBox is just storing the text per line.

To get the info you need from a Scrollbar you can register a Listener to the Scrollbar and check the ScrollBar::getCurrentRangeStart() method and some trickery with setting the ScrollBar position each time the list is updated. If you end up using a ListBox you can use ListBox::scrollToEnsureRowIsOnscreen if you want to automatically follow the bottom of the list.