Linux - moving the console cursor visual

后端 未结 2 1379
粉色の甜心
粉色の甜心 2020-12-15 00:26

I\'m currently designing a CLI interface for linux, and for various reasons I am not able to use ncurses. I am using exclusively C++ and the Qt framework.

相关标签:
2条回答
  • 2020-12-15 00:52

    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:

    • making call to dialog (for some example www.linuxjournal.com/article/2807 and for the doc: http://linux.die.net/man/1/dialog)
    • using the framebuffer mecanism with Qt4 (here)
    0 讨论(0)
  • 2020-12-15 00:53

    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
    0 讨论(0)
提交回复
热议问题