all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>, Kenichi Handa <handa@gnu.org>
Cc: 13011@debbugs.gnu.org, mario.giovinazzo@virgilio.it
Subject: bug#13011: 24.2; Text flickering moving cursor with box around text enabled
Date: Thu, 29 Nov 2012 18:42:47 +0200	[thread overview]
Message-ID: <83vccouzqw.fsf@gnu.org> (raw)
In-Reply-To: <jwvzk213u19.fsf-monnier+emacs@gnu.org>

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: mario giovinazzo <mario.giovinazzo@virgilio.it>,  13011@debbugs.gnu.org
> Date: Wed, 28 Nov 2012 23:39:04 -0500
> 
> When the box width is 1, indeed, there's no much Emacs could do, but
> when the width is -1 (i.e. drawn "inside" the normal text box),
> characters shouldn't move, whereas they do (they get shifted
> horizontally by a few pixels, and if you try it in the *Help* buffer
> you may see that the number of pixel shifts seems to increase at
> transition points between different fonts, such as italics for function
> arguments).

Looks like this was done on (some) purpose:

In xdisp.c:

	  /* If face has a box, add the box thickness to the character
	     height.  If character has a box line to the left and/or
	     right, add the box line width to the character's width.  */
	  if (face->box != FACE_NO_BOX)
	    {
	      int thick = face->box_line_width;

	      if (thick > 0)
		{
		  it->ascent += thick;
		  it->descent += thick;
		}
	      else
		thick = -thick;   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

	      if (it->start_of_box_run_p)
		it->pixel_width += thick;  <<<<<<<<<<<<<<<<<<<<<<<<<
	      if (it->end_of_box_run_p)
		it->pixel_width += thick;
	    }

Note that the ascent and descent are only enlarged when the value is
positive, but pixel_width is also enlarged when the value is negative.

And then in xterm.c:

  /* If first glyph of S has a left box line, start drawing the text
     of S to the right of that box line.  */
  if (s->face->box != FACE_NO_BOX
      && s->first_glyph->left_box_line_p)
    x = s->x + eabs (s->face->box_line_width);  <<<<<<<<<<<<<<<<<<<<
  else         ^^^^
    x = s->x;

Moreover, the commentary in dispextern.h explicitly says that the
left/right borders are not affected by the sign of the box width (note
the last sentence):

  /* Non-zero means characters in this face have a box of that
     thickness around them.  If this value is negative, its absolute
     value indicates the thickness, and the horizontal (top and
     bottom) borders of box are drawn inside of the character glyphs'
     area.  The vertical (left and right) borders of the box are drawn
     in the same way as when this value is positive.  */
  int box_line_width;

and the doc string in faces.el only mentions the top and bottom borders
of the box as being affected by negative values:

  `:box'

  VALUE specifies whether characters in FACE should have a box drawn
  around them.  If VALUE is nil, explicitly don't draw boxes.  If
  VALUE is t, draw a box with lines of width 1 in the foreground color
  of the face.  If VALUE is a string, the string must be a color name,
  and the box is drawn in that color with a line width of 1.  Otherwise,
  VALUE must be a property list of the form `(:line-width WIDTH
  :color COLOR :style STYLE)'.  If a keyword/value pair is missing from
  the property list, a default value will be used for the value, as
  specified below.  WIDTH specifies the width of the lines to draw; it
  defaults to 1.  If WIDTH is negative, the absolute value is the width
  of the lines, and draw top/bottom lines inside the characters area,
  not around it.

Only the ELisp manual makes it sound like both horizontal and vertical
borders are drawn inside the character cell:

    `(:line-width WIDTH :color COLOR :style STYLE)'
          This way you can explicitly specify all aspects of the box.
          The value WIDTH specifies the width of the lines to draw; it
          defaults to 1.  A negative width -N means to draw a line of
          width N that occupies the space of the underlying text, thus
          avoiding any increase in the character height or width.

I made a provisional change that behaves with left and right borders
like it does with horizontal ones, and it seems to work, at least with
character display (didn't text with images, image slices, composite
characters, etc.).  But I'd like to ask Handa-san (CC'ed), who wrote
the code for this feature (almost 12 years ago!), whether he might
remember why the code deliberately makes the left and right borders
behave differently from top and bottom ones.

To see the original changeset that introduced this feature, type

   bzr diff -r 36005..36010





  reply	other threads:[~2012-11-29 16:42 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-27 10:42 bug#13011: 24.2; Text flickering moving cursor with box around text enabled mario giovinazzo
2012-11-27 17:43 ` Eli Zaretskii
     [not found]   ` <1205106717.20121128161453@virgilio.it>
2012-11-28 17:54     ` Eli Zaretskii
2012-11-29  4:39       ` Stefan Monnier
2012-11-29 16:42         ` Eli Zaretskii [this message]
2012-11-29 19:06           ` Stefan Monnier
2012-12-03  9:29             ` Kenichi Handa
2012-12-03 16:33               ` Eli Zaretskii
2012-12-03 16:44                 ` Drew Adams
2012-12-03 18:08                   ` Eli Zaretskii
2012-12-03 18:41                     ` Drew Adams
2012-12-03 18:56                       ` Eli Zaretskii
2012-12-03 19:09                         ` Drew Adams
2012-12-03 21:04                           ` Eli Zaretskii
2012-12-03 22:20                             ` Stefan Monnier
2012-12-03 22:51                               ` Drew Adams
2012-12-03 22:21                             ` Drew Adams
2012-12-04  0:13                 ` Kenichi Handa
2018-01-19 18:08 ` bug#13011: Patch: " Alexandre Adolphe
2019-08-10 21:21 ` bug#13011: [PATCH] " Alexandre Adolphe
2019-08-20 13:44   ` Noam Postavsky
2019-10-11 23:31     ` Alexandre Adolphe
2019-10-15  7:40     ` Stefan Kangas
2020-04-01 22:05   ` Noam Postavsky
2020-04-03  1:27   ` Dmitry Gutov
     [not found] <13b4ec68081.mario.giovinazzo@virgilio.it>
2012-11-30  8:13 ` bug#13011: 24.2; " Eli Zaretskii
2012-12-11 12:26   ` Eli Zaretskii
2012-12-11 14:01     ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83vccouzqw.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=13011@debbugs.gnu.org \
    --cc=handa@gnu.org \
    --cc=mario.giovinazzo@virgilio.it \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.