You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If seems that accessing Console.cursorPosition is implemented via writing escape sequences to stdout and waiting in stdin to receive the answer. That may be inherent in how terminals work.
That poses a problem when pasting longer text into the command prompt, since one may access cursorPosition when there's remaining data to be read. This will cause the cursorPosition to get into bad state (probably because it sees this other pasted - but not-yet-read data instead of the answer from cursor-position query).
It's hard to work around this problem with the current API, since one doesn't know whether there's data available before accessing cursorPosition.
One suggestion I have is to provide a tryReadKey()
If seems that accessing
Console.cursorPosition
is implemented via writing escape sequences tostdout
and waiting instdin
to receive the answer. That may be inherent in how terminals work.That poses a problem when pasting longer text into the command prompt, since one may access
cursorPosition
when there's remaining data to be read. This will cause thecursorPosition
to get into bad state (probably because it sees this other pasted - but not-yet-read data instead of the answer from cursor-position query).It's hard to work around this problem with the current API, since one doesn't know whether there's data available before accessing
cursorPosition
.One suggestion I have is to provide a
tryReadKey()
If
stdin
supports non-blocking IO, one coulddup2()
thestdin
file descriptor (to avoid clashing with otherdart:io
functionality that assumesstdin
fd is blocking)Key
), or not if no data is available (returnnull
)This would give applications the option to manually call
tryReadKey()
until it returnsnull
and only ask forcursorPosition
afterwards.The text was updated successfully, but these errors were encountered: