mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
move Debug impls next to structs
This commit is contained in:
parent
71e19c9800
commit
763063f4ed
5 changed files with 47 additions and 50 deletions
|
|
@ -64,7 +64,7 @@ impl From<&Arc<Transport>> for ClockModel {
|
||||||
|
|
||||||
impl std::fmt::Debug for ClockModel {
|
impl std::fmt::Debug for ClockModel {
|
||||||
fn fmt (&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
|
fn fmt (&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
|
||||||
f.debug_struct("editor")
|
f.debug_struct("ClockModel")
|
||||||
.field("playing", &self.playing)
|
.field("playing", &self.playing)
|
||||||
.field("started", &self.started)
|
.field("started", &self.started)
|
||||||
.field("current", &self.current)
|
.field("current", &self.current)
|
||||||
|
|
|
||||||
|
|
@ -45,23 +45,6 @@ submod! {
|
||||||
tui_view_transport
|
tui_view_transport
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_focus_command (input: &TuiInput) -> Option<FocusCommand> {
|
|
||||||
use KeyCode::{Tab, BackTab, Up, Down, Left, Right, Enter, Esc};
|
|
||||||
Some(match input.event() {
|
|
||||||
key!(Tab) => FocusCommand::Next,
|
|
||||||
key!(Shift-Tab) => FocusCommand::Prev,
|
|
||||||
key!(BackTab) => FocusCommand::Prev,
|
|
||||||
key!(Shift-BackTab) => FocusCommand::Prev,
|
|
||||||
key!(Up) => FocusCommand::Up,
|
|
||||||
key!(Down) => FocusCommand::Down,
|
|
||||||
key!(Left) => FocusCommand::Left,
|
|
||||||
key!(Right) => FocusCommand::Right,
|
|
||||||
key!(Enter) => FocusCommand::Enter,
|
|
||||||
key!(Esc) => FocusCommand::Exit,
|
|
||||||
_ => return None
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct TuiTheme;
|
pub struct TuiTheme;
|
||||||
|
|
||||||
impl TuiTheme {
|
impl TuiTheme {
|
||||||
|
|
@ -91,43 +74,28 @@ impl TuiTheme {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use std::fmt::{Debug, Formatter, Error};
|
|
||||||
type DebugResult = std::result::Result<(), Error>;
|
|
||||||
|
|
||||||
impl Debug for TransportTui {
|
|
||||||
fn fmt (&self, f: &mut Formatter<'_>) -> DebugResult {
|
|
||||||
f.debug_struct("Measure")
|
|
||||||
.field("jack", &self.jack)
|
|
||||||
.field("size", &self.size)
|
|
||||||
.field("cursor", &self.cursor)
|
|
||||||
.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Debug for PhraseEditorModel {
|
|
||||||
fn fmt (&self, f: &mut Formatter<'_>) -> DebugResult {
|
|
||||||
f.debug_struct("editor")
|
|
||||||
.field("note_axis", &self.time_axis)
|
|
||||||
.field("time_axis", &self.note_axis)
|
|
||||||
.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Debug for PhrasePlayerModel {
|
|
||||||
fn fmt (&self, f: &mut Formatter<'_>) -> DebugResult {
|
|
||||||
f.debug_struct("editor")
|
|
||||||
.field("clock", &self.clock)
|
|
||||||
.field("play_phrase", &self.play_phrase)
|
|
||||||
.field("next_phrase", &self.next_phrase)
|
|
||||||
.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait FocusWrap<T> {
|
pub trait FocusWrap<T> {
|
||||||
fn wrap <'a, W: Widget<Engine = Tui>> (self, focus: T, content: &'a W)
|
fn wrap <'a, W: Widget<Engine = Tui>> (self, focus: T, content: &'a W)
|
||||||
-> impl Widget<Engine = Tui> + 'a;
|
-> impl Widget<Engine = Tui> + 'a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn to_focus_command (input: &TuiInput) -> Option<FocusCommand> {
|
||||||
|
use KeyCode::{Tab, BackTab, Up, Down, Left, Right, Enter, Esc};
|
||||||
|
Some(match input.event() {
|
||||||
|
key!(Tab) => FocusCommand::Next,
|
||||||
|
key!(Shift-Tab) => FocusCommand::Prev,
|
||||||
|
key!(BackTab) => FocusCommand::Prev,
|
||||||
|
key!(Shift-BackTab) => FocusCommand::Prev,
|
||||||
|
key!(Up) => FocusCommand::Up,
|
||||||
|
key!(Down) => FocusCommand::Down,
|
||||||
|
key!(Left) => FocusCommand::Left,
|
||||||
|
key!(Right) => FocusCommand::Right,
|
||||||
|
key!(Enter) => FocusCommand::Enter,
|
||||||
|
key!(Esc) => FocusCommand::Exit,
|
||||||
|
_ => return None
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[macro_export] macro_rules! impl_focus {
|
#[macro_export] macro_rules! impl_focus {
|
||||||
($Struct:ident $Focus:ident $Grid:expr) => {
|
($Struct:ident $Focus:ident $Grid:expr) => {
|
||||||
impl HasFocus for $Struct {
|
impl HasFocus for $Struct {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,16 @@ pub struct TransportTui {
|
||||||
pub focus: FocusState<TransportFocus>,
|
pub focus: FocusState<TransportFocus>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for TransportTui {
|
||||||
|
fn fmt (&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
|
||||||
|
f.debug_struct("TransportTui")
|
||||||
|
.field("jack", &self.jack)
|
||||||
|
.field("size", &self.size)
|
||||||
|
.field("cursor", &self.cursor)
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Create app state from JACK handle.
|
/// Create app state from JACK handle.
|
||||||
impl TryFrom<&Arc<RwLock<JackClient>>> for TransportTui {
|
impl TryFrom<&Arc<RwLock<JackClient>>> for TransportTui {
|
||||||
type Error = Box<dyn std::error::Error>;
|
type Error = Box<dyn std::error::Error>;
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,15 @@ pub struct PhraseEditorModel {
|
||||||
pub(crate) size: Measure<Tui>
|
pub(crate) size: Measure<Tui>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for PhraseEditorModel {
|
||||||
|
fn fmt (&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
|
||||||
|
f.debug_struct("PhraseEditorModel")
|
||||||
|
.field("note_axis", &self.time_axis)
|
||||||
|
.field("time_axis", &self.note_axis)
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for PhraseEditorModel {
|
impl Default for PhraseEditorModel {
|
||||||
fn default () -> Self {
|
fn default () -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,16 @@ pub struct PhrasePlayerModel {
|
||||||
pub note_buf: Vec<u8>,
|
pub note_buf: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for PhrasePlayerModel {
|
||||||
|
fn fmt (&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
|
||||||
|
f.debug_struct("PhrasePlayerModel")
|
||||||
|
.field("clock", &self.clock)
|
||||||
|
.field("play_phrase", &self.play_phrase)
|
||||||
|
.field("next_phrase", &self.next_phrase)
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<&ClockModel> for PhrasePlayerModel {
|
impl From<&ClockModel> for PhrasePlayerModel {
|
||||||
fn from (clock: &ClockModel) -> Self {
|
fn from (clock: &ClockModel) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue