Top Mud Sites Forum Return to TopMudSites.com
Go Back   Top Mud Sites Forum > Mud Development and Administration > MUD Coding
Click here to Register

Reply
 
Thread Tools
Old 03-16-2003, 11:17 PM   #1
Tezcatlipoca
Member
 
Join Date: Feb 2003
Posts: 46
Tezcatlipoca is an unknown quantity at this point
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?
Tezcatlipoca is offline   Reply With Quote
Old 03-17-2003, 07:34 AM   #2
kaylus1
 
Posts: n/a
Quote:
Originally Posted by
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,
To keep it simple, no. But I don't use Java Though it sure would be pretty simple to create your own ANSI color parser. Especially since you don't need the full support (I presume).

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
  Reply With Quote
Old 03-17-2003, 03:18 PM   #3
Tezcatlipoca
Member
 
Join Date: Feb 2003
Posts: 46
Tezcatlipoca is an unknown quantity at this point
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.
Tezcatlipoca is offline   Reply With Quote
Old 04-10-2005, 09:53 PM   #4
Jaregarde
New Member
 
Join Date: Dec 2004
Posts: 25
Jaregarde is on a distinguished road
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
Jaregarde is offline   Reply With Quote
Old 04-11-2005, 02:11 AM   #5
milliway
New Member
 
Join Date: Feb 2005
Posts: 7
milliway is on a distinguished road
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

}
milliway is offline   Reply With Quote
Old 04-11-2005, 01:11 PM   #6
Jaregarde
New Member
 
Join Date: Dec 2004
Posts: 25
Jaregarde is on a distinguished road
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?
Jaregarde is offline   Reply With Quote
Old 04-11-2005, 01:30 PM   #7
milliway
New Member
 
Join Date: Feb 2005
Posts: 7
milliway is on a distinguished road
out.println(ANSI.CYAN + "This is cyan" + ANSI.RED + ", and this is red.");
milliway is offline   Reply With Quote
Reply


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 12:22 PM
A Java Problem Almondine War MUD Coding 6 10-22-2004 12:17 AM
Ansi art, or whatever its called Enzo Tavern of the Blue Hand 3 08-21-2004 01:12 PM
ANSI prompts at initial login: good or bad? erdos Advanced MUD Concepts 9 01-10-2004 09:11 PM
ANSI Colors in muds markizs Tavern of the Blue Hand 9 04-10-2003 03:09 AM

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -4. The time now is 06:26 PM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Style based on a design by Essilor
Copyright Top Mud Sites.com 2014