Top Mud Sites Forum

Top Mud Sites Forum (http://www.topmudsites.com/forums/index.php)
-   MUD Coding (http://www.topmudsites.com/forums/forumdisplay.php?f=9)
-   -   Java and ANSI (http://www.topmudsites.com/forums/showthread.php?t=413)

Tezcatlipoca 03-16-2003 10:17 PM

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?

kaylus1 03-17-2003 06:34 AM


Tezcatlipoca 03-17-2003 02:18 PM


Jaregarde 04-10-2005 08:53 PM

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

milliway 04-11-2005 01:11 AM

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


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

}

Jaregarde 04-11-2005 12:11 PM

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?

milliway 04-11-2005 12:30 PM

out.println(ANSI.CYAN + "This is cyan" + ANSI.RED + ", and this is red.");


All times are GMT -4. The time now is 09:15 PM.

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright Top Mud Sites.com 2022