Linux - moving the console cursor visual

泄露秘密 提交于 2019-12-03 03:51:18

The answer was provided in the comment by Evilruff:

Cursor Movement

ANSI escape sequences allow you to move the cursor around the screen at will. This is more useful for full screen user interfaces generated by shell scripts, but can also be used in prompts. The movement escape sequences are as follows:

  • Position the Cursor: \033[;H Or \033[L;Cf puts the cursor at line L and column C.
  • Move the cursor up N lines: \033[NA
  • Move the cursor down N lines: \033[NB
  • Move the cursor forward N columns: \033[NC
  • Move the cursor backward N columns: \033[ND

  • Clear the screen, move to (0,0): \033[2J

  • Erase to end of line: \033[K

  • Save cursor position: \033[s

  • Restore cursor position: \033[u

Not using ncurses and co is a serious limitation.

It is hell to make correct input/output on shell for displaying anything.

The only others real solutions (I can't think as a solution to reimplement a ncurse-like library) I think of are:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!