diff --git a/src/project.cc b/src/project.cc index c224d6c..4925bb9 100644 --- a/src/project.cc +++ b/src/project.cc @@ -167,6 +167,8 @@ void Project::Clang::compile() { if(default_build_path.empty() || !build->update_default_build()) return; + Terminal::get().clear(); + compiling=true; Terminal::get().print("Compiling project "+build->project_path.string()+"\n"); Terminal::get().async_process(Config::get().project.make_command, default_build_path, [this](int exit_status) { @@ -199,6 +201,8 @@ void Project::Clang::compile_and_run() { arguments=filesystem::escape_argument(arguments); } + Terminal::get().clear(); + compiling=true; Terminal::get().print("Compiling and running "+arguments+"\n"); Terminal::get().async_process(Config::get().project.make_command, default_build_path, [this, arguments, project_path](int exit_status){ @@ -278,6 +282,8 @@ void Project::Clang::debug_start() { } } + Terminal::get().clear(); + debugging=true; Terminal::get().print("Compiling and debugging "+run_arguments+"\n"); Terminal::get().async_process(Config::get().project.make_command, debug_build_path, [this, breakpoints, run_arguments, project_path](int exit_status){ diff --git a/src/source.cc b/src/source.cc index 8376501..c26fc0f 100644 --- a/src/source.cc +++ b/src/source.cc @@ -284,7 +284,6 @@ Source::View::View(const boost::filesystem::path &file_path, Glib::RefPtr Terminal::print_in_progress(std::string start_msg) { - std::shared_ptr in_progress=std::shared_ptr(new Terminal::InProgress(start_msg)); + auto in_progress=std::shared_ptr(new Terminal::InProgress(start_msg), [this](Terminal::InProgress *in_progress) { + in_progresses_mutex.lock(); + in_progresses.erase(in_progress); + in_progresses_mutex.unlock(); + }); + in_progresses_mutex.lock(); + in_progresses.emplace(in_progress.get()); + in_progresses_mutex.unlock(); return in_progress; } @@ -234,6 +241,16 @@ void Terminal::async_print(size_t line_nr, const std::string &message) { }); } +void Terminal::clear() { + in_progresses_mutex.lock(); + for(auto &in_progress: in_progresses) + in_progress->stop=true; + in_progresses_mutex.unlock(); + while(g_main_context_pending(NULL)) + g_main_context_iteration(NULL, false); + get_buffer()->set_text(""); +} + bool Terminal::on_key_press_event(GdkEventKey *event) { processes_mutex.lock(); bool debug_is_running=false; diff --git a/src/terminal.h b/src/terminal.h index dd74ad9..7fd0c20 100644 --- a/src/terminal.h +++ b/src/terminal.h @@ -10,10 +10,12 @@ #include #include "process.hpp" #include "dispatcher.h" +#include class Terminal : public Gtk::TextView { public: class InProgress { + friend class Terminal; public: InProgress(const std::string& start_msg); ~InProgress(); @@ -45,6 +47,8 @@ public: std::shared_ptr print_in_progress(std::string start_msg); void async_print(const std::string &message, bool bold=false); void async_print(size_t line_nr, const std::string &message); + + void clear(); protected: bool on_key_press_event(GdkEventKey *event); private: @@ -56,6 +60,9 @@ private: std::string stdin_buffer; size_t deleted_lines=0; + + std::unordered_set in_progresses; + std::mutex in_progresses_mutex; }; #endif // JUCI_TERMINAL_H_ diff --git a/src/window.cc b/src/window.cc index c20fed2..490680c 100644 --- a/src/window.cc +++ b/src/window.cc @@ -146,6 +146,10 @@ void Window::configure() { style_context->add_provider_for_screen(screen, css_provider, GTK_STYLE_PROVIDER_PRIORITY_SETTINGS); Directories::get().update(); Menu::get().set_keys(); + if(Config::get().source.font.size()>0) { + Terminal::get().override_font(Pango::FontDescription(Config::get().source.font)); + Directories::get().override_font(Pango::FontDescription(Config::get().source.font)); + } } void Window::set_menu_actions() {