Feat: early mouse support
This commit is contained in:
18
src/main.rs
18
src/main.rs
@@ -20,7 +20,7 @@ use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use clap::Parser;
|
||||
use crossterm::event::{self, DisableBracketedPaste, EnableBracketedPaste, Event};
|
||||
use crossterm::event::{self, DisableBracketedPaste, EnableBracketedPaste, DisableMouseCapture, EnableMouseCapture, Event};
|
||||
use crossterm::terminal::{
|
||||
disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen,
|
||||
};
|
||||
@@ -30,7 +30,7 @@ use ratatui::Terminal;
|
||||
|
||||
use engine::{build_stream, AudioStreamConfig};
|
||||
use init::InitArgs;
|
||||
use input::{handle_key, InputContext, InputResult};
|
||||
use input::{handle_key, handle_mouse, InputContext, InputResult};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "cagire", version, about = "Forth-based live coding sequencer")]
|
||||
@@ -86,6 +86,7 @@ fn main() -> io::Result<()> {
|
||||
|
||||
enable_raw_mode()?;
|
||||
io::stdout().execute(EnableBracketedPaste)?;
|
||||
io::stdout().execute(EnableMouseCapture)?;
|
||||
io::stdout().execute(EnterAlternateScreen)?;
|
||||
let backend = CrosstermBackend::new(io::stdout());
|
||||
let mut terminal = Terminal::new(backend)?;
|
||||
@@ -253,6 +254,18 @@ fn main() -> io::Result<()> {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Event::Mouse(mouse) => {
|
||||
let mut ctx = InputContext {
|
||||
app: &mut app,
|
||||
link: &link,
|
||||
snapshot: &seq_snapshot,
|
||||
playing: &playing,
|
||||
audio_tx: &sequencer.audio_tx,
|
||||
seq_cmd_tx: &sequencer.cmd_tx,
|
||||
nudge_us: &nudge_us,
|
||||
};
|
||||
handle_mouse(&mut ctx, mouse, terminal.get_frame().area());
|
||||
}
|
||||
Event::Paste(text) => {
|
||||
if matches!(app.ui.modal, state::Modal::Editor) {
|
||||
app.editor_ctx.editor.insert_str(&text);
|
||||
@@ -282,6 +295,7 @@ fn main() -> io::Result<()> {
|
||||
}
|
||||
|
||||
disable_raw_mode()?;
|
||||
io::stdout().execute(DisableMouseCapture)?;
|
||||
io::stdout().execute(DisableBracketedPaste)?;
|
||||
io::stdout().execute(LeaveAlternateScreen)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user