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: Nick Roberts
Subject: Re: [RFA] Console based mouse face highlighting.
Date: Thu, 17 May 2007 09:46:00 +1200

 > 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.

I can't easily add an extra argument to write_glyphs as it's called in many
places.  However, I can use a (static) global variable and this is what I did
do earlier but it didn't work because had I assumed cursor_to (x, y) when it's
actually cursor_to (y, x) i.e vertical co-ordinate first.

Do you mean something like below?  (I've tested it and it works too.)  It's
certainly more lightweght, but I think global variables tend to spoil the flow.

-- 
Nick                                           http://www.inet.net.nz/~nickrob



In term.c:

static int draw_mouse_face;



In term_show_mouse_face:

        loop ...

          cursor_to (pos_y, pos_x);

          if (draw == DRAW_MOUSE_FACE)
            {
              draw_mouse_face = 1;
              write_glyphs (row->glyphs[TEXT_AREA] + start_hpos, nglyphs);
              draw_mouse_face = 0;
            }
          else /* draw == DRAW_NORMAL_TEXT */
            write_glyphs (row->glyphs[TEXT_AREA] + start_hpos, nglyphs);
        }
      cursor_to (save_y, save_x);



In write_glyphs:

  while (len > 0)
    {
      /* Identify a run of glyphs with the same face.  */
      int face_id = string->face_id;
      int n;

       if (draw_mouse_face)
        {
          face_id = mouse_face_face_id;
          n = len;
        }
       else
      for (n = 1; n < len; ++n)
        if (string[n].face_id != face_id)
          break;




reply via email to

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