uu 0.1.1

A simple graphic library only works on X11
extern crate uu;

use std::sync::Arc;
use std::sync::RwLock;
use uu::Application;
use uu::Window;

fn main() {
    let point_list = Arc::new(RwLock::new(vec![]));

    uu::init();
    let application = uu::create_application(uu::Backend::X11);
    application.create_window(400, 400);

    let rp = point_list.clone();
    application.add_event_listener(Box::new(move |application, ev| match ev {
        uu::Event::KeyPress(key_press_event) => match key_press_event.detail {
            65 => {
                let window = application.get_window(key_press_event.window_id);
                window.polygon(
                    &rp.read().unwrap(),
                    uu::Color {
                        r: 1.0,
                        g: 0.0,
                        b: 0.0,
                    },
                );

                rp.write().unwrap().clear();
                window.flush();
            }
            54 => {
                application.create_window(100, 100);
            }
            _ => {}
        },
        _ => {}
    }));
    application.add_event_listener(Box::new(|application, ev| match ev {
        uu::Event::CloseNotify(close_notify_event) => {
            application.destroy_window(close_notify_event.window_id);
        }
        _ => {}
    }));

    let p = point_list.clone();
    application.add_event_listener(Box::new(move |application, ev| match ev {
        uu::Event::ButtonPress(button_press_event) => {
            p.write().unwrap().push(button_press_event.cursor_position);

            let window = application.get_window(button_press_event.window_id);
            window.draw_text(
                button_press_event.cursor_position,
                uu::Color {
                    r: 1.0,
                    g: 0.0,
                    b: 0.0,
                },
                50,
                "Noto Sans CJK SC",
                "你好,世界",
            );
            window.flush();
        }
        _ => {}
    }));

    application.add_event_listener(Box::new(move |application, ev| match ev {
        uu::Event::CloseNotify(close_notification) => {
            if application.windows_len() == 0 {
                application.quit();
            }
        }
        _ => {}
    }));
    application.main_loop();
    return;
}