Ncurses - "move" 及其派生词删除屏幕内容
Ncurses - "move" and its deveratives delete screen contents
我是一名新手程序员,目前正在编写一个简单的 Ncurses 应用程序,但我遇到了这样的问题 - 调用 move
函数或 mvwadch
作为示例清理 window我要去的地方之后的内容。
代码如下:
#include <string>
#include <ncurses.h>
void function(WINDOW* win)
{
std::string somestring = "Test";
waddstr(win, somestring.c_str());
wmove(win , 0, 1);
wrefresh(win);
}
WINDOW* win_ = initscr();
int main()
{
function(win_);
wgetch(win_);
endwin();
}
它只留下 "T",例如,如果 somestring
是 "Test"。
P.S。抱歉,英语和 C++ 可能不好。
您的程序不会等待用户输入(例如,调用 getch
)并立即退出而不调用 endwin
。因为 ncurses 将终端初始化为原始模式,这使得终端处于原始模式,使换行符正常转换为carriage-return/line-feed您的 shell 不会立即工作(尽管大多数 shell 可以通过将模式重置回 cooked 来恢复此状态)。这会导致某些文本被覆盖,因为(而不是前进到 newline)shell 提示写在与短信。
我是一名新手程序员,目前正在编写一个简单的 Ncurses 应用程序,但我遇到了这样的问题 - 调用 move
函数或 mvwadch
作为示例清理 window我要去的地方之后的内容。
代码如下:
#include <string>
#include <ncurses.h>
void function(WINDOW* win)
{
std::string somestring = "Test";
waddstr(win, somestring.c_str());
wmove(win , 0, 1);
wrefresh(win);
}
WINDOW* win_ = initscr();
int main()
{
function(win_);
wgetch(win_);
endwin();
}
它只留下 "T",例如,如果 somestring
是 "Test"。
P.S。抱歉,英语和 C++ 可能不好。
您的程序不会等待用户输入(例如,调用 getch
)并立即退出而不调用 endwin
。因为 ncurses 将终端初始化为原始模式,这使得终端处于原始模式,使换行符正常转换为carriage-return/line-feed您的 shell 不会立即工作(尽管大多数 shell 可以通过将模式重置回 cooked 来恢复此状态)。这会导致某些文本被覆盖,因为(而不是前进到 newline)shell 提示写在与短信。