NCurses initialization without clearing the screen

本小妞迷上赌 提交于 2019-12-01 16:48:05

Curses wants to fully control the screen, and to optimize writes to the screen, especially over slow serial lines. To do this, it needs to know what is on the screen, and the only reasonable way to do that with most terminals is to start from an empty screen and keep track of what you write to the terminal.

Thus, I suspect (n)curses is the wrong tool for your shell. You probably need to go down a step on the abstraction layer and use terminfo and non-blocking reads from the terminal (standard input) instead.

(This is not very helpful. Sorry.)

It might be simpler to use an interface like readline() rather than resorting to full-blown ncurses.

You could just call your program from whithin rlwrap and have the functionality without the pain...

schnaader

Here is another discussion about this. The provided solutions are:

  1. "The 'filter()' function lets you use curses as a single-line."
  2. "You can write something equivalent in C, using setupterm to get the terminal data, and tparm, tputs for formatting and output."

Of course there is the third option to get the ncurses source code and modify it so it doesn't clear the screen anymore.

Have you considered the simple expedient of creating a custom terminfo or termcap entry lacking a sequence to clear the screen and then switching your terminal setting to that right before running your program? You could also just use newterm() and set_term() in ncurses. This used to be easier with termcap, since you could include another terminal and override some of its capabilities.

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