Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Multiple System.Console fixes #6488

Merged
merged 3 commits into from
Mar 2, 2016
Merged

Commits on Feb 28, 2016

  1. Multiple System.Console fixes

    - Lifetime of terminal attribute settings. Previously we were setting up the terminal's attributes (e.g. disabling echo) the first time the console was used, and leaving those settings for the duration of the process.  This has the very bad effect of leaving such settings on the terminal while other code using that terminal runs.  For example, if you launch a process with Process.Start and that process expects input, echo will still be disabled, and you won't be able to see the input.  This commit significantly changes how we do these attributes.  Instead of setting them and leaving them, we only set them while a read operation is in progress, reverting the settings immediately after.
    
    - Reapplication of terminal settings upon process resumption.  If the program was suspended with ctrl-z, when it was later resumed, both terminal settings and the application mode settings previously applied were lost.  With this commit, we now properly restore the application mode (which impacts how some keys, such as the arrows, are interpreted).  And if a read was in progress, we also restore the terminal settings.
    
    - EOL.  Typing ctrl-D is supposed to signal an end-of-line.  Previously we weren't doing anything special for it.  Now we look up the EOL characters in the terminal settings and act on them appropriately.
    
    - Console.Read.  This method, like ReadLine, is supposed to block until Enter, but it was only blocking until the first byte was available.  This commit fixes that.  It also makes it respond appropriately to EOL, return -1.
    
    - Cursor position robustness.  The protocol involved in getting the current cursor position involves writing an escape sequence to stdout and then reading a response that's written by the terminal to stdin.  Since the user can also be providing stdin input concurrently, this can lead to some flakiness, and with the current implementation, if we were to miss some of the input that comes from the terminal, we could end up hanging, waiting indefinitely for that input to arrive.  This commit adds a timeout so we'll only wait for a second on each read before giving up.
    stephentoub committed Feb 28, 2016
    Configuration menu
    Copy the full SHA
    2b0eab1 View commit details
    Browse the repository at this point in the history

Commits on Feb 29, 2016

  1. Address PR feedback

    stephentoub committed Feb 29, 2016
    Configuration menu
    Copy the full SHA
    b9bc4f4 View commit details
    Browse the repository at this point in the history

Commits on Mar 1, 2016

  1. Configuration menu
    Copy the full SHA
    933d187 View commit details
    Browse the repository at this point in the history