Search in sources :

Example 6 with KeyPress

use of org.apache.hadoop.hbase.hbtop.terminal.KeyPress 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)

Example 7 with KeyPress

use of org.apache.hadoop.hbase.hbtop.terminal.KeyPress in project hbase by apache.

the class KeyPressGenerator method ctrlAndCharacter.

private void ctrlAndCharacter(char ch) {
    char ctrlCode;
    switch(ch) {
        case 0:
            ctrlCode = ' ';
            break;
        case 28:
            ctrlCode = '\\';
            break;
        case 29:
            ctrlCode = ']';
            break;
        case 30:
            ctrlCode = '^';
            break;
        case 31:
            ctrlCode = '_';
            break;
        default:
            ctrlCode = (char) ('a' - 1 + ch);
            break;
    }
    offer(new KeyPress(KeyPress.Type.Character, ctrlCode, false, true, false));
}
Also used : KeyPress(org.apache.hadoop.hbase.hbtop.terminal.KeyPress)

Example 8 with KeyPress

use of org.apache.hadoop.hbase.hbtop.terminal.KeyPress in project hbase by apache.

the class KeyPressGenerator method doneEscapeSequenceCharacter.

private void doneEscapeSequenceCharacter(char last) {
    boolean alt = false;
    boolean ctrl = false;
    boolean shift = false;
    if (param2 != 0) {
        alt = isAlt(param2);
        ctrl = isCtrl(param2);
        shift = isShift(param2);
    }
    if (last != '~') {
        switch(last) {
            case 'A':
                offer(new KeyPress(KeyPress.Type.ArrowUp, null, alt, ctrl, shift));
                break;
            case 'B':
                offer(new KeyPress(KeyPress.Type.ArrowDown, null, alt, ctrl, shift));
                break;
            case 'C':
                offer(new KeyPress(KeyPress.Type.ArrowRight, null, alt, ctrl, shift));
                break;
            case 'D':
                offer(new KeyPress(KeyPress.Type.ArrowLeft, null, alt, ctrl, shift));
                break;
            case 'H':
                offer(new KeyPress(KeyPress.Type.Home, null, alt, ctrl, shift));
                break;
            case 'F':
                offer(new KeyPress(KeyPress.Type.End, null, alt, ctrl, shift));
                break;
            case 'P':
                offer(new KeyPress(KeyPress.Type.F1, null, alt, ctrl, shift));
                break;
            case 'Q':
                offer(new KeyPress(KeyPress.Type.F2, null, alt, ctrl, shift));
                break;
            case 'R':
                offer(new KeyPress(KeyPress.Type.F3, null, alt, ctrl, shift));
                break;
            case 'S':
                offer(new KeyPress(KeyPress.Type.F4, null, alt, ctrl, shift));
                break;
            case 'Z':
                offer(new KeyPress(KeyPress.Type.ReverseTab, null, alt, ctrl, shift));
                break;
            default:
                offer(new KeyPress(KeyPress.Type.Unknown, null, alt, ctrl, shift));
                break;
        }
        initState();
        return;
    }
    switch(param1) {
        case 1:
            offer(new KeyPress(KeyPress.Type.Home, null, alt, ctrl, shift));
            break;
        case 2:
            offer(new KeyPress(KeyPress.Type.Insert, null, alt, ctrl, shift));
            break;
        case 3:
            offer(new KeyPress(KeyPress.Type.Delete, null, alt, ctrl, shift));
            break;
        case 4:
            offer(new KeyPress(KeyPress.Type.End, null, alt, ctrl, shift));
            break;
        case 5:
            offer(new KeyPress(KeyPress.Type.PageUp, null, alt, ctrl, shift));
            break;
        case 6:
            offer(new KeyPress(KeyPress.Type.PageDown, null, alt, ctrl, shift));
            break;
        case 11:
            offer(new KeyPress(KeyPress.Type.F1, null, alt, ctrl, shift));
            break;
        case 12:
            offer(new KeyPress(KeyPress.Type.F2, null, alt, ctrl, shift));
            break;
        case 13:
            offer(new KeyPress(KeyPress.Type.F3, null, alt, ctrl, shift));
            break;
        case 14:
            offer(new KeyPress(KeyPress.Type.F4, null, alt, ctrl, shift));
            break;
        case 15:
            offer(new KeyPress(KeyPress.Type.F5, null, alt, ctrl, shift));
            break;
        case 17:
            offer(new KeyPress(KeyPress.Type.F6, null, alt, ctrl, shift));
            break;
        case 18:
            offer(new KeyPress(KeyPress.Type.F7, null, alt, ctrl, shift));
            break;
        case 19:
            offer(new KeyPress(KeyPress.Type.F8, null, alt, ctrl, shift));
            break;
        case 20:
            offer(new KeyPress(KeyPress.Type.F9, null, alt, ctrl, shift));
            break;
        case 21:
            offer(new KeyPress(KeyPress.Type.F10, null, alt, ctrl, shift));
            break;
        case 23:
            offer(new KeyPress(KeyPress.Type.F11, null, alt, ctrl, shift));
            break;
        case 24:
            offer(new KeyPress(KeyPress.Type.F12, null, alt, ctrl, shift));
            break;
        default:
            offer(new KeyPress(KeyPress.Type.Unknown, null, false, false, false));
            break;
    }
    initState();
}
Also used : KeyPress(org.apache.hadoop.hbase.hbtop.terminal.KeyPress)

Aggregations

KeyPress (org.apache.hadoop.hbase.hbtop.terminal.KeyPress)8 Terminal (org.apache.hadoop.hbase.hbtop.terminal.Terminal)3 IOException (java.io.IOException)1 TopScreenView (org.apache.hadoop.hbase.hbtop.screen.top.TopScreenView)1 TerminalPrinter (org.apache.hadoop.hbase.hbtop.terminal.TerminalPrinter)1