Java Code Examples for com.googlecode.lanterna.graphics.TextGraphics#disableModifiers()

The following examples show how to use com.googlecode.lanterna.graphics.TextGraphics#disableModifiers() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TerminalColorTest.java    From lanterna with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void main(String[] args) throws IOException {
    Screen screen = new TestTerminalFactory(args).createScreen();
    screen.startScreen();

    TextGraphics writer = new ScreenTextGraphics(screen);
    writer.setForegroundColor(TextColor.ANSI.DEFAULT);
    writer.setBackgroundColor(TextColor.ANSI.DEFAULT);
    writer.putString(10, 1, "Hello World");

    writer.setForegroundColor(TextColor.ANSI.BLACK);
    writer.setBackgroundColor(TextColor.ANSI.WHITE);
    writer.putString(11, 2, "Hello World");
    writer.setForegroundColor(TextColor.ANSI.WHITE);
    writer.setBackgroundColor(TextColor.ANSI.BLACK);
    writer.putString(12, 3, "Hello World");
    writer.setForegroundColor(TextColor.ANSI.BLACK);
    writer.setBackgroundColor(TextColor.ANSI.WHITE);
    writer.enableModifiers(SGR.BOLD);
    writer.putString(13, 4, "Hello World");
    writer.setForegroundColor(TextColor.ANSI.WHITE);
    writer.setBackgroundColor(TextColor.ANSI.BLACK);
    writer.putString(14, 5, "Hello World");
    writer.setForegroundColor(TextColor.ANSI.DEFAULT);
    writer.setBackgroundColor(TextColor.ANSI.DEFAULT);
    writer.putString(15, 6, "Hello World");
    writer.setForegroundColor(TextColor.ANSI.DEFAULT);
    writer.setBackgroundColor(TextColor.ANSI.DEFAULT);
    writer.disableModifiers(SGR.BOLD);
    writer.putString(16, 7, "Hello World");

    writer.setForegroundColor(TextColor.ANSI.BLUE);
    writer.setBackgroundColor(TextColor.ANSI.DEFAULT);
    writer.putString(10, 10, "Hello World");
    writer.setForegroundColor(TextColor.ANSI.BLUE);
    writer.setBackgroundColor(TextColor.ANSI.WHITE);
    writer.putString(11, 11, "Hello World");
    writer.setForegroundColor(TextColor.ANSI.BLUE);
    writer.setBackgroundColor(TextColor.ANSI.BLACK);
    writer.putString(12, 12, "Hello World");
    writer.setForegroundColor(TextColor.ANSI.BLUE);
    writer.setBackgroundColor(TextColor.ANSI.MAGENTA);
    writer.putString(13, 13, "Hello World");
    writer.setForegroundColor(TextColor.ANSI.GREEN);
    writer.setBackgroundColor(TextColor.ANSI.DEFAULT);
    writer.putString(14, 14, "Hello World");
    writer.setForegroundColor(TextColor.ANSI.GREEN);
    writer.setBackgroundColor(TextColor.ANSI.WHITE);
    writer.putString(15, 15, "Hello World");
    writer.setForegroundColor(TextColor.ANSI.GREEN);
    writer.setBackgroundColor(TextColor.ANSI.BLACK);
    writer.putString(16, 16, "Hello World");
    writer.setForegroundColor(TextColor.ANSI.GREEN);
    writer.setBackgroundColor(TextColor.ANSI.MAGENTA);
    writer.putString(17, 17, "Hello World");

    writer.setForegroundColor(TextColor.ANSI.BLUE);
    writer.setBackgroundColor(TextColor.ANSI.DEFAULT);
    writer.putString(10, 20, "Hello World", SGR.BOLD);
    writer.setForegroundColor(TextColor.ANSI.BLUE);
    writer.setBackgroundColor(TextColor.ANSI.WHITE);
    writer.putString(11, 21, "Hello World", SGR.BOLD);
    writer.setForegroundColor(TextColor.ANSI.BLUE);
    writer.setBackgroundColor(TextColor.ANSI.BLACK);
    writer.putString(12, 22, "Hello World", SGR.BOLD);
    writer.setForegroundColor(TextColor.ANSI.BLUE);
    writer.setBackgroundColor(TextColor.ANSI.MAGENTA);
    writer.putString(13, 23, "Hello World", SGR.BOLD);
    writer.setForegroundColor(TextColor.ANSI.GREEN);
    writer.setBackgroundColor(TextColor.ANSI.DEFAULT);
    writer.putString(14, 24, "Hello World", SGR.BOLD);
    writer.setForegroundColor(TextColor.ANSI.GREEN);
    writer.setBackgroundColor(TextColor.ANSI.WHITE);
    writer.putString(15, 25, "Hello World", SGR.BOLD);
    writer.setForegroundColor(TextColor.ANSI.GREEN);
    writer.setBackgroundColor(TextColor.ANSI.BLACK);
    writer.putString(16, 26, "Hello World", SGR.BOLD);
    writer.setForegroundColor(TextColor.ANSI.CYAN);
    writer.setBackgroundColor(TextColor.ANSI.BLUE);
    writer.putString(17, 27, "Hello World", SGR.BOLD);
    
    writer.setForegroundColor(TextColor.ANSI.DEFAULT);
    writer.setBackgroundColor(TextColor.ANSI.RED);
    writer.fill(' ');
    
    screen.refresh();

    try {
        Thread.sleep(5000);
    } catch(InterruptedException ignored) {
    }
    screen.stopScreen();
}
 
Example 2
Source File: SGRTest.java    From lanterna with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void main(String[] args) throws IOException {
    Terminal rawTerminal = new TestTerminalFactory(args).createTerminal();
    rawTerminal.enterPrivateMode();
    rawTerminal.clearScreen();
    
    String string = "Hello!";
    
    TextGraphics textGraphics = rawTerminal.newTextGraphics();
    textGraphics.setForegroundColor(TextColor.ANSI.RED);
    textGraphics.enableModifiers(SGR.BLINK);
    textGraphics.putString(10, 2, string);
    textGraphics.disableModifiers(SGR.BLINK);
    textGraphics.enableModifiers(SGR.BOLD);
    textGraphics.putString(10, 4, string);
    textGraphics.disableModifiers(SGR.BOLD);
    textGraphics.enableModifiers(SGR.BORDERED);
    textGraphics.putString(10, 6, string);
    textGraphics.disableModifiers(SGR.BORDERED);
    textGraphics.enableModifiers(SGR.CIRCLED);
    textGraphics.putString(10, 8, string);
    textGraphics.disableModifiers(SGR.CIRCLED);
    textGraphics.enableModifiers(SGR.CROSSED_OUT);
    textGraphics.putString(10, 10, string);
    textGraphics.disableModifiers(SGR.CROSSED_OUT);
    textGraphics.enableModifiers(SGR.UNDERLINE);
    textGraphics.putString(10, 12, string);
    textGraphics.disableModifiers(SGR.UNDERLINE);
    textGraphics.enableModifiers(SGR.FRAKTUR);
    textGraphics.putString(10, 14, string);
    textGraphics.disableModifiers(SGR.FRAKTUR);
    textGraphics.enableModifiers(SGR.REVERSE);
    textGraphics.putString(10, 16, string);
    textGraphics.disableModifiers(SGR.REVERSE);
    rawTerminal.setCursorPosition(0, 0);
    textGraphics.setForegroundColor(TextColor.ANSI.RED_BRIGHT);
    textGraphics.putString(10, 18, string);
    rawTerminal.flush();
    try {
        while(rawTerminal.pollInput() == null) {
            Thread.sleep(1);
        }
    }
    catch(InterruptedException e) {}
    rawTerminal.exitPrivateMode();
}