use of org.apache.hadoop.hbase.hbtop.terminal.TerminalPrinter in project hbase by apache.
the class HelpScreenView method showHelpScreen.
public void showHelpScreen(long refreshDelay, CommandDescription[] commandDescriptions) {
showScreenDescription(refreshDelay);
TerminalPrinter printer = getTerminalPrinter(COMMAND_DESCRIPTION_START_ROW);
for (CommandDescription commandDescription : commandDescriptions) {
showCommandDescription(printer, commandDescription);
}
printer.endOfLine();
printer.print("Press any key to continue").endOfLine();
}
use of org.apache.hadoop.hbase.hbtop.terminal.TerminalPrinter in project hbase by apache.
the class ModeScreenView method showMode.
public void showMode(int pos, Mode mode, boolean selected, int modeHeaderMaxLength, int modeDescriptionMaxLength) {
String modeHeader = String.format("%-" + modeHeaderMaxLength + "s", mode.getHeader());
String modeDescription = String.format("%-" + modeDescriptionMaxLength + "s", mode.getDescription());
int row = MODE_START_ROW + pos;
TerminalPrinter printer = getTerminalPrinter(row);
if (selected) {
printer.startHighlight().print(modeHeader).stopHighlight().printFormat(" = %s", modeDescription).endOfLine();
} else {
printer.printFormat("%s = %s", modeHeader, modeDescription).endOfLine();
}
}
use of org.apache.hadoop.hbase.hbtop.terminal.TerminalPrinter in project hbase by apache.
the class TopScreenView method showRecords.
private void showRecords(List<Header> headers, List<Record> records, Record selectedRecord) {
TerminalPrinter printer = getTerminalPrinter(RECORD_START_ROW);
int size;
if (pageSize != null) {
size = pageSize;
} else {
size = records.size();
}
List<String> buf = new ArrayList<>(headers.size());
for (int i = 0; i < size; i++) {
if (i < records.size()) {
Record record = records.get(i);
buf.clear();
for (Header header : headers) {
String value = "";
if (record.containsKey(header.getField())) {
value = record.get(header.getField()).asString();
}
buf.add(limitLineLength(String.format(header.format(), value), header.getLength()));
}
String recordString = String.join(" ", buf);
if (!recordString.isEmpty()) {
recordString += " ";
}
if (record == selectedRecord) {
printer.startHighlight().print(recordString).stopHighlight().endOfLine();
} else {
printer.print(recordString).endOfLine();
}
} else {
printer.endOfLine();
}
}
}
use of org.apache.hadoop.hbase.hbtop.terminal.TerminalPrinter in project hbase by apache.
the class TestTerminalPrinter method main.
public static void main(String[] args) throws Exception {
try (Terminal terminal = new TerminalImpl()) {
terminal.hideCursor();
terminal.refresh();
TerminalPrinter printer = terminal.getTerminalPrinter(0);
printer.print("Normal string").endOfLine();
printer.startHighlight().print("Highlighted string").stopHighlight().endOfLine();
printer.startBold().print("Bold string").stopBold().endOfLine();
printer.startHighlight().startBold().print("Highlighted bold string").stopBold().stopHighlight().endOfLine();
printer.endOfLine();
printer.print("Press any key to finish").endOfLine();
terminal.refresh();
while (true) {
KeyPress keyPress = terminal.pollKeyPress();
if (keyPress == null) {
TimeUnit.MILLISECONDS.sleep(100);
continue;
}
break;
}
}
}
Aggregations