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

Feature Request: change scrolling region #165

Open
wookayin opened this issue May 4, 2020 · 3 comments
Open

Feature Request: change scrolling region #165

wookayin opened this issue May 4, 2020 · 3 comments

Comments

@wookayin
Copy link

wookayin commented May 4, 2020

I wonder if it is possible to implement a fixed-height window with blessed. We could have some scrolling feature with this (like less), either programmatically or through keybindings, with other part of the terminal screen being intact (rather than a full-screen window).

One example of similar terminal UI can be found in fzf (e.g. fzf --height 30%):

image

I quickly searched the current Terminal API but didn't find any relevant methods.

@jquast jquast changed the title Feature Request: fixed-height scrollable window? Feature Request: change scrolling region May 4, 2020
@jquast
Copy link
Owner

jquast commented May 4, 2020

We can absolutely add this to blessed, it is a very basic capability. This is a vt100 sequence, "set scrolling region", it is \x1b[10;20r, where 10 is starting row, 20 is ending row.

http://www.termsys.demon.co.uk/vtansi.htm
https://vt100.net/docs/vt102-ug/chapter5.html
https://github.com/0x5c/VT100-Examples/blob/master/vt_seq.md#scrolling-margins

@wookayin
Copy link
Author

wookayin commented May 4, 2020

@jquast Thanks, I didn't know it was such a basic sequence. I tried the following example and it works for me. Look forward to blessed having this feature!

printf "\033[5;20r"        # needs to set proper value for top,bottom 
seq 1 100 | xargs -I{} bash -c 'echo {}; printf "\033[K"; sleep 0.01'
printf "\033[r"            # reset (it may clear the screen though)

@jquast
Copy link
Owner

jquast commented May 10, 2020

the change scrolling region attribute is already in blessed because it is a termcap capability.

It is just not documented.

from blessed import Terminal
term = Terminal()
term.csr(10, 20)
'\x1b[11;21r'

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

No branches or pull requests

2 participants