Created
October 6, 2013 12:03
-
-
Save rgoulter/6853251 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TextColorTerm { | |
static final int RESET = 0; | |
static final int BRIGHT = 1; | |
static final int DIM = 2; | |
static final int UNDERLINE = 3; | |
static final int BLINK = 4; | |
static final int REVERSE = 7; | |
static final int HIDDEN = 8; | |
static final int BLACK = 0; | |
static final int RED = 1; | |
static final int GREEN = 2; | |
static final int YELLOW = 3; | |
static final int BLUE = 4; | |
static final int MAGENTA = 5; | |
static final int CYAN = 6; | |
static final int WHITE = 7; | |
public static void main(String args[]) { | |
textcolor(BRIGHT, RED, BLACK); | |
System.out.println("In color\n"); | |
textcolor(RESET, WHITE, BLACK); | |
} | |
static void textcolor(int attr, int fg, int bg) { | |
String command = ((char)0x1B) + "[" + attr + ";" + (fg + 30) + ";" + (bg + 40) + "m"; | |
System.out.print(command); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
xterm only.