Clearing only part of the console output

前端 未结 3 1385
生来不讨喜
生来不讨喜 2020-12-29 16:48

What I want to do:

The cursor is initially blinking on the top left corner of the screen:

160 characters remaining
_

3条回答
  •  孤独总比滥情好
    2020-12-29 17:17

    If you want to manage the complete screen, curses is the way to go. Otherwise, you can do a lot just using escape sequences; see http://en.wikipedia.org/wiki/ANSI_escape_code, for example. (Historically, such sequences varied from one terminal to the next, and curses was originally a way of working around this. Today, the ANSI escape codes are pretty universal for console windows under a windowing system, being used by both Windows console window and xterm.)

    In addition to encapsulating the actual sequences, curses supports character oriented input, with or without echo. This is more difficult to do without curses, and is still very unportable.

提交回复
热议问题