|
|
|
@ -81,9 +81,9 @@ int Terminal::process(const std::string &command, const boost::filesystem::path |
|
|
|
std::unique_ptr<TinyProcessLib::Process> process; |
|
|
|
std::unique_ptr<TinyProcessLib::Process> process; |
|
|
|
if(use_pipes) |
|
|
|
if(use_pipes) |
|
|
|
process = std::make_unique<TinyProcessLib::Process>(command, path.string(), [this](const char *bytes, size_t n) { |
|
|
|
process = std::make_unique<TinyProcessLib::Process>(command, path.string(), [this](const char *bytes, size_t n) { |
|
|
|
sync_print(std::string(bytes, n)); |
|
|
|
async_print(std::string(bytes, n)); |
|
|
|
}, [this](const char *bytes, size_t n) { |
|
|
|
}, [this](const char *bytes, size_t n) { |
|
|
|
sync_print(std::string(bytes, n), true); |
|
|
|
async_print(std::string(bytes, n), true); |
|
|
|
}); |
|
|
|
}); |
|
|
|
else |
|
|
|
else |
|
|
|
process = std::make_unique<TinyProcessLib::Process>(command, path.string()); |
|
|
|
process = std::make_unique<TinyProcessLib::Process>(command, path.string()); |
|
|
|
@ -111,7 +111,7 @@ int Terminal::process(std::istream &stdin_stream, std::ostream &stdout_stream, c |
|
|
|
if(stderr_stream) |
|
|
|
if(stderr_stream) |
|
|
|
stderr_stream->write(bytes, n); |
|
|
|
stderr_stream->write(bytes, n); |
|
|
|
else |
|
|
|
else |
|
|
|
sync_print(std::string(bytes, n), true); |
|
|
|
async_print(std::string(bytes, n), true); |
|
|
|
}, true); |
|
|
|
}, true); |
|
|
|
|
|
|
|
|
|
|
|
if(process.get_id() <= 0) { |
|
|
|
if(process.get_id() <= 0) { |
|
|
|
@ -140,11 +140,25 @@ void Terminal::async_process(const std::string &command, const boost::filesystem |
|
|
|
LockGuard lock(processes_mutex); |
|
|
|
LockGuard lock(processes_mutex); |
|
|
|
stdin_buffer.clear(); |
|
|
|
stdin_buffer.clear(); |
|
|
|
auto process = std::make_shared<TinyProcessLib::Process>(command, path.string(), [this, quiet](const char *bytes, size_t n) { |
|
|
|
auto process = std::make_shared<TinyProcessLib::Process>(command, path.string(), [this, quiet](const char *bytes, size_t n) { |
|
|
|
if(!quiet) |
|
|
|
if(!quiet) { |
|
|
|
sync_print(std::string(bytes, n)); |
|
|
|
// Print stdout message sequentially to avoid the GUI becoming unresponsive
|
|
|
|
|
|
|
|
std::promise<void> message_printed; |
|
|
|
|
|
|
|
dispatcher.post([message = std::string(bytes, n), &message_printed]() mutable { |
|
|
|
|
|
|
|
Terminal::get().print(std::move(message)); |
|
|
|
|
|
|
|
message_printed.set_value(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
message_printed.get_future().get(); |
|
|
|
|
|
|
|
} |
|
|
|
}, [this, quiet](const char *bytes, size_t n) { |
|
|
|
}, [this, quiet](const char *bytes, size_t n) { |
|
|
|
if(!quiet) |
|
|
|
if(!quiet) { |
|
|
|
sync_print(std::string(bytes, n), true); |
|
|
|
// Print stderr message sequentially to avoid the GUI becoming unresponsive
|
|
|
|
|
|
|
|
std::promise<void> message_printed; |
|
|
|
|
|
|
|
dispatcher.post([message = std::string(bytes, n), &message_printed]() mutable { |
|
|
|
|
|
|
|
Terminal::get().print(std::move(message), true); |
|
|
|
|
|
|
|
message_printed.set_value(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
message_printed.get_future().get(); |
|
|
|
|
|
|
|
} |
|
|
|
}, true); |
|
|
|
}, true); |
|
|
|
auto pid = process->get_id(); |
|
|
|
auto pid = process->get_id(); |
|
|
|
if(pid <= 0) { |
|
|
|
if(pid <= 0) { |
|
|
|
@ -328,15 +342,6 @@ void Terminal::async_print(std::string message, bool bold) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Terminal::sync_print(std::string message, bool bold) { |
|
|
|
|
|
|
|
std::promise<void> message_printed; |
|
|
|
|
|
|
|
dispatcher.post([message = std::move(message), bold, &message_printed]() mutable { |
|
|
|
|
|
|
|
Terminal::get().print(std::move(message), bold); |
|
|
|
|
|
|
|
message_printed.set_value(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
message_printed.get_future().get(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Terminal::configure() { |
|
|
|
void Terminal::configure() { |
|
|
|
link_tag->property_foreground_rgba() = get_style_context()->get_color(Gtk::StateFlags::STATE_FLAG_LINK); |
|
|
|
link_tag->property_foreground_rgba() = get_style_context()->get_color(Gtk::StateFlags::STATE_FLAG_LINK); |
|
|
|
|
|
|
|
|
|
|
|
|