views:

317

answers:

3

I am looking to handle incoming telnet text that has ANSI escape codes. For the bounty I am looking for a full implementation where I can just append text to the end of a buffer. The control should be scrollable, yet still be able to handle appending text, cursor positioning, etc.. while the user is scrolled out of view.

For example,

"\e[0;32mHello \e[0;37mWorld"

Would display a green "Hello" and a white "World"

As this would need to handle cursor positioning, setting a default 80 characters per row (80 columns) would be fine, but also needs to handle other column sizes. Would be nice to be able to change the font as well.

See Wikipedia ANSI Escape Codes for more information.

+1  A: 

Assuming you mean "ANSI escape code," you can start by converting each escape code in your string into a color (since it sounds like those are the only codes you're interested in). Just use a table like the one here (bottom of page) and do a little bit of custom string parsing.

ANSI escape codes are pretty old-school, so I wouldn't expect them to have the intended effect. They're meant for controlling output to text terminals, not fancy stuff like a .NET user control.

Matt Ball
I've already written the parser, and unfortunately I do need to handle a few more such as cursor positioning, clearing the screen, etc.
esac
Sounds like you're stuck parsing those codes as well. I don't have much more to offer since it's really up to you to interpret how each control character effects your RichTextBox. Are you basically looking to write a control which functions like a terminal? There's got to be a better way to do this...
Matt Ball
a control which functions like a terminal, yes to some degree. i already determined how i could draw the characters to screen, with color in my own control. but then i lose a lot of the functionality that something like a richtextbox has. and i have to convert it to my own structure of colors/characters and memory map that onto screen. preferably i would just leave the ansi escape codes in the stirng, and the control would parse and render as it goes along
esac
+2  A: 

Take a look at Dart's Vt.NET control (assuming that a VTxxx emulation is close enough to an ansi emulation).

jdigital
The VTxxx, specifically VT52 escape sequences are what grew into the ANSI standard escape sequences as in ANSI X3.64.Dart's control is worth looking at.
Slaftos
A: 

checkout the following link: AckTerm @ sourceforge.com

i'm trying to translate ANSI codes coming from a serial interface using Terminal Control project from www.sourceforge.com written in C# - if ackterm won't be good for you google terminal control project

hope it is what you are looking for...

arik