Giter Site home page Giter Site logo

pancurses's Introduction

pancurses Build Status Build status Crates.io

pancurses is a curses libary 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.

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.8"

main.rs

extern crate pancurses;

use pancurses::{initscr, endwin};

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

Example: 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();
}

License

Licensed under the MIT license, see LICENSE.md

pancurses's People

Watchers

 avatar  avatar  avatar

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.