Lots + MIDI implementation
This commit is contained in:
@@ -6,6 +6,7 @@ use ratatui::Frame;
|
||||
|
||||
use crate::app::App;
|
||||
use crate::engine::LinkState;
|
||||
use crate::midi;
|
||||
use crate::state::OptionsFocus;
|
||||
use crate::theme;
|
||||
|
||||
@@ -73,6 +74,32 @@ pub fn render(frame: &mut Frame, app: &App, link: &LinkState, area: Rect) {
|
||||
let tempo_style = Style::new().fg(theme.values.tempo).add_modifier(Modifier::BOLD);
|
||||
let value_style = Style::new().fg(theme.values.value);
|
||||
|
||||
// MIDI device lists
|
||||
let midi_outputs = midi::list_midi_outputs();
|
||||
let midi_inputs = midi::list_midi_inputs();
|
||||
|
||||
let midi_out_display = if let Some(idx) = app.midi.selected_output {
|
||||
midi_outputs
|
||||
.get(idx)
|
||||
.map(|d| d.name.as_str())
|
||||
.unwrap_or("(disconnected)")
|
||||
} else if midi_outputs.is_empty() {
|
||||
"(none found)"
|
||||
} else {
|
||||
"(not connected)"
|
||||
};
|
||||
|
||||
let midi_in_display = if let Some(idx) = app.midi.selected_input {
|
||||
midi_inputs
|
||||
.get(idx)
|
||||
.map(|d| d.name.as_str())
|
||||
.unwrap_or("(disconnected)")
|
||||
} else if midi_inputs.is_empty() {
|
||||
"(none found)"
|
||||
} else {
|
||||
"(not connected)"
|
||||
};
|
||||
|
||||
// Build flat list of all lines
|
||||
let lines: Vec<Line> = vec![
|
||||
// DISPLAY section (lines 0-8)
|
||||
@@ -143,12 +170,19 @@ pub fn render(frame: &mut Frame, app: &App, link: &LinkState, area: Rect) {
|
||||
render_option_line("Quantum", &quantum_str, focus == OptionsFocus::Quantum, &theme),
|
||||
// Blank line (line 16)
|
||||
Line::from(""),
|
||||
// SESSION section (lines 17-22)
|
||||
// SESSION section (lines 17-20)
|
||||
render_section_header("SESSION", &theme),
|
||||
render_divider(content_width, &theme),
|
||||
render_readonly_line("Tempo", &tempo_str, tempo_style, &theme),
|
||||
render_readonly_line("Beat", &beat_str, value_style, &theme),
|
||||
render_readonly_line("Phase", &phase_str, value_style, &theme),
|
||||
// Blank line (line 22)
|
||||
Line::from(""),
|
||||
// MIDI section (lines 23-26)
|
||||
render_section_header("MIDI", &theme),
|
||||
render_divider(content_width, &theme),
|
||||
render_option_line("Output", midi_out_display, focus == OptionsFocus::MidiOutput, &theme),
|
||||
render_option_line("Input", midi_in_display, focus == OptionsFocus::MidiInput, &theme),
|
||||
];
|
||||
|
||||
let total_lines = lines.len();
|
||||
@@ -166,6 +200,8 @@ pub fn render(frame: &mut Frame, app: &App, link: &LinkState, area: Rect) {
|
||||
OptionsFocus::LinkEnabled => 12,
|
||||
OptionsFocus::StartStopSync => 13,
|
||||
OptionsFocus::Quantum => 14,
|
||||
OptionsFocus::MidiOutput => 25,
|
||||
OptionsFocus::MidiInput => 26,
|
||||
};
|
||||
|
||||
// Calculate scroll offset to keep focused line visible (centered when possible)
|
||||
|
||||
@@ -70,6 +70,7 @@ fn compute_stack_display(lines: &[String], editor: &cagire_ratatui::Editor, cach
|
||||
speed: 1.0,
|
||||
fill: false,
|
||||
nudge_secs: 0.0,
|
||||
cc_memory: None,
|
||||
};
|
||||
|
||||
match forth.evaluate(&script, &ctx) {
|
||||
|
||||
Reference in New Issue
Block a user