98 stable releases

2.4.5 Oct 8, 2021
2.3.17 Aug 22, 2021
2.3.12 Jul 29, 2021
2.2.4 Mar 28, 2021
1.2.4 Mar 24, 2020

#48 in Command-line interface

Download history 41/week @ 2021-06-25 36/week @ 2021-07-02 38/week @ 2021-07-09 127/week @ 2021-07-16 33/week @ 2021-07-23 293/week @ 2021-07-30 35/week @ 2021-08-06 173/week @ 2021-08-13 53/week @ 2021-08-20 33/week @ 2021-08-27 23/week @ 2021-09-03 36/week @ 2021-09-10 36/week @ 2021-09-17 105/week @ 2021-09-24 23/week @ 2021-10-01 168/week @ 2021-10-08

334 downloads per month
Used in 2 crates


7.5K SLoC

Crate API MSRV: 1.48.0

libnotcurses-sys is a low-level Rust wrapper for the notcurses C library

This library is built with several layers of zero-overhead abstractions over the C functions and pointers accessed through FFI.

How to use this library

There are basically two ways: The Rust way, and the C way. (Or a mix of both).

1. The Rust way

Where you use the more safely wrapped types, with its methods and constructors, and painless error handling, like this:

use libnotcurses_sys::*;

fn main() -> NcResult<()> {
    let mut nc = Nc::with_flags(NCOPTION_NO_ALTERNATE_SCREEN)?;
    let plane = nc.stdplane();
    plane.putstr("hello world")?;

Although you still have to manually call the stop() method for Nc and NcDirect objects, and the destroy() method for the rest of types that allocate, (like NcPlane, NcMenu…) at the end of their scope, since the Drop trait is not implemented for any wrapping type in libnotcurses-sys.

But they do implement methods and use NcResult as the return type, for handling errors in the way we are used to in Rust.

For the types that don't allocate, most are based on primitives like i32, u32, u64… without a name in the C library. In Rust they are type aliased (e.g.: NcChannel, NcChannelPair, NcRgb, NcColor…), to leverage type checking, and they implement methods through traits (e.g. NcChannelMethods must be in scope to use the NcChannel methods.

2. The C way

You can always use the C API functions directly if you prefer, in a very similar way as the C library is used.

It requires the use of unsafe, since most functions are wrapped directly by bindgen marked as such.

Error handling is done this way by checking the returned NcIntResult, or in case of receiving a pointer, by comparing it to null_mut().


use core::ptr::{null, null_mut};
use std::process::exit;

use libnotcurses_sys::*;

fn main() {
    let options = ffi::notcurses_options {
        termtype: null(),
        loglevel: 0,
        margin_t: 0,
        margin_r: 0,
        margin_b: 0,
        margin_l: 0,
    unsafe {
        let nc = notcurses_init(&options, null_mut());
        if nc == null_mut() {
        let plane = notcurses_stdplane(nc);
        let cols = ncplane_putstr(&mut *plane, "hello world");
        if cols < NCRESULT_OK {
        if notcurses_stop(nc) < NCRESULT_OK {

The notcurses C API docs


~31K SLoC