Open lebaphi opened 4 years ago
https://stackoverflow.com/questions/8343250/how-can-i-get-position-of-cursor-in-terminal
We should indeed document this better.
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... :/
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.write
ing all the logs
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.
aight, thanks. Know some library for my needs? I mean "redrawing" what's in terminal without clearing history
@carljohnesan Check out blessed
, though it's quite high level. Maybe that's what you're looking for.
This seemed to work for me decently well.
https://github.com/bubkoo/get-cursor-position/blob/master/index.js
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 likescursorMove
?