cursorPosition method
Requests the current coordinates of the cursor asynchronously.
Implementation
Future<Point<int>> cursorPosition() async {
if (_cursorCallback != null) {
try {
await _cursorCallback!.future;
} catch (_) {}
return await cursorPosition();
}
final completer = Completer<Point<int>>();
_cursorCallback = completer;
backend.write('\x1b[6n');
try {
final pos = await completer.future.timeout(
const Duration(milliseconds: 200),
);
return pos;
} catch (_) {
if (_cursorCallback == completer) {
_cursorCallback = null;
}
rethrow;
}
}