mirror of https://github.com/fdehau/tui-rs
Remove cache system and add unicode segmentation
parent
bd404f0238
commit
fde0ba95dd
@ -0,0 +1,43 @@
|
|||||||
|
extern crate tui;
|
||||||
|
extern crate termion;
|
||||||
|
|
||||||
|
use std::io;
|
||||||
|
use termion::event;
|
||||||
|
use termion::input::TermRead;
|
||||||
|
|
||||||
|
use tui::Terminal;
|
||||||
|
use tui::widgets::{Widget, Block};
|
||||||
|
use tui::layout::{Group, Direction, Alignment, Size};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut terminal = Terminal::new().unwrap();
|
||||||
|
let stdin = io::stdin();
|
||||||
|
terminal.clear();
|
||||||
|
terminal.hide_cursor();
|
||||||
|
for c in stdin.keys() {
|
||||||
|
let evt = c.unwrap();
|
||||||
|
if evt == event::Key::Char('q') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
draw(&mut terminal);
|
||||||
|
}
|
||||||
|
terminal.show_cursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn draw(t: &mut Terminal) {
|
||||||
|
|
||||||
|
Group::default()
|
||||||
|
.direction(Direction::Vertical)
|
||||||
|
.alignment(Alignment::Left)
|
||||||
|
.chunks(&[Size::Fixed(7), Size::Min(5), Size::Fixed(3)])
|
||||||
|
.render(&Terminal::size().unwrap(), |chunks| {
|
||||||
|
t.render(chunks[0], Block::default().title("Block"));
|
||||||
|
Group::default()
|
||||||
|
.direction(Direction::Vertical)
|
||||||
|
.alignment(Alignment::Left)
|
||||||
|
.chunks(&[Size::Fixed(7), Size::Min(5), Size::Fixed(3)])
|
||||||
|
.render(&chunks[1], |chunks| {
|
||||||
|
t.render(chunks[0], Block::default().title("Block"));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -1,23 +1,36 @@
|
|||||||
pub mod block {
|
pub mod block {
|
||||||
pub const FULL: char = '█';
|
pub const FULL: &'static str = "█";
|
||||||
pub const SEVEN_EIGHTHS: char = '▉';
|
pub const SEVEN_EIGHTHS: &'static str = "▉";
|
||||||
pub const THREE_QUATERS: char = '▊';
|
pub const THREE_QUATERS: &'static str = "▊";
|
||||||
pub const FIVE_EIGHTHS: char = '▋';
|
pub const FIVE_EIGHTHS: &'static str = "▋";
|
||||||
pub const HALF: char = '▌';
|
pub const HALF: &'static str = "▌";
|
||||||
pub const THREE_EIGHTHS: char = '▍';
|
pub const THREE_EIGHTHS: &'static str = "▍";
|
||||||
pub const ONE_QUATER: char = '▎';
|
pub const ONE_QUATER: &'static str = "▎";
|
||||||
pub const ONE_EIGHTH: char = '▏';
|
pub const ONE_EIGHTH: &'static str = "▏";
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod bar {
|
pub mod bar {
|
||||||
pub const FULL: char = '█';
|
pub const FULL: &'static str = "█";
|
||||||
pub const SEVEN_EIGHTHS: char = '▇';
|
pub const SEVEN_EIGHTHS: &'static str = "▇";
|
||||||
pub const THREE_QUATERS: char = '▆';
|
pub const THREE_QUATERS: &'static str = "▆";
|
||||||
pub const FIVE_EIGHTHS: char = '▅';
|
pub const FIVE_EIGHTHS: &'static str = "▅";
|
||||||
pub const HALF: char = '▄';
|
pub const HALF: &'static str = "▄";
|
||||||
pub const THREE_EIGHTHS: char = '▃';
|
pub const THREE_EIGHTHS: &'static str = "▃";
|
||||||
pub const ONE_QUATER: char = '▂';
|
pub const ONE_QUATER: &'static str = "▂";
|
||||||
pub const ONE_EIGHTH: char = '▁';
|
pub const ONE_EIGHTH: &'static str = "▁";
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const DOT: char = '•';
|
pub mod line {
|
||||||
|
pub const TOP_RIGHT: &'static str = "┐";
|
||||||
|
pub const VERTICAL: &'static str = "│";
|
||||||
|
pub const HORIZONTAL: &'static str = "─";
|
||||||
|
pub const TOP_LEFT: &'static str = "┌";
|
||||||
|
pub const BOTTOM_RIGHT: &'static str = "┘";
|
||||||
|
pub const BOTTOM_LEFT: &'static str = "└";
|
||||||
|
pub const VERTICAL_LEFT: &'static str = "┤";
|
||||||
|
pub const VERTICAL_RIGHT: &'static str = "├";
|
||||||
|
pub const HORIZONTAL_DOWN: &'static str = "┬";
|
||||||
|
pub const HORIZONTAL_UP: &'static str = "┴";
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const DOT: &'static str = "•";
|
||||||
|
Loading…
Reference in New Issue