Search in sources :

Example 6 with TerminalPrinter

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();
}
Also used : TerminalPrinter(org.apache.hadoop.hbase.hbtop.terminal.TerminalPrinter)

Example 7 with TerminalPrinter

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();
    }
}
Also used : TerminalPrinter(org.apache.hadoop.hbase.hbtop.terminal.TerminalPrinter)

Example 8 with TerminalPrinter

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();
        }
    }
}
Also used : TerminalPrinter(org.apache.hadoop.hbase.hbtop.terminal.TerminalPrinter) ArrayList(java.util.ArrayList) Record(org.apache.hadoop.hbase.hbtop.Record)

Example 9 with TerminalPrinter

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;
        }
    }
}
Also used : KeyPress(org.apache.hadoop.hbase.hbtop.terminal.KeyPress) TerminalPrinter(org.apache.hadoop.hbase.hbtop.terminal.TerminalPrinter) Terminal(org.apache.hadoop.hbase.hbtop.terminal.Terminal)

Aggregations

TerminalPrinter (org.apache.hadoop.hbase.hbtop.terminal.TerminalPrinter)9 ArrayList (java.util.ArrayList)1 Record (org.apache.hadoop.hbase.hbtop.Record)1 KeyPress (org.apache.hadoop.hbase.hbtop.terminal.KeyPress)1 Terminal (org.apache.hadoop.hbase.hbtop.terminal.Terminal)1