|
|
|
@ -930,14 +930,16 @@ Source::ClangViewAutocomplete(file_path, project_path, language) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
auto_indent=[this]() { |
|
|
|
auto_indent=[this]() { |
|
|
|
boost::filesystem::path temp_file_path = boost::filesystem::unique_path(); |
|
|
|
boost::filesystem::path temp_file = "jucipp_auto_indent_tmp_file"; |
|
|
|
|
|
|
|
auto temp_directory=boost::filesystem::temp_directory_path(); |
|
|
|
|
|
|
|
boost::filesystem::path temp_file_path=temp_directory.string()+'/'+temp_file.string(); |
|
|
|
juci::filesystem::write(temp_file_path, get_buffer()); |
|
|
|
juci::filesystem::write(temp_file_path, get_buffer()); |
|
|
|
std::string command="clang-format \""+temp_file_path.string()+"\""; |
|
|
|
std::string command="clang-format \""+temp_file_path.string()+"\""; |
|
|
|
command+=" -style=\"{IndentWidth: "+std::to_string(tab_size); |
|
|
|
command+=" -style=\"{IndentWidth: "+std::to_string(tab_size); |
|
|
|
command+="}\""; |
|
|
|
command+="}\""; |
|
|
|
std::stringstream stdout_stream; |
|
|
|
std::stringstream stdout_stream; |
|
|
|
auto exit_code=Singleton::terminal()->execute(stdout_stream, command); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto exit_code=Singleton::terminal()->execute(stdout_stream, command); |
|
|
|
if(exit_code==0) { |
|
|
|
if(exit_code==0) { |
|
|
|
get_source_buffer()->begin_user_action(); |
|
|
|
get_source_buffer()->begin_user_action(); |
|
|
|
auto cursor_line_nr=get_buffer()->get_insert()->get_iter().get_line(); |
|
|
|
auto cursor_line_nr=get_buffer()->get_insert()->get_iter().get_line(); |
|
|
|
@ -948,6 +950,8 @@ Source::ClangViewAutocomplete(file_path, project_path, language) { |
|
|
|
get_source_buffer()->end_user_action(); |
|
|
|
get_source_buffer()->end_user_action(); |
|
|
|
set_tab_char_and_size(' ', tab_size); //clang-format only does basic indentation with spaces as I understand it
|
|
|
|
set_tab_char_and_size(' ', tab_size); //clang-format only does basic indentation with spaces as I understand it
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boost::filesystem::remove(temp_file_path); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
get_token=[this]() -> Token { |
|
|
|
get_token=[this]() -> Token { |
|
|
|
|