From c2eedbfce15e4098ef1804037b990bcd868d2fd1 Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 26 Mar 2026 13:09:47 +0100 Subject: [PATCH] Now draws markdown lines in tooltips --- src/tooltips.cpp | 16 +++++++++++++--- src/tooltips.hpp | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/tooltips.cpp b/src/tooltips.cpp index 10cf1da..ed72bf0 100644 --- a/src/tooltips.cpp +++ b/src/tooltips.cpp @@ -444,12 +444,17 @@ void Tooltip::create_tags() { code_tag = buffer->create_tag(); code_tag->property_family() = source_font_family; auto background_rgba = Gdk::RGBA(); + auto line_rgba = Gdk::RGBA(); auto normal_color = window->get_style_context()->get_color(Gtk::StateFlags::STATE_FLAG_NORMAL); auto light_theme = (normal_color.get_red() + normal_color.get_green() + normal_color.get_blue()) / 3 < 0.5; - if(light_theme) + if(light_theme) { background_rgba.set_rgba(1.0, 1.0, 1.0, 0.4); - else + line_rgba.set_rgba(0.0, 0.0, 0.0, 0.25); + } + else { background_rgba.set_rgba(0.0, 0.0, 0.0, 0.2); + line_rgba.set_rgba(1.0, 1.0, 1.0, 0.25); + } code_tag->property_background_rgba() = background_rgba; code_block_tag = buffer->create_tag(); @@ -464,6 +469,11 @@ void Tooltip::create_tags() { strikethrough_tag = buffer->create_tag(); strikethrough_tag->property_strikethrough() = true; + + line_tag = buffer->create_tag(); + line_tag->property_paragraph_background_rgba() = line_rgba; + line_tag->property_foreground_rgba() = line_rgba; + line_tag->property_size() = 1; } } @@ -846,7 +856,7 @@ void Tooltip::insert_markdown(const std::string &input) { if(i == input.size() || input[i] == '\n') { if(i < input.size()) ++i; - buffer->insert_at_cursor("---\n"); + buffer->insert_with_tag(buffer->get_insert()->get_iter(), "---\n", line_tag); if(is_empty_line()) buffer->insert_at_cursor("\n"); return true; diff --git a/src/tooltips.hpp b/src/tooltips.hpp index c7124be..22a3d91 100644 --- a/src/tooltips.hpp +++ b/src/tooltips.hpp @@ -56,6 +56,7 @@ private: Glib::RefPtr bold_tag; Glib::RefPtr italic_tag; Glib::RefPtr strikethrough_tag; + Glib::RefPtr line_tag; std::map, std::string> links; std::map, std::string> reference_links;