microsoft / microsoft/terminal

ENABLE_WRAP_AT_EOL_OUTPUT is not working with VT100

Open
#349 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Area-Output Issue-Bug Product-Conhost
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

The cursor doesn't moves to the beginning of the next row when it reaches the end of the current row. It works as intended when VT100 is disabled.

Windows build number: Microsoft Windows [Version 10.0.17134.523]

Code:

#include <iostream>
#include <string>
#include <Windows.h>

using std::string;
using std::cout;
using std::endl;

int main()
{
    HANDLE stdOut = GetStdHandle(STD_OUTPUT_HANDLE);

    DWORD consoleMode =
        ENABLE_PROCESSED_OUTPUT |
        ENABLE_WRAP_AT_EOL_OUTPUT |
        ENABLE_VIRTUAL_TERMINAL_PROCESSING;

    SetConsoleMode(stdOut, consoleMode);

    CONSOLE_SCREEN_BUFFER_INFO screenBufferInfo;
    GetConsoleScreenBufferInfo(stdOut, &screenBufferInfo);

    SHORT length = screenBufferInfo.dwSize.X;
    string str(length - 1, '.');
    cout << str;

    int before = 0;
    int after = 0;

    GetConsoleScreenBufferInfo(stdOut, &screenBufferInfo);
    before = screenBufferInfo.dwCursorPosition.X;

    cout << 'x';

    GetConsoleScreenBufferInfo(stdOut, &screenBufferInfo);
    after = screenBufferInfo.dwCursorPosition.X;

    cout << endl
        << "before: " << before << endl
        << "after: " << after << endl;
}

Output:

before: 119
after: 119

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided C++ reproducer on Windows with ENABLE_WRAP_AT_EOL_OUTPUT and ENABLE_VIRTUAL_TERMINAL_PROCESSING enabled, then inspect the cursor positions reported before and after the final character. Done means the cursor advances to the beginning of the next row at the end of the buffer while VT100 processing remains enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.