From 67c7c4bb10111ae65cbdbbf8582f4143956fa664 Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Sat, 15 Feb 2025 02:47:38 -0500 Subject: [PATCH] GUI2/Canvas: clean up some remnants of old attribute handling --- src/gui/core/canvas.cpp | 14 ++++---------- src/gui/core/canvas_private.hpp | 25 +++++-------------------- 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/src/gui/core/canvas.cpp b/src/gui/core/canvas.cpp index 1d1dfd85806..0353dd03ab4 100644 --- a/src/gui/core/canvas.cpp +++ b/src/gui/core/canvas.cpp @@ -412,10 +412,6 @@ text_shape::text_shape(const config& cfg, wfl::action_function_symbol_table& fun , highlight_start_(cfg["highlight_start"]) , highlight_end_(cfg["highlight_end"]) , highlight_color_(cfg["highlight_color"], color_t::from_hex_string("215380")) - , attr_start_(cfg["attr_start"]) - , attr_end_(cfg["attr_end"]) - , attr_name_(cfg["attr_name"]) - , attr_data_(cfg["attr_data"]) , outline_(cfg["outline"], false) , actions_formula_(cfg["actions"], &functions) { @@ -444,13 +440,11 @@ void text_shape::draw(wfl::map_formula_callable& variables) // // Highlight // - std::vector starts = utils::split(highlight_start_, ','); - std::vector stops = utils::split(highlight_end_, ','); + const int highlight_start = highlight_start_(variables); + const int highlight_end = highlight_end_(variables); - for(size_t i = 0; i < std::min(starts.size(), stops.size()); i++) { - typed_formula hstart(starts.at(i)); - typed_formula hstop(stops.at(i)); - add_attribute_bg_color(text_attributes, hstart(variables), hstop(variables), highlight_color_(variables)); + if(highlight_start != highlight_end) { + add_attribute_bg_color(text_attributes, highlight_start, highlight_end, highlight_color_(variables)); } // diff --git a/src/gui/core/canvas_private.hpp b/src/gui/core/canvas_private.hpp index 9f5baedc034..47aff47aaf6 100644 --- a/src/gui/core/canvas_private.hpp +++ b/src/gui/core/canvas_private.hpp @@ -285,30 +285,15 @@ private: /** The maximum height for the text. */ typed_formula maximum_height_; - /** Start and end offsets for highlight */ - std::string highlight_start_; - std::string highlight_end_; + /** Start offset for highlight */ + typed_formula highlight_start_; + + /** End offset for highlight */ + typed_formula highlight_end_; /** The color to be used for highlighting */ typed_formula highlight_color_; - /** Generic start and end offsets for various attributes */ - std::string attr_start_; - std::string attr_end_; - - /** - * The attribute type - * Possible values : - * color/foreground, bgcolor/background, font_size/size, - * bold, italic, underline - * The first three require extra data - * the color for the first two, and font size for the last - */ - std::string attr_name_; - - /** extra data for the attribute, if any */ - std::string attr_data_; - /** Whether to apply a text outline. */ typed_formula outline_;