本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
}
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}