Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require xterm-style virtual terminal on all platforms, including Windows #27487

Merged
merged 6 commits into from
Jan 13, 2021

Commits on Jan 12, 2021

  1. internal/terminal: Interrogate and initialize the terminal, if any

    This is a helper package that creates a very thin abstraction over
    terminal setup, with the main goal being to deal with all of the extra
    setup we need to do in order to get a UTF-8-supporting virtual terminal
    on a Windows system.
    apparentlymart committed Jan 12, 2021
    Configuration menu
    Copy the full SHA
    5372045 View commit details
    Browse the repository at this point in the history
  2. main: initialize the terminal (if any) using internal/terminal

    We need to call into terminal.Init in early startup to make sure that we
    either have a suitable Terminal or that we disable attempts to use virtual
    terminal escape sequences.
    
    This commit gets the terminal initialized but doesn't do much with it
    after that. Subsequent commits will make more use of this.
    apparentlymart committed Jan 12, 2021
    Configuration menu
    Copy the full SHA
    d6b920f View commit details
    Browse the repository at this point in the history

Commits on Jan 13, 2021

  1. command: Use the new terminal.Streams object

    Here we propagate in the initialized terminal.Streams from package main,
    and then onwards to backends running in CLI mode.
    
    This also replaces our use of helper/wrappedstreams to determine whether
    stdin is a terminal or a pipe. helper/wrappedstreams returns incorrect
    file descriptors on Windows, causing StdinPiped to always return false on
    that platform and thus causing one of the odd behaviors discussed in
    
    Finally, this includes some wrappers around the ability to look up the
    number of columns in the terminal in preparation for use elsewhere. These
    wrappers deal with the fact that our unit tests typically won't populate
    meta.Streams.
    apparentlymart committed Jan 13, 2021
    Configuration menu
    Copy the full SHA
    c75b21a View commit details
    Browse the repository at this point in the history
  2. backend/local: Use terminal properties to tweak the plan output

    We now require the output to accept UTF-8 and we can determine how wide
    the terminal (if any) is, so here we begin to make use of that for the
    "terraform plan" command.
    
    The horizontal rule is now made of box drawing characters instead of
    hyphens and fills the whole terminal width.
    
    The paragraphs of text in the output are now also wrapped to fill the
    terminal width, instead of the hard-wrapping we did before.
    
    This is just a start down the road of making better use of the terminal
    capabilities. Lots of other commands could benefit from updates like these
    too.
    apparentlymart committed Jan 13, 2021
    Configuration menu
    Copy the full SHA
    afab845 View commit details
    Browse the repository at this point in the history
  3. command/format: Use box drawing chars for rules in diagnostics

    We were previously using some ASCII art to create some visual divisions
    between parts of the diagnostic output. Now that we are requiring a UTF-8
    terminal we can print out box drawing characters instead.
    apparentlymart committed Jan 13, 2021
    Configuration menu
    Copy the full SHA
    0e6c415 View commit details
    Browse the repository at this point in the history
  4. command/format: Don't try to fill the last terminal column

    In some terminal emulators, writing a character into the last column on a
    row causes the terminal to immediately wrap to the beginning of the next
    line, even if the very next character in the stream is a hard newline.
    That can then lead to errant blank lines in the final output which make
    it harder to navigate the visual hierarchy.
    
    As a compromise to avoid this, we'll format our horizontal rules and
    paragraphs to one column less than the terminal width. That does mean that
    our horizontal rules won't _quite_ cover the whole terminal width, but
    it seems like a good compromise in order to get consistent behavior across
    a wider variety of terminal implementations.
    apparentlymart committed Jan 13, 2021
    Configuration menu
    Copy the full SHA
    e272c5d View commit details
    Browse the repository at this point in the history