rust: use libnotcurses-sys, add test

pull/433/head
nick black 4 years ago
parent cbacf006e5
commit 6c81cb3b45
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -9,6 +9,7 @@ version = "1.2.4"
links = "notcurses"
build = "build.rs"
edition = "2018"
categories = ["external-ffi-bindings"]
[dependencies]
libc = "0.2.66"
[build-dependencies]

@ -12,3 +12,5 @@ homepage = "https://nick-black.com/dankwiki/index.php/Notcurses"
[dependencies]
libnotcurses-sys = "^1.2.4"
libc = "0.2.66"
libc-stdhandle = ">= 0.1.0"

@ -1,7 +1,33 @@
extern crate libnotcurses_sys as ffi;
extern {
fn libc_stdout() -> *mut ffi::_IO_FILE;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
fn create_context() {
unsafe {
let _ = libc::setlocale(libc::LC_ALL, std::ffi::CString::new("").unwrap().as_ptr());
let opts: ffi::notcurses_options = ffi::notcurses_options {
inhibit_alternate_screen: false,
loglevel: 0,
termtype: std::ptr::null(),
retain_cursor: false,
suppress_banner: false,
no_winch_sighandler: false,
no_quit_sighandlers: false,
renderfp: std::ptr::null_mut(),
margin_t: 0,
margin_r: 0,
margin_b: 0,
margin_l: 0,
};
let nc = ffi::notcurses_init(&opts, libc_stdout());
ffi::notcurses_stop(nc);
}
}
}

@ -102,7 +102,8 @@ name = "colloquy"
version = "0.1.0"
dependencies = [
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
"notcurses 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"libnotcurses-sys 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -195,14 +196,6 @@ dependencies = [
"version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "notcurses"
version = "1.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libnotcurses-sys 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "peeking_take_while"
version = "0.1.2"
@ -372,7 +365,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
"checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
"checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6"
"checksum notcurses 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ae81c8e1543e0dc8c599fd0ddecf146cc52468b6f27fffcc21a4caa6cc3d358b"
"checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
"checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
"checksum proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435"

@ -9,7 +9,8 @@ description = "Notcurses-based utility for command-line TUI widgets"
homepage = "https://nick-black.com/dankwiki/index.php/Notcurses"
[dependencies]
notcurses = ">= 1.2.3"
libc = ">= 0.2.66"
libnotcurses-sys = ">= 1.2.3"
[dependencies.clap]
version = ">= 2.33.0"

@ -8,4 +8,22 @@ fn main() {
eprintln!("Needed a widget type");
std::process::exit(1);
}
let _ = libc::setlocale(libc::LC_ALL, std::ffi::CString::new("").unwrap().as_ptr());
let opts: notcurses_options = libnotcurses-sys::notcurses_options {
inhibit_alternate_screen: true,
loglevel: 0,
termtype: std::ptr::null(),
retain_cursor: false,
suppress_banner: false,
no_winch_sighandler: false,
no_quit_sighandlers: false,
renderfp: std::ptr::null_mut(),
margin_t: 0,
margin_r: 0,
margin_b: 0,
margin_l: 0,
};
let nc = notcurses_init(&opts, libc_stdout());
notcurses_stop(nc);
}

Loading…
Cancel
Save