microsoft / microsoft/terminal

Saving/restoring character attributes (and DECSCNM)?

Open
#8,913 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Microsoft Windows 10 Pro for Workstations
10.0.19042.746 (2009, 20H2)
WindowsTerminalPreview_1.5.3242.0_x64

I have a VBEEP command (visual beep, plugin for TCC.EXE from JPSoft). It saves the character attributes in the viewport like this.

dwSize = con.csbi.dwSize.X * con.csbi.dwSize.Y;	// terminal viewport
ReadConsoleOutputAttribute(con.h, attrs_original, dwSize, {0,0}, &dwRead); // get current attributes

Then it momentarily changes all attributes to the reverse of the default, like this.

attrs_reversed = ((con.csbi.wAttributes & 0x00F0) >> 4) | ((con.csbi.wAttributes & 0x000F) << 4);
FillConsoleOutputAttribute(con.h, attrs_reversed, dwSize, {0,0}, &dwWritten);

Then it restores the original attributes, like this.

WriteConsoleOutputAttribute(con.h, attrs_original, dwSize, {0,0}, &dwWritten); // back to original attributes

But, as I hope can be seen below, After executing VBEEP, the attributes of previously displayed text seem to have changed. Check out the display of the previous "echos ..." commands before/after the "vbeep" command; lines that were half yellow before the vbeep, are all yellow afterward.

https://user-images.githubusercontent.com/61856645/106033613-eef48180-609f-11eb-95d6-b508c3c01e62.mp4

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 with the VBEEP reproduction on Windows Terminal 1.5.3242.0 and compare the viewport before and after the ReadConsoleOutputAttribute, FillConsoleOutputAttribute, and WriteConsoleOutputAttribute sequence. Trace how these console attribute operations affect previously displayed text; done means the original attributes remain unchanged after VBEEP runs, with the behavior verified against the supplied video scenario.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.