diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp index e6683f33097a0f90e97f5e942c694e6edcc0139c..ec5a9f8949047992d4506581ae7cb8d51c448f95 100644 --- a/src/ui/dialog/attrdialog.cpp +++ b/src/ui/dialog/attrdialog.cpp @@ -92,11 +92,11 @@ constexpr int MAX_POPOVER_HEIGHT = 450; constexpr int MAX_POPOVER_WIDTH = 520; constexpr int TEXT_MARGIN = 3; -std::unique_ptr AttrDialog::init_text_view(AttrDialog* owner, Syntax::SyntaxMode coloring, bool map) +std::unique_ptr AttrDialog::init_text_view(AttrDialog* owner, Syntax::SyntaxMode coloring, bool map, bool wrap) { auto edit = Syntax::TextEditView::create(coloring); auto& textview = edit->getTextView(); - textview.set_wrap_mode(Gtk::WrapMode::WRAP_WORD); + textview.set_wrap_mode(wrap ? Gtk::WrapMode::WRAP_CHAR : Gtk::WrapMode::WRAP_WORD); // this actually sets padding rather than margin and extends textview's background color to the sides textview.set_top_margin(TEXT_MARGIN); @@ -144,6 +144,9 @@ AttrDialog::AttrDialog() _text_edit = init_text_view(this, SyntaxMode::PlainText, false); _style_edit = init_text_view(this, SyntaxMode::CssStyle, false); + // Href editing + _href_edit = init_text_view(this, SyntaxMode::PlainText, false, true); + set_size_request(20, 15); // For text and comment nodes: update XML on the fly, as users type @@ -402,6 +405,9 @@ void AttrDialog::startValueEdit(Gtk::CellEditable *cell, const Glib::ustring &pa } else if (attribute == "points") { enable_rouding = true; set_current_textedit(_points_edit.get()); + } else if (attribute == "href" || attribute == "xlink:href") { + set_current_textedit(_href_edit.get()); + edit_in_popup = true; } else { set_current_textedit(_attr_edit.get()); edit_in_popup = false; diff --git a/src/ui/dialog/attrdialog.h b/src/ui/dialog/attrdialog.h index 434b5724d6894299b47cd18cf44d88dccd4fb849..96ae281a5f01b8e7853705e549b8dae6be5711aa 100644 --- a/src/ui/dialog/attrdialog.h +++ b/src/ui/dialog/attrdialog.h @@ -147,6 +147,7 @@ private: std::unique_ptr _css_edit; // in-line CSS style std::unique_ptr _svgd_edit; // SVG path data std::unique_ptr _points_edit; // points in a or + std::unique_ptr _href_edit; // long entries without spaces std::unique_ptr _attr_edit; // all other attributes (plain text) Syntax::TextEditView* _current_text_edit = nullptr; // current text edit for attribute value editing auto_connection _adjust_size; @@ -162,7 +163,7 @@ private: static Glib::ustring round_numbers(const Glib::ustring& text, int precision); Gtk::TextView &_activeTextView() const; void set_current_textedit(Syntax::TextEditView* edit); - static std::unique_ptr init_text_view(AttrDialog* owner, Syntax::SyntaxMode coloring, bool map); + static std::unique_ptr init_text_view(AttrDialog* owner, Syntax::SyntaxMode coloring, bool map, bool char_wrap = false); }; } // namespace UI::Dialog