|
|
|
@ -1206,6 +1206,52 @@ void Source::View::setup_format_style(bool is_generic_view) { |
|
|
|
|
|
|
|
|
|
|
|
std::stringstream stdin_stream(get_buffer()->get_text()), stdout_stream; |
|
|
|
std::stringstream stdin_stream(get_buffer()->get_text()), stdout_stream; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto exit_status = Terminal::get().process(stdin_stream, stdout_stream, command, this->file_path.parent_path()); |
|
|
|
|
|
|
|
if(exit_status == 0) |
|
|
|
|
|
|
|
replace_text(stdout_stream.str()); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if(language_id == "latex") { |
|
|
|
|
|
|
|
static auto yapf = filesystem::find_executable("latexindent"); |
|
|
|
|
|
|
|
if(!yapf.empty()) { |
|
|
|
|
|
|
|
format_style = [this](bool continue_without_style_file, bool ignore_selection) { |
|
|
|
|
|
|
|
std::string command = "latexindent"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!ignore_selection && get_buffer()->get_has_selection()) { |
|
|
|
|
|
|
|
// Does not work with standard input...
|
|
|
|
|
|
|
|
// Gtk::TextIter start, end;
|
|
|
|
|
|
|
|
// get_buffer()->get_selection_bounds(start, end);
|
|
|
|
|
|
|
|
// command += " –-lines " + std::to_string(start.get_line() + 1) + '-' + std::to_string(end.get_line() + 1);
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto search_path = file_path.parent_path(); |
|
|
|
|
|
|
|
while(true) { |
|
|
|
|
|
|
|
static std::vector<boost::filesystem::path> files = {"localSettings.yaml", ".localSettings.yaml", "indentconfig.yaml", ".indentconfig.yaml"}; |
|
|
|
|
|
|
|
boost::system::error_code ec; |
|
|
|
|
|
|
|
bool found = false; |
|
|
|
|
|
|
|
for(auto &file : files) { |
|
|
|
|
|
|
|
if(boost::filesystem::exists(search_path / file, ec)) { |
|
|
|
|
|
|
|
command += " -l=" + file.string(); |
|
|
|
|
|
|
|
found = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(found) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
if(search_path == search_path.root_directory()) { |
|
|
|
|
|
|
|
if(!continue_without_style_file) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
search_path = search_path.parent_path(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
command += " -"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::stringstream stdin_stream(get_buffer()->get_text()), stdout_stream; |
|
|
|
|
|
|
|
|
|
|
|
auto exit_status = Terminal::get().process(stdin_stream, stdout_stream, command, this->file_path.parent_path()); |
|
|
|
auto exit_status = Terminal::get().process(stdin_stream, stdout_stream, command, this->file_path.parent_path()); |
|
|
|
if(exit_status == 0) |
|
|
|
if(exit_status == 0) |
|
|
|
replace_text(stdout_stream.str()); |
|
|
|
replace_text(stdout_stream.str()); |
|
|
|
|