Skip to content

Instantly share code, notes, and snippets.

@rgoulter
Created October 6, 2013 12:03
Show Gist options
  • Save rgoulter/6853251 to your computer and use it in GitHub Desktop.
Save rgoulter/6853251 to your computer and use it in GitHub Desktop.
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);
}
}
@rgoulter
Copy link
Author

rgoulter commented Oct 6, 2013

xterm only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment