-
Trying to learn how this works and abandon |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Setting the cursor position is done with the The only cursor tracking currently supported is via the The reason that there isn't a more general If you're curious about how Given the drawbacks, complexity, and unknowns of implementing this, I've opted not to do it for now. I'm not necessarily opposed to doing it at some point, but I reasoned that most applications would probably be fine with
Do you mean screen position as in where the console window is on the monitor? If so, there's no way to get that information on Unix platforms, so the API doesn't currently expose it. It's certainly possible to expose this information regardless and just throw |
Beta Was this translation helpful? Give feedback.
-
Hi @alexrp thank you for the answer. I'm trying to design an interactive console app where you can use the arrow keys to select output and being able to at least know where the cursor is lets me understand what parts i need to clear and rewrite. I guess I can try and figure out some logic around it, but it still will be a bit tricky. What about when that command is sent, turning on a peek within the code that is watching the incoming stream looking for the appropriate codes. When the codes are found, get the result, turn off the peek. Each peek on the stream is passing back to the normal terminal output when it's not matching what is being looked for. You can also have a timeout that gives up on looking and either raises an event or just does nothing. When I was talking about the buffer, I was meaning where top line of the screen within the buffer area. Like the buffer is currently 1000 lines long and the screen top is looking at line 24 of the buffer and the screen is 25 lines tall, meaning the bottom of the screen is at line 49 or something along those lines. Thanks! |
Beta Was this translation helpful? Give feedback.
-
My recommendation would be to keep track of the cursor position as you write output, if that's possible in your case.
Similarly, I think you would have to keep track of this yourself as you write output. I don't know that there's any way to query this from the terminal.
Sure, there are many ways it could be done. It's just that all of them are fairly tricky and seem to involve user-visible trade-offs - e.g. in |
Beta Was this translation helpful? Give feedback.
Setting the cursor position is done with the
MoveCursor*
family of methods onTerminal
.The only cursor tracking currently supported is via the
SaveCursorPosition
/RestoreCursorPosition
methods onTerminal
, which use DECSC and DECSR.The reason that there isn't a more general
CursorPosition
property is that it's actually really complicated to do in VT100. You have to write a DECXCPR and then read a response. That sounds simple enough on the surface until you realize that there can be arbitrary data coming in on standard input between sending the query and getting the response. That data then has to be put into a buffer of…