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

Flickering screen #189

Open
alberti42 opened this issue Jan 6, 2025 · 6 comments
Open

Flickering screen #189

alberti42 opened this issue Jan 6, 2025 · 6 comments

Comments

@alberti42
Copy link

Wonderful utility! Thanks a lot!

I have a question whether it is normal that the screen flickers a lot when I use arrows up and down to move throught the choices. It appears that it is redrawing the entire content on the fly, and it flickers.

Is it just me? Am I missing some options to make flickering disappear?

@casr
Copy link
Contributor

casr commented Jan 10, 2025

I notice this as well. It seems to be more pronounced when using arrow keys over using C-p/C-n (I tend to use the latter so didn't really notice it until you brought it up).

I tried this on Alacritty and Terminal.app on MacOS

@alberti42
Copy link
Author

Thank you for the suggestion! I checked it again, and I must say that the problem is gone. It was a strong flickering. Unfortunately, I am unable to reproduce it, but I suspect I had a wrong configuration for my key bindings in zsh.

If someone else experiences similar problems, I am now running with

autoload -U up-line-or-beginning-search
zle -N up-line-or-beginning-search
bindkey "^[[A" up-line-or-beginning-search  # Up arrow
bindkey "^[OA" up-line-or-beginning-search  # Up arrow
autoload -U down-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "^[[B" down-line-or-beginning-search  # Down arrow
bindkey "^[OB" down-line-or-beginning-search  # Down arrow

bindkey "^p"       up-line-or-beginning-search
bindkey "^n"       down-line-or-beginning-search

and the problems are gone. @casr: Can you try to configure both CTRL-p and CTRL-n the same way as your arrow keys (see my configuration above)? This should make the behavior equal and possibly solve all flickering.

PS: Thanks so much again for pointing out the right direction for me.

@alberti42
Copy link
Author

I checked more and I could reproduce what the problem was. I had meanwhile forgotten. Indeed, in normal applications from the terminal, I do not see any flickering.

I was testing fzy as an alternative to fzf for my new plugin https://github.com/alberti42/tmux-fzf-links. I wanted to support both fuzzy search utilities.

However, I realized that inside a tmux popup, it flickers a lot. See animated gif.

Flickering_fzy.mp4

When I replace fzy with fzf in my application, there is no flickering.

@alberti42
Copy link
Author

Uff.. as you can see from the video, the flickering is pretty bad. However, when I try:

tmux popup -E 'echo "Choice 1\nChoice 2\nChoice 3\nChoice 4" | fzy'

there is no flickering whatsoever. So it must be something in my app, which however, does not appear with fzf.

@casr
Copy link
Contributor

casr commented Jan 11, 2025

I've found that it is when fzy needs to handle more of the screen update that it flickers the most. That is then further compounded when it's pushed through other systems like tmux. Lastly, I'm guessing that because the arrow keys have an escape sequence to process (on my system that is ^[[A, ^[[B for up and down respectively) that adds to how the terminal processes it when compared to C-p/C-n.

When my terminal size is 108 columns by 50 lines and I use fzy -l 45 to fill more of the screen space and using exclusively arrow keys, I get:

terminal.app (no tmux) = slight flicker
terminal.app (tmux) = noticeable flicker
alacritty (no tmux) = very slight flicker
alacritty (tmux) = noticeable flicker

Here's the recording, if helpful:

Terminal.app:

Screen.Recording.2025-01-11.at.11.57.02.mov

Alacritty:

Screen.Recording.2025-01-11.at.12.02.36.mov
The video script
# show we're not in a tmux session
env | grep -i tmux

clear; find /System/Library -type f 2>/dev/null | head -1000 | fzy

clear; find /System/Library -type f 2>/dev/null | head -1000 | fzy -l 45

# show no previous tmux session is running (i.e. tmux is using another terminal's terminfo settings)
tmux attach

# start a new session
tmux new-session -Ac ~ -s scratch

# show that we're now in a tmux session
env | grep -i tmux

clear; find /System/Library -type f 2>/dev/null | head -1000 | fzy

clear; find /System/Library -type f 2>/dev/null | head -1000 | fzy -l 45

@alberti42
Copy link
Author

Thank you for the very systematic comparison! It perfectly matches my experience.

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

No branches or pull requests

2 participants