|
|||||||
This is a discussion on "Java and ANSI" in the Top Mud Sites MUD Coding forum : To keep it simple, does anyone here know of, and where to get, a Java package, or even just a single class that provides ANSI tag support for transfer over a socket, obviously for the use of colour support in a Java coded MUD(or any telnetable server really)? I'm quite confident it is out there, as java MUDclients have been made that supports ANSI interpretation, and others have made MUDs in Java, and I would assume that at least a few of them have colour support. So my question is, where can i get my hands on it?... |
|
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our MUD community today! If you have any problems with the registration process or your account login, please contact us. If you are a registered member of the old TMS forums, please click here
|
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
|
Member
Join Date: Feb 2003
Posts: 36
![]() |
To keep it simple, does anyone here know of, and where to get, a Java package, or even just a single class that provides ANSI tag support for transfer over a socket, obviously for the use of colour support in a Java coded MUD(or any telnetable server really)? I'm quite confident it is out there, as java MUDclients have been made that supports ANSI interpretation, and others have made MUDs in Java, and I would assume that at least a few of them have colour support. So my question is, where can i get my hands on it?
|
|
|
|
|
|
#2 | |
|
Posts: n/a
|
Quote:
The format for the colors is \033[#(;#)m (the parentheses being an optional number. So the easiest way is to check for the ESC character (ascii = 27, octal \033) and go parsing through to the m. There are numerous sites that list these codes here is one: Ansi Color Codes Personally, as I was on a mud the other day that was bashing across full color wilderness maps, I was thinking that it would be great for someone to take advantage of the cursor positioning code in a MUD specific client. Anyways, Kaylus@Solice |
|
|
|
|
#3 |
|
Member
Join Date: Feb 2003
Posts: 36
![]() |
Ah yes. I had previously dug up the code for the ANSI colouring and tried it out, in the format specified at the end of that page (Black = \e[0;30m and so forth) and just tacked it on to the front of the string, but it didnt recognize the escape char, which i attributed to the fact that java uses Unicode text instead of ASCII text.
However, after viewing the page you specified, and useing "\033" instead of "\e" as the initial escape char, it worked properly, and i now have colour Thanks for the tip. |
|
|
|
|
|
#4 |
|
New Member
Join Date: Dec 2004
Posts: 25
![]() |
I'm working on using ANSI color with Java too, but I'm not quite sure if I'm doing it right...would this, for example, be a correct string?
"\033[0;34m Bla bla blah..." I was also wondering if anyone could tell me how to test this? (I'm planning on starting a MUD, but I, er, haven't yet so I don't yet have a server with which to test it.) Thanks, Jaregarde |
|
|
|
|
|
#5 |
|
New Member
Join Date: Feb 2005
Posts: 7
![]() |
Here's a little piece of code I wrote in 2001, you're welcome to use it. You also might be able to include the .jar's from some other project in your classpath, and reuse their classes...
Thedia http://aelfengard.com public final class ANSI { public static final String SANE = "\u001B[0m"; public static final String HIGH_INTENSITY = "\u001B[1m"; public static final String LOW_INTESITY = "\u001B[2m"; public static final String ITALIC = "\u001B[3m"; public static final String UNDERLINE = "\u001B[4m"; public static final String BLINK = "\u001B[5m"; public static final String RAPID_BLINK = "\u001B[6m"; public static final String REVERSE_VIDEO = "\u001B[7m"; public static final String INVISIBLE_TEXT = "\u001B[8m"; public static final String BLACK = "\u001B[30m"; public static final String RED = "\u001B[31m"; public static final String GREEN = "\u001B[32m"; public static final String YELLOW = "\u001B[33m"; public static final String BLUE = "\u001B[34m"; public static final String MAGENTA = "\u001B[35m"; public static final String CYAN = "\u001B[36m"; public static final String WHITE = "\u001B[37m"; public static final String BACKGROUND_BLACK = "\u001B[40m"; public static final String BACKGROUND_RED = "\u001B[41m"; public static final String BACKGROUND_GREEN = "\u001B[42m"; public static final String BACKGROUND_YELLOW = "\u001B[43m"; public static final String BACKGROUND_BLUE = "\u001B[44m"; public static final String BACKGROUND_MAGENTA = "\u001B[45m"; public static final String BACKGROUND_CYAN = "\u001B[46m"; public static final String BACKGROUND_WHITE = "\u001B[47m"; private ANSI() {} // disable automatic constructor } |
|
|
|
|
|
#6 |
|
New Member
Join Date: Dec 2004
Posts: 25
![]() |
Ok, thank you, Milliway; I was wondering something else, too, though. What if you want to have parts of the string have different colors? Do you just insert a new tag whenever you want to change the color?
|
|
|
|
|
|
#7 |
|
New Member
Join Date: Feb 2005
Posts: 7
![]() |
out.println(ANSI.CYAN + "This is cyan" + ANSI.RED + ", and this is red.");
|
|
|
|
![]() |
| Thread Tools | |
Java and ANSI - Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ANSI logon screen for Circle-based mud | Lazari | MUD Coding | 4 | 06-03-2006 11:22 AM |
| A Java Problem | Almondine War | MUD Coding | 6 | 10-21-2004 11:17 PM |
| Ansi art, or whatever its called | Enzo | Tavern of the Blue Hand | 3 | 08-21-2004 12:12 PM |
| ANSI prompts at initial login: good or bad? | erdos | Advanced MUD Concepts | 9 | 01-10-2004 08:11 PM |
| ANSI Colors in muds | markizs | Tavern of the Blue Hand | 9 | 04-10-2003 02:09 AM |
|
|