mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 13:16:44 +01:00
wip: running interface in separate or combined mode
also disassociating render functions from state structs
This commit is contained in:
parent
f9218e887a
commit
d6bf840a1f
31 changed files with 905 additions and 532 deletions
82
src/sequencer/render.rs
Normal file
82
src/sequencer/render.rs
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
use crate::prelude::*;
|
||||
use super::Sequencer;
|
||||
|
||||
pub fn render (
|
||||
state: &mut Sequencer,
|
||||
stdout: &mut Stdout,
|
||||
offset: (u16, u16)
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
render_toolbar(state, stdout, offset)?;
|
||||
render_grid(state, stdout, offset)?;
|
||||
render_events(state, stdout, offset)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn render_toolbar (
|
||||
state: &mut Sequencer,
|
||||
stdout: &mut Stdout,
|
||||
offset: (u16, u16)
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
stdout
|
||||
.queue(MoveTo(1, 0))?
|
||||
.queue(PrintStyledContent("Arrows".yellow().bold()))?
|
||||
.queue(MoveTo(1, 1))?
|
||||
.queue(PrintStyledContent("Navigate".yellow()))?
|
||||
|
||||
.queue(MoveTo(12, 0))?
|
||||
.queue(PrintStyledContent("+/-".yellow().bold()))?
|
||||
.queue(MoveTo(12, 1))?
|
||||
.queue(PrintStyledContent("Zoom".yellow()))?
|
||||
|
||||
.queue(MoveTo(20, 0))?
|
||||
.queue(PrintStyledContent("a/d".yellow().bold()))?
|
||||
.queue(MoveTo(20, 1))?
|
||||
.queue(PrintStyledContent("Add/delete".yellow()))?
|
||||
|
||||
.queue(MoveTo(33, 0))?
|
||||
.queue(PrintStyledContent("[/]".yellow().bold()))?
|
||||
.queue(MoveTo(33, 1))?
|
||||
.queue(PrintStyledContent("Duration".yellow()))?
|
||||
|
||||
.queue(MoveTo(45, 0))?
|
||||
.queue(PrintStyledContent("CapsLock".yellow().bold()))?
|
||||
.queue(MoveTo(45, 1))?
|
||||
.queue(PrintStyledContent("Auto advance".yellow()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn render_grid (
|
||||
state: &mut Sequencer,
|
||||
stdout: &mut Stdout,
|
||||
offset: (u16, u16)
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
let bg = "┊···············┊···············┊···············┊···············";
|
||||
let cursor: String = if state.duration == 0 {
|
||||
"X".into()
|
||||
} else {
|
||||
std::iter::repeat("·")
|
||||
.take(state.duration as usize)
|
||||
.collect()
|
||||
};
|
||||
stdout
|
||||
.queue(MoveTo(1, 3))?.queue(Print("1.1"))?
|
||||
.queue(MoveTo(17, 3))?.queue(Print("1.2"))?
|
||||
.queue(MoveTo(33, 3))?.queue(Print("1.3"))?
|
||||
.queue(MoveTo(49, 3))?.queue(Print("1.4"))?
|
||||
.queue(MoveTo(1, 4))?.queue(PrintStyledContent(bg.grey()))?
|
||||
.queue(MoveTo(1, 5))?.queue(PrintStyledContent(bg.grey()))?
|
||||
.queue(MoveTo(1, 6))?.queue(PrintStyledContent(bg.grey()))?
|
||||
.queue(MoveTo(1, 7))?.queue(PrintStyledContent(bg.grey()))?
|
||||
.queue(MoveTo(1 + state.cursor.0, 4 + state.cursor.1))?
|
||||
.queue(PrintStyledContent(cursor.reverse()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn render_events (
|
||||
state: &mut Sequencer,
|
||||
stdout: &mut Stdout,
|
||||
offset: (u16, u16)
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue