本文整理汇总了Java中com.googlecode.lanterna.input.KeyType.Escape方法的典型用法代码示例。如果您正苦于以下问题:Java KeyType.Escape方法的具体用法?Java KeyType.Escape怎么用?Java KeyType.Escape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.googlecode.lanterna.input.KeyType
的用法示例。
在下文中一共展示了KeyType.Escape方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleKeyStroke
import com.googlecode.lanterna.input.KeyType; //导入方法依赖的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);
}
示例2: handleInput
import com.googlecode.lanterna.input.KeyType; //导入方法依赖的package包/类
@Override
public boolean handleInput(KeyStroke key) {
if(key.getKeyType() == KeyType.Escape) {
close();
return true;
}
return super.handleInput(key);
}
示例3: pollInput
import com.googlecode.lanterna.input.KeyType; //导入方法依赖的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;
}
示例4: VirtualScreenTest
import com.googlecode.lanterna.input.KeyType; //导入方法依赖的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();
}
示例5: main
import com.googlecode.lanterna.input.KeyType; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException {
Terminal terminal = new TestTerminalFactory(args).createTerminal();
if(terminal instanceof SwingTerminalFrame) {
((SwingTerminalFrame) terminal).setAutoCloseTrigger(SwingTerminalFrame.AutoCloseTrigger.DoNotAutoClose);
}
boolean normalTerminal = true;
printNormalTerminalText(terminal);
KeyStroke keyStroke = null;
while(keyStroke == null || keyStroke.getKeyType() != KeyType.Escape) {
keyStroke = terminal.pollInput();
if(keyStroke != null && keyStroke.getKeyType() == KeyType.Character && keyStroke.getCharacter() == ' ') {
normalTerminal = !normalTerminal;
if(normalTerminal) {
terminal.exitPrivateMode();
printNormalTerminalText(terminal);
}
else {
terminal.enterPrivateMode();
printPrivateModeTerminalText(terminal);
}
}
else {
Thread.sleep(1);
}
}
if(!normalTerminal) {
terminal.exitPrivateMode();
}
terminal.putCharacter('\n');
if(terminal instanceof SwingTerminalFrame) {
((SwingTerminalFrame) terminal).dispose();
}
}
示例6: keyStrokesTestDataProvider
import com.googlecode.lanterna.input.KeyType; //导入方法依赖的package包/类
@DataProvider
public Object[][] keyStrokesTestDataProvider() {
return new Object[][] { { new KeyStroke(KeyType.Enter), "Enter", },
{ new KeyStroke(KeyType.ArrowDown, true, false), "Ctrl+ArrowDown", },
{ new KeyStroke(KeyType.Escape, false, true), "Alt+Escape", },
{ new KeyStroke(' ', true, true), "Ctrl+Alt+Space", }, { new KeyStroke('w', false, false), "w", },
{ new KeyStroke('A', true, false), "Ctrl+A", }, { new KeyStroke('s', false, true), "Alt+s", },
{ new KeyStroke('D', true, true), "Ctrl+Alt+D", }, };
}
示例7: main
import com.googlecode.lanterna.input.KeyType; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException {
boolean useAnsiColors = false;
boolean useFilled = false;
boolean slow = false;
for(String arg: args) {
if(arg.equals("--ansi-colors")) {
useAnsiColors = true;
}
if(arg.equals("--filled")) {
useFilled = true;
}
if(arg.equals("--slow")) {
slow = true;
}
}
Screen screen = new TestTerminalFactory(args).createScreen();
screen.startScreen();
TextGraphics textGraphics = new ScreenTextGraphics(screen);
Random random = new Random();
long startTime = System.currentTimeMillis();
while(System.currentTimeMillis() - startTime < 1000 * 20) {
KeyStroke keyStroke = screen.pollInput();
if(keyStroke != null && keyStroke.getKeyType() == KeyType.Escape) {
break;
}
screen.doResizeIfNecessary();
TerminalSize size = textGraphics.getSize();
TextColor color;
if(useAnsiColors) {
color = TextColor.ANSI.values()[random.nextInt(TextColor.ANSI.values().length)];
}
else {
//Draw a rectangle in random indexed color
color = new TextColor.Indexed(random.nextInt(256));
}
TerminalPosition topLeft = new TerminalPosition(random.nextInt(size.getColumns()), random.nextInt(size.getRows()));
TerminalSize rectangleSize = new TerminalSize(random.nextInt(size.getColumns() - topLeft.getColumn()), random.nextInt(size.getRows() - topLeft.getRow()));
textGraphics.setBackgroundColor(color);
if(useFilled) {
textGraphics.fillRectangle(topLeft, rectangleSize, ' ');
}
else {
textGraphics.drawRectangle(topLeft, rectangleSize, ' ');
}
screen.refresh(Screen.RefreshType.DELTA);
if(slow) {
Thread.sleep(500);
}
}
screen.stopScreen();
}
示例8: main
import com.googlecode.lanterna.input.KeyType; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException, IOException {
final Terminal rawTerminal = new TestTerminalFactory(args).createTerminal();
rawTerminal.enterPrivateMode();
for(String arg: args) {
if("--mouse-click".equals(arg)) {
((ExtendedTerminal)rawTerminal).setMouseCaptureMode(MouseCaptureMode.CLICK_RELEASE);
}
else if("--mouse-drag".equals(arg)) {
((ExtendedTerminal)rawTerminal).setMouseCaptureMode(MouseCaptureMode.CLICK_RELEASE_DRAG);
}
else if("--mouse-move".equals(arg)) {
((ExtendedTerminal)rawTerminal).setMouseCaptureMode(MouseCaptureMode.CLICK_RELEASE_DRAG_MOVE);
}
}
int currentRow = 0;
rawTerminal.setCursorPosition(0, 0);
while(true) {
KeyStroke key = rawTerminal.pollInput();
if(key == null) {
Thread.sleep(1);
continue;
}
if(key.getKeyType() == KeyType.Escape) {
break;
}
if(currentRow == 0) {
rawTerminal.clearScreen();
}
rawTerminal.setCursorPosition(0, currentRow++);
putString(rawTerminal, key.toString());
if(currentRow >= rawTerminal.getTerminalSize().getRows()) {
currentRow = 0;
}
}
((ExtendedTerminal)rawTerminal).setMouseCaptureMode(null);
rawTerminal.exitPrivateMode();
}