mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
tabula rasa
This commit is contained in:
commit
11a9f3ba50
33 changed files with 1937 additions and 0 deletions
58
src/transport.rs
Normal file
58
src/transport.rs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
use std::error::Error;
|
||||
use std::io::Write;
|
||||
|
||||
pub struct Transport {
|
||||
cols: u16,
|
||||
rows: u16,
|
||||
}
|
||||
|
||||
impl Transport {
|
||||
pub fn run_tui () -> Result<(), Box<dyn Error>> {
|
||||
let mut app = Self { cols: 0, rows: 0 };
|
||||
let sleep = std::time::Duration::from_millis(16);
|
||||
let mut stdout = std::io::stdout();
|
||||
loop {
|
||||
app.render(&mut stdout)?;
|
||||
std::thread::sleep(sleep);
|
||||
}
|
||||
}
|
||||
fn render (&mut self, stdout: &mut std::io::Stdout) -> Result<(), Box<dyn Error>> {
|
||||
use crossterm::{*, style::{*, Stylize}};
|
||||
let (cols, rows) = terminal::size()?;
|
||||
if cols != self.cols || rows != self.rows {
|
||||
self.cols = cols;
|
||||
self.rows = rows;
|
||||
stdout
|
||||
.queue(terminal::Clear(terminal::ClearType::All))?
|
||||
.queue(cursor::Hide)?
|
||||
|
||||
.queue(cursor::MoveTo(1, 0))?
|
||||
.queue(PrintStyledContent("[Home]".yellow().bold()))?
|
||||
.queue(cursor::MoveTo(1, 1))?
|
||||
.queue(PrintStyledContent("⏹ Stop and rewind".yellow().bold()))?
|
||||
|
||||
.queue(cursor::MoveTo(20, 0))?
|
||||
.queue(PrintStyledContent("[Enter]".yellow().bold()))?
|
||||
.queue(cursor::MoveTo(20, 1))?
|
||||
.queue(PrintStyledContent("⏮ Play from start".yellow().bold()))?
|
||||
|
||||
.queue(cursor::MoveTo(40, 0))?
|
||||
.queue(PrintStyledContent("[Space]".yellow().bold()))?
|
||||
.queue(cursor::MoveTo(40, 1))?
|
||||
.queue(PrintStyledContent("⯈ Play from cursor".yellow().bold()))?
|
||||
|
||||
.queue(cursor::MoveTo(1, 3))?.queue(Print("Rate: "))?
|
||||
.queue(cursor::MoveTo(7, 3))?.queue(PrintStyledContent("48000Hz".white().bold()))?
|
||||
.queue(cursor::MoveTo(20, 3))?.queue(Print("BPM: "))?
|
||||
.queue(cursor::MoveTo(25, 3))?.queue(PrintStyledContent("120.34".white().bold()))?
|
||||
.queue(cursor::MoveTo(35, 3))?.queue(Print("Signature: "))?
|
||||
.queue(cursor::MoveTo(46, 3))?.queue(PrintStyledContent("4 / 4".white().bold()))?
|
||||
.queue(cursor::MoveTo(1, 4))?.queue(Print("Time: "))?
|
||||
.queue(cursor::MoveTo(7, 4))?.queue(PrintStyledContent("1m 23.456s".white().bold()))?
|
||||
.queue(cursor::MoveTo(20, 4))?.queue(Print("Beat: "))?
|
||||
.queue(cursor::MoveTo(26, 4))?.queue(PrintStyledContent("30x 3/4".white().bold()))?
|
||||
.flush()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue