Coder Social home page Coder Social logo

pancurses's People

Contributors

aaron1011 avatar bobwhitelock avatar coder543 avatar czipperz avatar fierthraix avatar gyscos avatar hcnelson99 avatar ihalila avatar kraai avatar piepieonline avatar roughsketch avatar spearman avatar vainiovano avatar wfraser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pancurses's Issues

Release and activity

Hi there,

I've been working on a library that uses pancurses. Tough I had some complications with some features that it was still lacking. When I checked out the pull requests there were some valuable ones that can be very useful and fixed my problems if they were merged and released.

The activity of this library is very low. Is there any plan to do a new release and work trough the pull requests? If not I am afraid I have to work around this problem by forking this library and releasing it to get the features that I need.

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);
}

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.

Window: Send

Is it sound to make Window impl Send? Right now, I'm trying to make an ncurses-based UI that is a futures::Sink, but all useful tokio operations require Sink: Send.

Expose ncurses setlocale or call it on initialization

In order to properly support unicode output on linux, ncurses::setlocale has to be called at the beginning of the program (before initscr()).
This is not currently exposed by pancurses.
Possible solutions:

  • Expose a setlocale() method, similar to ncurses-rs

  • Run the following code in pancurses::initscr():

    let buf = CString::new("").unwrap().as_ptr();
    unsafe { curses::setlocale(0, buf) }; // The magic number 0 corresponds to LC_ALL
    • Always
    • Only when some feature is activated

mousemask API safety

The pancurses::mousemask accepts a mutable pointer as a second argument and proceeds to pass this to an unsafe FFI. Part of the point of a library around an FFI is to allow the Rust programmer to work without unsafe features, like pointers.

With this in mind, I was wondering if there was a reason that mousemask didn't just accept an Option<&mut mmask_t> for its second argument. This solves both requirements of the pointer API, in that you have to be able to pass a "nonexistent" option (null pointer) or a reference to a modifiable mmask_t. The advantage is that you no longer risk passing a non-null pointer that doesn't reference valid memory.

In fact, if I'm reading this correctly, the Option version of the interface could even be used in the extern function declaration, though that's outside the scope of this library.

`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

KeyBackspace is not mapped properly on Arch Linux

Hi, thanks for the library.

When I press backspace, the match arm for KeyBackspace is skipped over and instead a match is found for Character('\u{7f}').

I did some research and tried running in raw mode, but there was no change in behavior.

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?

Disable wrapping

Is there currently a way to disable wrapping lines in pancurses? Normal curses has it in the form of add_wchstr, but there doesn't seem to be any parallel in pancurses.

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)

Add `stdscr()`

  • ncurses provides the stdscr() -> WINDOW method
  • pdcurses-sys provides a pub static mut stdscr: *mut WINDOW;

Without this, it appears difficult to use pancurses::newterm(), since it doesn't return a Window.

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

`ctrl`+`space` causes panic on `unwrap`

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: NulError(6, [104, 101, 108, 108, 111, 10, 0])', libcore/result.rs:945:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:511
   5: std::panicking::continue_panic_fmt
             at libstd/panicking.rs:426
   6: rust_begin_unwind
             at libstd/panicking.rs:337
   7: core::panicking::panic_fmt
             at libcore/panicking.rs:92
   8: core::result::unwrap_failed
             at /checkout/src/libcore/macros.rs:26
   9: <core::result::Result<T, E>>::unwrap
             at /checkout/src/libcore/result.rs:782
  10: pancurses::window::Window::addstr
             at /home/alexander/.cargo/registry/src/github.com-1ecc6299db9ec823/pancurses-0.16.0/src/window.rs:33
  11: pancake::menu::load_menu::LoadMenu::render
             at src/menu/load_menu.rs:27
  12: pancake::menu::load_menu::LoadMenu::run
             at src/menu/load_menu.rs:13
  13: pancake::menu::Menu::run
             at src/menu/mod.rs:37
  14: pancake::run
             at src/main.rs:27
  15: pancake::main
             at src/main.rs:15
  16: std::rt::lang_start::{{closure}}
             at /checkout/src/libstd/rt.rs:74
  17: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  18: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  19: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:392
             at libstd/rt.rs:58
  20: std::rt::lang_start
             at /checkout/src/libstd/rt.rs:74
  21: main
  22: __libc_start_main
  23: _start

The code:

                Some(Character(c)) => { filename.push(c)      }
                Some(KeyUp)        => { return Some(filename) }
                _                  => { return None           }

It seems that ctrl+space is being interpreted as a character but push panics. Am I using matchers incorrectly here?

Some key combinations cause panic

Simple program to try input support:

extern crate pancurses;

fn main() {
    let pc = pancurses::initscr();
    pc.keypad(true);
    loop {
        if let Some(ev) = pc.getch() {
            println!("{:?}", ev);
        }
    }
}

Pressing Ctrl-Left (and some other combinations) results in a panic:

thread 'main' panicked at 'index out of bounds: the len is 108 but the index is 243', /home/gyscos/.cargo/registry/src/github.com-1ecc6299db9ec823/pancurses-0.4.0/src/unix/mod.rs:66
stack backtrace:
   1:     0x555e3f9df4ff - std::sys::backtrace::tracing::imp::write::h22f199c1dbb72ba2
   2:     0x555e3f9e1fad - std::panicking::default_hook::{{closure}}::h9a389c462b6a22dd
   3:     0x555e3f9e150a - std::panicking::default_hook::h852b4223c1c00c59
   4:     0x555e3f9e1a58 - std::panicking::rust_panic_with_hook::hcd9d05f53fa0dafc
   5:     0x555e3f9e18f2 - std::panicking::begin_panic::hf6c488cee66e7f17
   6:     0x555e3f9e1830 - std::panicking::begin_panic_fmt::hb0a7126ee57cdd27
   7:     0x555e3f9e17b1 - rust_begin_unwind
   8:     0x555e3fa16d9f - core::panicking::panic_fmt::h9af671b78898cdba
   9:     0x555e3fa16d43 - core::panicking::panic_bounds_check::h56f656aa4e352200
  10:     0x555e3f9d7840 - pancurses::unix::to_special_keycode::hb00b80a8963e12bc
                        at /home/gyscos/.cargo/registry/src/github.com-1ecc6299db9ec823/pancurses-0.4.0/src/unix/mod.rs:66
  11:     0x555e3f9d78e8 - pancurses::Window::getch::h179489f0c955b58f
                        at /home/gyscos/.cargo/registry/src/github.com-1ecc6299db9ec823/pancurses-0.4.0/src/lib.rs:178
  12:     0x555e3f9d6c2e - pan::main::hecb42b9052c3a41e
                        at /home/gyscos/test/pan/src/main.rs:7
  13:     0x555e3f9e9a76 - __rust_maybe_catch_panic
  14:     0x555e3f9e0d81 - std::rt::lang_start::h14cbded5fe3cd915
  15:     0x555e3f9d6d43 - main
  16:     0x7fcca047d290 - __libc_start_main
  17:     0x555e3f9d6a09 - _start
  18:                0x0 - <unknown>

Tested using pancurses 0.4.0 on linux.

win32a consistently crashes

Using the win32a feature set on pdcurses consistently crashes, possibly due to threading issues. Is there a fix for this coming shortly?

Flickering text on Windows

I'm not quite sure if this goes here or with pdcurses-sys, but if you clear the window then fill it with characters the characters within the first 49 cells of the first row will flicker slightly while the rest don't flicker at all.

Minimal example program to reproduce:

extern crate pancurses;

fn main () {
    let w = pancurses::initscr();
    pancurses::curs_set(0);
    pancurses::noecho();
    let (rows,cols) = w.get_max_yx();
    loop {
        let some_i = w.getch();
        w.clear();
        w.mv(0, 0);
        for _ in 0..rows {
            for _ in 0..cols {
                w.addch('#');
            }
        }
        w.refresh();
    }
}

If you just tap any key a few times you'll see it flicker between loops, but only with part of the first row.

Support `raw` and `noraw`.

I went to add support for raw/noraw to my wrapper lib and noticed that they're actually missing from pancurses.

Library does not support 'winsch'

The library does not currently support the winsch function. This allows you to insert a character into the window specified at the current position, pushing other characters to the right (and possibly pushing the final char off the screen entirely).

Ideally this would be implemented as an insch method on the Window type, along with the mvinsch variant as well.

Release current HEAD?

The current HEAD has a lot of new features (like Window::attroff()) which would be good to have.

Support resizable window on Windows

On Windows, the pdcurses window is created with a fixed height and width, and there appears to be no way for the user to resize the window or for the programmer to do so.

from the log over here:

screenshot-2017-10-24 pdcurses log

It would be nice if the PDC_set_resize_limits function were either called directly from the initscr() function, setting effectively unlimited resize limits so that terminals would have the same expectation of resizability on Windows that they do on Linux, or if it were exposed directly through pancurses somehow so a programmer could invoke it. I guess I could always invoke it through pdcurses-sys directly, of course.

Segfault can be triggered with printw

During some tests my program segfaulted and the backtrace was indicating a crash in the way pancurses uses libncursesw.

extern crate pancurses;

use pancurses::{initscr, endwin};

fn main() {
    let crash = "!~&@%+ S";

    let window = initscr();
    window.printw(crash);
    window.refresh();
    window.getch();
    endwin();
}

The segfault is due to a read from an invalid pointer:

<Could not read memory at 0xffffffffb9772078>

Backtrace:

pwndbg> bt
#0  0x00006de9c1c0d5d5 in __wcslen_avx2 () from /usr/lib/libc.so.6
#1  0x00006de9c1b51883 in wcsrtombs () from /usr/lib/libc.so.6
#2  0x00006de9c1afee34 in vfprintf () from /usr/lib/libc.so.6
#3  0x00006de9c1bb6c5f in __vsnprintf_chk () from /usr/lib/libc.so.6
#4  0x00006de9c1ce5f5a in _nc_printf_string_sp () from /usr/lib/libncursesw.so.6
#5  0x00006de9c1cdf862 in vwprintw () from /usr/lib/libncursesw.so.6
#6  0x00006de9c1cdf9f5 in wprintw () from /usr/lib/libncursesw.so.6
#7  0x00000b979d7ec874 in pancurses::window::Window::printw (self=0x7929b9772b28, string=...) at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/pancurses-0.16.0/src/window.rs:487
#8  0x00000b979d7ec905 in pancrash::main () at src/main.rs:9
#9  0x00000b979d7ec780 in std::rt::lang_start::{{closure}} () at libstd/rt.rs:74
#10 0x00000b979d7f4e93 in std::rt::lang_start_internal::{{closure}} () at libstd/rt.rs:59
#11 std::panicking::try::do_call () at libstd/panicking.rs:310
#12 0x00000b979d80c1ca in __rust_maybe_catch_panic () at libpanic_unwind/lib.rs:103
#13 0x00000b979d7fb0f6 in std::panicking::try () at libstd/panicking.rs:289
#14 std::panic::catch_unwind () at libstd/panic.rs:392
#15 std::rt::lang_start_internal () at libstd/rt.rs:58
#16 0x00000b979d7ec758 in std::rt::lang_start (main=0xb979d7ec8c0 <pancrash::main>, argc=1, argv=0x7929b9772da8) at libstd/rt.rs:74
#17 0x00000b979d7ec9aa in main ()
#18 0x00006de9c1ad0223 in __libc_start_main () from /usr/lib/libc.so.6
#19 0x00000b979d7ec5ce in _start ()
pwndbg> 

*mut i8 cannot be sent between threads safely

Error description

Error occurs when I'm trying to pass a subwindow to a thread. Subwindow is created from the main window using the subwin function.

Code

let w = create_new_window(
  &mut windows_vector,
  &main_window,
  width_of_windows,
);
let handle = 
  thread::spawn(move || {process(characters, w)});

Error output

error[E0277]: `*mut i8` cannot be sent between threads safely
   --> src/main.rs:118:29
    |
118 |                             thread::spawn(move || {
    |                             ^^^^^^^^^^^^^ `*mut i8` cannot be sent between threads safely
    |
    = help: within `[closure@src/main.rs:118:43: 120:30 characters:std::string::String, w:pancurses::Window]`, the trait `std::marker::Send` is not implemented for `*mut i8`
    = note: required because it appears within the type `pancurses::Window`
    = note: required because it appears within the type `[closure@src/main.rs:118:43: 120:30 characters:std::string::String, w:pancurses::Window]`
    = note: required by `std::thread::spawn`

get_max_x and get_max_y return width and height instead of max x and y

Hello,

I was playing around with pancurses and while trying to write chars on the edges of the window I noticed that the get_max_? methods were returning the width and height instead of max x or y. This can be easily worked around by subtracting 1 but I thought that these names are a bit counter intuitive since width is not the same as max x.

Should this be renamed? Or maybe should the behaviour be changed?

Change str functions to take AsRef<str>

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.

Asynchronous stdin

I'm trying to do something similar to what termion does with async_stdin in cases where there are other streams that can cause draws, like an irc client. Do you have any pointers how something like this can be done? :)

Thanks!

Support newterm

initscr works in certain limited circumstances but when you wish to use stdout as well as the terminal or avoid resetting the whole screen then newterm is needed.

Numpad keys are listed as Unknown

The numpad keys appear as unknown keys. Here is a list in hope of implementing them :)

I am under Windows 10 with pancurses master branch

Numlock On

Key Code
Enter 155
+ 161
- 160
* 159
/ 154

Numlock Off

Key Code
Insert (0) 202
Del (.) 158
End (1) 151
Down (2) 152
Page Down (3) 153
Left (4) 148
Center (5) 149
Right (6) 150
Home (7) 145
Up (8) 146
Page Up (9) 147

Unable to find variable COLORS

The documentation often refers to the variable COLORS, which however seems to be defined nowere:

$ grep "\<COLORS\>" $(find . -type f)
./src/lib.rs:/// must be a legal color value, i.e., 0 through COLORS-1, inclusive. The values that are returned
./src/lib.rs:/// inclusive. The foreground and background must be between 0 and `COLORS` - 1, inclusive. If the
./src/lib.rs:/// of COLORS according to this function -- 16 for FALSE, and 8 for TRUE.
./src/lib.rs:/// and white), and two global variables; `COLORS` and `COLOR_PAIRS` (respectively defining the

Unicode support?

It looks to me like ncurses-sys and pdcurses-sys both have unicode support, but I can't figure out how to enable it here. Is this a planned feature?

Cannot build with win32 as feature

I am attempting to compile the fireworks.rs example. It compiles and runs great on normal win32a. I don't need the win32 feature at the moment, I was just curious. I also tested using the newtest.rs example, also.

Cargo.toml

[dependencies]
pancurses = { version = "0.15.0", features = ["win32"] }
rand = "0.5.1"

Output

> cargo run
   Compiling pancurses v0.15.0
error: cannot find macro `warn!` in this scope
   --> C:\Users\lukew\.cargo\registry\src\github.com-1ecc6299db9ec823\pancurses-0.15.0\src\windows\mod.rs:167:45
    |
167 |                                             warn!("Decoding input as UTF-16 failed. The two values that could not be decoded were {} and {}.", first_error.unpaired_surrogate(), second_error.unpaired_surrogate());
    |                                             ^^^^

error: aborting due to previous error

error: Could not compile `pancurses`.

To learn more, run the command again with --verbose.

Great library btw.

Move to latest `winreg` version

The current version of pancurses relies on winreg 0.4, which in turn uses the 0.2 series of winapi. Recently winapi moved to 0.3, which includes many improvements, among which is greatly reduced build times. winreg has a new 0.5 version out which uses the new winapi, and that should be moved to when possible.

delch() not working?

I'm trying to delete some char from a prompt of mine doing this:

window.mv(window.get_cur_y() - 1, window.get_cur_x());
window.delch();
window.refresh();

I see the cursor going back, but it does not delete de char.
This code is called when KEY_BACKSPACE is pressed.

EDIT: using pdcurses as backend

Add keyname function

Used to get the name for any key code.
ncurses returns a Option<String>, while pdcurses returns a (possibly null) *mut ::std::os::raw::c_char (which really shouldn't be mut, but that's another problem).

Add wide feature to ncurses

Ncurses used to include the wide feature by default, but this changed recently.
It'd be nice to forward this feature.

get cursor xy?

Hi,

Is there any function to get the cursors x and y position in the terminal?

Segfault when noechoing before creating window

As per the title.

For example, the following code segfaults:

extern crate pancurses;
use pancurses::noecho;
fn main() {
    noecho();
}

This should at least be documented, if not fixed as segfaults in Rust are very rare and don't provide much insight into where the error is.

echo is not implemented

The docs for noecho claim that you can also use echo, but you can't because it's not implemented at the pancurses level.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.