Browse Source

Added markdown_command to project preferences

merge-requests/399/head
eidheim 6 years ago
parent
commit
a9d421fff7
  1. 2
      CMakeLists.txt
  2. 1
      src/config.cc
  3. 1
      src/config.h
  4. 3
      src/files.h
  5. 25
      src/project.cc
  6. 2
      src/project.h

2
CMakeLists.txt

@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 2.8.8)
project(juci)
set(JUCI_VERSION "1.5.0.4")
set(JUCI_VERSION "1.5.0.5")
set(CPACK_PACKAGE_NAME "jucipp")
set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim <eidheim@gmail.com>")

1
src/config.cc

@ -203,6 +203,7 @@ void Config::read(const boost::property_tree::ptree &cfg) {
project.clear_terminal_on_compile = cfg.get<bool>("project.clear_terminal_on_compile");
project.ctags_command = cfg.get<std::string>("project.ctags_command");
project.python_command = cfg.get<std::string>("project.python_command");
project.markdown_command = cfg.get<std::string>("project.markdown_command");
terminal.history_size = cfg.get<int>("terminal.history_size");
terminal.font = cfg.get<std::string>("terminal.font");

1
src/config.h

@ -49,6 +49,7 @@ public:
bool clear_terminal_on_compile;
std::string ctags_command;
std::string python_command;
std::string markdown_command;
};
class Source {

3
src/files.h

@ -192,7 +192,8 @@ const std::string default_config_file = R"RAW({
"save_on_compile_or_run": true,
"clear_terminal_on_compile": true,
"ctags_command": "ctags",
"python_command": "PYTHONUNBUFFERED=1 python"
"python_command": "PYTHONUNBUFFERED=1 python",
"markdown_command": "grip -b"
},
"documentation_searches": {
"clang": {

25
src/project.cc

@ -928,28 +928,13 @@ void Project::Clang::recreate_build() {
}
}
Project::Markdown::~Markdown() {
if(!last_temp_path.empty()) {
boost::filesystem::remove(last_temp_path);
last_temp_path = boost::filesystem::path();
}
}
void Project::Markdown::compile_and_run() {
if(!last_temp_path.empty()) {
boost::filesystem::remove(last_temp_path);
last_temp_path = boost::filesystem::path();
}
std::stringstream stdin_stream, stdout_stream;
auto exit_status = Terminal::get().process(stdin_stream, stdout_stream, "command -v grip");
if(exit_status == 0) {
auto command = "grip -b " + filesystem::escape_argument(filesystem::get_short_path(Notebook::get().get_current_view()->file_path).string());
Terminal::get().print("Running: " + command + " in a quiet background process\n");
Terminal::get().async_process(command, "", nullptr, true);
}
else
Terminal::get().print("Warning: install grip to preview Markdown files\n");
auto command = Config::get().project.markdown_command + ' ' + filesystem::escape_argument(filesystem::get_short_path(Notebook::get().get_current_view()->file_path).string());
Terminal::get().async_process(command, "", [command](int exit_status) {
if(exit_status == 127)
Terminal::get().async_print("Error: executable not found: " + command + "\n", true);
}, true);
}
void Project::Python::compile_and_run() {

2
src/project.h

@ -119,9 +119,7 @@ namespace Project {
class Markdown : public Base {
public:
Markdown(std::unique_ptr<Build> &&build) : Base(std::move(build)) {}
~Markdown() override;
boost::filesystem::path last_temp_path;
void compile_and_run() override;
};

Loading…
Cancel
Save