Subject: bug#22873: Can we support multiple cursors?

From: Eli Zaretskii <[email-masked]>
Date: Sun, 13 Aug 2017 21:36:22 +0300

> Date:  Sun, 13 Aug 2017 11:19:30 -0700
> From:  Keith David Bershatsky <[email-masked]>
> Cc:  [email-masked],John Wiegley <[email-masked]>,Marcin Borkowski <[email-masked]>,Richard Stallman <[email-masked]>
> 
> I have encountered a situation where the Y and VPOS coordinates returned by `move_it_to` are sometimes out of bounds, and MATRIX_ROW crashes Emacs when drawing fake cursors that are out of bounds.  The solution appears to be a test for whether Y and VPOS are out of bounds.

Actually, the usual solution is to limit move_it_to to
last_visible_y.  Are you saying that you already do that, and the
values of Y and VPOS are still out of bounds?  That would be strange,
because the display engine does that in many places.

> I would like to use `window_box_height` to give me essentially the same value as `window-body-height` with a non-nil PIXELWISE argument.

And that's not what you get?  Can you show a simple example?

`count-screen-lines` is not a viable option because using `vertical-motion` is too slow.

It's strange that you say so because vertical-motion uses the same
move_it_to subroutines that you'd like to use directly.

> Testing and limiting the drawing of fake cursors with `y <= window_box_height (w)` gives me mixed results; i.e., sometimes fake cursors are drawn/erased only up to line 49, but sometimes it works up to line 50 (partially visible).  I think I want to test for whether Y is less than or equal to 1000 and if VPOS is less than or equal to 50 -- if the test is true, then go ahead and draw fake cursors up to and including that location.

Are you sure you account for the height of the cursor and the line on
which it is shown?  The Y coordinate is where the line begins; it ends
several pixels lower, i.e. at a greater value of Y.

> However, I can foresee situations where there might be mixed line heights on the visible window, and relying upon the frame character height and window body height will not be reliable.  In a simple case, we can take 1000 divided by 20 and know that the VPOS is 50.

For reliable calculations, you must do everything in pixels.

> Is there a more reliable test for the last partially visible Y and VPOS within the window body height?  Should I be using pos_visible_p in some capacity here?

You could use pos_visible_p, although it, again, uses move_it_to.  But
I don't think I have a clear understanding of your problem, so maybe
it's immaterial.