我如何使用从诅咒残培不清除屏幕? [英] How do I use getch from curses without clearing the screen?
问题描述
我正在学习用C编程,并希望能够将字符输入到终端,而我的code,而不pressing运行<大骨节病>返回骨节病>。我的程序工作,但是当我打电话 initscr的()
,清屏 - 甚至要求在过滤器()
。 过滤器
的文件表明,它应该关闭清算 - 然而,这是不适合我的情况下
I'm learning to program in C and want to be able to type characters into the terminal while my code is running without pressing return. My program works, however when I call initscr()
, the screen is cleared - even after calling filter()
. The documentation for filter
suggests it should disable clearing - however this is not the case for me.
#include <stdio.h>
#include <curses.h>
#include <term.h>
int main(void) {
int ch;
filter();
initscr();
cbreak();
noecho();
keypad(stdscr, TRUE);
while((ch = getch()) != EOF);
endwin();
return 0;
}
为什么上面的code仍然clearr屏幕,并可以做些什么来解决?
Why does the above code still clearr the screen, and what could be done to fix it?
我使用Debian Lenny的(稳定)和gnome-终端是否有帮助。
I'm using Debian Lenny (stable) and gnome-terminal if that helps.
推荐答案
使用 newterm()
而不是 initscr的()
,你应该罚款即可。而且不要忘了 delscreen()
如果你遵循这个建议。
Use newterm()
instead of initscr()
, you should be fine then. And don't forget about delscreen()
if you follow this advice.
这篇关于我如何使用从诅咒残培不清除屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!