From: Gerd Möllmann Date: Tue, 23 Jul 2024 06:15:09 +0000 (+0200) Subject: Fix disappearing bar cursor on Hebrew text (bug#72230) X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a2ec043f5e749d00fdc7f4a0a5a6662d78ad8789;p=emacs.git 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. (cherry picked from commit 2074e94c3b1800b795c11658f35fc30e74ecfb60) --- diff --git a/src/nsterm.m b/src/nsterm.m index 794630de1c1..2aadada2df6 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -3026,7 +3026,7 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, 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 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, /* 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 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, [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; }