/* Return 1 if position CHARPOS is visible in window W.
+ CHARPOS < 0 means return info about WINDOW_END position.
If visible, set *X and *Y to pixel coordinates of top left corner.
Set *RTOP and *RBOT to pixel height of an invisible area of glyph at POS.
Set *ROWH and *VPOS to row's visible height and VPOS (row number). */
start_display (&it, w, top);
move_it_to (&it, charpos, -1, it.last_visible_y-1, -1,
- MOVE_TO_POS | MOVE_TO_Y);
+ (charpos >= 0 ? MOVE_TO_POS : 0) | MOVE_TO_Y);
/* Note that we may overshoot because of invisible text. */
- if (IT_CHARPOS (it) >= charpos)
+ if (charpos >= 0 && IT_CHARPOS (it) >= charpos)
{
int top_x = it.current_x;
int top_y = it.current_y;
{
struct image *img;
struct face *face;
- int glyph_ascent;
+ int glyph_ascent, crop;
struct glyph_slice slice;
xassert (it->what == IT_IMAGE);
take_vertical_position_into_account (it);
+ /* Automatically crop wide image glyphs at right edge so we can
+ draw the cursor on same display row. */
+ if ((crop = it->pixel_width - (it->last_visible_x - it->current_x), crop > 0)
+ && (it->hpos == 0 || it->pixel_width > it->last_visible_x / 4))
+ {
+ it->pixel_width -= crop;
+ slice.width -= crop;
+ }
+
if (it->glyph_row)
{
struct glyph *glyph;