A Rust curses library, supports Unix platforms and Windows

Overview

pancurses Build Status Build status Crates.io

pancurses is a curses library for Rust that supports both Linux and Windows by abstracting away the backend that it uses (ncurses-rs and pdcurses-sys respectively).

The aim is to provide a more Rustic interface over the usual curses functions for ease of use while remaining close enough to curses to make porting easy.

Documentation

Requirements

Linux

ncurses-rs links with the native ncurses library so that needs to be installed so that the linker can find it.

Check ncurses-rs for more details.

Windows

pdcurses-sys compiles the native PDCurses library as part of the build process, so you need to have a compatible C compiler available that matches the ABI of the version of Rust you're using (so either gcc for the GNU ABI or cl for MSVC)

Check pdcurses-sys for more details.

Usage

Cargo.toml

[dependencies]
pancurses = "0.16"

main.rs

extern crate pancurses;

use pancurses::{initscr, endwin};

fn main() {
  let window = initscr();
  window.printw("Hello Rust");
  window.refresh();
  window.getch();
  endwin();
}

Pattern matching with getch()

extern crate pancurses;

use pancurses::{initscr, endwin, Input, noecho};

fn main() {
  let window = initscr();
  window.printw("Type things, press delete to quit\n");
  window.refresh();
  window.keypad(true);
  noecho();
  loop {
      match window.getch() {
          Some(Input::Character(c)) => { window.addch(c); },
          Some(Input::KeyDC) => break,
          Some(input) => { window.addstr(&format!("{:?}", input)); },
          None => ()
      }
  }
  endwin();
}

Handling mouse input

To receive mouse events you need to both enable keypad mode and set a mouse mask that corresponds to the events you are interested in. Mouse events are received in the same way as keyboard events, ie. by calling getch().

extern crate pancurses;

use pancurses::{ALL_MOUSE_EVENTS, endwin, getmouse, initscr, mousemask, Input};

fn main() {
    let window = initscr();

    window.keypad(true); // Set keypad mode
    mousemask(ALL_MOUSE_EVENTS, std::ptr::null_mut()); // Listen to all mouse events

    window.printw("Click in the terminal, press q to exit\n");
    window.refresh();

    loop {
        match window.getch() {
            Some(Input::KeyMouse) => {
                if let Ok(mouse_event) = getmouse() {
                    window.mvprintw(1, 0,
                                    &format!("Mouse at {},{}", mouse_event.x, mouse_event.y),
                    );
                };
            }
            Some(Input::Character(x)) if x == 'q' => break,
            _ => (),
        }
    }
    endwin();
}

You can also receive events for the mouse simply moving (as long as the terminal you're running on supports it) by also specifying the REPORT_MOUSE_POSITION flag:

mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, std::ptr::null_mut());

Terminal resizing

Whenever the terminal is resized by the user a Input::KeyResize event is raised. You should handle this by calling resize_term(0, 0) to have curses adjust it's internal structures to match the new size.

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.

By default the win32a flavor is used, but you can specify which one you want to use by using Cargo flags. Simply specify the feature in Cargo.toml like so:

[dependencies.pancurses]
version = "0.16"
features = ["win32a"]

or

[dependencies.pancurses]
version = "0.16"
features = ["win32"]

(Font, Paste) menu

PDCurses win32a has a menu that allows you to change the font and paste text into the window. pancurses disables the window by default, though the user can still right-click the title bar to access it. If you want to retain the PDCurses default behaviour of having the menu there set the feature "show_menu".

Resizing

On win32a the default is to allow the user to freely resize the window. If you wish to disable resizing set the feature "disable_resize"

License

Licensed under the MIT license, see LICENSE.md

Comments
  • Change str functions to take AsRef<str>

    Change str functions to take AsRef

    I'm formatting some of my output with format!(), which produces String instead of str.

    I'd like to suggest changing, e.g., Window.addstr(&self, string:&str) to be generic, something like Window.addstr<T: AsRef<str>>(&self, string:T) instead. This would allow passing either str or String parameters.

    opened by aghast 9
  • Using the

    Using the "paste" button in Windows/PDCurses dumps debug info

    Using PDCurses on windows, the Font button works without issue, but the Paste button prints out a bunch of debug seeming info in addition to pasting.

    Clipboard: );

    Output:

    D:\dev\curse-test>cargo run
       Compiling curse-test v0.1.0 (file:///D:/dev/curse-test)
        Finished dev [unoptimized + debuginfo] target(s) in 0.43 secs
         Running `target\debug\curse-test.exe`
    ilen = 2
    29 3b Some(Character(')'))
    Some(Character(';'))
    

    program:

    extern crate pancurses;
    
    use pancurses::{initscr, endwin};
    
    fn main() {
        let window = initscr();
        window.printw("Hello Rust");
        window.refresh();
        let out = window.getch();
        let out2 = window.getch();
        endwin();
        println!("{:?}", out);
        println!("{:?}", out2);
    }
    
    opened by Lokathor 7
  • Inconsistency between linux and windows on getch

    Inconsistency between linux and windows on getch

    I stumpled upon this during https://github.com/gyscos/Cursive/issues/210

    Getch bahaves different under windows (10) and linux. A uniform solution would be nice. To reproduce this, just use the getch example under windows and under linux.

    opened by hellow554 6
  • Implement Drop for Window

    Implement Drop for Window

    This change will automatically free up window resources when a Window is dropped and makes calling delwin optional. Calling delwin and then dropping does not seem to cause issues.

    opened by Roughsketch 6
  • Use `slice::iter` instead of `into_iter` to avoid future breakage

    Use `slice::iter` instead of `into_iter` to avoid future breakage

    an_array.into_iter() currently just works because of the autoref feature, which then calls <[T] as IntoIterator>::into_iter. But in the future, arrays will implement IntoIterator, too. In order to avoid problems in the future, the call is replaced by iter() which is shorter and more explicit.

    See https://github.com/rust-lang/rust/pull/65819 for more information

    opened by Aaron1011 4
  • `pancurses::newterm()` takes pointer of possibly-dropped `CString`

    `pancurses::newterm()` takes pointer of possibly-dropped `CString`

    https://github.com/ihalila/pancurses/blob/master/src/lib.rs#L318

            curses::newterm(
                t.map(|x| CString::new(x).unwrap().as_ptr())
                    .unwrap_or(std::ptr::null()),
                output,
                input,
            )
    

    Here a CString is created, a pointer is taken from it, but the CString itself is destroyed when map returns; so the Option<*const char>, if not None, contains a pointer to freed memory.

    This is actually in a big warning from the std docs: https://doc.rust-lang.org/std/ffi/struct.CString.html#method.as_ptr

    opened by gyscos 4
  • [Feat request] expose a way to hide PDCurses menu

    [Feat request] expose a way to hide PDCurses menu

    I'd like to hide the menu with "Font" and "Paste" entries.

    Maybe by exposing https://github.com/Bill-Gray/PDCurses/blob/18404de78edbc62220899a60902d3f3b44759d86/win32a/pdcscrn.c#L1740

    opened by Geobert 4
  • non-blokcing getch ?

    non-blokcing getch ?

    hello. i just want to get a character in non blocking way.

    use pancurses::{
        initscr,
        endwin,
        Input,
        noecho,
    };
    
    use rand::{
        thread_rng,
        Rng,
    };
    
    fn main() {
        let window = initscr();
        window.printw("Type things, press delete to quit\n");
        window.refresh();
        window.keypad(true);
        noecho();
        loop {
            let rn = thread_rng().gen_range(1..1000);
            window.mv(1, 1);
            window.addstr(format!("{}-------------{}", rn, rn));
            window.mv(10, 1);
    
            // how can get here a char and let the loop continue ?
            match window.getch() {
                Some(Input::Character(c)) => {
                    window.addch(c);
                },
                Some(Input::KeyDC) => break,
                Some(input) => {
                    window.addstr(&format!("{:?}", input));
                },
                None => (),
            }
        }
        endwin();
    }
    
    opened by alexzanderr 3
  • Moving subwindow leaves behind the old windows

    Moving subwindow leaves behind the old windows

    Sorry if this is a very basic question, this is the first time I'm using ncurses.

    When I create a subwindow, and I move it, the window is still visible in its old location, it effectively looks like I have two windows.

    fn main() {
        let window = initscr();
        window.keypad(true);
        noecho();
        curs_set(0);
        window.draw_box(0,0);
        let subwin = window.derwin(10, 10, 5, 5).unwrap();)
        subwin.draw_box(0,0);
        subwin.printw("Hello");
        subwin.mvwin(15, 15);
        window.refresh();
        subwin.refresh();
        window.getch();
    }
    

    This causes the screen to look like this: tmp hjkbp4y1fa

    I was expecting the "hello" window to only show up once, is there something I'm missing?

    opened by WishCow 3
  • error: linking with `link.exe` failed: exit code: 1120 (x86_64-pc-windows-msvc)

    error: linking with `link.exe` failed: exit code: 1120 (x86_64-pc-windows-msvc)

    >rustup show
    Default host: x86_64-pc-windows-msvc
    
    nightly-x86_64-pc-windows-msvc (default)
    rustc 1.33.0-nightly (f960f377f 2018-12-24)
    
    [package]
    name = "pancurses-test"
    version = "0.1.0"
    authors = ["..."]
    edition = "2018"
    
    [dependencies]
    pancurses = "0.16.0"
    
    extern crate pancurses;
    
    fn main() {
        let _w = pancurses::initscr();
        _w.printw("...");
        _w.refresh();
        pancurses::endwin();
    }
    
    Compiling pancurses-test v0.1.0 (D:\Projects\pancurses-test)
    error: linking with `link.exe` failed: exit code: 1120
      |
      = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.1qv6ii4z90filoau.rcgu.o" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.2a4hvx18vi5ej8qc.rcgu.o" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.2lem7grdm3n81b39.rcgu.o" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.2zadbzqnynh04kto.rcgu.o" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.3wdyn4goph7yyq3d.rcgu.o" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.43e0i23r8pr7qqw5.rcgu.o" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.4kkyfogwlubwqdd1.rcgu.o" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.4rpl8pc34fnf6wc0.rcgu.o" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.tdwfpvmdmek4gx7.rcgu.o" "/OUT:D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.exe" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.39o8xahgquiyxytd.rcgu.o" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/LIBPATH:D:\\Projects\\pancurses-test\\target\\debug\\deps" "/LIBPATH:D:\\Projects\\pancurses-test\\target\\debug\\build\\pdcurses-sys-4218591296d1e390\\out" "/LIBPATH:C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\libpancurses-78565180174e2913.rlib" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\libwinreg-43bccb7da3b9b652.rlib" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\libwinapi-04976881e162ab74.rlib" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\libpdcurses-0430486901416dfe.rlib" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\liblibc-de4f7a93d737b6d0.rlib" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\liblog-e1c8c400c7095c58.rlib" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\libcfg_if-964a44305aaa5824.rlib" "C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-d3093c8b992a9ed3.rlib" "C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-cfbe5ec5b0fba3d4.rlib" "C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-2114b0b2fe263a95.rlib" "C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-89b39bd88e35564a.rlib" "C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-470fbdace3a6fe44.rlib" "C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-0c4677dba6613377.rlib" "C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-d18c6d3ade8ca66c.rlib" "C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-807f4cb6e3486a88.rlib" "C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-998a2807cd158421.rlib" "advapi32.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "comdlg32.lib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "msvcrt.lib"
      = note: Non-UTF-8 output: libpdcurses-0430486901416dfe.rlib(pdcscrn.o) : error LNK2019: __imp_ExtractIconW \xbf\xdc\xba\xce \xb1\xe2\xc8\xa3(\xc2\xfc\xc1\xb6 \xc0\xa7\xc4\xa1: get_app_icon \xc7\xd4\xbc\xf6)\xbf\xa1\xbc\xad \xc8\xae\xc0\xce\xc7\xcf\xc1\xf6 \xb8\xf8\xc7\xdf\xbd\xc0\xb4\xcf\xb4\xd9.\r\nD:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.exe : fatal error LNK1120: 1\xb0\xb3\xc0\xc7 \xc8\xae\xc0\xce\xc7\xd2 \xbc\xf6 \xbe\xf8\xb4\xc2 \xbf\xdc\xba\xce \xc2\xfc\xc1\xb6\xc0\xd4\xb4\xcf\xb4\xd9.\r\n
    
    error: aborting due to previous error
    
    error: Could not compile `pancurses-test`.
    
    To learn more, run the command again with --verbose.
    
    Process finished with exit code 101
    
    >cargo build -v
           Fresh cc v1.0.28
           Fresh cfg-if v0.1.6
           Fresh log v0.4.6
           Fresh winapi v0.3.6
           Fresh libc v0.2.45
           Fresh winreg v0.5.1
           Fresh pdcurses-sys v0.7.0
           Fresh pancurses v0.16.0
       Compiling pancurses-test v0.1.0 (D:\Projects\pancurses-test)
         Running `rustc --edition=2018 --crate-name pancurses_test src\main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=7e592f7f7c1c1ae2 -C extra-filename=-7e592f7f7c1c1ae2 --out-dir D:\Projects\pa
    ncurses-test\target\debug\deps -C incremental=D:\Projects\pancurses-test\target\debug\incremental -L dependency=D:\Projects\pancurses-test\target\debug\deps --extern pancurses=D:\Projects\pancurses-test\target\debug\deps\libpancurse
    s-78565180174e2913.rlib -L native=D:\Projects\pancurses-test\target\debug\build\pdcurses-sys-4218591296d1e390\out`
    error: linking with `link.exe` failed: exit code: 1120
      |
      = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windo
    ws-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.1qv6ii4z90filoau.rcgu.o" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e59
    2f7f7c1c1ae2.2a4hvx18vi5ej8qc.rcgu.o" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.2lem7grdm3n81b39.rcgu.o" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.2
    zadbzqnynh04kto.rcgu.o" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.3wdyn4goph7yyq3d.rcgu.o" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.43e0i23r8pr7qqw
    5.rcgu.o" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.4kkyfogwlubwqdd1.rcgu.o" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.4rpl8pc34fnf6wc0.rcgu.o" "D:\
    \Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.tdwfpvmdmek4gx7.rcgu.o" "/OUT:D:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.exe" "D:\\Projects\\pancurses-test\\tar
    get\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.39o8xahgquiyxytd.rcgu.o" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\U
    sers\\alpha\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/LIBPATH:D:\\P
    rojects\\pancurses-test\\target\\debug\\deps" "/LIBPATH:D:\\Projects\\pancurses-test\\target\\debug\\build\\pdcurses-sys-4218591296d1e390\\out" "/LIBPATH:C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\ru
    stlib\\x86_64-pc-windows-msvc\\lib" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\libpancurses-78565180174e2913.rlib" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\libwinreg-43bccb7da3b9b652.rlib" "D:\\Projects\\pancurse
    s-test\\target\\debug\\deps\\libwinapi-04976881e162ab74.rlib" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\libpdcurses-0430486901416dfe.rlib" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\liblibc-de4f7a93d737b6d0.rlib"
    "D:\\Projects\\pancurses-test\\target\\debug\\deps\\liblog-e1c8c400c7095c58.rlib" "D:\\Projects\\pancurses-test\\target\\debug\\deps\\libcfg_if-964a44305aaa5824.rlib" "C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows
    -msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-d3093c8b992a9ed3.rlib" "C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-cfbe5ec5b0fba3d4.rlib
    " "C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-2114b0b2fe263a95.rlib" "C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustl
    ib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-89b39bd88e35564a.rlib" "C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-470fbdace3a6fe44.rlib" "C:\\Users\\
    alpha\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-0c4677dba6613377.rlib" "C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-w
    indows-msvc\\lib\\librustc_std_workspace_core-d18c6d3ade8ca66c.rlib" "C:\\Users\\...\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-807f4cb6e3486a88.rlib" "C:\\Users\\...
    \\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-998a2807cd158421.rlib" "advapi32.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "comdlg32.lib" "advapi32.lib" "ws2_
    32.lib" "userenv.lib" "msvcrt.lib"
      = note: Non-UTF-8 output: libpdcurses-0430486901416dfe.rlib(pdcscrn.o) : error LNK2019: __imp_ExtractIconW \xbf\xdc\xba\xce \xb1\xe2\xc8\xa3(\xc2\xfc\xc1\xb6 \xc0\xa7\xc4\xa1: get_app_icon \xc7\xd4\xbc\xf6)\xbf\xa1\xbc\xad \xc8\xa
    e\xc0\xce\xc7\xcf\xc1\xf6 \xb8\xf8\xc7\xdf\xbd\xc0\xb4\xcf\xb4\xd9.\r\nD:\\Projects\\pancurses-test\\target\\debug\\deps\\pancurses_test-7e592f7f7c1c1ae2.exe : fatal error LNK1120: 1\xb0\xb3\xc0\xc7 \xc8\xae\xc0\xce\xc7\xd2 \xbc\xf6
     \xbe\xf8\xb4\xc2 \xbf\xdc\xba\xce \xc2\xfc\xc1\xb6\xc0\xd4\xb4\xcf\xb4\xd9.\r\n
    
    error: aborting due to previous error
    
    error: Could not compile `pancurses-test`.
    
    Caused by:
      process didn't exit successfully: `rustc --edition=2018 --crate-name pancurses_test src\main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=7e592f7f7c1c1ae2 -C extra-filename=-7e592f7f7c1c1ae2 -
    -out-dir D:\Projects\pancurses-test\target\debug\deps -C incremental=D:\Projects\pancurses-test\target\debug\incremental -L dependency=D:\Projects\pancurses-test\target\debug\deps --extern pancurses=D:\Projects\pancurses-test\target
    \debug\deps\libpancurses-78565180174e2913.rlib -L native=D:\Projects\pancurses-test\target\debug\build\pdcurses-sys-4218591296d1e390\out` (exit code: 1)
    
    opened by jdeokkim 3
  • Compile error on windows with feature

    Compile error on windows with feature "win32" enabled

    This line fails to compile (warn! macro is missing) https://github.com/ihalila/pancurses/blob/65621d5731927dd7090e1055c7d358dfc7354875/src/windows/mod.rs#L167 duo to incorrect cfg condition https://github.com/ihalila/pancurses/blob/65621d5731927dd7090e1055c7d358dfc7354875/src/lib.rs#L4

    opened by DaTa- 3
  • Input enum for control/shift?

    Input enum for control/shift?

    I've tried looking for how to get input for non-character keys such as control and alt, does anyone know how this can be achieved? I've tried testing with some sample code which prints out getch input but I have yet to find out how I can get an input for control

    opened by Wrenderbender 0
  • Example Code throws Error

    Example Code throws Error

    The Example for Mouse Input throws

    error[E0308]: mismatched types --> src/main.rs:9:33 expected enum Option, found *-ptr

    note: expected enum Option<&mut u32> found raw pointer *mut _

    on version 17.0. Sadly I couldn't find a fix myself.

    opened by file-acomplaint 0
  • Added docstring warning for multi-byte characters

    Added docstring warning for multi-byte characters

    I wasn't aware of the issues with multi-byte characters until I found this issue, so it's probably worth adding a warning to the documentation.

    I looked into possible fixes, but unfortunately it seems like a message in the docs is the best fix I can think of. Otherwise it becomes a mess of type conversions or ends up with unnecessary methods that are just clones of addstr.

    opened by eshimoniak 0
  • panic of unwrap() on CString creation

    panic of unwrap() on CString creation

    Hi

    I did some fuzzing of display of untrusted strings in cursive that uses this library and found this crash:

    thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: NulError(0, [0])', /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/pancurses-0.16.1/src/window.rs:392:47
    

    It seems to be because the library uses this construct CString::new(string.as_ref()).unwrap(); which fails on some strings, for example a string created like this:

    let null : Vec<u8> = vec![0];
    let null_str = str::from_utf8(&null).unwrap();
    

    As far as I can find there is 8 different cases of this pattern.

    opened by alexanderkjall 0
  • Window::border() and unicode

    Window::border() and unicode

    So basically I want to create a window border with the character. I've read in old issues here that addch() doesn't work because it calls a non-wide char using function in the backend so I guess it's the same for border(). Does that mean I have to print the border tediously using addstr() or is there a better way?

    And to make it more of an issue and less of a support question, I'm not sure if ncurses and pdcurses have wide char border functions but since Rust is so unicode-oriented I guess pancurses should call wide functions whenever possible

    opened by GOKOP 3
Releases(v0.17.0)
  • v0.17.0(Sep 29, 2021)

    • Updated ncurses-rs to 5.101.0 (#60, #83)
    • Cleanup Window::drop() (#61)
    • Expose Window::resize() (#65)
    • Fix Unix A_CHARTEXT constant (#67)
    • Rust 2018 edition compatibility (#69)
    • Use slice::iter instead of into_iter to avoid future breakage (#70)
    • Use setlocale from libc rather than ncurses-rs (#78)
    • Fix warnings and lints (#81)
    • Make compatible with ncurses-rs NetBSD fixes (#82)
    Source code(tar.gz)
    Source code(zip)
  • v0.16.1(Dec 26, 2018)

    • Fixed an issue on windows, using the wrong min function (#49)
    • Rename bgkdset() -> bkgdset() to be consistent with bkgd() (#52)
    • Remove try! so example compiles with 2018 edition (#55)
    • Fix Window::mouse_trafo's implementation (#56)
    • Make Window::mouse_trafo take an immutable &self (#59)
    Source code(tar.gz)
    Source code(zip)
  • v0.16.0(Jun 9, 2018)

    • Make the various window string methods generic on AsRef (#39)
    • Fixed registry permissions (#45)
    • Fixed missing log crate when using the win32 feature (#46)
    Source code(tar.gz)
    Source code(zip)
  • v0.15.0(Feb 25, 2018)

    • Improved input handling, pancurses supports UTF-16 input on Windows and UTF-8 on Linux.
    • Numpad keys are now converted consistently between platforms.
    • Added raw() and noraw().
    Source code(tar.gz)
    Source code(zip)
  • v0.14.0(Jan 20, 2018)

  • v0.13.0(Nov 18, 2017)

    • Mouse event constants are now exported allowing easier handling of mouse events
    • Added mouseinterval(), enclose() and mouse_trafo() (#18)
    • Use pdcurses-sys 0.7 adding support for the win32 flavor of PDCurses
    • Enable resizing win32a windows by default (#20)
    • Disable the Font menu on win32 by default (#17)
    Source code(tar.gz)
    Source code(zip)
  • v0.12.0(Nov 4, 2017)

    • Implement Drop for Window (#19)
    • Added is_linetouched(), is_touched(), touch(), touchline(), touchln(), untouch(), dupwin(), mvderwin() and mvwin()
    • Fix typo in pancurses::set_blink documentation (#21)
    • pdcurses-sys 0.6
    Source code(tar.gz)
    Source code(zip)
  • v0.11.0(Sep 18, 2017)

  • 0.10.0(Sep 17, 2017)

  • 0.9.0(Jul 24, 2017)

    Issue #11 : COLORS() and COLOR_PAIRS() now available Issue #12 : newterm(), set_term() and delscreen() implemented Issue #14 : echo() implemented

    Source code(tar.gz)
    Source code(zip)
  • 0.8.0(Mar 5, 2017)

    • Added doupdate(), noutrefresh(), delay_output()
    • There is now an Attribute enum and a ColorPair struct that should make working with attributes and color pairs easier. This is the first step towards deprecating the 'chtype' based API in favour of a more strongly typed one. Attributes and ColorPairs support the | and ^ operators, at least for now, so that they work as a drop-in replacement for chtypes.
    Source code(tar.gz)
    Source code(zip)
  • 0.7.0(Oct 22, 2016)

    • attrget(), baudrate(), beep(), bgkdset(), can_change_color(), chgat(), clrtobot(), clrtoeol(), color_content(), color_set(), copywin(), def_prog_mode(), def_shell_mode(), delwin(), flash(), getbkgd(), init_color, mvchgat(), overlay(), overwrite(), reset_prog_mode(), reset_shell_mode()
    • Input derives Eq and Hash
    Source code(tar.gz)
    Source code(zip)
  • 0.6.0(Oct 12, 2016)

  • 0.5.0(Oct 11, 2016)

  • 0.4.1(Oct 11, 2016)

  • 0.4.0(Oct 10, 2016)

    Mouse handling, addnstr, attroff, mvaddnstr, mvprintw, clearok, scrollok, setscrreg, set_title (PDCurses only), set_blink (PDCurses only).

    The 'newtest' PDCurses example is ported, though lacking some PDCurses-specific bits.

    Source code(tar.gz)
    Source code(zip)
  • 0.3.0(Mar 31, 2016)

  • 0.2.0(Mar 25, 2016)

    A much improved getch(), it now returns an Option instead of just an integer. The Input enum makes it easy to pattern match the return value to determine if it was a character or a special key. Support for the rain example.

    Source code(tar.gz)
    Source code(zip)
Owner
Ilkka Halila
Ilkka Halila
Use Git installed in Bash on Windows/Windows Subsystem for Linux (WSL) from Windows and Visual Studio Code (VSCode)

WSLGit This project provides a small executable that forwards all arguments to git running inside Bash on Windows/Windows Subsystem for Linux (WSL). T

A. R. S. 1.1k Jan 3, 2023
A small unix and windows lib to search for executables in PATH folders.

A small unix and windows lib to search for executables in path folders.

Robiot 2 Dec 25, 2021
Universal Windows library for discovering common render engines functions. Supports DirectX9 (D3D9), DirectX10 (D3D10), DirectX11 (D3D11), DirectX12 (D3D12).

Shroud Universal library for discovering common render engines functions. Supports DirectX9 (D3D9), DirectX10 (D3D10), DirectX11 (D3D11), DirectX12 (D

Chase 6 Dec 10, 2022
Design token framework — adopt a unified design language across platforms, codebases, and teams

Palette Design tokens framework with atomic classes for React and Master CSS. Deliver a consistent visual identity across your apps with design tokens

Foretag 4 Aug 23, 2022
Tool that mirrors questions and resolutions from other forecasting platforms to Manifold.

Tool that mirrors questions and resolutions from other forecasting platforms to Manifold. Managram commands People can interact with the bot by sendin

Joris Kerkhoff 3 Nov 7, 2023
A mono-repo for the Engineering Practice Domains of Development, Data, Infrastructure, Testing, and Platforms

Engineering Practice Domains Introduction Welcome to the Engineering Practice Domains at Fearless! This repository serves as a monorepo for our collab

Fearless 7 Apr 29, 2024
Windows-rs - Rust for Windows

Rust for Windows The windows crate lets you call any Windows API past, present, and future using code generated on the fly directly from the metadata

Microsoft 7.7k Dec 30, 2022
Library for Unix users and groups in Rust.

uzers-rs Adoption and continuation of the unmaintained ogham/rust-users crate. Big shout-out to its creator Benjamin Sago. This is a library for acces

null 8 Aug 25, 2023
Library for Unix users and groups in Rust.

uzers-rs Adoption and continuation of the unmaintained ogham/rust-users crate. Big shout-out to its creator Benjamin Sago. This is a library for acces

null 8 Sep 18, 2023
Switch windows of same app with alt + ` on windows pc.

Windows Switcher Switch windows of same app with alt + ` on windows pc. 250k single file executable downloaded from Github Release. No installation re

null 172 Dec 10, 2022
Check if the process is running inside Windows Subsystem for Linux (Bash on Windows)

is-wsl Check if the process is running inside Windows Subsystem for Linux (Bash on Windows) Inspired by sindresorhus/is-wsl and made for Rust lang. Ca

Sean Larkin 6 Jan 31, 2023
Windows Capture Simple Screen Capture for Windows 🔥

Windows Capture   Windows Capture is a highly efficient Rust library that enables you to effortlessly capture the screen using the Graphics Capture AP

null 3 Sep 24, 2023
The auto-managed -sys crate for Apple platforms using bindgen directly from build environment

apple-sys Apple platforms have a rather monotonous programming environment compared to other platforms. On several development machines, we will depen

Jeong, YunWon 34 Apr 17, 2023
.NET PhysX 5 binding to all platforms(win, osx, linux) for 3D engine, deep learning, dedicated server of gaming.

MagicPhysX .NET PhysX 5 binding to all platforms(win-x64, osx-x64, osx-arm64, linux-x64, linux-arm64) for 3D engine, deep learning, dedicated server o

Cysharp, Inc. 37 Jul 4, 2023
Utility library for some Lenovo IdeaPad laptops. Supports IdeaPad Intel and AMD Models (15IIL05 and 15ARE05)

ideapad A Rust utility library for some Lenovo IdeaPad specific functionality. A Fair Warning This crate calls raw ACPI methods, which on the best cas

ALinuxPerson 2 Aug 31, 2022
skyWM is an extensible tiling window manager written in Rust. skyWM has a clear and distinct focus adhering to the KISS and Unix philosophy.

Please note: skyWM is currently in heavy development and is not usable as of yet. Documentation and versions will change quickly. skyWM skyWM is an ex

MrBeeBenson 74 Dec 28, 2022
A Unix shell written and implemented in rust 🦀

vsh A Blazingly fast shell made in Rust ?? Installation Copy and paste the following command and choose the appropriate installtion method for you. Yo

XMantle 89 Dec 18, 2022
Just a UNIX's cat copy, but less bloated and in Rust.

RAT The opposite of UNIX's cat, less bloated, and in Rust. About the project The idea of this CLI is "A CLI program that is basically UNIX's cat comma

Renan Fernandes 2 Mar 5, 2022
Safe Unix shell-like parameter expansion/variable substitution via cross-platform CLI or Rust API

Safe Unix shell-like parameter expansion/variable substitution for those who need a more powerful alternative to envsubst but don't want to resort to

Isak Wertwein 4 Oct 4, 2022