diff --git a/src/main.rs b/src/main.rs index 268cc56..c1973df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,6 +18,8 @@ use crossbeam::channel::Receiver; use crossbeam::channel::Sender; use crossterm::event::DisableBracketedPaste; use crossterm::event::EnableBracketedPaste; +use crossterm::event::KeyEvent; +use crossterm::event::KeyModifiers; use event::EventMessage; use parking_lot::RwLock; use ropey::Rope; @@ -315,7 +317,7 @@ fn init_message_passing() -> (Receiver, Sender) { #[allow(clippy::too_many_lines)] #[cfg_attr(debug_assertions, instrument(skip(terminal, app)))] -fn run_app(terminal: &mut Terminal, app: App) -> Result> { +fn run_app(terminal: &mut Terminal, mut app: App) -> Result> { // When starting the app, ensure the command runs at least once { let mut command_options = app.command_options.write(); @@ -343,6 +345,22 @@ fn run_app(terminal: &mut Terminal, app: App) -> Result { + // Move stdout to stdin + if let Some(result) = &command_options.command_result { + app.text_orig = Arc::new(Some(result.stdout.to_string())); + app.text_orig_rope = Some(result.stdout.clone()); + command_options.cmdline = String::new(); + command_options.cmdline_position = 0; + if command_options.autorun { + app.run_command()?; + } + } + } Event::Key(key) => match key.code { KeyCode::Esc => { return Ok(None); diff --git a/src/ui.rs b/src/ui.rs index 43b2bfb..9d8ccaa 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -88,9 +88,8 @@ pub fn draw(f: &mut Frame, app: &App) { ui_output(f, chunks[1], &mut render_states, command_result); } else { f.render_widget( - Block::default().title("Output") - .borders(Borders::ALL), - chunks[1] + Block::default().title("Output").borders(Borders::ALL), + chunks[1], ) }