Browse Source

Suggestion to #179

merge-requests/365/head
eidheim 10 years ago
parent
commit
670d4bba14
  1. 6
      src/project.cc
  2. 1
      src/source.cc
  3. 19
      src/terminal.cc
  4. 7
      src/terminal.h
  5. 4
      src/window.cc

6
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){

1
src/source.cc

@ -284,7 +284,6 @@ Source::View::View(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::L
tab_str="<space>";
else
tab_str="<tab>";
Terminal::get().print("Tab char and size for file "+file_path.string()+" set to: "+tab_str+", "+std::to_string(tab_char_and_size.second)+".\n");
}
tab_char=tab_char_and_size.first;

19
src/terminal.cc

@ -205,7 +205,14 @@ size_t Terminal::print(const std::string &message, bool bold){
}
std::shared_ptr<Terminal::InProgress> Terminal::print_in_progress(std::string start_msg) {
std::shared_ptr<Terminal::InProgress> in_progress=std::shared_ptr<Terminal::InProgress>(new Terminal::InProgress(start_msg));
auto in_progress=std::shared_ptr<Terminal::InProgress>(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;

7
src/terminal.h

@ -10,10 +10,12 @@
#include <iostream>
#include "process.hpp"
#include "dispatcher.h"
#include <unordered_set>
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<InProgress> 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<InProgress*> in_progresses;
std::mutex in_progresses_mutex;
};
#endif // JUCI_TERMINAL_H_

4
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() {

Loading…
Cancel
Save