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

Visual bells do not work #72

Closed
bitcrazed opened this issue Feb 16, 2018 · 8 comments
Closed

Visual bells do not work #72

bitcrazed opened this issue Feb 16, 2018 · 8 comments
Labels
Area-Interaction Interacting with the vintage console window (as opposed to driving via API or hooks) Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Conhost For issues in the Console codebase Resolution-Fix-Available It's available in an Insiders build or a release

Comments

@bitcrazed
Copy link
Contributor

From @yoctozepto on November 16, 2017 11:6

As mentioned in #715 - visual bells do not work - the terminal does not blink.

How to reproduce?

Enable visual bells either in bash:
set bell-style visible
in
~/.inputrc
or vim:
set visualbell
in
~/.vimrc
and execute any action triggering a bell (e.g. walking past the buffer).

The terminal should blink but it does not.

Extra info

Sound bells do work (the beeping) when enabled (by default).

This functionality is useful for people disabling sounds and still hoping to get some feedback that they are doing something wrong. :-)

Copied from original issue: microsoft/WSL#2678

@bitcrazed bitcrazed added backlog Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. labels Feb 16, 2018
@zadjii-msft zadjii-msft added Product-Conhost For issues in the Console codebase and removed console labels May 21, 2018
@ghost
Copy link

ghost commented Feb 21, 2019

Has there been any movement on this in the past year?

@zadjii-msft
Copy link
Member

Nope.

@andreas-wilm
Copy link

+1

@zadjii-msft
Copy link
Member

@andreas-wilm Please don't comment "+1" on issues without providing valuable, additional information. It creates unnecessary email noise for everyone following the issue. There's a perfectly good +1 button you can use to express the same sentiment without pinging everyone on the thread.
image

@andreas-wilm
Copy link

Apologies. You're absolutely right of course. Last time I make noise here

@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label May 17, 2019
@miniksa miniksa added the Area-Interaction Interacting with the vintage console window (as opposed to driving via API or hooks) label May 29, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label May 29, 2019
@egmontkob
Copy link

My terminfo entry (on Ubuntu, for xterm-256color) contains this entry:

flash=\E[?5h$<100/>\E[?5l

where I guess that $<100/> stands for an intended pause of this many milliseconds.

strace'ing bash reveals that on visual bell it does a

write(2, "\33[?5h\33[?5l", 10)          = 10

that is, switches to global reverse mode and then immediately back to normal. I don't know if MS Terminal supports global reverse mode, but even if it does, if an app immediately reverts it then it makes perfect sense that the display is actually never reversed. So I'd argue there's a bug in bash to begin with, by omitting the delay. (I haven't checked vim.)

(And on a side note, I'd argue that this escape sequence is broken by design. A visual bell cannot reliably be shown over an ssh or such, since due to timing differences the length of the flash varies a lot, including easily not being shown at all. Instead, IMO, it would be a better approach if applications kept emitting \a for bell, and it was the terminal emulator that could decide to handle it differently than playing a sound, e.g. by reversing the contents for 0.1 seconds, or showing an animated ring icon etc.)

@j4james
Copy link
Collaborator

j4james commented Dec 3, 2019

For the record, I've just submitted PR #3817, which mostly fixes this issue. Executing tput flash now flashes the screen, and the visualbell in vim now works, but the bash visible bell-style does not. As @egmontkob explained above, the way the bash visible bell is implemented, there is not enough of a delay for the flash to be discernible.

Personally I'm in agreement with @egmontkob that that is a bug in bash, and not something we should be trying to fix. But I'll leave that call for the MS devs to make.

ghost pushed a commit that referenced this issue Jan 22, 2020
## Summary of the Pull Request

This adds support for the [`DECSCNM`](https://vt100.net/docs/vt510-rm/DECSCNM.html) private mode escape sequence, which toggles the display between normal and reverse screen modes. When reversed, the background and foreground colors are switched. Tested manually, with [Vttest](https://invisible-island.net/vttest/), and with some new unit tests.

## References

This also fixes issue #72 for the most part, although if you toggle the mode too fast, there is no discernible flash.

## PR Checklist
* [x] Closes #3773
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [x] Tests added/passed
* [ ] Requires documentation to be updated
* [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

## Detailed Description of the Pull Request / Additional comments

I've implemented this as a new flag in the `Settings` class, along with updates to the `LookupForegroundColor` and `LookupBackgroundColor` methods, to switch the returned foreground and background colors when that flag is set. 

It also required a new private API in the `ConGetSet` interface to toggle the setting. And that API is then called from the `AdaptDispatch` class when the screen mode escape sequence is received.

The last thing needed was to add a step to the `HardReset` method, to reset the mode back to normal, which is one of the `RIS` requirements.

Note that this does currently work in the Windows Terminal, but once #2661 is implemented that may no longer be the case. It might become necessary to let the mode change sequences pass through conpty, and handle the color reversing on the client side.
 
## Validation Steps Performed

I've added a state machine test to make sure the escape sequence is dispatched correctly, and a screen buffer test to confirm that the mode change does alter the interpretation of colors as expected.

I've also confirmed that the various "light background" tests in Vttest now display correctly, and that the `tput flash` command (in a bash shell) does actually cause the screen to flash.
@zadjii-msft
Copy link
Member

You know, the fundamental support for this was added in #3817, even to conhost, so I'm gonna close this one out as fixed.

@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label Oct 4, 2021
@zadjii-msft zadjii-msft added Resolution-Fix-Available It's available in an Insiders build or a release and removed Needs-Tag-Fix Doesn't match tag requirements labels Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Interaction Interacting with the vintage console window (as opposed to driving via API or hooks) Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Conhost For issues in the Console codebase Resolution-Fix-Available It's available in an Insiders build or a release
Projects
None yet
Development

No branches or pull requests

6 participants