File: completion.rs

package info (click to toggle)
tiny 0.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,780 kB
  • sloc: makefile: 29
file content (42 lines) | stat: -rw-r--r-- 1,149 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use std::fs::File;
use std::io::Read;
use std::path::PathBuf;

use libtiny_common::MsgTarget;
use libtiny_tui::TUI;

fn main() {
    let runtime = tokio::runtime::Builder::new_current_thread()
        .enable_all()
        .build()
        .unwrap();

    let local = tokio::task::LocalSet::new();

    local.block_on(&runtime, async move {
        let (tui, _) = TUI::run(PathBuf::from("../tiny/config.yml"));
        tui.new_server_tab("debug", None);
        let debug_tab = MsgTarget::Server { serv: "debug" };

        tui.add_msg(
            "Loading word list for auto-completion ...",
            time::OffsetDateTime::now_utc(),
            &debug_tab,
        );
        tui.draw();

        {
            let mut contents = String::new();
            let mut file = File::open("/usr/share/dict/american-english").unwrap();
            file.read_to_string(&mut contents).unwrap();
            for word in contents.lines() {
                tui.add_nick(word, None, &debug_tab);
            }
        }

        tui.add_msg("Done.", time::OffsetDateTime::now_utc(), &debug_tab);
        tui.draw();
    });

    runtime.block_on(local);
}