Skip to content

Implement stream writing mechanism on buffer (a.k.a. WriteCharsLegacy2ElectricBoogaloo) #780

Closed

Description

Apologies if this explanation is confusing. I've mentally internalized the problem here, but I'm not sure if I can fully articulate. Here goes...

When receiving characters in a stream fashion (in either conhost or the Terminal), there are a bunch of situations that occur that run off the golden path rails of "just put this into the buffer and move the cursor forward by one".

A few major categories of these are:

  1. C0 control characters (tab, backspace, newline, carriage return, etc.)
  2. Surrogate pairs for UTF-16 (two wchar_ts are required to form one U+ codepoint)
  3. An entire run of characters required to figure out a particular cell display or run of cells.

We need to solve 1 and 2 first. Solving 3 will probably require a bit more interaction with the CustomTextLayout in the DirectWrite renderer to perform some sort of read-ahead or multiple-pass calculation over text as it flows in stream-wise to figure out the columns it should take.

The existing manifests of this sort of work are WriteCharsLegacy in the console host (which is a thousand line or more monstrosity full of multi-pass switch cases, loops, and gotos) and the stream write thing in TerminalControl (I think, might be TerminalConnection) which Mike Griese (@zadjii-msft) affectionately warned against it becoming "WriteCharsLegacy2ElectricBoogaloo" in one of his comments.

I think what needs to be done here is:

  1. Create a third entry point to the buffer object that accepts text in a stream write fashion, potentially "buffering" before it inserts into the buffer for reals (or has the ability to look-behind at what was just written) taking over the duties of the "WriteCharsLegacy" type methods into the buffer itself so at least 1 and 2 can be handled in a unified-ish manner.
  2. Teach the buffer and/or let the buffer accept some sort of loose pfn that will connect it up to the text layout engine and let it query for column counts or glyph run information as stream characters show up and adjust the behavior of their neighboring glyphs.

Activity

  1. added
    Issue-FeatureComplex enough to require an in depth planning process and actual budgeted, scheduled work.
    Area-OutputRelated to output processing (inserting text into buffer, retrieving buffer text, etc.)
    on May 14, 2019
  2. added
    Issue-TaskIt's a feature request, but it doesn't really need a major design.
    and removed
    Issue-FeatureComplex enough to require an in depth planning process and actual budgeted, scheduled work.
    on Jun 20, 2019
  3. added a commit that references this issue on Sep 26, 2019
  4. ghost added a commit that references this issue on Oct 1, 2019
  5. added 2 commits that reference this issue on Oct 3, 2019
  6. added a commit that references this issue on Oct 15, 2019
  7. reli-msft commented on Nov 16, 2019

    @reli-msft

    Michael Niksa (@miniksa) Dustin L. Howett (@DHowett)
    It looks like that we can have a "Carriage" class that overall manipulates the cursor and backbuffer. It will take WCHARs one by one to decide what to do.

  8. 22 remaining items

  9. ghost added
    In-PRThis issue has a related PR
    on Jan 6, 2023
  10. ghost closed this as completedin #14640on Jan 18, 2023
  11. ghost closed this as completedin a1865b9on Jan 18, 2023
  12. ghost removed
    In-PRThis issue has a related PR
    on Jan 18, 2023
  13. ghost added
    Resolution-Fix-CommittedFix is checked in, but it might be 3-4 weeks until a release.
    on Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area-OutputRelated to output processing (inserting text into buffer, retrieving buffer text, etc.)Issue-TaskIt's a feature request, but it doesn't really need a major design.Priority-1A description (P1)Product-TerminalThe new Windows Terminal.Resolution-Fix-CommittedFix is checked in, but it might be 3-4 weeks until a release.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions