当前位置: 首页>>代码示例>>Java>>正文


Java KeyStroke.getKeyType方法代码示例

本文整理汇总了Java中com.googlecode.lanterna.input.KeyStroke.getKeyType方法的典型用法代码示例。如果您正苦于以下问题:Java KeyStroke.getKeyType方法的具体用法?Java KeyStroke.getKeyType怎么用?Java KeyStroke.getKeyType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.googlecode.lanterna.input.KeyStroke的用法示例。


在下文中一共展示了KeyStroke.getKeyType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processInput

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
@Override
public synchronized boolean processInput() throws IOException {
    boolean gotInput = false;
    KeyStroke keyStroke = readKeyStroke();
    if(keyStroke != null) {
        gotInput = true;
        do {
            if (keyStroke.getKeyType() == KeyType.EOF) {
                throw new EOFException();
            }
            boolean handled = handleInput(keyStroke);
            if(!handled) {
                handled = fireUnhandledKeyStroke(keyStroke);
            }
            dirty = handled || dirty;
            keyStroke = pollInput();
        } while(keyStroke != null);
    }
    return gotInput;
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:21,代码来源:AbstractTextGUI.java

示例2: handleKeyStroke

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
@Override
public Result handleKeyStroke(KeyStroke keyStroke) {
    switch (keyStroke.getKeyType()) {
        case ArrowDown:
            return Result.MOVE_FOCUS_DOWN;
        case ArrowLeft:
            return Result.MOVE_FOCUS_LEFT;
        case ArrowRight:
            return Result.MOVE_FOCUS_RIGHT;
        case ArrowUp:
            return Result.MOVE_FOCUS_UP;
        case Tab:
            return Result.MOVE_FOCUS_NEXT;
        case ReverseTab:
            return Result.MOVE_FOCUS_PREVIOUS;
        case MouseEvent:
            getBasePane().setFocusedInteractable(this);
            return Result.HANDLED;
        default:
    }
    return Result.UNHANDLED;
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:23,代码来源:AbstractInteractableComponent.java

示例3: stopScreen

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
@Override
public synchronized void stopScreen() throws IOException {
    if(!isStarted) {
        return;
    }

    //Drain the input queue
    KeyStroke keyStroke;
    do {
        keyStroke = pollInput();
    }
    while(keyStroke != null && keyStroke.getKeyType() != KeyType.EOF);

    getTerminal().exitPrivateMode();
    isStarted = false;
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:17,代码来源:TerminalScreen.java

示例4: readInput

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
private KeyStroke readInput(boolean blocking) throws IOException {
    synchronized(readMutex) {
        if(!keyQueue.isEmpty())
            return keyQueue.poll();

        KeyStroke key = inputDecoder.getNextCharacter(blocking);
        if (key != null && key.getKeyType() == KeyType.CursorLocation) {
            TerminalPosition reportedTerminalPosition = inputDecoder.getLastReportedTerminalPosition();
            if (reportedTerminalPosition != null)
                onResized(reportedTerminalPosition.getColumn(), reportedTerminalPosition.getRow());

            return pollInput();
        } else {
            return key;
        }
    }
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:18,代码来源:StreamBasedTerminal.java

示例5: handleKeyStroke

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
@Override
public Result handleKeyStroke(KeyStroke keyStroke) {
	Runnable selectedItem = getSelectedItem();
	KeyType keyType = keyStroke.getKeyType();
	if (selectedItem != null
			&& (keyType == KeyType.Enter || (keyType == KeyType.Character && keyStroke.getCharacter() == ' '))) {
		selectedItem.run();
		return Result.HANDLED;
	}
	if (keyType == KeyType.Character) {
		selectItem(keyStroke.getCharacter());
	}
	if (keyType == KeyType.Escape) {
		closeListener.run();
		return Result.HANDLED;
	}
	return super.handleKeyStroke(keyStroke);
}
 
开发者ID:BrunoEberhard,项目名称:minimal-j,代码行数:19,代码来源:MenuItemListBox.java

示例6: handleKeyStroke

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
@Override
public Result handleKeyStroke(KeyStroke keyStroke) {
    Object selectedItem = getSelectedItem();
    if(selectedItem != null &&
            (keyStroke.getKeyType() == KeyType.Enter ||
            (keyStroke.getKeyType() == KeyType.Character && keyStroke.getCharacter() == ' '))) {

        ((Runnable)selectedItem).run();
        return Result.HANDLED;
    }
    return super.handleKeyStroke(keyStroke);
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:13,代码来源:ActionListBox.java

示例7: handleKeyStroke

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
@Override
public Result handleKeyStroke(KeyStroke keyStroke) {
    if(keyStroke.getKeyType() == KeyType.Enter) {
        action.run();
        return Result.HANDLED;
    }
    return super.handleKeyStroke(keyStroke);
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:9,代码来源:Button.java

示例8: handleKeyStroke

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
@Override
public Result handleKeyStroke(AbstractListBox<V, T> listBox, KeyStroke keyStroke) {
    switch (keyStroke.getKeyType()) {
        case PageUp:
            listBox.setSelectedIndex(listBox.getSelectedIndex() - pageSize);
            return Result.HANDLED;

        case PageDown:
            listBox.setSelectedIndex(listBox.getSelectedIndex() + pageSize);
            return Result.HANDLED;

        default:
    }
    return Result.UNHANDLED;
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:16,代码来源:AbstractListBox.java

示例9: handleKeyStroke

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
@Override
public synchronized Result handleKeyStroke(KeyStroke keyStroke) {
    if(keyStroke.getKeyType() == KeyType.Enter ||
            (keyStroke.getKeyType() == KeyType.Character && keyStroke.getCharacter() == ' ')) {
        if(itemStatus.get(getSelectedIndex()))
            itemStatus.set(getSelectedIndex(), Boolean.FALSE);
        else
            itemStatus.set(getSelectedIndex(), Boolean.TRUE);
        return Result.HANDLED;
    }
    return super.handleKeyStroke(keyStroke);
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:13,代码来源:CheckBoxList.java

示例10: handleKeyStroke

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
@Override
public Result handleKeyStroke(KeyStroke keyStroke) {
    if((keyStroke.getKeyType() == KeyType.Character && keyStroke.getCharacter() == ' ') ||
            keyStroke.getKeyType() == KeyType.Enter) {
        setChecked(!isChecked());
        return Result.HANDLED;
    }
    return super.handleKeyStroke(keyStroke);
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:10,代码来源:CheckBox.java

示例11: handleInput

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
@Override
public boolean handleInput(KeyStroke key) {
    if(key.getKeyType() == KeyType.Escape) {
        close();
        return true;
    }
    return super.handleInput(key);
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:9,代码来源:AbstractWindow.java

示例12: handleKeyStroke

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
@Override
public synchronized Result handleKeyStroke(KeyStroke keyStroke) {
    if(keyStroke.getKeyType() == KeyType.Enter ||
            (keyStroke.getKeyType() == KeyType.Character && keyStroke.getCharacter() == ' ')) {
        checkedIndex = getSelectedIndex();
        invalidate();
        return Result.HANDLED;
    }
    return super.handleKeyStroke(keyStroke);
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:11,代码来源:RadioBoxList.java

示例13: filter

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
private KeyStroke filter(KeyStroke keyStroke) throws IOException {
    if(keyStroke == null) {
        return null;
    }
    else if(keyStroke.isCtrlDown() && keyStroke.getKeyType() == KeyType.ArrowLeft) {
        if(viewportTopLeft.getColumn() > 0) {
            viewportTopLeft = viewportTopLeft.withRelativeColumn(-1);
            refresh();
        }
        return null;
    }
    else if(keyStroke.isCtrlDown() && keyStroke.getKeyType() == KeyType.ArrowRight) {
        if(viewportTopLeft.getColumn() + viewportSize.getColumns() < getTerminalSize().getColumns()) {
            viewportTopLeft = viewportTopLeft.withRelativeColumn(1);
            refresh();
        }
        return null;
    }
    else if(keyStroke.isCtrlDown() && keyStroke.getKeyType() == KeyType.ArrowUp) {
        if(viewportTopLeft.getRow() > 0) {
            viewportTopLeft = viewportTopLeft.withRelativeRow(-1);
            realScreen.scrollLines(0,viewportSize.getRows()-1,-1);
            refresh();
        }
        return null;
    }
    else if(keyStroke.isCtrlDown() && keyStroke.getKeyType() == KeyType.ArrowDown) {
        if(viewportTopLeft.getRow() + viewportSize.getRows() < getTerminalSize().getRows()) {
            viewportTopLeft = viewportTopLeft.withRelativeRow(1);
            realScreen.scrollLines(0,viewportSize.getRows()-1,1);
            refresh();
        }
        return null;
    }
    return keyStroke;
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:37,代码来源:VirtualScreen.java

示例14: pollInput

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
@Override
public KeyStroke pollInput() {
    if(disposed) {
        return new KeyStroke(KeyType.EOF);
    }
    KeyStroke keyStroke = swingTerminal.pollInput();
    if(autoCloseTrigger == AutoCloseTrigger.CloseOnEscape && 
            keyStroke != null && 
            keyStroke.getKeyType() == KeyType.Escape) {
        dispose();
    }
    return keyStroke;
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:14,代码来源:SwingTerminalFrame.java

示例15: VirtualScreenTest

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
public VirtualScreenTest(String[] args) throws InterruptedException, IOException {
    Screen screen = new TestTerminalFactory(args).createScreen();
    screen = new VirtualScreen(screen);
    screen.startScreen();

    TextGraphics textGraphics = screen.newTextGraphics();
    textGraphics.setBackgroundColor(TextColor.ANSI.GREEN);
    textGraphics.fillTriangle(new TerminalPosition(40, 0), new TerminalPosition(25,19), new TerminalPosition(65, 19), ' ');
    textGraphics.setBackgroundColor(TextColor.ANSI.RED);
    textGraphics.drawRectangle(TerminalPosition.TOP_LEFT_CORNER, screen.getTerminalSize(), ' ');
    screen.refresh();

    while(true) {
        KeyStroke keyStroke = screen.pollInput();
        if(keyStroke != null) {
            if(keyStroke.getKeyType() == KeyType.Escape) {
                break;
            }
        }
        else if(screen.doResizeIfNecessary() != null) {
            screen.refresh();
        }
        else {
            Thread.sleep(1);
        }
    }
    screen.stopScreen();
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:29,代码来源:VirtualScreenTest.java


注:本文中的com.googlecode.lanterna.input.KeyStroke.getKeyType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。