Subject: bug#16856: [PATCH] Prevent cursor from over-drawing the fringe

From: Anders Lindgren <[email-masked]>
Date: Fri, 20 May 2016 21:33:52 +0200

Hi!

I gave this patch a try.

It works well, the ns port now behaves like the win32 and gtk+ parts of
Emacs.

Do you want me to push it to master?

    -- Anders

Ps. When the text area doesn't partially overlap a column, the cursor can
be drawn in the fringe. It's a bit unfortunate that when it do overlap,
only the part of the cursor in the text area is drawn. A worst case
scenario is that only a single pixel of the cursor is visible. An ideal
solution would be to draw the cursor partially in the text area and
partially in the fringe, but without leaving garbage behind when moved.
However, this is nothing that we can solve here and now as it would require
change to all emacs ports and possibly the core system.

On Tue, May 17, 2016 at 11:14 PM, Alan Third <[email-masked]> wrote:

> src/nsterm.m (ns_draw_window_cursor): Reduce clip area from ANY_AREA to
> TEXT_AREA. (bug#16856)
> ---
>  src/nsterm.m | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/src/nsterm.m b/src/nsterm.m
> index 1d48c04..5eb4c8f 100644
> --- a/src/nsterm.m
> +++ b/src/nsterm.m
> @@ -2873,9 +2873,8 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar
> cursors.
>    r.size.height = h;
>    r.size.width = w->phys_cursor_width;
>
> -  /* TODO: only needed in rare cases with last-resort font in HELLO..
> -     should we do this more efficiently? */
> -  ns_clip_to_row (w, glyph_row, ANY_AREA, NO); /* do ns_focus(f, &r, 1);
> if remove */
> +  /* Prevent the cursor from being drawn outside the text area. */
> +  ns_clip_to_row (w, glyph_row, TEXT_AREA, NO); /* do ns_focus(f, &r, 1);
> if remove */
>
>
>    face = FACE_FROM_ID (f, phys_cursor_glyph->face_id);
> --
>
> I believe this fixes it.
>
> --
> Alan Third
>