-
Notifications
You must be signed in to change notification settings - Fork 137
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
Reporting cursors current location #65
Comments
you can always use relative, term.down, term.up etc. For example, term.move_x(0). but yes, it is possible to query the terminal emulator to report its current position -- however this would require blessings to capture and parse "keyboard input", which it does not currently do. I'll consider such feature for my fork, and I've discussed the ability previously in issue #4 which this may be a duplicate of. In summary, for vt100-derived terminals, write '\x1b[6n' and expect return pattern r"[(\d+);(\d+)R" from stdin. For sun, '\x1b[18t' and r"[8;(\d+);(\d+)t". see: xresize.c from X11.org -- xresize works by moving the cursor to position 999,999, then query the current cursor position -- its return value is the bounds of the window (height, width). Problem is that it is slow, blocking, and could time out, and won't work for win32's cmd.exe. But it works. |
Work could proceed on this, just assume Blessed has cursor query by using https://github.com/thomasballinger/blessings/tree/cursor-query |
@thomasballinger and I hope to contribute this upstream once 'blessed-integration' is merged (we require polling for "keyboard input") |
get_location() is released in blessed, which is API-compatible with blessings, https://blessed.readthedocs.io/en/latest/location.html#finding-the-cursor |
Hello,
I love blessings. It's super convenient. Many many thanks. I just have a small suggestion.
It would be great if you could report the current cursor position so that one could create "position dependant" outputting.
I see this as being possible within the current paradigm if I could just access where my cursor was relative to the width and height. This stems from the fact that sometimes (height-1) isn't what I need. Sometimes (curpos + 1) is where I need to print (particularly if the user invokes my program without filling up a whole terminal screen yet.
Would this be possible? Pardon me if there is already a way of doing this.
Kind Regards,
Henry
EDIT: Looking at the source code, might this have something to do with accurate reporting of the Terminal.restore or Terminal.save variables?
The text was updated successfully, but these errors were encountered: