GNOME Bugzilla – Bug 114237
Add squiggly-red underline type
Last modified: 2004-12-22 21:47:04 UTC
For gtksourceview/glimmer/gedit, we'd like to be able to display programming/spelling etc. errors by displaying a "wavy line" below the text (same as underline). Evolution 1.4 is probably also very interested in this (afaics they regressed in this wrt to the 1.2 version because pango doesn't support it). See http://www.xs4all.nl/~jeroen/screenshots/Screenshot-JBuilder.png how it's done in Swing/Java. Afaics, the only way to do this now is to hack pango to add a new text attribute. Is this correct? If so, what would be the correct solution? I can think of two things: 1. Add a new text attribute to pango itself and hope that covers all the possible attributes. 2. Extend pango/GtkTextView somehow to support custom text attributes in a usable manner.
Pango already allows custom attributes ... but it doesn't do you any good: A) GDK would have to know how to render the new attribute B) GtkTextView, as it turns out, actually uses a custom attribute when passing its style information through Pango rather than the standard ones C) Even if B) wasn't true, how would you *set* it within a GtkTextView? I don't see a way that is going to magically allow GTK+ Pango and GDK to magically know all about new attribute types. I thought there was a squiggly-red-underline bug open, but I can't find it, so I'll retitle this bug report.
(added Conglomerate's Bugzilla-tracking mailing list to the cc, as this may be of use to us as well)
Created attachment 21527 [details] [review] Underlining using wavy lines. Introduces PANGO_UNDERLINE_ERROR.
Created attachment 21528 [details] [review] Add handling in gdk/gtk and tests for PANGO_UNDERLINE_ERROR
I have attached patches introducing a new pango underlining attribute, PANGO_UNDERLINE_COLOR, that draws a wavy, red underline. The main issue concerning this patch is the "red" color: right now it is hard-coded in gtktextdisplay.c, but the right place for this color would be in the style. Since this is not done yet, the only place where I actually use the "red" color is in the drawing of the wavy underline for the gtk_text_view. Some other points, which I think could be done incrementally, at later stages: - we should draw the underline thicker for big fonts - we could use a pair of stippled lines to draw the wave, instead of drawing point by point, for better efficiency.
Looks good in testtext. Can we get this in gtk 2.3?
The Pango patch looks basically OK - two comments about the XDrawPoint() calls - the line break is wrong, and I'm not sure why you are using lines for the two other backends and points here.
Sorry about the line wrong breaks - I'm used to the Ada style :-/ About the "points vs lines" issue, I first implemented with points, then realized lines would be a better way to go, especially when scaling up was involved. But then, I didn't really work to make these procedure exactly alike, since the final aspect is the same, and is probably subject to changes. After all, there wasn't any discussion on the graphical aspect of the lines (maybe I should have brought this up :-/) Right now the lines are drawn like this: (zoom on the pixels) OO OO OO OO OO OO OO OO OO OO OO OO OO OO OO OO I arbitrarily chose to render the wave this way, since it is what Evolution draws when activating the spell checker. But other applications (such as JBuilder) draw the lines like that: /\ /\ /\ /\ / \ / \ / \ / \ \/ \/ \/ \/ Which is also pretty cool and "scales up" more nicely. What do you think ? As soon as there is consensus, I'll be happy to go back to the patch and implement the chosen solution.
Added myself to the CC
Applied Pango patch with reordering of enum values to avoid changing the numeric value of PANGO_UNDERLINE_LOW. Also, changed the drawing routines not to overshoot by one for odd underline widths. Sun Feb 29 15:31:09 2004 Owen Taylor <otaylor@redhat.com> Patch from Nicolas Setton, #114237 * pango/pango-attributes.h pango/pango-markup.c: Add a new underline type, PANGO_UNDERLINE_ERROR. * pango/pangowin32.c pango/pangox.c pango/pangoft2.c: Implement drawing of PANGO_UNDERLINE_ERROR. * pango/pango-layout.c (pango_layout_run_get_extents): Handle PANGO_UNDERLINE_ERROR. I think the more wavy wave would be nice, but for right now, when we don't have modification of the underline thickness with font size, keeping things small is probably good.
Sun Feb 29 16:35:23 2004 Owen Taylor <otaylor@redhat.com> * gdk/gdkpango.c gtk/gtktextdisplay.c: Implement PANGO_UNDERLINE_ERROR (Based on a patch by Nicolas Setton, #114237) * gtk/gtktextview.c: Add a error-underline-color style property.