| java.lang.Object ti.swing.console.InputAdapter ti.swing.console.ColorInputHandler
ColorInputHandler | public class ColorInputHandler extends InputAdapter (Code) | | An input handler which provides support for color, by use of escaped
sequences of characters. The escape character, and the format of the
escaped character sequences, is not well defined, so the static methods
ColorInputHandler.fgColor ,
ColorInputHandler.bgColor , and
ColorInputHandler.hyperlink should be
used, for example:
// to make text with blue background, green foreground:
out.println(
ColorInputHandler.fgColor( Color.green,
ColorInputHandler.bgColor( Color.blue, "Some Text" ) ) );
// to make a hyperlink:
out.println(
ColorInputHandler.hyperlink( new Runnable() {
public void run() {
// do something here!
}
}, "Some Text" ) );
Attributes can be combined and nested as needed. Attributes created by
ColorInputHandler.fgColor and
ColorInputHandler.bgColor are constant, and so the resulting
string can be reused, written to disk, read from disk, etc. Attributes
created by
ColorInputHandler.hyperlink are dynamic, and can only be used once for
each time they are created by calling
ColorInputHandler.hyperlink .
author: Rob Clark version: 0.1 |
BGCOLOR_ATTR_CLOSE | final static char BGCOLOR_ATTR_CLOSE(Code) | | |
BGCOLOR_ATTR_OPEN | final static char BGCOLOR_ATTR_OPEN(Code) | | |
ESCAPE_CHAR | final static char ESCAPE_CHAR(Code) | | |
FGCOLOR_ATTR_CLOSE | final static char FGCOLOR_ATTR_CLOSE(Code) | | |
FGCOLOR_ATTR_OPEN | final static char FGCOLOR_ATTR_OPEN(Code) | | |
HYPERLINK_ATTR_CLOSE | final static char HYPERLINK_ATTR_CLOSE(Code) | | |
HYPERLINK_ATTR_OPEN | final static char HYPERLINK_ATTR_OPEN(Code) | | |
ColorInputHandler | public ColorInputHandler(Console console)(Code) | | Class Constructor.
Parameters: console - the console we are adding this input handler to |
append | public void append(char[] cbuf, int off, int len)(Code) | | Append characters to the end of the character stream. Note that this
method is the entry point to a bunch of internal processing that is
not thread safe, so it is synchronized on the buffer lock.
Parameters: cbuf - the character buffer Parameters: off - the offset into cbuf to first character to append Parameters: len - the number of characters to append |
bgColor | public static String bgColor(Color c, String str)(Code) | | Create a string with a background color attribute applied.
Parameters: c - the color to apply Parameters: str - the string to apply it to a string with embedded control characters |
close | public void close()(Code) | | |
fgColor | public static String fgColor(Color c, String str)(Code) | | Create a string with a foreground color attribute applied.
Parameters: c - the color to apply Parameters: str - the string to apply it to a string with embedded control characters |
hyperlink | public static String hyperlink(Runnable r, String str)(Code) | | Create a string with a hyperlink. Each time the user clicks the
hyperlink, the runnable is invoked.
Parameters: r - the runnable to invoke when user clicks link Parameters: str - the string to apply it to a string with embedded control characters |
hyperlink | public static String hyperlink(Color c, Runnable r, String str)(Code) | | Create a string with a hyperlink. Each time the user clicks the
hyperlink, the runnable is invoked.
Parameters: c - the color to apply Parameters: r - the runnable to invoke when user clicks link Parameters: str - the string to apply it to a string with embedded control characters |
|
|