Another ASCII Formatting Question

P

pbd22

Been struggling with find the correct ESC sequence for this.

A telnet session is established using Win XP DOS prompt.

I have provided a custom telnet screen - not the Server 2003
telnet. I am taking control of the port 23 session using the basic
API tools available to me in .NET.

I want the session to have a BLUE background and either white
or red letters (or, some white, some red).

Anybody out there know what the correct sequence is and, how
do I maintain the session's "blueness" until the connection is
dropped? Details appreciated.

Thanks!
Peter
 
J

Jon Skeet [C# MVP]

Been struggling with find the correct ESC sequence for this.

A telnet session is established using Win XP DOS prompt.

Is this the default Windows telnet client? What terminal type is being
used?

Jon
 
P

pbd22

no. this is just MS DOS with:

C:\telnet 172.33.2.30

connecting to the custom telnet server.

I am pretty sure this is VT 100 but don't
know how to check. If any of this sounds wrong,
maybe you could tell me?

Thanks.
Peter
 
J

Jon Skeet [C# MVP]

no. this is just MS DOS with:

C:\telnet 172.33.2.30

connecting to the custom telnet server.

I am pretty sure this is VT 100 but don't
know how to check. If any of this sounds wrong,
maybe you could tell me?

On my XP box, by default I've got ansi as the preferred terminal type.
To check, just type "telnet" and then from the prompt, enter "d" (on
its own) and see what the "Preferred term type" is. Of course, you can
do terminal negotiation in your server if you want...

Jon
 
P

pbd22

yeah, that is what I am doing.
There is no "d" unless I program a "d" and give it logic.
All the terminal negotiation is happening from the program
I wrote on the server. Not sure if this helps you answer your
"preferred type" question.

If I am doing the terminal negotiation, how do I change
the color/font?

Peter
 
J

Jon Skeet [C# MVP]

pbd22 said:
yeah, that is what I am doing.
There is no "d" unless I program a "d" and give it logic.

Yes, there is. If you type "telnet" and hit return, it will give you a
prompt of "Microsoft Telnet>"

At that prompt, press d and hit return.
All the terminal negotiation is happening from the program
I wrote on the server. Not sure if this helps you answer your
"preferred type" question.

If I am doing the terminal negotiation, how do I change
the color/font?

If you're doing terminal negotiation, you should know what terminal
type you've agreed - and that will determine how to do the colour.
 
P

pbd22

Sorry, i thought you meant once the connection was established.
The preferred TERM type is ANSI.
 
J

Jon Skeet [C# MVP]

pbd22 said:
Sorry, i thought you meant once the connection was established.
The preferred TERM type is ANSI.

Okay - and given that you're doing terminal negotiation, which terminal
are you actually accepting? That's the one you need to look up
information about.
 
J

Jon Skeet [C# MVP]

pbd22 said:
if it is not telnet "d", how would i find that out?

Your code is doing the negotiation with the client - you should only be
accepting the terminal types you're willing to support.
 
P

pbd22

"you should only be accepting the terminal types you're willing to
support."

With all due respect, this really isn't helping me provide you with
an answer. I am new to telnet programming. Would you mind being
more clear as to "how I can check this". In other words, what, in my
program, should I be looking at to tell you what terminal types I
accept?

Thanks again for your help.
Peter
 
J

Jon Skeet [C# MVP]

pbd22 said:
"you should only be accepting the terminal types you're willing to
support."

With all due respect, this really isn't helping me provide you with
an answer. I am new to telnet programming. Would you mind being
more clear as to "how I can check this". In other words, what, in my
program, should I be looking at to tell you what terminal types I
accept?

The easiest thing would be to only support one terminal type which you
happen to know your telnet client also supports. Do you only need to
support the Windows telnet client, for instance? If so, the options
suggested by "telnet /?" are vt100, vt52, ansi and vtnt. I don't know
the capabilities of these terminals, but searches for them with Google
will probably yield good results. "ansi" would probably be a good
choice and reasonably easy to support. For instance, here are the
appropriate colour sequences for ANSI terminals:

http://rrbrandt.blogspot.com/2007/11/ansi-codes-part-two.html
 
P

pbd22

OK,

Assuming ANSI,

I am having some probs.
Thanks for the link you sent.
I am trying to send the commands as text to the client.
Since the decimal command for BLUE is 44, the
hex is 2C. So, i figured the below command would work:

StringBuilder bs = new StringBuilder();
bs.Append("\u002C");

But, I get a comma.
What is going wrong?
 
J

Jon Skeet [C# MVP]

pbd22 said:
Assuming ANSI,

I am having some probs.
Thanks for the link you sent.
I am trying to send the commands as text to the client.
Since the decimal command for BLUE is 44, the
hex is 2C. So, i figured the below command would work:

StringBuilder bs = new StringBuilder();
bs.Append("\u002C");

But, I get a comma.
What is going wrong?

Well, did you put in the ESC [P part beforehand and the m afterwards?
 
P

pbd22

OK.
That doesnt work.
It was my understanding that the \u replaces the ESC
in my particular case - outputting strings using the networkstream.
If I put ESC[P beforehand and P after I get

ESC[P\u002CP
or
\uESC[P002CP

or whatever

I want the first line to the client to be the
condition for the color blue and i want that to persist throughout
the session. Since we established that I am using ANSI and that
44 is BLUE (2CP in HEX), would you mind simply showing me
what this command would be?
 
J

Jon Skeet [C# MVP]

pbd22 said:
That doesnt work.
It was my understanding that the \u replaces the ESC
in my particular case - outputting strings using the networkstream.

No. The \uxxxx is just a way of getting a single unicode character.
If I put ESC[P beforehand and P after I get

ESC[P\u002CP
or
\uESC[P002CP

or whatever

You need to understand what \uxxxx is about. It's nothing to do with
terminals etc, it's just a way of representing a Unicode character in
C# source code. So the strings:

"\u0041"
and
"A"

are *exactly* the same. But "ESC" in the above is just a shorthand for
"character 27 (0x1B)".
I want the first line to the client to be the
condition for the color blue and i want that to persist throughout
the session. Since we established that I am using ANSI and that
44 is BLUE (2CP in HEX), would you mind simply showing me
what this command would be?

Untested, but based on the page mentioned and other pages from a quick
Google search:

"\u001B[P44m"

(That's a blue background - use 34 for a blue foreground.)
 
C

christery

Good job by the pepole helping you... didnt think there where any
vt100 experts left...
//CY
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top