Fix disappearing bar cursor on Hebrew text (bug#72230)

* src/nsterm.m (ns_draw_window_cursor): Compute the correct bar cursor
rectangle for R2L before setting the clipping.
This commit is contained in:
Gerd Möllmann 2024-07-23 08:15:09 +02:00
parent 1aaadc8aec
commit 2074e94c3b

View file

@ -3026,7 +3026,7 @@ External call (RIF): draw cursor.
Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
-------------------------------------------------------------------------- */
{
NSRect r, s;
NSRect r;
int fx, fy, h, cursor_height;
struct frame *f = WINDOW_XFRAME (w);
struct glyph *phys_cursor_glyph;
@ -3076,6 +3076,12 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
/* The bar cursor should never be wider than the glyph. */
if (cursor_width < w->phys_cursor_width)
w->phys_cursor_width = cursor_width;
/* If the character under cursor is R2L, draw the bar cursor
on the right of its glyph, rather than on the left. */
cursor_glyph = get_phys_cursor_glyph (w);
if ((cursor_glyph->resolved_level & 1) != 0)
fx += cursor_glyph->pixel_width - w->phys_cursor_width;
}
/* If we have an HBAR, "cursor_width" MAY specify height. */
else if (cursor_type == HBAR_CURSOR)
@ -3126,18 +3132,8 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
[ctx restoreGraphicsState];
break;
case HBAR_CURSOR:
NSRectFill (r);
[ctx restoreGraphicsState];
break;
case BAR_CURSOR:
s = r;
/* If the character under cursor is R2L, draw the bar cursor
on the right of its glyph, rather than on the left. */
cursor_glyph = get_phys_cursor_glyph (w);
if ((cursor_glyph->resolved_level & 1) != 0)
s.origin.x += cursor_glyph->pixel_width - s.size.width;
NSRectFill (s);
NSRectFill (r);
[ctx restoreGraphicsState];
break;
}