emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFA] Console based mouse face highlighting.


From: Eli Zaretskii
Subject: Re: [RFA] Console based mouse face highlighting.
Date: Wed, 16 May 2007 21:19:25 +0300

> From: Nick Roberts <address@hidden>
> Date: Wed, 16 May 2007 22:00:52 +1200
> 
>        term_show_mouse_face (draw)
>        loop ...
> 
>         if (draw == DRAW_MOUSE_FACE)
>           {
>             glyph = xmalloc (nglyphs * sizeof (struct glyph));
>             memcpy (glyph, row->glyphs[TEXT_AREA] + start_hpos,
>                     nglyphs * sizeof (struct glyph));
>             for (j = 0; j < nglyphs; j = j++)
>                 (glyph + j)->face_id = mouse_face_face_id;
>           }
>         else /* draw == DRAW_NORMAL_TEXT */
>             glyph = row->glyphs[TEXT_AREA] + start_hpos;
> 
>         pos_y = row->y + WINDOW_TOP_EDGE_Y (w);
>         pos_x = row->used[LEFT_MARGIN_AREA] + start_hpos
>           + WINDOW_LEFT_EDGE_X (w);
>         
>         cursor_to (pos_y, pos_x);
>         write_glyphs (glyph, nglyphs);
>         if (draw == DRAW_MOUSE_FACE)
>           xfree (glyph);
>       cursor_to (save_y, save_x);
>     }

I don't think you need to poke the face of the glyphs in the glyph
matrix to have them in mouse highlight face.  Instead, you need to
turn on the mouse highlight face before the call to fwrite that
actually delivers the glyphs to the screen.  To this end, either
modify write_glyphs to teach it to use mouse_face_face_id when that is
necessary (e.g., add an additional argument to write_glyphs), or write
a new function that is identical to write_glyphs which will use the
mouse face instead of the face encoded in the glyph matrix.

I think this will be a more elegant solution, and it also avoids
malloc'ing memory.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]