emacs-devel
[Top][All Lists]
Advanced

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

move_it_vertically_backward question


From: Po Lu
Subject: move_it_vertically_backward question
Date: Mon, 13 Dec 2021 10:47:48 +0800

I've been trying to introduce a new redisplay primitive to speed up
precision pixel scrolling, but I don't understand the behaviour of
move_it_vertically_backward.  According to the comment, it will move IT
backwards by at least as many pixels as DY, but that's not how it seems
to behave, at least in the primitive I'm trying to implement.

DEFUN ("point-and-pixel-height-of-unseen-line-above",
       Fpoint_and_pixel_height_of_unseen_line_above,
       Spoint_and_pixel_height_of_unseen_line_above, 1, 1, 0,
       doc: /* Find a visual line at least PIXELS above window start.
Return the dimensions of the line as a cons of the buffer position of
the start of the line, and the vertical distance in pixels between that
line and the start of the window.  */)
  (Lisp_Object pixels)
{
  int pix;
  struct it it;
  struct text_pos pt;
  struct window *w;
  struct buffer *old_buffer = NULL;
  Lisp_Object result;

  CHECK_FIXNAT (pixels);
  pix = XFIXNAT (pixels);
  w = XWINDOW (selected_window);

  if (XBUFFER (w->contents) != current_buffer)
    {
      old_buffer = current_buffer;
      set_buffer_internal_1 (XBUFFER (w->contents));
    }

  SET_TEXT_POS_FROM_MARKER (pt, w->start);
  void *itdata = bidi_shelve_cache ();
  start_display (&it, w, pt);
  it.vpos = it.current_y = 0;
  last_height = 0;
  move_it_by_lines (&it, 0);
  move_it_vertically_backward (&it, pix);

  result = Fcons (make_fixnum (IT_CHARPOS (it)),
                  make_fixnum (-it.current_y));

  if (old_buffer)
    set_buffer_internal_1 (old_buffer);

  bidi_unshelve_cache (itdata, false);
  return result;
}

If there are 3 lines above window start, all of which are 17 pixels
tall, calling this new primitive with PIXELS anything between 18 and 33
will result in the start and height of the first line being returned,
while I would have expected it to move onto the second line, as anything
between 18 and 33 pixels above window start should be inside the second
line.

Ideas?  Thanks in advance.


reply via email to

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