Browse Source

Added -m switch to latexindent

merge-requests/413/head
eidheim 4 years ago
parent
commit
d3d54b48b6
  1. 25
      src/source.cpp

25
src/source.cpp

@ -471,7 +471,7 @@ void Source::View::configure() {
if((property_show_right_margin() = Config::get().source.show_right_margin))
property_right_margin_position() = Config::get().source.right_margin_position;
//Create tags for diagnostic warnings and errors:
// Create tags for diagnostic warnings and errors:
auto scheme = get_source_buffer()->get_style_scheme();
auto tag_table = get_buffer()->get_tag_table();
auto style = scheme->get_style("def:warning");
@ -484,7 +484,7 @@ void Source::View::configure() {
warning_property = style->property_background().get_value();
diagnostic_tag_underline->property_underline() = Pango::Underline::UNDERLINE_ERROR;
auto tag_class = G_OBJECT_GET_CLASS(diagnostic_tag_underline->gobj()); //For older GTK+ 3 versions:
auto tag_class = G_OBJECT_GET_CLASS(diagnostic_tag_underline->gobj()); // For older GTK+ 3 versions:
auto param_spec = g_object_class_find_property(tag_class, "underline-rgba");
if(param_spec)
diagnostic_tag_underline->set_property("underline-rgba", Gdk::RGBA(warning_property));
@ -501,7 +501,7 @@ void Source::View::configure() {
diagnostic_tag_underline->property_underline() = Pango::Underline::UNDERLINE_ERROR;
diagnostic_tag_underline->set_property("underline-rgba", Gdk::RGBA(error_property));
}
//TODO: clear tag_class and param_spec?
// TODO: clear tag_class and param_spec?
style = scheme->get_style("selection");
if(style && style->property_foreground_set())
@ -1216,13 +1216,12 @@ void Source::View::setup_format_style(bool is_generic_view) {
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";
std::string command = "latexindent -m";
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);
Gtk::TextIter start, end;
get_buffer()->get_selection_bounds(start, end);
command += " –n " + std::to_string(start.get_line() + 1) + '-' + std::to_string(end.get_line() + 1);
}
auto search_path = file_path.parent_path();
@ -2919,7 +2918,7 @@ bool Source::View::on_key_press_event_basic(GdkEventKey *event) {
return false;
}
//Bracket language indentation
// Bracket language indentation
bool Source::View::on_key_press_event_bracket_language(GdkEventKey *event) {
const static std::regex no_bracket_statement_regex("^[ \t]*(if( +constexpr)?|for|while) *\\(.*[^;}{] *$|"
"^[ \t]*[}]? *else if( +constexpr)? *\\(.*[^;}{] *$|"
@ -3131,7 +3130,7 @@ bool Source::View::on_key_press_event_bracket_language(GdkEventKey *event) {
return true;
}
else {
//Insert new lines with bracket end
// Insert new lines with bracket end
get_buffer()->insert_at_cursor('\n' + tabs + tab + '\n' + tabs + static_cast<char>(close_symbol));
auto insert_it = get_buffer()->get_insert()->get_iter();
if(insert_it.backward_chars(tabs.size() + 2)) {
@ -3505,7 +3504,7 @@ bool Source::View::on_key_press_event_smart_brackets(GdkEventKey *event) {
auto previous_iter = iter;
previous_iter.backward_char();
if(is_code_iter(iter)) {
//Move after ')' if closed expression
// Move after ')' if closed expression
if(event->keyval == GDK_KEY_parenright) {
if(*iter == ')' && symbol_count(iter, '(', ')') <= 0) {
iter.forward_char();
@ -3514,7 +3513,7 @@ bool Source::View::on_key_press_event_smart_brackets(GdkEventKey *event) {
return true;
}
}
//Move after '>' if >( and closed expression
// Move after '>' if >( and closed expression
else if(event->keyval == GDK_KEY_greater) {
if(*iter == '>') {
iter.forward_char();
@ -3526,7 +3525,7 @@ bool Source::View::on_key_press_event_smart_brackets(GdkEventKey *event) {
}
}
}
//Move after '(' if >( and select text inside parentheses
// Move after '(' if >( and select text inside parentheses
else if(event->keyval == GDK_KEY_parenleft) {
auto previous_iter = iter;
previous_iter.backward_char();

Loading…
Cancel
Save