Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions src/apps/cli/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl App {
let mut outputs = self.outputs.borrow_mut();
let state = outputs
.entry(id)
.or_insert_with(|| task::Task::new(pty_cols, pty_rows, 1024));
.or_insert_with(|| task::Task::new(id, pty_cols, pty_rows, 1024));
let command = exec::run_code(
code,
size,
Expand Down Expand Up @@ -395,19 +395,15 @@ impl App {
};

let was_alt = state.is_alternate_screen();
exec::handle_stream(state, stream);
let now_alt = state.is_alternate_screen();

// When a full-screen TUI app (vim, less, htop) is active in the
// alternate screen buffer, write its PTY output directly to the
// real terminal so escape sequences (cursor positioning, alt
// screen entry/exit) are processed natively.
if let Stream::Out(s) = stream {
if self.batch_output.is_terminal() && focused && (was_alt || now_alt) {
let _ = io::stdout().write_all(s.as_bytes());
let _ = io::stdout().flush();
match stream {
Stream::Out(text) => {
state.process_output(text, self.batch_output.is_terminal() && focused);
}
_ => {
exec::handle_stream(state, stream);
}
}
let now_alt = state.is_alternate_screen();

// Resize PTY when entering/exiting alternate screen so TUI apps
// get the full terminal dimensions and line-oriented programs get
Expand Down Expand Up @@ -1170,7 +1166,7 @@ echo world
}

fn insert_completed_output(app: &App, id: CodeId, text: &str, exit_code: i32) {
let mut output = task::Task::new(80, 24, 1024);
let mut output = task::Task::new(id, 80, 24, 1024);
exec::handle_stream(&mut output, &Stream::Out(text.to_string()));
exec::handle_stream(&mut output, &Stream::Exit(exit_code));
exec::handle_stream(&mut output, &Stream::End);
Expand Down
8 changes: 5 additions & 3 deletions src/apps/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub fn run_code(
.parser
.parse(&format!("Failed to determine current directory: {e}"));
output.done = true;
output.report_status();
return None;
}
},
Expand All @@ -44,11 +45,13 @@ pub fn run_code(
Ok(exec) => {
let rx = exec.receiver();
output.execution = Some(exec);
output.report_status();
Some(rx)
}
Err(err) => {
output.parser.parse(&err.to_string());
output.done = true;
output.report_status();
None
}
}
Expand All @@ -60,9 +63,7 @@ pub fn run_code(
pub fn handle_stream(output: &mut Task, stream: &Stream) -> bool {
let mut force_rebuild = false;
match stream {
Stream::Out(s) => {
output.parser.parse(s);
}
Stream::Out(s) => output.process_output(s, false),
Stream::Env(envs) => {
output.captured_envs = Some(envs.clone());
}
Expand All @@ -77,6 +78,7 @@ pub fn handle_stream(output: &mut Task, stream: &Stream) -> bool {
Stream::End => {
force_rebuild = !output.done;
output.done = true;
output.report_status();
}
}
force_rebuild
Expand Down
1 change: 1 addition & 0 deletions src/apps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod config;
pub mod exec;
pub mod navigation;
pub mod picker;
mod program_status;
pub mod task;
mod theme;
pub mod tui;
Expand Down
Loading
Loading