Skip to content

Pass ANSI Escape Sequences up to the Console #406

Closed

Description

Currently ConEmu cannot process escape codes generated by applications running under the Windows Subsystem for Linux because they are processed before they can reach ConEmu (as stated in ConEmu/ConEmu#573). These sequences should be passed along to be handled at the console level.

Activity

  1. musm commented on Jul 8, 2016

    @musm

    Desperately needed. I mean apple fanboys always try to show off with fancy iterm2, while I hide in the corner living in an 8-bit world.

  2. rfc1459 commented on Aug 4, 2016

    @rfc1459

    This not only breaks (potential) 256 color support, but also causes serious issues with basic ANSI functionality (arrow keys among other things - which have been worked around in ConEmu).

    Simple reproducer for ANSI reverse:

    printf "Normal\n\x1b[7mReverse\x1b[0m\nNormal\n"

    The "reverse" sequence is silently swallowed and interpreted locally by the console emulation layer before it can reach ConEmu, so in plain bash.exe it would display "Reverse" with fg/bg swapped, but in ConEmu fg and bg are not swapped.

    If you want a more complex reproducer, fire up aptitude in both plain bash.exe and ConEmu: the former will correctly highlight the current item, the latter won't because aptitude uses ANSI reverse for the current item.

  3. ysc3839 commented on Oct 7, 2016

    @ysc3839

    The bash.exe uses SetConsoleMode setted ENABLE_VIRTUAL_TERMINAL_PROCESSING (MSDN). And we can get original ANSI sequences after disable it.
    1

  4. Maximus5 commented on Oct 18, 2016

    @Maximus5

    We can't get original ANSI. They are written directly into conhost memory. That means one console line would have few chars instead of full line of data.

  5. antitoxic commented on Oct 19, 2016

    @antitoxic

    I am also looking forward this. ref: #345 (comment)

    Richard Yu (@ysc3839) how do I do this? Are you sure it's possible?

  6. ysc3839 commented on Oct 19, 2016

    @ysc3839

    Anton Stoychev (@antitoxic) I hooked SetConsoleMode then clear the ENABLE_VIRTUAL_TERMINAL_PROCESSING bit. But ConEmu can't process them.

  7. be5invis commented on Oct 19, 2016

    @be5invis

    Maksim Moisiuk (@Maximus5) We should push for the official PTY API, instead of hooking.

  8. Maximus5 commented on Oct 19, 2016

    @Maximus5

    There would be no new API. Example of the answer: #345 (comment)

  9. be5invis commented on Oct 19, 2016

    @be5invis

    Maksim Moisiuk (@Maximus5) It’s the API for implementing an alternative terminal, instead of an API for writing text in 24 bit colors (or something like that).

  10. be5invis commented on Oct 19, 2016

    @be5invis

    cf. #1117

  11. zadjii-msft commented on Oct 19, 2016

    @zadjii-msft
    Member

    I agree with Belleve (@be5invis). Hooking is bad. If you want to hook the console to make your own, then you can go ahead and parse the VT sequences yourself too :p

  12. Maximus5 commented on Oct 19, 2016

    @Maximus5

    Unless Microsoft would provide official way to implement pty interface, the hooking is only possible technique.
    And of course, it has no sense to read VT sequences from console surface because: a) third-party terminal (ConEmu) can't realize what was a sequence and what was some RAW data; b) unprocessed VT sequences takes a lot more cells than processes, so "full screen" applications like Vim would not work at all.

  13. zadjii-msft commented on Oct 19, 2016

    @zadjii-msft
    Member

    a) you'd have to implement a VT parser, and have your own mechanism for determining if it's enabled or not. No, technically there's no way to determine if the output is a sequence or not, but that's because most terminals just assume that it is.

    b) That they do. you'd have to assume that the conhost buffer is garbage, and manage it all on your own.

    Again, we're not supporting hooking, and in the most general and vague way possible, we'll have some things to announce in the future that you'll all be very happy about, but we've got a lot to do before that

  14. Maximus5 commented on Oct 19, 2016

    @Maximus5

    a) VT parser was implemented in ConEmu years ago. But any application may write to conhost buffer via WriteConsoleOutput. And these sequences are not valid VT sequences. Without hooking or the imaginary pty API ConEmu can't distinct them.

    b) I can't. Due to a). And disability to understand are sequences were enabled or disabled. Without hooking I can't restrict bash to turn on 0x200 flag, and even if it would be dropped by ConEmu hooks, there would be absolutely no guarantee that some other application, attached to this console, is not trying to use native WinAPI instead of VT.

    So, when it really would be possible, I'll be happy to go of hooking, but till than there is no other way. If you are interested in, hooking is used for many other things in ConEmu. For example, GetConsoleWindow have to return ConEmu window instead of conhost, otherwise applications would work improperly when they use console HWND.

  15. be5invis commented on Oct 20, 2016

    @be5invis

    Mike Griese (@zadjii-msft) So, to avoid hooking, we NEED a PTY API which makes us able to implement an alternative console host, and things like tmux. This thing is missing since the creation of Windows. It's been 30 years, bro.

  16. rdeforest commented on Jul 10, 2017

    @rdeforest

    Was going to submit a bug but it would have been a dupe of this one I think. I too see problems in aptitude as of Windows build 16237. I'd include a screenshot, but it's so easy to repro it would add nothing.

    If the bug isn't obvious as soon as you run aptitude, try navigating (down arrow or 'j' or whatever).

    Edit for correction: the problem I'm having may be slightly different. Text is ending up in the wrong locations so that in the aptitude example (the only program I've seen so far with the behavior) the "New Packages" heading is drawn on line 3, the cursor is on line 4, and when I navigate the headings are re-drawn one line down as they are highlighted and de-highlighted. Looks like a cursor position surprise of some sort. Also this happens in and out of GNU Screen.

  17. bitcrazed commented on May 22, 2018

    @bitcrazed
    Contributor

    Thanks for the discussion.

    Closing this issue since:

    1. We're working on a feature that will remedy this issue for Maksim Moisiuk (@Maximus5) & others
    2. This is the WSL issues repo, but this is an issue in Console which has its own Console GitHub Repo
    3. GitHub doesn't allow issues to be moved between repos, preserving posters' identity :(

    If you have further asks/issues, please file new issues on our Console GitHub Repo.

  18. samvv commented on Jan 17, 2024

    @samvv

    Rich Turner (@bitcrazed) What feature were you referring to? I'm still not able to create true colors using WSL 2 and Ubuntu 22.04.

  19. zadjii-msft commented on Jan 17, 2024

    @zadjii-msft
    Member

    Sam Vervaeck (@samvv) How have you tried so far? RGB color support has shipped in the console for like, 5 years now. curl https://raw.githubusercontent.com/csdvrx/sixel-testsuite/master/ansi-vte52.sh | bash will get you something like:

    image

    If you're still having troubles, I'd recommend opening a new issue over on the Terminal repo.

  20. samvv commented on Jan 17, 2024

    @samvv

    Thanks for the link. I'll be sure to check it tomorrow and open a new issue if it still is relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions