提交 23220696 编写于 作者: R Romain Vimont

Extract control event String parsing

Parsing a String from a serialized control event, encoded as length (2
bytes) + data, will be necessary in several events.

Extract it to a separate method.
上级 61f5f96b
......@@ -92,7 +92,7 @@ public class ControlEventReader {
return ControlEvent.createKeycodeControlEvent(action, keycode, metaState);
}
private ControlEvent parseTextControlEvent() {
private String parseString() {
if (buffer.remaining() < 2) {
return null;
}
......@@ -101,7 +101,14 @@ public class ControlEventReader {
return null;
}
buffer.get(textBuffer, 0, len);
String text = new String(textBuffer, 0, len, StandardCharsets.UTF_8);
return new String(textBuffer, 0, len, StandardCharsets.UTF_8);
}
private ControlEvent parseTextControlEvent() {
String text = parseString();
if (text == null) {
return null;
}
return ControlEvent.createTextControlEvent(text);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册