rustpdcurses

Rust's pancurses library is opening a new terminal instead of running in the current terminal


I'm hoping to develop a cross-platform CUI using a curses library in Rust called "pancurses", but I'm encountering a strange problem in windows. For some reason, instead of running the CUI in the current terminal emulator (i.e. cmd), some new terminal emulator is opening and running the CUI, while the stdout is directed to the current terminal. This is different from what I've seen in the windows-curses library in python, for instance so I suspect this is some kind of configuration option in pancurses, pdcurses, or the rust compiler but I haven't been able to find any documentation that seems related. Any help is appreciated.

Edit to include minimum reproducible example (using pancurses 0.17):

extern crate pancurses;
use pancurses::{initscr, noecho};

fn main() {
    let window = initscr();
    window.refresh();
    window.keypad(true);
    noecho();

    window.getch();
}

This produces a terminal that looks like this: enter image description here


Solution

  • pancurses is built on top of ncurses-rs on Linux and pdcurses-sys on Windows.

    As mentioned in the README of pdcurses-sys and pancurses:

    PDCurses (Windows) details
    pdcurses-sys supports two flavors of PDCurses, win32a and win32. win32a is the GDI mode while win32 runs in the Windows console. win32a has better support for colors and text effects.

    To enable the win32 feature for pancurses, you can do so by configuring a feature in your Cargo.toml file with this command:

    $ cargo add pancurses --features win32
    

    or by adding this to your Cargo.toml:

    [dependencies]
    pancurses = { version = "0.17.0", features = ["win32"] }