diff --git a/src/ct/ct_actions.h b/src/ct/ct_actions.h index f4683845..cbde2e7e 100644 --- a/src/ct/ct_actions.h +++ b/src/ct/ct_actions.h @@ -1,7 +1,7 @@ /* * ct_actions.h * - * Copyright 2009-2024 + * Copyright 2009-2025 * Giuseppe Penone * Evgenii Gurianov * @@ -325,7 +325,7 @@ class CtActions // format actions void save_tags_at_cursor_as_latest(); void apply_tags_latest(); - void remove_text_formatting(); + void remove_text_formatting() { _remove_text_formatting(false/*dismiss_link*/); } void apply_tag_foreground(); void apply_tag_background(); void apply_tag_bold(); @@ -363,6 +363,7 @@ class CtActions void _text_selection_change_case(gchar change_type); int _find_previous_indent_margin(); void _apply_tag_hN(const char* tagPropScaleVal); + void _remove_text_formatting(const bool dismiss_link); public: void image_insert_png(Gtk::TextIter iter_insert, diff --git a/src/ct/ct_actions_format.cc b/src/ct/ct_actions_format.cc index 3630db8f..7c256942 100644 --- a/src/ct/ct_actions_format.cc +++ b/src/ct/ct_actions_format.cc @@ -91,7 +91,7 @@ void CtActions::apply_tags_latest() } // Cleans the Selected Text from All Formatting Tags -void CtActions::remove_text_formatting() +void CtActions::_remove_text_formatting(const bool dismiss_link) { if (not _is_there_selected_node_or_error()) return; if (not _is_curr_node_not_syntax_highlighting_or_error()) return; @@ -112,17 +112,20 @@ void CtActions::remove_text_formatting() std::vector> curr_tags = it_sel_start.get_tags(); for (auto& curr_tag : curr_tags) { const Glib::ustring tag_name = curr_tag->property_name(); - if (str::startswith(tag_name, "weight_") or - str::startswith(tag_name, "foreground_") or - str::startswith(tag_name, "background_") or - str::startswith(tag_name, "style_") or - str::startswith(tag_name, "underline_") or - str::startswith(tag_name, "strikethrough_") or - str::startswith(tag_name, "indent_") or - str::startswith(tag_name, "scale_") or - str::startswith(tag_name, "invisible_") or - str::startswith(tag_name, "justification_") or - str::startswith(tag_name, "family_")) + if ( (not dismiss_link and + (str::startswith(tag_name, "weight_") or + str::startswith(tag_name, "foreground_") or + str::startswith(tag_name, "background_") or + str::startswith(tag_name, "style_") or + str::startswith(tag_name, "underline_") or + str::startswith(tag_name, "strikethrough_") or + str::startswith(tag_name, "indent_") or + str::startswith(tag_name, "scale_") or + str::startswith(tag_name, "invisible_") or + str::startswith(tag_name, "justification_") or + str::startswith(tag_name, "family_"))) + or + (dismiss_link and str::startswith(tag_name, "link_")) ) { Gtk::TextIter it_sel_end = curr_buffer->get_iter_at_offset(offset+1); curr_buffer->remove_tag(curr_tag, it_sel_start, it_sel_end); diff --git a/src/ct/ct_actions_others.cc b/src/ct/ct_actions_others.cc index ae9b92a8..9f2f3523 100644 --- a/src/ct/ct_actions_others.cc +++ b/src/ct/ct_actions_others.cc @@ -1,7 +1,7 @@ /* * ct_actions_others.cc * - * Copyright 2009-2024 + * Copyright 2009-2025 * Giuseppe Penone * Evgenii Gurianov * @@ -68,7 +68,7 @@ void CtActions::link_dismiss() if (not _is_curr_node_not_read_only_or_error()) return; _link_right_click_pre_action(); if (not _link_check_around_cursor().empty()) { - remove_text_formatting(); + _remove_text_formatting(true/*dismiss_link*/); } }