问题描述
每当我启动以下程序时,我都会看到一个空屏幕而不是字符串“hello”:
use ncurses as n;
fn main() {
render::setup_ncurses();
let win = n::newwin(30,30,0);
n::waddstr(win,"hello");
n::wrefresh(win);
// n::refresh(); <-- this doesn't work either
n::getch();
// n::wgetch(win); <-- doesn't work either
n::endwin();
}
具有设置功能:
pub fn setup_ncurses() {
// Allows for wide characters
n::setlocale(n::LcCategory::all,"");
n::initscr();
// Captures signal sequences and no buffer
n::raw();
// F keys and arrows
n::keypad(n::stdscr(),true);
// Doesn't echo typed keys
n::noecho();
}
我遗漏的窗户有什么奇怪的行为吗?使用 stdscr
时不会发生这种情况。
解决方法
变化:
let win = n::newwin(30,30,0);
用于:
let win = n::subwin(n::stdscr(),0);