console fix

This commit is contained in:
jusax23 2023-09-18 20:25:23 +02:00
parent 0e08b591b7
commit 768179ab24
Signed by: jusax23
GPG key ID: 499E2AA870C1CD41

View file

@ -117,7 +117,7 @@ class _SerialDetailPageState extends State<SerialDetailPage> {
serial.sprintln(_textController.text);
_messages.add(_textController.text);
messageIndex = _messages.length;
_textController.clear();
_textController.text = "";
});
_textFocus.requestFocus();
}
@ -127,26 +127,28 @@ class _SerialDetailPageState extends State<SerialDetailPage> {
if (event.runtimeType.toString() == 'RawKeyDownEvent') {
if (event.logicalKey == LogicalKeyboardKey.arrowUp) {
if (messageIndex > 0) {
setState(() {
messageIndex--;
print("up: " + _messages[messageIndex]);
messageIndex--;
Future.delayed(const Duration(microseconds: 10), () {
_textController.text = _messages[messageIndex];
_textController.selection =
TextSelection.collapsed(offset: _textController.text.length);
});
}
} else if (event.logicalKey == LogicalKeyboardKey.arrowDown) {
if (messageIndex >= _messages.length - 1) {
setState(() {
print("clear");
messageIndex = _messages.length;
_textController.clear();
_textFocus.requestFocus();
Future.delayed(const Duration(microseconds: 10), () {
_textController.text = "";
_textController.selection = const TextSelection.collapsed(offset: 0);
});
});
} else {
setState(() {
messageIndex++;
print("down: " + _messages[messageIndex]);
messageIndex++;
Future.delayed(const Duration(microseconds: 10), () {
_textController.text = _messages[messageIndex];
_textFocus.requestFocus();
_textController.selection =
TextSelection.collapsed(offset: _textController.text.length);
});
}
}