unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Kenichi Handa <handa@m17n.org>
Cc: jsbien@mimuw.edu.pl
Subject: Re: problem of display property [Re: list-charset-chars and unicode-bmp]
Date: Wed, 29 Jan 2003 16:39:59 +0900 (JST)	[thread overview]
Message-ID: <200301290739.QAA17357@etlken.m17n.org> (raw)
In-Reply-To: <868yx5jvuf.fsf@gerd.free-bsd.org> (gerd.moellmann@t-online.de)

In article <868yx5jvuf.fsf@gerd.free-bsd.org>, gerd.moellmann@t-online.de (Gerd Moellmann) writes:
> When current glyphs are reused, their positions are adjusted for the
> changes in the buffer since the glyphs were made current.  The
> function try_window_id is one such example.  I didn't see this being
> done for the new slot you added to struct glyph.  (Insofar, the
> comment of struct glyph doesn't appear to be that devious :).)

Ah, thank you!  That explains the strange behaviour I
noticed after I applied my patch, and is fixed by adjusting
buf_charpos in increment_row_positions.  But...

> Be it as it may, I think I'd rather try to avoid enlarging struct
> glyph.  Instead, I'd try using the function string_buffer_position in
> the cursor position computation.  Strings aren't displayed frequently,
> so the additional function calls shouldn't matter, and anyway,
> enlarging glyphs costs performance too, and that in all cases.

Oops, I didn't know about string_buffer_position.  You are
right.  By using it, we can confine the change to
set_cursor_from_row as attached.  The change was not that
straight, but I think it is better than the previous one.

The reason why the change looks complicated is to correctly
handle this kind of case where string_buffer_position is
confused by the same string used in display properties.

(setq s1 "<dot>")
(setq s2 "<comma>")
(setq c1 (propertize "." 'display s1))
(setq c2 (propertize "," 'display s2))
(insert c1 c2 c1 c2 c1 c2)

Could you check the change and comment again?

---
Ken'ichi HANDA
handa@m17n.org

*** xdisp.c.~1.729.2.12.~	Thu Nov  7 15:24:40 2002
--- xdisp.c	Wed Jan 29 15:54:27 2003
***************
*** 9369,9374 ****
--- 9369,9382 ----
  {
    struct glyph *glyph = row->glyphs[TEXT_AREA];
    struct glyph *end = glyph + row->used[TEXT_AREA];
+   /* The first glyph that starts a sequence of glyphs from string.  */
+   struct glyph *string_start;
+   /* The X coordinate of string_start.  */
+   int string_start_x;
+   /* The last known character position.  */
+   int last_pos = MATRIX_ROW_START_CHARPOS (row) + delta;
+   /* The last known character position before string_start.  */
+   int string_before_pos;
    int x = row->x;
    int pt_old = PT - delta;
  
***************
*** 9384,9396 ****
  	++glyph;
        }
  
    while (glyph < end
  	 && !INTEGERP (glyph->object)
  	 && (!BUFFERP (glyph->object)
! 	     || glyph->charpos < pt_old))
      {
!       x += glyph->pixel_width;
!       ++glyph;
      }
  
    w->cursor.hpos = glyph - row->glyphs[TEXT_AREA];
--- 9392,9454 ----
  	++glyph;
        }
  
+   string_start = NULL;
    while (glyph < end
  	 && !INTEGERP (glyph->object)
  	 && (!BUFFERP (glyph->object)
! 	     || (last_pos = glyph->charpos) < pt_old))
      {
!       if (! STRINGP (glyph->object))
! 	{
! 	  string_start = NULL;
! 	  x += glyph->pixel_width;
! 	  ++glyph;
! 	}
!       else
! 	{
! 	  string_before_pos = last_pos;
! 	  string_start = glyph;
! 	  string_start_x = x;
! 	  /* Skip all glyphs from string.  */
! 	  do
! 	    {
! 	      x += glyph->pixel_width;
! 	      ++glyph;
! 	    }
! 	  while (glyph < end && STRINGP (glyph->object));
! 	}
!     }
! 
!   if (string_start
!       && (glyph == end || !BUFFERP (glyph->object) || last_pos > pt_old))
!     {
!       /* We may have skipped over point because the previous glyphs
! 	 are from string.  As there's no easy way to know the
! 	 character position of the current glyph, find the correct
! 	 glyph on point by scanning from string_start again.  */
!       Lisp_Object pos, limit;
! 
!       limit = make_number (MATRIX_ROW_END_CHARPOS (row) + delta);
!       glyph = string_start;
!       x = string_start_x;
!       pos = make_number (string_buffer_position (w, glyph->object,
! 						 string_before_pos));
!       pos = Fnext_single_char_property_change (pos, Qdisplay, Qnil, limit);
!       while (XINT (pos) <= pt_old)
! 	{
! 	  /* Skip glyphs from the same string.  */
! 	  do
! 	    {
! 	      x += glyph->pixel_width;
! 	      ++glyph;
! 	    }
! 	  while (glyph < end
! 		 && EQ (glyph->object, string_start->object));
! 	  if (glyph == end || !STRINGP (glyph->object))
! 	    break;
! 	  string_start = glyph;
! 	  pos = Fnext_single_char_property_change (pos, Qdisplay, Qnil, limit);
! 	}
      }
  
    w->cursor.hpos = glyph - row->glyphs[TEXT_AREA];

  reply	other threads:[~2003-01-29  7:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87u1g3atvf.fsf@mimuw.edu.pl>
     [not found] ` <200301210831.RAA03126@etlken.m17n.org>
     [not found]   ` <871y35kej4.fsf@mimuw.edu.pl>
     [not found]     ` <rzqsmvjtrnx.fsf@albion.dl.ac.uk>
2003-01-28 11:29       ` problem of display property [Re: list-charset-chars and unicode-bmp] Kenichi Handa
2003-01-28 12:35         ` Gerd Moellmann
2003-01-29  7:39           ` Kenichi Handa [this message]
2003-01-29 12:45             ` Gerd Moellmann
2003-01-29 13:15               ` Kenichi Handa
2003-01-29 14:27                 ` Eli Zaretskii
2003-01-30  4:26                   ` Kenichi Handa
2003-01-30 20:07                     ` Eli Zaretskii
2003-01-30 20:26                       ` Stefan Monnier
2003-01-30 20:56                       ` Gerd Moellmann
2003-01-31 13:21         ` Dave Love

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=200301290739.QAA17357@etlken.m17n.org \
    --to=handa@m17n.org \
    --cc=jsbien@mimuw.edu.pl \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).