Re: [gedit-list] GtkSourceView, highlight lines with errors



On Fri, 2016-05-20 at 14:53 +0200, Sébastien Wilmet wrote:
Some applications have a function to choose a color in a smart way:
choose the best color depending on some other colors. But
GtkSourceView
doesn't have such function, unfortunately.

The style schemes have a list of colors. Maybe you can use one of
them.

There are some code in GtkSourceView that do:

gtk_style_context_get (style_context,
                       gtk_style_context_get_state (style_context),
                       "background-color", &background_color,
                       NULL);

Thanks. So I missed no easier and smarter way :-)

My feeling is that gtk_style_context_get() is related to
deprecated gtk_style_context_get_background_color (), see
 https://developer.gnome.org/gtk3/stable/GtkStyleContext.html#gtk-style-context-get-background-color

But as long gtk_style_context_get() is not deprecated and works I will
use that. My solution so far was mixing in grey color with low alpha,
which should work for very bright and very dark background, but may be
not always nice:

  var attrs: MarkAttributes
  attrs = newMarkAttributes()
  var color = RGBAObj(red: 0.5, green: 0.5, blue: 0.5, alpha: 0.2)
  setBackground(attrs, color)
  setMarkAttributes (view, "error", attrs, 1)

Best regards,

Stefan Salewski



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]