Browse Source

Added python and javascript projects

merge-requests/365/head
eidheim 10 years ago
parent
commit
86927153f9
  1. 9
      src/notebook.cc
  2. 20
      src/project.cc
  3. 20
      src/project.h

9
src/notebook.cc

@ -356,9 +356,12 @@ boost::filesystem::path Notebook::get_current_folder() {
std::unique_ptr<Project> Notebook::get_project() {
if(get_current_page()!=-1) {
if(get_current_view()->language->get_id()=="markdown") {
return std::unique_ptr<Project>(new ProjectMarkDown(*this));
}
if(get_current_view()->language->get_id()=="markdown")
return std::unique_ptr<Project>(new ProjectMarkdown(*this));
if(get_current_view()->language->get_id()=="python")
return std::unique_ptr<Project>(new ProjectPython(*this));
if(get_current_view()->language->get_id()=="js")
return std::unique_ptr<Project>(new ProjectJavaScript(*this));
}
return std::unique_ptr<Project>(new ProjectClang(*this));

20
src/project.cc

@ -381,14 +381,14 @@ void ProjectClang::debug_delete() {
}
#endif
ProjectMarkDown::~ProjectMarkDown() {
ProjectMarkdown::~ProjectMarkdown() {
if(!last_temp_path.empty()) {
boost::filesystem::remove(last_temp_path);
last_temp_path=boost::filesystem::path();
}
}
void ProjectMarkDown::compile_and_run() {
void ProjectMarkdown::compile_and_run() {
if(!last_temp_path.empty()) {
boost::filesystem::remove(last_temp_path);
last_temp_path=boost::filesystem::path();
@ -412,3 +412,19 @@ void ProjectMarkDown::compile_and_run() {
}
}
}
void ProjectPython::compile_and_run() {
auto command="python "+notebook.get_current_view()->file_path.string();
Terminal::get().print("Running "+command+"\n");
Terminal::get().async_process(command, notebook.get_current_view()->file_path.parent_path(), [command](int exit_status) {
Terminal::get().async_print(command+" returned: "+std::to_string(exit_status)+'\n');
});
}
void ProjectJavaScript::compile_and_run() {
auto command="node "+notebook.get_current_view()->file_path.string();
Terminal::get().print("Running "+command+"\n");
Terminal::get().async_process(command, notebook.get_current_view()->file_path.parent_path(), [command](int exit_status) {
Terminal::get().async_print(command+" returned: "+std::to_string(exit_status)+'\n');
});
}

20
src/project.h

@ -69,13 +69,27 @@ public:
void debug_delete() override;
};
class ProjectMarkDown : public Project {
class ProjectMarkdown : public Project {
public:
ProjectMarkDown(Notebook &notebook) : Project(notebook) {}
~ProjectMarkDown();
ProjectMarkdown(Notebook &notebook) : Project(notebook) {}
~ProjectMarkdown();
boost::filesystem::path last_temp_path;
void compile_and_run() override;
};
class ProjectPython : public Project {
public:
ProjectPython(Notebook &notebook) : Project(notebook) {}
void compile_and_run() override;
};
class ProjectJavaScript : public Project {
public:
ProjectJavaScript(Notebook &notebook) : Project(notebook) {}
void compile_and_run() override;
};
#endif // JUCI_PROJECT_H_

Loading…
Cancel
Save