kkx/kkdisp/src/lib.rs

66 lines
1.5 KiB
Rust

use crate::component::Cursed;
use component::{Plan, Section};
use event::Event;
use std::{
io::{Stdout, Write},
time::Duration,
};
use termion::{
clear,
input::{MouseTerminal, TermRead},
};
use termion::{
cursor,
raw::{IntoRawMode, RawTerminal},
screen::{AlternateScreen, IntoAlternateScreen},
};
use theme::{Color, ColorSet};
use token::Token;
extern crate termion;
mod component;
mod theme;
mod token;
mod widget;
pub struct Display {
// needs to hold the termion display
screen: MouseTerminal<RawTerminal<Stdout>>,
}
impl Display {
pub fn new() -> Result<Self, anyhow::Error> {
Ok(Self {
screen: MouseTerminal::from(
std::io::stdout().into_raw_mode()?,
),
})
}
pub fn testing_loop_show_input() -> ! {
let mut scr = MouseTerminal::from(
std::io::stdout()
.into_alternate_screen()
.unwrap()
.into_raw_mode()
.unwrap(),
);
write!(scr, "{}", clear::All).unwrap();
scr.flush().unwrap();
let inp = std::io::stdin();
let mut evs = inp.events();
loop {
let ev = evs.next().unwrap().unwrap();
write!(
scr,
"{clear}{oo}{:#?}",
ev,
oo = cursor::Goto(1, 1),
clear = clear::All
)
.unwrap();
scr.flush().unwrap();
}
}
}