#ifndef JUCI_TERMINAL_H_ #define JUCI_TERMINAL_H_ #include #include #include "gtkmm.h" #include #include #include #include class Terminal : public Gtk::HBox { public: class InProgress { public: InProgress(const std::string& start_msg); ~InProgress(); void done(const std::string& msg); void cancel(const std::string& msg); private: void start(const std::string& msg); int line_nr; std::atomic stop; Glib::Dispatcher waiting_print; std::thread wait_thread; }; Terminal(); bool execute(const std::string &command, const std::string &path=""); void async_execute(const std::string &command, const std::string &path="", std::function callback=nullptr); std::unordered_map > async_pid_descriptors; std::unordered_map async_pid_status; std::mutex async_pid_mutex; int print(std::string message); void print(int line_nr, std::string message); std::shared_ptr print_in_progress(std::string start_msg); private: Gtk::TextView text_view; Gtk::ScrolledWindow scrolled_window; Glib::Dispatcher async_execute_print; std::string async_execute_print_string; std::mutex async_execute_print_string_mutex; }; #endif // JUCI_TERMINAL_H_