[Top][All Lists]

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

Re: [patch] add "underwave" face attribute

From: Aurélien Aptel
Subject: Re: [patch] add "underwave" face attribute
Date: Wed, 1 Feb 2012 00:38:40 +0100

Ok so I've taken into account what has been said on the list. Here's
another attempt.

For a quick glance at the result, apply my patch, compile and run.
$ ./emacs -Q --eval "(set-face-attribute 'default nil :underline
'(:color \"red\" :style wave))

It works on X11, see below for the rest.

Summary of the changes

The :underline attribute has now a new way to be set:

(:color color :style style)
    If `color' is a string, underline in it.
    If `color' is `foreground-color', underline with the
    foreground color of the face.

    If `style' is `wave' underline with a wave.
    If `style' is `line' underline with a line.

    If the attribute :color is omited, underline with the
    foreground color of the face.
    If the attribute :style is omited, underline with a line.

All the previous ways to set :underline behave the same.

Customize menu

The customize menu now looks like this:

  Underline: [Off/On]
    Color: [Foreground color/...]
    Style: [Line/Wave]


-- src/dispextern.h --

Add a new enum for the underlining type.

  enum face_underline_type {

And a new field in struct face.

  struct face {
         enum face_underline_type underline_type;

-- src/xterm.c --

Update X11 backend.
Add x_draw_underwave()
The code seems to use unsigned long for pixel offsets so that's what I used.
The wave is drown correctly now. No more wave breaks in C-h h.

   static void
   x_draw_underwave (Display *dpy, Window win, GC gc,
                     unsigned long x0, unsigned long y0,
                     unsigned long width,
                     unsigned long wave_height, unsigned long wave_length)

Add a new codepath in x_draw_glyph_string() to handle the new style.

  /* Draw underline.  */
  if (s->face->underline_p)
      if (s->face->underline_type == FACE_UNDER_WAVE)
           ...new code...
      else if (s->face->underline_type == FACE_UNDER_LINE)
            ...re-indented old code...

-- src/w32term.m --
-- src/nsterm.c --

 I do not have access to a Window/Mac OSX system.
 Someone needs to test and complete this.
 I don't event know if it compiles.

First attempt at porting to Windows and Mac OSX.
Same change made to src/xterm.c, basically.
Just replaced line drawing primitive by the system one.

-- src/xfaces.c --

Add List_Object for symbol `line' and `wave'.
Reuse Qforeground_color, QCstyle, QCcolor.
Change checks made to :underline value to accept CONS construct.
Handle CONS construct when updating struct face attribute.

-- lisp/faces.el --
-- doc/lispref/display.texi --

Update :underline documentation

-- lisp/cus-face.el --

Update customize menu for :underline.

 (choice :tag "Underline"
         :help-echo "Control text underlining."
         (const :tag "Off" nil)
         (list :tag "On"
           (const :format "" :value :color)
           (choice :tag "Color" (const :tag "Foreground Color"
foreground-color) color)
               (const :format "" :value :style)
               (choice :tag "Style"
                       (const :tag "Line" line)
                       (const :tag "Wave" wave)))))

Attachment: underwave.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]