TextEditor: How to delete the first few lines?

I’ve been staring at TextEditor methods, and it seems there is still no obvious way to delete the first few lines, in order to restrict the text in the TextEditor to a certain number of lines. This would be suitable for some type of error logging, or interactive console.

I had a look-see at CodeEditorComponent but it seems to be too heavily engineered for this simple purpose. Save points? Undos? I need to provide a CodeDocument in order to use this thing?


That’s definitely not the kind of thing the TextEditor is designed for… You could highlight the first few lines and then tell it to delete them, and then clear the undomanager, I guess. Not pretty though - if you need a console, you should really write a component that works in a line-by-line mode, not on a block of text.

Yikes! That means I would have to re-implement selection…non trivial!

Well, the code editor is probably more suitable, but neither one is really designed for this. But if you need selection, then yep, it’d probably be a lot easier to try to get them working than to write a whole new component!