When using a program like htop
- mouse scroll wheel action will not do anything.
How can I reproduce such behavior in my Bash script?
I guess there should be a way to tell the terminal to ignore scrolling requests. How is that done?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityWhen using a program like htop
- mouse scroll wheel action will not do anything.
How can I reproduce such behavior in my Bash script?
I guess there should be a way to tell the terminal to ignore scrolling requests. How is that done?
htop
happens to use ncurses
ncurses (and other things that use the full screen in a terminal) initializes the terminal using the terminfo capability smcup
. For xterm (and terminal emulators that imitate it), that switches to the alternate screen. Those terminals may respond to a wheel mouse by sending up/down cursor keys instead of scrolling the terminal window (which you would see in htop
by the focus-line moving up/down). Your bash script may see those cursor keys, but not handle them.
You can experiment with the feature in a script using
tput smcup
to switch to the alternate screen, and
tput rmcup
to switch back to the normal screen.