initial commit
This commit is contained in:
commit
ff8a6e66eb
|
@ -0,0 +1,5 @@
|
|||
# IDE stuff
|
||||
.idea
|
||||
|
||||
# Rust stuff
|
||||
target/
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "trinitrix"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
tui = "0.19"
|
||||
crossterm = "0.25"
|
||||
matrix-sdk = "0.6"
|
|
@ -0,0 +1,10 @@
|
|||
mod ui;
|
||||
|
||||
use std::io;
|
||||
use ui::ui_create;
|
||||
|
||||
fn main() -> Result<(), io::Error> {
|
||||
ui_create();
|
||||
|
||||
Ok(())
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
use crate::ui;
|
||||
use crossterm::event::KeyCode::Null;
|
||||
use crossterm::{
|
||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
||||
execute,
|
||||
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
||||
};
|
||||
use std::io::Stdout;
|
||||
use std::{io, thread, time::Duration};
|
||||
use tui::{
|
||||
backend::CrosstermBackend,
|
||||
layout::{Constraint, Direction, Layout},
|
||||
widgets::{Block, Borders, Widget},
|
||||
Terminal,
|
||||
};
|
||||
|
||||
pub struct UI {
|
||||
backend: CrosstermBackend<Stdout>,
|
||||
terminal: Terminal<CrosstermBackend<Stdout>>,
|
||||
}
|
||||
|
||||
pub fn ui_create() -> Result<(), io::Error> {
|
||||
// setup terminal
|
||||
enable_raw_mode()?;
|
||||
let mut stdout = io::stdout();
|
||||
execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?;
|
||||
let backend = CrosstermBackend::new(stdout);
|
||||
let mut terminal = Terminal::new(backend)?;
|
||||
|
||||
terminal.draw(|f| {
|
||||
let size = f.size();
|
||||
let block = Block::default().title("Layout design in work...").borders(Borders::ALL);
|
||||
f.render_widget(block, size);
|
||||
})?;
|
||||
|
||||
thread::sleep(Duration::from_millis(5000));
|
||||
|
||||
// restore terminal
|
||||
disable_raw_mode()?;
|
||||
execute!(
|
||||
terminal.backend_mut(),
|
||||
LeaveAlternateScreen,
|
||||
DisableMouseCapture
|
||||
)?;
|
||||
terminal.show_cursor()?;
|
||||
|
||||
Ok(())
|
||||
}
|
Reference in New Issue