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

Get x, y from the result of cursorGetPosition #22

Open
lebaphi opened this issue Aug 28, 2020 · 7 comments
Open

Get x, y from the result of cursorGetPosition #22

lebaphi opened this issue Aug 28, 2020 · 7 comments

Comments

@lebaphi
Copy link

lebaphi commented Aug 28, 2020

I get the result from cursorGetPosition is: ^[[12;1R. So how can to parse or convert this to x, y then I can use other API likes cursorMove?

@sindresorhus
Copy link
Owner

@devingfx
Copy link

And so?
Do you have a nodejs working exemple? Because knowing how to get the position using bash is a bit useless here...

I tried to listen process.stdin while outputing ansi.cursorGetPosition on process.stdout but without success... :/

@carljohnson93
Copy link

Yeah have the same question as @lebaphi. How do I use this with provided API? In my case I need to fully redraw what's on the terminal "screen" but without removing history, so I came up with idea to remember initial cursor position and set it before process.stdout.writeing all the logs

@Qix-
Copy link
Contributor

Qix- commented Mar 6, 2021

To be completely fair and honest, I've never personally gotten this escape code to work.

Supposedly, you're supposed to read from stdin after issuing this code. This, however, has never worked for me. I've not seen a program actually use this before and I've always kind of assumed it's a dead escape code lost to the sands of time, lol.

If you want my domain-expert opinion, don't use this escape code. Find a better way to do it.

@carljohnson93
Copy link

aight, thanks. Know some library for my needs? I mean "redrawing" what's in terminal without clearing history

@Qix-
Copy link
Contributor

Qix- commented Mar 6, 2021

@carljohnesan Check out blessed, though it's quite high level. Maybe that's what you're looking for.

@jamonholmgren
Copy link

This seemed to work for me decently well.

https://github.com/bubkoo/get-cursor-position/blob/master/index.js

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

6 participants