2 个不稳定版本
使用旧的 Rust 2015
| 0.2.0 | 2019年2月19日 | 
|---|---|
| 0.1.0 | 2018年3月22日 | 
#3 在 #pancurses
14KB
274 行
syrup-rs  
  
  
 
基于 pancurses 的简单抽象,用于类似聊天的界面。
# Cargo.toml
[dependencies]
syrup = "0.1"
要开始使用,请参阅文档和 examples/ 文件夹中的示例。
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
依赖
~0.7–1.4MB
~19K SLoC