本文整理了Java中io.termd.core.readline.KeyEvent
类的一些代码示例,展示了KeyEvent
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyEvent
类的具体详情如下:
包路径:io.termd.core.readline.KeyEvent
类名称:KeyEvent
[英]A key event.
[中]关键事件。
代码示例来源:origin: io.termd/termd-core
next:
for (KeyEvent action : bindings) {
if (action.length() > 0) {
if (action.length() <= buffer.length) {
for (int i = 0;i < action.length();i++) {
if (action.getCodePointAt(i) != buffer[i]) {
continue next;
if (candidate != null && candidate.length() > action.length()) {
continue next;
} else {
for (int i = 0;i < buffer.length;i++) {
if (action.getCodePointAt(i) != buffer[i]) {
continue next;
代码示例来源:origin: io.termd/termd-core
public KeyEvent next() {
if (events.isEmpty()) {
KeyEvent next = match(pending);
if (next != null) {
events.add(next);
pending = Arrays.copyOfRange(pending, next.length(), pending.length);
}
}
return events.removeFirst();
}
代码示例来源:origin: io.vertx/vertx-shell
void checkPending() {
if (stdinHandler != null && readline.hasEvent()) {
stdinHandler.handle(Helper.fromCodePoints(readline.nextEvent().buffer().array()));
vertx.runOnContext(v -> {
checkPending();
});
}
}
代码示例来源:origin: termd/termd
public KeyEvent next() {
if (events.isEmpty()) {
KeyEvent next = match(pending);
if (next != null) {
events.add(next);
pending = Arrays.copyOfRange(pending, next.length(), pending.length);
}
}
return events.removeFirst();
}
代码示例来源:origin: termd/termd
next:
for (KeyEvent action : bindings) {
if (action.length() > 0) {
if (action.length() <= buffer.length) {
for (int i = 0;i < action.length();i++) {
if (action.getCodePointAt(i) != buffer[i]) {
continue next;
if (candidate != null && candidate.length() > action.length()) {
continue next;
} else {
for (int i = 0;i < buffer.length;i++) {
if (action.getCodePointAt(i) != buffer[i]) {
continue next;
代码示例来源:origin: io.termd/termd-core
default IntBuffer buffer() {
int length = length();
IntBuffer buf = IntBuffer.allocate(length);
for (int i = 0;i < length;i++) {
buf.put(getCodePointAt(i));
}
buf.flip();
return buf;
}
代码示例来源:origin: termd/termd
default IntBuffer buffer() {
int length = length();
IntBuffer buf = IntBuffer.allocate(length);
for (int i = 0;i < length;i++) {
buf.put(getCodePointAt(i));
}
buf.flip();
return buf;
}
代码示例来源:origin: termd/termd
private void handle(KeyEvent event) {
if (event.length() == 1) {
if (event.getCodePointAt(0) == 4 && buffer.getSize() == 0) {
} else if (event.getCodePointAt(0) == 3) {
for (int i = 0;i < event.length();i++) {
int codePoint = event.getCodePointAt(i);
try {
buf.insert(codePoint);
代码示例来源:origin: io.termd/termd-core
private void handle(KeyEvent event) {
if (event.length() == 1) {
if (event.getCodePointAt(0) == 4 && buffer.getSize() == 0) {
} else if (event.getCodePointAt(0) == 3) {
for (int i = 0;i < event.length();i++) {
int codePoint = event.getCodePointAt(i);
try {
buf.insert(codePoint);
代码示例来源:origin: io.termd/termd-core
@Test
public void testDecodeKeySeqPrefix() {
EventQueue queue = new EventQueue(new Keymap(new ByteArrayInputStream("\"ab\":foo".getBytes())));
assertFalse(queue.append('a').hasNext());
assertTrue(queue.append('c').hasNext());
KeyEvent key = (KeyEvent) queue.next();
assertEquals(1, key.length());
assertEquals('a', key.getCodePointAt(0));
assertTrue(queue.hasNext());
key = (KeyEvent) queue.next();
assertEquals(1, key.length());
assertEquals('c', key.getCodePointAt(0));
assertFalse(queue.hasNext());
}
代码示例来源:origin: com.alibaba.middleware/termd-core
@Test
public void testDecodeKeySeqPrefix() {
EventQueue queue = new EventQueue(new Keymap(new ByteArrayInputStream("\"ab\":foo".getBytes())));
assertFalse(queue.append('a').hasNext());
assertTrue(queue.append('c').hasNext());
KeyEvent key = (KeyEvent) queue.next();
assertEquals(1, key.length());
assertEquals('a', key.getCodePointAt(0));
assertTrue(queue.hasNext());
key = (KeyEvent) queue.next();
assertEquals(1, key.length());
assertEquals('c', key.getCodePointAt(0));
assertFalse(queue.hasNext());
}
代码示例来源:origin: termd/termd
@Test
public void testDecodeKeySeqPrefix() {
EventQueue queue = new EventQueue(new Keymap(new ByteArrayInputStream("\"ab\":foo".getBytes())));
assertFalse(queue.append('a').hasNext());
assertTrue(queue.append('c').hasNext());
KeyEvent key = (KeyEvent) queue.next();
assertEquals(1, key.length());
assertEquals('a', key.getCodePointAt(0));
assertTrue(queue.hasNext());
key = (KeyEvent) queue.next();
assertEquals(1, key.length());
assertEquals('c', key.getCodePointAt(0));
assertFalse(queue.hasNext());
}
代码示例来源:origin: termd/termd
@Test
public void testNotRecognizePredefinedKey() {
EventQueue queue = new EventQueue(new Keymap());
queue.append('a');
assertTrue(queue.hasNext());
KeyEvent key = (KeyEvent) queue.next();
assertEquals(1, key.length());
assertEquals('a', key.getCodePointAt(0));
}
代码示例来源:origin: io.termd/termd-core
@Test
public void testNotRecognizePredefinedKey() {
EventQueue queue = new EventQueue(new Keymap());
queue.append('a');
assertTrue(queue.hasNext());
KeyEvent key = (KeyEvent) queue.next();
assertEquals(1, key.length());
assertEquals('a', key.getCodePointAt(0));
}
代码示例来源:origin: com.alibaba.middleware/termd-core
@Test
public void testNotRecognizePredefinedKey() {
EventQueue queue = new EventQueue(new Keymap());
queue.append('a');
assertTrue(queue.hasNext());
KeyEvent key = (KeyEvent) queue.next();
assertEquals(1, key.length());
assertEquals('a', key.getCodePointAt(0));
}
代码示例来源:origin: com.alibaba.middleware/termd-core
@Test
public void testDecodeKeySeq() {
EventQueue queue = new EventQueue(new Keymap(new ByteArrayInputStream("\"ab\":foo".getBytes())));
assertFalse(queue.append('a').hasNext());
assertTrue(queue.append('b', 'c').hasNext());
FunctionEvent action = (FunctionEvent) queue.next();
assertEquals("foo", action.name());
assertTrue(queue.hasNext());
KeyEvent key = (KeyEvent) queue.next();
assertEquals(1, key.length());
assertEquals('c', key.getCodePointAt(0));
assertFalse(queue.hasNext());
}
代码示例来源:origin: termd/termd
@Test
public void testDecodeKeySeq() {
EventQueue queue = new EventQueue(new Keymap(new ByteArrayInputStream("\"ab\":foo".getBytes())));
assertFalse(queue.append('a').hasNext());
assertTrue(queue.append('b', 'c').hasNext());
FunctionEvent action = (FunctionEvent) queue.next();
assertEquals("foo", action.name());
assertTrue(queue.hasNext());
KeyEvent key = (KeyEvent) queue.next();
assertEquals(1, key.length());
assertEquals('c', key.getCodePointAt(0));
assertFalse(queue.hasNext());
}
代码示例来源:origin: io.termd/termd-core
@Test
public void testDecodeKeySeq() {
EventQueue queue = new EventQueue(new Keymap(new ByteArrayInputStream("\"ab\":foo".getBytes())));
assertFalse(queue.append('a').hasNext());
assertTrue(queue.append('b', 'c').hasNext());
FunctionEvent action = (FunctionEvent) queue.next();
assertEquals("foo", action.name());
assertTrue(queue.hasNext());
KeyEvent key = (KeyEvent) queue.next();
assertEquals(1, key.length());
assertEquals('c', key.getCodePointAt(0));
assertFalse(queue.hasNext());
}
代码示例来源:origin: com.alibaba.middleware/termd-core
@Test
public void testRecognizePredefinedKey1() {
EventQueue queue = new EventQueue(new Keymap());
queue.append(27, 91);
assertTrue(queue.hasNext());
assertEquals(1, ((KeyEvent) queue.peek()).length());
assertEquals(27, ((KeyEvent) queue.peek()).getCodePointAt(0));
queue.append(65);
assertTrue(queue.hasNext());
assertEquals(Keys.UP, queue.next());
}
代码示例来源:origin: io.termd/termd-core
@Test
public void testRecognizePredefinedKey2() {
EventQueue queue = new EventQueue(new Keymap());
queue.append(27, 91);
assertEquals(1, ((KeyEvent) queue.peek()).length());
assertEquals(27, ((KeyEvent)queue.peek()).getCodePointAt(0));
assertTrue(queue.hasNext());
queue.append(66);
assertTrue(queue.hasNext());
assertEquals(Keys.DOWN, queue.next());
}
内容来源于网络,如有侵权,请联系作者删除!