微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

启动时 Ncurses 屏幕空白

如何解决启动时 Ncurses 屏幕空白

每当我启动以下程序时,我都会看到一个空屏幕而不是字符串“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);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。