How do I programmatically change the position of the cursor in a Mac terminal program?
How do I programmatically change the position of the cursor in a Mac terminal program? I'm teaching a couple of kids to program and we're l开发者_如何学Goearning by writing a little terminal game. I've done this with C# on Windows with SetCursorPosition(x, y) so I'm hoping for something like that.
Normally you'll be using a library like ncurses that provides an abstraction to control the terminal. However, if you want to emit the raw ANSI escape code to do this directly, you'll want the CUP code, which looks like \e[n;mH
where n and m are the row and column numbers (1-based, origin is top-left corner) and \e is the ESC control code (0x1b).
精彩评论