0

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 learning 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.

4

1 回答 1

2

通常,您将使用像 ncurses 这样的库,它提供了控制终端的抽象。但是,如果您想直接发出原始的ANSI 转义码来执行此操作,您将需要 CUP 代码,它看起来像\e[n;mH其中 n 和 m 是行号和列号(从 1 开始,原点是左上角) \e 是 ESC 控制代码 (0x1b)。

于 2010-10-28T02:47:48.527 回答