Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ichizok
Copy link
Contributor

@ichizok ichizok commented Jun 23, 2017

repro steps

test-environments:

  • macOS 10.12.5, Terminal.app
  • Ubuntu 16.04, gnome-terminal
vim -Nu NONE -c 'set vb'

and input h, but expected visual-bell (flashing screen) doesn't happen.

details

Vim sends terminal-control-sequences at visualbell event when t_vb is ^[[?5h$<100/>^[[?5l:

expected: CSI ?5h (reverse video) → 100ms delay → CSI ?5l (normal video)
actual: 100ms delay → CSI ?5h (reverse video) → CSI ?5l (normal video)

cause

At visualbell event, tputs() in out_str(T_VB) is called,
and out_char_nf() writes characters of T_VB except $<100/> (terminfo string) to out_buf.

$<100/> is interpreted and executed before out_buf is flushed.

100ms delay by "$<100/>" in tputs()
out_flush() flushes out_buf (=="\e[?5h\e[?5l")

proposal of fix

T_VB has to be flushed, at least, before $<...>.

desirable sequence:

tputs("\e[?5h")
out_flush()
tputs("$<100/>\e[?5l")

This patch adds out_str_cf() to check $< in T_VB and to insert flushing.

Ozaki Kiichi

@codecov-io
Copy link

codecov-io commented Jun 23, 2017

Codecov Report

Merging #1789 into master will decrease coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1789      +/-   ##
==========================================
- Coverage   75.11%   75.11%   -0.01%     
==========================================
  Files          76       76              
  Lines      125109   125173      +64     
==========================================
+ Hits        93978    94026      +48     
- Misses      31131    31147      +16
Impacted Files Coverage Δ
src/misc1.c 82.56% <0%> (-0.12%) ⬇️
src/term.c 53.26% <0%> (-0.57%) ⬇️
src/if_xcmdsrv.c 85.37% <0%> (-0.56%) ⬇️
src/window.c 81.75% <0%> (-0.07%) ⬇️
src/gui_gtk_x11.c 47.39% <0%> (-0.06%) ⬇️
src/evalfunc.c 81.61% <0%> (-0.03%) ⬇️
src/os_unix.c 58.82% <0%> (+0.19%) ⬆️
src/if_py_both.h 76.01% <0%> (+0.7%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 41cc038...c403e95. Read the comment docs.

@ichizok
Copy link
Contributor Author

ichizok commented Jun 24, 2017

Sorry, I wrote an incorrect content of "cause". I have revised it.

@brammool
Copy link
Contributor

brammool commented Jun 24, 2017 via email

@ichizok
Copy link
Contributor Author

ichizok commented Jun 27, 2017

I updated patch.

  • Add do_visualbell() to adjust the interval of visualbell flashing

It appears this doesn't work for me. I actually liked the tiny flash,
making it flash for 200 msec would be a problem. Especially when it
repeats.

I agree, but I think it would be better not to include specific process for visual-bell into out_str_cf() and better to add new function to control.
I'd like to make out_str_cf() purely handle terminal-strings.

I set 200msec intervals of visualbell. I felt 1sec intervals are less responsiveness of flashing to input (e.g. at key-repeat).

@brammool
Copy link
Contributor

Thanks. I think we should apply the restriction of once per second also to the normal bell. I don't think anyone counts on lots of bells :-)

@brammool brammool closed this in 2e147ca Jun 27, 2017
@brammool
Copy link
Contributor

brammool commented Jun 27, 2017 via email

@ichizok ichizok deleted the fix/visualbell branch June 28, 2017 01:43
dpelle pushed a commit to dpelle/vim that referenced this pull request Jul 31, 2017
Problem:    When using a visual bell there is no delay, causing the flash to
            be very short, possibly unnoticeable.  Also, the flash and the
            beep can lockup the UI when repeated often.
Solution:   Do the delay in Vim or flush the output before the delay. Limit the
            bell to once per half a second. (Ozaki Kiichi, closes vim#1789)
janlazo added a commit to janlazo/neovim that referenced this pull request Jul 17, 2018
Problem:    When using a visual bell there is no delay, causing the flash to
            be very short, possibly unnoticeable.  Also, the flash and the
            beep can lockup the UI when repeated often.
Solution:   Do the delay in Vim or flush the output before the delay. Limit the
            bell to once per half a second. (Ozaki Kiichi, closes vim/vim#1789)
vim/vim@2e147ca
janlazo added a commit to janlazo/neovim that referenced this pull request Apr 13, 2019
Problem:    When using a visual bell there is no delay, causing the flash to
            be very short, possibly unnoticeable.  Also, the flash and the
            beep can lockup the UI when repeated often.
Solution:   Do the delay in Vim or flush the output before the delay. Limit the
            bell to once per half a second. (Ozaki Kiichi, closes vim/vim#1789)
vim/vim@2e147ca
janlazo added a commit to janlazo/neovim that referenced this pull request Apr 13, 2019
Problem:    When using a visual bell there is no delay, causing the flash to
            be very short, possibly unnoticeable.  Also, the flash and the
            beep can lockup the UI when repeated often.
Solution:   Do the delay in Vim or flush the output before the delay. Limit the
            bell to once per half a second. (Ozaki Kiichi, closes vim/vim#1789)
vim/vim@2e147ca
janlazo added a commit to janlazo/neovim that referenced this pull request Apr 13, 2019
Problem:    When using a visual bell there is no delay, causing the flash to
            be very short, possibly unnoticeable.  Also, the flash and the
            beep can lockup the UI when repeated often.
Solution:   Do the delay in Vim or flush the output before the delay. Limit the
            bell to once per half a second. (Ozaki Kiichi, closes vim/vim#1789)
vim/vim@2e147ca
janlazo added a commit to janlazo/neovim that referenced this pull request May 25, 2019
Problem:    When using a visual bell there is no delay, causing the flash to
            be very short, possibly unnoticeable.  Also, the flash and the
            beep can lockup the UI when repeated often.
Solution:   Do the delay in Vim or flush the output before the delay. Limit the
            bell to once per half a second. (Ozaki Kiichi, closes vim/vim#1789)
vim/vim@2e147ca
@fghsgh
Copy link

fghsgh commented Jul 24, 2019

I don't think anyone counts on lots of bells :-)

I do actually, and it took me quite some time to figure out that this was the cause of this (reason for this is below). I am currently using a recompiled version of Vim (with a part of misc1.c commented out) but I would appreciate an option to adjust the half a second delay to, say, 0.

OK, but I think we should also limit the normal bell. I know terminals that turn it into a visual bell and then one has to wait for the flashing to finish.

That is a good reasoning, but even in that case, some other terminals do audible bells. VX Connectbot (Android) even uses vibrate.

In any case, the 200 ms delay for the visual bell could also be configurable. If the first two people who write to this issue are already disagreeing on the length of time, other people will want it differently, too.

In case anyone is interested in the reason why I sometimes hold down a key to hear the bell repeating: the bell sound I use is kind of soothing and repeating it adds rhythm to that. It lets me relax in between the programming work :-). Plus, it's always good to know that no programs are currently slowing down the computer.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants