mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
shorten TuiIn, TuiOut
This commit is contained in:
parent
ca16a91015
commit
21741ebc52
20 changed files with 77 additions and 75 deletions
|
|
@ -40,9 +40,9 @@ it composes:
|
||||||
the manner of output is determined by the
|
the manner of output is determined by the
|
||||||
`Engine::Output` type, a mutable pointer to which
|
`Engine::Output` type, a mutable pointer to which
|
||||||
is passed to the render method, e.g. in the case of
|
is passed to the render method, e.g. in the case of
|
||||||
the `Tui` engine: `fn render(&self, output: &mut TuiOutput)`
|
the `Tui` engine: `fn render(&self, output: &mut TuiOut)`
|
||||||
|
|
||||||
you can use `TuiOutput::blit` and `TuiOutput::place`
|
you can use `TuiOut::blit` and `TuiOut::place`
|
||||||
to draw at specified coordinates of the display, and/or
|
to draw at specified coordinates of the display, and/or
|
||||||
directly modify the underlying `ratatui::Buffer` at
|
directly modify the underlying `ratatui::Buffer` at
|
||||||
`output.buffer`
|
`output.buffer`
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ pub type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Handle<Tui> for TestComponent {
|
impl Handle<Tui> for TestComponent {
|
||||||
fn handle (&mut self, from: &TuiInput) -> Perhaps<bool> {
|
fn handle (&mut self, from: &TuiIn) -> Perhaps<bool> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,9 @@ impl Engine for Tui {
|
||||||
type Unit = u16;
|
type Unit = u16;
|
||||||
type Size = [Self::Unit;2];
|
type Size = [Self::Unit;2];
|
||||||
type Area = [Self::Unit;4];
|
type Area = [Self::Unit;4];
|
||||||
type Input = TuiInput;
|
type Input = TuiIn;
|
||||||
type Handled = bool;
|
type Handled = bool;
|
||||||
type Output = TuiOutput;
|
type Output = TuiOut;
|
||||||
fn exited (&self) -> bool {
|
fn exited (&self) -> bool {
|
||||||
self.exited.fetch_and(true, Relaxed)
|
self.exited.fetch_and(true, Relaxed)
|
||||||
}
|
}
|
||||||
|
|
@ -125,7 +125,7 @@ impl<T: Content<Tui> + Handle<Tui> + Sized + 'static> TuiRun<T> for Arc<RwLock<T
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
let exited = exited.clone();
|
let exited = exited.clone();
|
||||||
if let Err(e) = state.write().unwrap().handle(&TuiInput { event, exited }) {
|
if let Err(e) = state.write().unwrap().handle(&TuiIn { event, exited }) {
|
||||||
panic!("{e}")
|
panic!("{e}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +153,7 @@ impl<T: Content<Tui> + Handle<Tui> + Sized + 'static> TuiRun<T> for Arc<RwLock<T
|
||||||
buffer.resize(size);
|
buffer.resize(size);
|
||||||
buffer.reset();
|
buffer.reset();
|
||||||
}
|
}
|
||||||
let mut output = TuiOutput { buffer, area: [0, 0, width, height] };
|
let mut output = TuiOut { buffer, area: [0, 0, width, height] };
|
||||||
state.render(&mut output);
|
state.render(&mut output);
|
||||||
buffer = engine.write().unwrap().flip(output.buffer, size);
|
buffer = engine.write().unwrap().flip(output.buffer, size);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
use crate::{*, tui::*};
|
use crate::{*, tui::*};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct TuiInput {
|
pub struct TuiIn {
|
||||||
pub(crate) exited: Arc<AtomicBool>,
|
pub(crate) exited: Arc<AtomicBool>,
|
||||||
pub(crate) event: crossterm::event::Event,
|
pub(crate) event: crossterm::event::Event,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Input<Tui> for TuiInput {
|
impl Input<Tui> for TuiIn {
|
||||||
type Event = crossterm::event::Event;
|
type Event = crossterm::event::Event;
|
||||||
fn event (&self) -> &crossterm::event::Event {
|
fn event (&self) -> &crossterm::event::Event {
|
||||||
&self.event
|
&self.event
|
||||||
|
|
@ -124,7 +124,7 @@ pub const fn shift (key: KeyEvent) -> KeyEvent {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
impl TuiInput {
|
impl TuiIn {
|
||||||
// TODO remove
|
// TODO remove
|
||||||
pub fn handle_keymap <T> (&self, state: &mut T, keymap: &KeyMap<T>) -> Usually<bool> {
|
pub fn handle_keymap <T> (&self, state: &mut T, keymap: &KeyMap<T>) -> Usually<bool> {
|
||||||
match self.event() {
|
match self.event() {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
use crate::{*, tui::*};
|
use crate::{*, tui::*};
|
||||||
|
|
||||||
pub struct TuiOutput {
|
pub struct TuiOut {
|
||||||
pub buffer: Buffer,
|
pub buffer: Buffer,
|
||||||
pub area: [u16;4]
|
pub area: [u16;4]
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Output<Tui> for TuiOutput {
|
impl Output<Tui> for TuiOut {
|
||||||
#[inline] fn area (&self) -> [u16;4] { self.area }
|
#[inline] fn area (&self) -> [u16;4] { self.area }
|
||||||
#[inline] fn area_mut (&mut self) -> &mut [u16;4] { &mut self.area }
|
#[inline] fn area_mut (&mut self) -> &mut [u16;4] { &mut self.area }
|
||||||
#[inline] fn place (&mut self, area: [u16;4], content: &impl Content<Tui>) {
|
#[inline] fn place (&mut self, area: [u16;4], content: &impl Content<Tui>) {
|
||||||
|
|
@ -20,7 +20,7 @@ impl Output<Tui> for TuiOutput {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TuiOutput {
|
impl TuiOut {
|
||||||
pub fn buffer_update (&mut self, area: [u16;4], callback: &impl Fn(&mut Cell, u16, u16)) {
|
pub fn buffer_update (&mut self, area: [u16;4], callback: &impl Fn(&mut Cell, u16, u16)) {
|
||||||
buffer_update(&mut self.buffer, area, callback);
|
buffer_update(&mut self.buffer, area, callback);
|
||||||
}
|
}
|
||||||
|
|
@ -69,6 +69,38 @@ impl TuiOutput {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Content<Tui> for &str {
|
||||||
|
fn area (&self, to: [u16;4]) -> [u16;4] {
|
||||||
|
[to[0], to[1], self.chars().count() as u16, 1]
|
||||||
|
}
|
||||||
|
fn render (&self, to: &mut TuiOut) {
|
||||||
|
to.blit(self, to.area.x(), to.area.y(), None)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Content<Tui> for String {
|
||||||
|
fn area (&self, to: [u16;4]) -> [u16;4] {
|
||||||
|
[to[0], to[1], self.chars().count() as u16, 1]
|
||||||
|
}
|
||||||
|
fn render (&self, to: &mut TuiOut) {
|
||||||
|
to.blit(self, to.area.x(), to.area.y(), None)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn buffer_update (buf: &mut Buffer, area: [u16;4], callback: &impl Fn(&mut Cell, u16, u16)) {
|
||||||
|
for row in 0..area.h() {
|
||||||
|
let y = area.y() + row;
|
||||||
|
for col in 0..area.w() {
|
||||||
|
let x = area.x() + col;
|
||||||
|
if x < buf.area.width && y < buf.area.height {
|
||||||
|
callback(buf.get_mut(x, y), col, row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//impl Area<u16> for Rect {
|
//impl Area<u16> for Rect {
|
||||||
//fn x (&self) -> u16 { self.x }
|
//fn x (&self) -> u16 { self.x }
|
||||||
//fn y (&self) -> u16 { self.y }
|
//fn y (&self) -> u16 { self.y }
|
||||||
|
|
@ -86,33 +118,3 @@ pub fn half_block (lower: bool, upper: bool) -> Option<char> {
|
||||||
}
|
}
|
||||||
|
|
||||||
//impl<T: Content<Tui>> Render<Tui> for T {}
|
//impl<T: Content<Tui>> Render<Tui> for T {}
|
||||||
|
|
||||||
impl Content<Tui> for &str {
|
|
||||||
fn area (&self, to: [u16;4]) -> [u16;4] {
|
|
||||||
[to[0], to[1], self.chars().count() as u16, 1]
|
|
||||||
}
|
|
||||||
fn render (&self, to: &mut TuiOutput) {
|
|
||||||
to.blit(self, to.area.x(), to.area.y(), None)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Content<Tui> for String {
|
|
||||||
fn area (&self, to: [u16;4]) -> [u16;4] {
|
|
||||||
[to[0], to[1], self.chars().count() as u16, 1]
|
|
||||||
}
|
|
||||||
fn render (&self, to: &mut TuiOutput) {
|
|
||||||
to.blit(self, to.area.x(), to.area.y(), None)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn buffer_update (buf: &mut Buffer, area: [u16;4], callback: &impl Fn(&mut Cell, u16, u16)) {
|
|
||||||
for row in 0..area.h() {
|
|
||||||
let y = area.y() + row;
|
|
||||||
for col in 0..area.w() {
|
|
||||||
let x = area.x() + col;
|
|
||||||
if x < buf.area.width && y < buf.area.height {
|
|
||||||
callback(buf.get_mut(x, y), col, row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ impl Content for Demo<Tui> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Handle<Tui> for Demo<Tui> {
|
impl Handle<Tui> for Demo<Tui> {
|
||||||
fn handle (&mut self, from: &TuiInput) -> Perhaps<bool> {
|
fn handle (&mut self, from: &TuiIn) -> Perhaps<bool> {
|
||||||
use KeyCode::{PageUp, PageDown};
|
use KeyCode::{PageUp, PageDown};
|
||||||
match from.event() {
|
match from.event() {
|
||||||
key_expr!(PageUp) => {
|
key_expr!(PageUp) => {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ render!(<Tui>|self:BspDemo<Tui>|Fill::xy(Align::c(
|
||||||
)));
|
)));
|
||||||
|
|
||||||
impl Handle<Tui> for BspDemo<Tui> {
|
impl Handle<Tui> for BspDemo<Tui> {
|
||||||
fn handle (&mut self, from: &TuiInput) -> Perhaps<bool> {
|
fn handle (&mut self, from: &TuiIn) -> Perhaps<bool> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ impl<E: Engine> Measure<E> {
|
||||||
//fn min_size (&self, _: [u16;2]) -> Perhaps<[u16;2]> {
|
//fn min_size (&self, _: [u16;2]) -> Perhaps<[u16;2]> {
|
||||||
//Ok(Some([0u16.into(), 0u16.into()].into()))
|
//Ok(Some([0u16.into(), 0u16.into()].into()))
|
||||||
//}
|
//}
|
||||||
//fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
//fn render (&self, to: &mut TuiOut) -> Usually<()> {
|
||||||
//self.set_w(to.area().w());
|
//self.set_w(to.area().w());
|
||||||
//self.set_h(to.area().h());
|
//self.set_h(to.area().h());
|
||||||
//Ok(())
|
//Ok(())
|
||||||
|
|
@ -98,7 +98,7 @@ impl<E: Engine> Measure<E> {
|
||||||
//}
|
//}
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//render!(<Tui>|self: ShowMeasure<'a>|render(|to: &mut TuiOutput|Ok({
|
//render!(<Tui>|self: ShowMeasure<'a>|render(|to: &mut TuiOut|Ok({
|
||||||
//let w = self.0.w();
|
//let w = self.0.w();
|
||||||
//let h = self.0.h();
|
//let h = self.0.h();
|
||||||
//to.blit(&format!(" {w} x {h} "), to.area.x(), to.area.y(), Some(
|
//to.blit(&format!(" {w} x {h} "), to.area.x(), to.area.y(), Some(
|
||||||
|
|
@ -114,7 +114,7 @@ impl<E: Engine> Measure<E> {
|
||||||
//fn min_size (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
//fn min_size (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
||||||
//self.1.min_size(to)
|
//self.1.min_size(to)
|
||||||
//}
|
//}
|
||||||
//fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
//fn render (&self, to: &mut TuiOut) -> Usually<()> {
|
||||||
//let [x, y, w, h] = to.area();
|
//let [x, y, w, h] = to.area();
|
||||||
//self.1.render(to)?;
|
//self.1.render(to)?;
|
||||||
//Ok(to.blit(&format!("{w}x{h}+{x}+{y}"), x, y, Some(Style::default().green())))
|
//Ok(to.blit(&format!("{w}x{h}+{x}+{y}"), x, y, Some(Style::default().green())))
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ input_to_command!(ArrangerCommand: <Tui>|state: ArrangerTui, input|match input.e
|
||||||
None
|
None
|
||||||
})?
|
})?
|
||||||
});
|
});
|
||||||
fn to_arrangement_command (state: &ArrangerTui, input: &TuiInput) -> Option<ArrangerCommand> {
|
fn to_arrangement_command (state: &ArrangerTui, input: &TuiIn) -> Option<ArrangerCommand> {
|
||||||
use ArrangerCommand as Cmd;
|
use ArrangerCommand as Cmd;
|
||||||
use ArrangerSelection as Selected;
|
use ArrangerSelection as Selected;
|
||||||
use ArrangerSceneCommand as Scene;
|
use ArrangerSceneCommand as Scene;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ from!(|args:(&ArrangerTui, usize)|ArrangerVCursor = Self {
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
impl Content<Tui> for ArrangerVCursor {
|
impl Content<Tui> for ArrangerVCursor {
|
||||||
fn render (&self, to: &mut TuiOutput) {
|
fn render (&self, to: &mut TuiOut) {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let focused = true;
|
let focused = true;
|
||||||
let selected = self.selected;
|
let selected = self.selected;
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ pub trait BorderStyle: Send + Sync + Copy {
|
||||||
fn sw (&self) -> &str { Self::SW }
|
fn sw (&self) -> &str { Self::SW }
|
||||||
fn se (&self) -> &str { Self::SE }
|
fn se (&self) -> &str { Self::SE }
|
||||||
#[inline] fn draw <'a> (
|
#[inline] fn draw <'a> (
|
||||||
&self, to: &mut TuiOutput
|
&self, to: &mut TuiOut
|
||||||
) -> Usually<()> {
|
) -> Usually<()> {
|
||||||
self.draw_horizontal(to, None)?;
|
self.draw_horizontal(to, None)?;
|
||||||
self.draw_vertical(to, None)?;
|
self.draw_vertical(to, None)?;
|
||||||
|
|
@ -61,7 +61,7 @@ pub trait BorderStyle: Send + Sync + Copy {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
#[inline] fn draw_horizontal (
|
#[inline] fn draw_horizontal (
|
||||||
&self, to: &mut TuiOutput, style: Option<Style>
|
&self, to: &mut TuiOut, style: Option<Style>
|
||||||
) -> Usually<[u16;4]> {
|
) -> Usually<[u16;4]> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let style = style.or_else(||self.style_horizontal());
|
let style = style.or_else(||self.style_horizontal());
|
||||||
|
|
@ -73,7 +73,7 @@ pub trait BorderStyle: Send + Sync + Copy {
|
||||||
Ok(area)
|
Ok(area)
|
||||||
}
|
}
|
||||||
#[inline] fn draw_vertical (
|
#[inline] fn draw_vertical (
|
||||||
&self, to: &mut TuiOutput, style: Option<Style>
|
&self, to: &mut TuiOut, style: Option<Style>
|
||||||
) -> Usually<[u16;4]> {
|
) -> Usually<[u16;4]> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let style = style.or_else(||self.style_vertical());
|
let style = style.or_else(||self.style_vertical());
|
||||||
|
|
@ -91,7 +91,7 @@ pub trait BorderStyle: Send + Sync + Copy {
|
||||||
Ok(area)
|
Ok(area)
|
||||||
}
|
}
|
||||||
#[inline] fn draw_corners (
|
#[inline] fn draw_corners (
|
||||||
&self, to: &mut TuiOutput, style: Option<Style>
|
&self, to: &mut TuiOut, style: Option<Style>
|
||||||
) -> Usually<[u16;4]> {
|
) -> Usually<[u16;4]> {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let style = style.or_else(||self.style_corners());
|
let style = style.or_else(||self.style_corners());
|
||||||
|
|
@ -129,7 +129,7 @@ macro_rules! border {
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct $T(pub Style);
|
pub struct $T(pub Style);
|
||||||
impl Content<Tui> for $T {
|
impl Content<Tui> for $T {
|
||||||
fn render (&self, to: &mut TuiOutput) { self.draw(to); }
|
fn render (&self, to: &mut TuiOut) { self.draw(to); }
|
||||||
}
|
}
|
||||||
)+}
|
)+}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@ pub trait FocusWrap<T> {
|
||||||
fn wrap <W: Content<Tui>> (self, focus: T, content: &'_ W) -> impl Content<Tui> + '_;
|
fn wrap <W: Content<Tui>> (self, focus: T, content: &'_ W) -> impl Content<Tui> + '_;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_focus_command <T: Send + Sync> (input: &TuiInput) -> Option<FocusCommand<T>> {
|
pub fn to_focus_command <T: Send + Sync> (input: &TuiIn) -> Option<FocusCommand<T>> {
|
||||||
Some(match input.event() {
|
Some(match input.event() {
|
||||||
key_pat!(Tab) => FocusCommand::Next,
|
key_pat!(Tab) => FocusCommand::Next,
|
||||||
key_pat!(Shift-Tab) => FocusCommand::Prev,
|
key_pat!(Shift-Tab) => FocusCommand::Prev,
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ pub(crate) use ::tek_layout::{
|
||||||
Input, Handle, handle,
|
Input, Handle, handle,
|
||||||
kexp, key_pat, key_event_pat, key_event_expr,
|
kexp, key_pat, key_event_pat, key_event_expr,
|
||||||
tui::{
|
tui::{
|
||||||
Tui, TuiInput, TuiOutput,
|
Tui, TuiIn, TuiOut,
|
||||||
crossterm::{
|
crossterm::{
|
||||||
self,
|
self,
|
||||||
event::{
|
event::{
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ pub struct TrackView<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Content<Tui> for TrackView<'a> {
|
impl<'a> Content<Tui> for TrackView<'a> {
|
||||||
fn render (&self, to: &mut TuiOutput) {
|
fn render (&self, to: &mut TuiOut) {
|
||||||
todo!();
|
todo!();
|
||||||
//let mut area = to.area();
|
//let mut area = to.area();
|
||||||
//if let Some(chain) = self.chain {
|
//if let Some(chain) = self.chain {
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ impl Plugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Content<Tui> for Plugin {
|
impl Content<Tui> for Plugin {
|
||||||
fn render (&self, to: &mut TuiOutput) {
|
fn render (&self, to: &mut TuiOut) {
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let [x, y, _, height] = area;
|
let [x, y, _, height] = area;
|
||||||
let mut width = 20u16;
|
let mut width = 20u16;
|
||||||
|
|
@ -187,7 +187,7 @@ impl Content<Tui> for Plugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_header (state: &Plugin, to: &mut TuiOutput, x: u16, y: u16, w: u16) {
|
fn draw_header (state: &Plugin, to: &mut TuiOut, x: u16, y: u16, w: u16) {
|
||||||
let style = Style::default().gray();
|
let style = Style::default().gray();
|
||||||
let label1 = format!(" {}", state.name);
|
let label1 = format!(" {}", state.name);
|
||||||
to.blit(&label1, x + 1, y, Some(style.white().bold()));
|
to.blit(&label1, x + 1, y, Some(style.white().bold()));
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ input_to_command!(PoolCommand:<Tui>|state: PoolModel,input|match state.phrases_m
|
||||||
_ => to_phrases_command(state, input)?
|
_ => to_phrases_command(state, input)?
|
||||||
});
|
});
|
||||||
|
|
||||||
fn to_phrases_command (state: &PoolModel, input: &TuiInput) -> Option<PoolCommand> {
|
fn to_phrases_command (state: &PoolModel, input: &TuiIn) -> Option<PoolCommand> {
|
||||||
use KeyCode::{Up, Down, Delete, Char};
|
use KeyCode::{Up, Down, Delete, Char};
|
||||||
use PoolCommand as Cmd;
|
use PoolCommand as Cmd;
|
||||||
let index = state.phrase_index();
|
let index = state.phrase_index();
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ impl Command<PoolModel> for PhraseRenameCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InputToCommand<Tui, PoolModel> for PhraseRenameCommand {
|
impl InputToCommand<Tui, PoolModel> for PhraseRenameCommand {
|
||||||
fn input_to_command (state: &PoolModel, from: &TuiInput) -> Option<Self> {
|
fn input_to_command (state: &PoolModel, from: &TuiIn) -> Option<Self> {
|
||||||
use KeyCode::{Char, Backspace, Enter, Esc};
|
use KeyCode::{Char, Backspace, Enter, Esc};
|
||||||
if let Some(PoolMode::Rename(_, ref old_name)) = state.phrases_mode() {
|
if let Some(PoolMode::Rename(_, ref old_name)) = state.phrases_mode() {
|
||||||
Some(match from.event() {
|
Some(match from.event() {
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ fn scan (dir: &PathBuf) -> Usually<(Vec<OsString>, Vec<OsString>)> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_sample (
|
fn draw_sample (
|
||||||
to: &mut TuiOutput, x: u16, y: u16, note: Option<&u7>, sample: &Sample, focus: bool
|
to: &mut TuiOut, x: u16, y: u16, note: Option<&u7>, sample: &Sample, focus: bool
|
||||||
) -> Usually<usize> {
|
) -> Usually<usize> {
|
||||||
let style = if focus { Style::default().green() } else { Style::default() };
|
let style = if focus { Style::default().green() } else { Style::default() };
|
||||||
if focus {
|
if focus {
|
||||||
|
|
@ -171,7 +171,7 @@ fn draw_sample (
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Content<Tui> for AddSampleModal {
|
impl Content<Tui> for AddSampleModal {
|
||||||
fn render (&self, to: &mut TuiOutput) {
|
fn render (&self, to: &mut TuiOut) {
|
||||||
todo!()
|
todo!()
|
||||||
//let area = to.area();
|
//let area = to.area();
|
||||||
//to.make_dim();
|
//to.make_dim();
|
||||||
|
|
@ -208,7 +208,7 @@ impl Content<Tui> for AddSampleModal {
|
||||||
}
|
}
|
||||||
|
|
||||||
//impl Handle<Tui> for AddSampleModal {
|
//impl Handle<Tui> for AddSampleModal {
|
||||||
//fn handle (&mut self, from: &TuiInput) -> Perhaps<bool> {
|
//fn handle (&mut self, from: &TuiIn) -> Perhaps<bool> {
|
||||||
//if from.handle_keymap(self, KEYMAP_ADD_SAMPLE)? {
|
//if from.handle_keymap(self, KEYMAP_ADD_SAMPLE)? {
|
||||||
//return Ok(Some(true))
|
//return Ok(Some(true))
|
||||||
//}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ impl<W: Content<Tui>> Content<Tui> for Bold<W> {
|
||||||
fn content (&self) -> impl Content<Tui> {
|
fn content (&self) -> impl Content<Tui> {
|
||||||
Some(&self.1)
|
Some(&self.1)
|
||||||
}
|
}
|
||||||
fn render (&self, to: &mut TuiOutput) {
|
fn render (&self, to: &mut TuiOut) {
|
||||||
to.fill_bold(to.area(), self.0);
|
to.fill_bold(to.area(), self.0);
|
||||||
self.1.render(to)
|
self.1.render(to)
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +38,7 @@ impl<W: Content<Tui>> Content<Tui> for Foreground<W> {
|
||||||
fn content (&self) -> impl Content<Tui> {
|
fn content (&self) -> impl Content<Tui> {
|
||||||
Some(&self.1)
|
Some(&self.1)
|
||||||
}
|
}
|
||||||
fn render (&self, to: &mut TuiOutput) {
|
fn render (&self, to: &mut TuiOut) {
|
||||||
to.fill_fg(to.area(), self.0);
|
to.fill_fg(to.area(), self.0);
|
||||||
self.1.render(to)
|
self.1.render(to)
|
||||||
}
|
}
|
||||||
|
|
@ -50,7 +50,7 @@ impl<W: Content<Tui>> Content<Tui> for Background<W> {
|
||||||
fn content (&self) -> impl Content<Tui> {
|
fn content (&self) -> impl Content<Tui> {
|
||||||
Some(&self.1)
|
Some(&self.1)
|
||||||
}
|
}
|
||||||
fn render (&self, to: &mut TuiOutput) {
|
fn render (&self, to: &mut TuiOut) {
|
||||||
to.fill_bg(to.area(), self.0);
|
to.fill_bg(to.area(), self.0);
|
||||||
self.1.render(to)
|
self.1.render(to)
|
||||||
}
|
}
|
||||||
|
|
@ -62,7 +62,7 @@ impl Content<Tui> for Styled<&str> {
|
||||||
fn content (&self) -> impl Content<Tui> {
|
fn content (&self) -> impl Content<Tui> {
|
||||||
Some(&self.1)
|
Some(&self.1)
|
||||||
}
|
}
|
||||||
fn render (&self, to: &mut TuiOutput) {
|
fn render (&self, to: &mut TuiOut) {
|
||||||
// FIXME
|
// FIXME
|
||||||
let [x, y, ..] = to.area();
|
let [x, y, ..] = to.area();
|
||||||
//let [w, h] = self.min_size(to.area().wh())?.unwrap();
|
//let [w, h] = self.min_size(to.area().wh())?.unwrap();
|
||||||
|
|
|
||||||
|
|
@ -180,12 +180,12 @@ command!(|self:TransportCommand,state:TransportTui|match self {
|
||||||
//Ok(None)
|
//Ok(None)
|
||||||
//});
|
//});
|
||||||
impl InputToCommand<Tui, TransportTui> for TransportCommand {
|
impl InputToCommand<Tui, TransportTui> for TransportCommand {
|
||||||
fn input_to_command (state: &TransportTui, input: &TuiInput) -> Option<Self> {
|
fn input_to_command (state: &TransportTui, input: &TuiIn) -> Option<Self> {
|
||||||
to_transport_command(state, input)
|
to_transport_command(state, input)
|
||||||
.or_else(||to_focus_command(input).map(TransportCommand::Focus))
|
.or_else(||to_focus_command(input).map(TransportCommand::Focus))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn to_transport_command <T, U> (state: &T, input: &TuiInput) -> Option<TransportCommand>
|
pub fn to_transport_command <T, U> (state: &T, input: &TuiIn) -> Option<TransportCommand>
|
||||||
where
|
where
|
||||||
T: TransportControl<U>,
|
T: TransportControl<U>,
|
||||||
U: Into<Option<TransportFocus>>,
|
U: Into<Option<TransportFocus>>,
|
||||||
|
|
@ -228,7 +228,7 @@ where
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
fn to_bpm_command (input: &TuiInput, bpm: f64) -> Option<TransportCommand> {
|
fn to_bpm_command (input: &TuiIn, bpm: f64) -> Option<TransportCommand> {
|
||||||
Some(match input.event() {
|
Some(match input.event() {
|
||||||
key_pat!(Char(',')) => Clock(SetBpm(bpm - 1.0)),
|
key_pat!(Char(',')) => Clock(SetBpm(bpm - 1.0)),
|
||||||
key_pat!(Char('.')) => Clock(SetBpm(bpm + 1.0)),
|
key_pat!(Char('.')) => Clock(SetBpm(bpm + 1.0)),
|
||||||
|
|
@ -237,7 +237,7 @@ fn to_bpm_command (input: &TuiInput, bpm: f64) -> Option<TransportCommand> {
|
||||||
_ => return None,
|
_ => return None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
fn to_quant_command (input: &TuiInput, quant: &Quantize) -> Option<TransportCommand> {
|
fn to_quant_command (input: &TuiIn, quant: &Quantize) -> Option<TransportCommand> {
|
||||||
Some(match input.event() {
|
Some(match input.event() {
|
||||||
key_pat!(Char(',')) => Clock(SetQuant(quant.prev())),
|
key_pat!(Char(',')) => Clock(SetQuant(quant.prev())),
|
||||||
key_pat!(Char('.')) => Clock(SetQuant(quant.next())),
|
key_pat!(Char('.')) => Clock(SetQuant(quant.next())),
|
||||||
|
|
@ -246,7 +246,7 @@ fn to_quant_command (input: &TuiInput, quant: &Quantize) -> Option<TransportComm
|
||||||
_ => return None,
|
_ => return None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
fn to_sync_command (input: &TuiInput, sync: &LaunchSync) -> Option<TransportCommand> {
|
fn to_sync_command (input: &TuiIn, sync: &LaunchSync) -> Option<TransportCommand> {
|
||||||
Some(match input.event() {
|
Some(match input.event() {
|
||||||
key_pat!(Char(',')) => Clock(SetSync(sync.prev())),
|
key_pat!(Char(',')) => Clock(SetSync(sync.prev())),
|
||||||
key_pat!(Char('.')) => Clock(SetSync(sync.next())),
|
key_pat!(Char('.')) => Clock(SetSync(sync.next())),
|
||||||
|
|
@ -255,7 +255,7 @@ fn to_sync_command (input: &TuiInput, sync: &LaunchSync) -> Option<TransportComm
|
||||||
_ => return None,
|
_ => return None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
fn to_seek_command (input: &TuiInput) -> Option<TransportCommand> {
|
fn to_seek_command (input: &TuiIn) -> Option<TransportCommand> {
|
||||||
Some(match input.event() {
|
Some(match input.event() {
|
||||||
key_pat!(Char(',')) => todo!("transport seek bar"),
|
key_pat!(Char(',')) => todo!("transport seek bar"),
|
||||||
key_pat!(Char('.')) => todo!("transport seek bar"),
|
key_pat!(Char('.')) => todo!("transport seek bar"),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue