1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.hbtop.terminal.impl;
19
20 import java.util.concurrent.TimeUnit;
21
22 import org.apache.hadoop.hbase.hbtop.terminal.KeyPress;
23 import org.apache.hadoop.hbase.hbtop.terminal.Terminal;
24 import org.apache.hadoop.hbase.hbtop.terminal.TerminalPrinter;
25
26
27 public final class TestTerminalPrinter {
28
29 private TestTerminalPrinter() {
30 }
31
32 public static void main(String[] args) throws Exception {
33 try (Terminal terminal = new TerminalImpl()) {
34 terminal.hideCursor();
35 terminal.refresh();
36
37 TerminalPrinter printer = terminal.getTerminalPrinter(0);
38 printer.print("Normal string").endOfLine();
39 printer.startHighlight().print("Highlighted string").stopHighlight().endOfLine();
40 printer.startBold().print("Bold string").stopBold().endOfLine();
41 printer.startHighlight().startBold().print("Highlighted bold string")
42 .stopBold().stopHighlight().endOfLine();
43 printer.endOfLine();
44 printer.print("Press any key to finish").endOfLine();
45
46 terminal.refresh();
47
48 while (true) {
49 KeyPress keyPress = terminal.pollKeyPress();
50 if (keyPress == null) {
51 TimeUnit.MILLISECONDS.sleep(100);
52 continue;
53 }
54 break;
55 }
56 }
57 }
58 }