| Crates.io | syrup |
| lib.rs | syrup |
| version | 0.2.0 |
| created_at | 2018-03-22 03:49:31.870573+00 |
| updated_at | 2019-02-19 15:07:47.005834+00 |
| description | Simple abstraction around pancurses for chat-like interfaces |
| homepage | |
| repository | https://github.com/kpcyrd/syrup-rs |
| max_upload_size | |
| id | 56836 |
| size | 29,352 |
Simple abstraction around pancurses for chat-like interfaces.
# Cargo.toml
[dependencies]
syrup = "0.1"
To get started, see the docs and the examples/ folder.
extern crate syrup;
use syrup::Window;
use std::thread;
use std::sync::mpsc;
use std::time::Duration;
fn main() {
let mut window = Window::initscr();
window.writeln("");
window.writeln(" === welcome to example chat");
window.writeln("");
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
loop {
tx.send(String::from("ohai")).unwrap();
thread::sleep(Duration::from_secs(3));
}
});
loop {
if let Ok(msg) = rx.try_recv() {
window.writeln(format!("> {:?}", msg));
}
if let Some(line) = window.get() {
if line == "/quit" {
break;
}
window.writeln(format!("< {:?}", line));
}
}
}
MIT/Apache-2.0