Skip to content
/ syrup-rs Public
forked from kpcyrd/syrup-rs

Simple abstraction around pancurses for chat-like interfaces

License

Notifications You must be signed in to change notification settings

KurSh/syrup-rs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

syrup-rs Build Status Build status crates.io docs.rs

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));
        }
    }
}

License

MIT/Apache-2.0

About

Simple abstraction around pancurses for chat-like interfaces

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%