End Google Ads 201810 - BS.net 01 --> Hi all,
I'm writing what is essentially a kind of terminal emulator (for various reasons I can't use a pre-existing one, as this needs some pretty specific features).
One thing I'm a bit stuck on is trying to figure out how to make a custom control for the output text box. I need something that looks and acts somewhat like a textbox (however "read-only" from the user's perspective, as they enter commands in a separate control (or commands will be fired programmatically), and this control is just to show the output from the server.
The problem is, the "history". RichTextBoxes (and TextBoxes of course) have a maximum amount of characters. This is fine, and of course completely acceptable. However, when the control reaches it's maximum, I want it to behave in such a way that the oldest lines disappear from the start and the new lines come in at the end. As I will set the maximum length to be very long, doing this by taking ALL the text in the box, cutting the first line and then rewriting the whole lot in the text box again would be absolutely terrible for both memory usage and speed (i.e. totally unacceptable user experience). Such controls seem to be quite common for terminal emulators, telnet clients, MUD clients, custom consoles, etc, so I assume there should be some pretty nice examples out there, but I really can't find anything (every example of these types of apps I've come across seems to forget about this issue and doesn't handle what happens when the text box maximum is reached!)
It should ideally be derived from RichTextBox since I need colour support, however if it supports colour and looks somewhat like a text box, I'm happy to work with anything as I'll probably be modifying it heavily anyway. I'd also love it if it was entirely .NET managed code rather than making Windows specific calls since I intend my application to work under mono as well as on Windows... however if that's asking too much, I'll accept native Windows calls if that's what you suggest and then will come up with different methods for other platforms.
Any ideas?