mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-10-08 18:56:42 +02:00
add (data) to config
This commit is contained in:
parent
353a20bab9
commit
b6f7d2d361
6 changed files with 142 additions and 96 deletions
39
src/tek.rs
39
src/tek.rs
|
|
@ -102,10 +102,10 @@ pub struct App {
|
|||
pub size: Sizer,
|
||||
/// Performance counter
|
||||
pub perf: PerfModel,
|
||||
/// Available view modes and input bindings
|
||||
/// Configuration watcher
|
||||
pub watch: Arc<Watch>,
|
||||
/// Currently active modes
|
||||
pub stack: Arc<RwLock<Vec<Arc<str>>>>,
|
||||
pub stack: Arc<RwLock<Vec<Frame>>>,
|
||||
/// Undo history
|
||||
pub history: Vec<(AppCmd, Option<AppCmd>)>,
|
||||
/// Dialog overlay
|
||||
|
|
@ -132,7 +132,7 @@ impl App {
|
|||
exit: Option<Exit>,
|
||||
project: Project,
|
||||
watch: impl Into<Option<Arc<Watch>>>,
|
||||
modes: impl Into<Option<Vec<Arc<str>>>>,
|
||||
modes: impl Into<Option<Vec<Frame>>>,
|
||||
) -> Self {
|
||||
App {
|
||||
exit: exit.unwrap_or_default(),
|
||||
|
|
@ -150,11 +150,12 @@ impl App {
|
|||
pub use self::conf::*; mod conf {
|
||||
use crate::*;
|
||||
|
||||
mod axis; pub use self::axis::*;
|
||||
mod bind; pub use self::bind::*;
|
||||
mod lang; pub use self::lang::*;
|
||||
mod mode; pub use self::mode::*;
|
||||
mod view; pub use self::view::*;
|
||||
mod axis; pub use self::axis::*;
|
||||
mod bind; pub use self::bind::*;
|
||||
mod lang; pub use self::lang::*;
|
||||
mod mode; pub use self::mode::*;
|
||||
mod stack; pub use self::stack::*;
|
||||
mod view; pub use self::view::*;
|
||||
|
||||
pub trait HasError<T> {
|
||||
fn error (&self) -> &RwLock<Option<T>>;
|
||||
|
|
@ -408,8 +409,12 @@ fn tek_jack_event (state: &mut App, event: JackEvent) {
|
|||
PortRegistration(_id, false) => {
|
||||
/*println!("\rport del: {id}")*/
|
||||
},
|
||||
PortsConnected(_a, _b, true) => { /*println!("\rport conn: {a} {b}")*/ },
|
||||
PortsConnected(_a, _b, false) => { /*println!("\rport disc: {a} {b}")*/ },
|
||||
PortsConnected(_a, _b, true) => {
|
||||
/*println!("\rport conn: {a} {b}")*/
|
||||
},
|
||||
PortsConnected(_a, _b, false) => {
|
||||
/*println!("\rport disc: {a} {b}")*/
|
||||
},
|
||||
ClientRegistration(_id, true) => {},
|
||||
ClientRegistration(_id, false) => {},
|
||||
ThreadInit => {},
|
||||
|
|
@ -863,7 +868,7 @@ impl Draw<Tui> for App {
|
|||
#[cfg(feature = "prof2")] profiling::scope!("App::draw");
|
||||
self.perf.cycle(&mut |_|{
|
||||
draw_error(to, self.error.as_ref())?;
|
||||
draw_mode_stack(to, &self)?;
|
||||
draw_stack(to, &self)?;
|
||||
view_debug(&*self.stack.read(), &self.perf, &self.size).draw(to)?;
|
||||
#[cfg(feature = "prof2")] profiling::finish_frame!();
|
||||
Ok(Some(to.area().into()))
|
||||
|
|
@ -871,7 +876,7 @@ impl Draw<Tui> for App {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait DispatchBind<C: Clone>: HasBinds + HasModeStack + HasModes + Namespace<C> {
|
||||
pub trait DispatchBind<C: Clone>: HasBinds + HasStack + HasModes + Namespace<C> {
|
||||
fn dispatch_bind (&mut self, input: &TuiEvent) -> Usually<()> {
|
||||
if let Some(bindings) = self.dispatch_bind_match(input) {
|
||||
return self.dispatch_bind_exec(bindings)
|
||||
|
|
@ -897,7 +902,7 @@ pub trait DispatchBind<C: Clone>: HasBinds + HasModeStack + HasModes + Namespace
|
|||
/// assert!(app.dispatch_bind_match(&"@up".into()).is_none());
|
||||
///
|
||||
/// // Push mode onto stack:
|
||||
/// app.mode_stack_push("Test");
|
||||
/// app.stack_push("Test");
|
||||
/// assert!(app.dispatch_bind_match(&"@left".into()).is_none());
|
||||
/// assert!(app.dispatch_bind_match(&"@enter".into()).is_some());
|
||||
/// assert!(app.dispatch_bind_match(&"@escape".into()).is_some());
|
||||
|
|
@ -905,7 +910,7 @@ pub trait DispatchBind<C: Clone>: HasBinds + HasModeStack + HasModes + Namespace
|
|||
/// assert!(app.dispatch_bind_match(&"@up".into()).is_some());
|
||||
/// ```
|
||||
fn dispatch_bind_match (&self, input: &TuiEvent) -> Option<Arc<[Binding<Arc<str>>]>> {
|
||||
for name in self.mode_stack().read().iter().rev() {
|
||||
for Frame { name, data } in self.stack().read().iter().rev() {
|
||||
if let Some(mode) = self.modes_get(name).as_ref().map(Arc::clone) {
|
||||
if let Some(binds) = self.dispatch_bind_match_axis(mode.as_ref(), input) {
|
||||
return Some(binds)
|
||||
|
|
@ -924,7 +929,7 @@ pub trait DispatchBind<C: Clone>: HasBinds + HasModeStack + HasModes + Namespace
|
|||
/// )).unwrap();
|
||||
/// assert!(app.dispatch_bind_match(&"@down".into()).is_none());
|
||||
/// assert!(app.dispatch_bind_match(&"@up".into()).is_none());
|
||||
/// app.mode_stack_push("Test");
|
||||
/// app.stack_push("Test");
|
||||
/// assert!(app.dispatch_bind_match(&"@down".into()).is_some());
|
||||
/// assert!(app.dispatch_bind_match(&"@up".into()).is_some());
|
||||
/// ```
|
||||
|
|
@ -950,7 +955,7 @@ pub trait DispatchBind<C: Clone>: HasBinds + HasModeStack + HasModes + Namespace
|
|||
/// )).unwrap();
|
||||
/// assert!(app.dispatch_bind_match(&"@enter".into()).is_none());
|
||||
/// assert!(app.dispatch_bind_match(&"@escape".into()).is_none());
|
||||
/// app.mode_stack_push("Test");
|
||||
/// app.stack_push("Test");
|
||||
/// assert!(app.dispatch_bind_match(&"@enter".into()).is_some());
|
||||
/// assert!(app.dispatch_bind_match(&"@escape".into()).is_some());
|
||||
/// ```
|
||||
|
|
@ -958,11 +963,11 @@ pub trait DispatchBind<C: Clone>: HasBinds + HasModeStack + HasModes + Namespace
|
|||
-> Option<Arc<[Binding<Arc<str>>]>>
|
||||
{
|
||||
for id in mode.keys.iter() {
|
||||
println!("{input:?} {id:?}");
|
||||
if let Some(event_map) = self.binds_find(id)
|
||||
&& let Some(bindings) = event_map.query(input) {
|
||||
return Some(bindings.into())
|
||||
}
|
||||
|
||||
if let Ok(Some(expr)) = id.expr()
|
||||
&& let Ok(Some(head)) = expr.head()
|
||||
&& *input == head.into()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue