all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Nick Roberts <nickrob@snap.net.nz>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] Console based mouse face highlighting.
Date: Wed, 16 May 2007 00:15:12 +0300	[thread overview]
Message-ID: <uejlheqlb.fsf@gnu.org> (raw)
In-Reply-To: <17993.11948.400368.430713@kahikatea.snap.net.nz> (message from Nick Roberts on Tue, 15 May 2007 15:53:16 +1200)

> From: Nick Roberts <nickrob@snap.net.nz>
> Date: Tue, 15 May 2007 15:53:16 +1200
> Cc: emacs-devel@gnu.org
> 
> Is cursor movement expensive on GNU/Linux?

I don't think so, but in any case, it is IMO wrong to try to optimize
this case before you actually see that it slows down redisplay.  I
suggest to do it right first, and worry about speed afterwards, if
needed.

> msdos.c uses:
> 
> 	  IT_set_face (dpyinfo->mouse_face_face_id);
> 	  _farsetsel (_dos_ds);
> 	  while (nglyphs--)
> 	    {
> 	      _farnspokeb (offset, ScreenAttrib);
> 	      offset += 2;
> 	    }
> 	  if (screen_virtual_segment)
> 	    dosv_refresh_virtual_screen (start_offset, end_hpos - start_hpos);
> 
> 
> Can I write directly to the screen like this in term.c?

Not on a tty in general, no.  I'm not an expert on Linux terminals, so
perhaps you can do that there.  But again, I suggest to do it first
with straight file I/O (fwrite etc.) and only worry about direct I/O
if standard I/O is too slow.  (msdos.c has good reasons for direct
access, since file I/O would have required a switch from protected
mode to real mode and back -- because DOS system calls run DOS code
that cannot run in protected mode -- and these mode switches are
painfully slow.  Also, file I/O does not support color on MSDOS.)

> Or do I have to modify the current glyph matrix somehow?

term.c is a terminal-specific back-end of the display code (like
xterm.c is for X, w32term.c for Windows, etc.).  It is therefore
invoked when the glyph matrices were already modified, and the diffs
between the current and desired matrices were already calculated.  In
particular, mouse highlight appears in the glyph matrices as either a
text property or an overlay, and the display engine notices that and
invokes the terminal code in term.c and its ilk to redraw the affected
portions of text.  This means that when you are in term.c, you are way
past glyph matrices changing time, and should never modify them, or
you will wreak havoc on the display engine operation.

> >From term_show_mouse_face in my term.c:
> 
> 
> 	  if(draw_mouse_face == DRAW_MOUSE_FACE)
> 	    {
> 	      //TODO
> 	    }
> 	  else /* draw_mouse_face == DRAW_NORMAL_TEXT */
> 	    {
> 	      /* write_glyphs writes at cursor position, so we need to
> 		 temporarily move cursor coordinates to the beginning of
> 		 the highlight region.  */
> 
> 	      /* Save current cursor co-ordinates */
> 	      save_x = curX;
> 	      save_y = curY;
> 
> 	      pos_x = row->used[LEFT_MARGIN_AREA] + start_hpos
> 		+ WINDOW_LEFT_EDGE_X (w);
> 	      pos_y = row->y + WINDOW_TOP_EDGE_Y (w);
> 	
> 	      cursor_to (pos_x, pos_y);
> 	      write_glyphs (row->glyphs[TEXT_AREA] + start_hpos, nglyphs);
> 	      cursor_to (save_x, save_y);
> 	    }

This whole code should probably be invoked only if FRAME_TERMCAP_P,
because msdos.c does not need that and will not like being called (via
cursor_to_hook), nor should write_glyphs be called on MSDOS.  In fact,
I think the whole term_show_mouse_face should be called only for
FRAME_TERMCAP_P frames.

Also, perhaps compute `row->glyphs[TEXT_AREA] + start_hpos' only once
and reuse the value in the call to write_glyphs.  But that's
nit-picking.

Other than that, looks about right.

  reply	other threads:[~2007-05-15 21:15 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-12 10:02 [PATCH] Console based mouse face highlighting Nick Roberts
2007-05-12 10:11 ` Nick Roberts
2007-05-12 13:25 ` Eli Zaretskii
2007-05-12 23:54   ` Nick Roberts
2007-05-13  3:42     ` Eli Zaretskii
2007-05-13  4:19       ` Nick Roberts
2007-05-13  4:41         ` Eli Zaretskii
2007-05-14 21:11           ` Nick Roberts
2007-05-15  3:26             ` Eli Zaretskii
2007-05-15  3:53               ` Nick Roberts
2007-05-15 21:15                 ` Eli Zaretskii [this message]
2007-05-15 21:33                   ` David Kastrup
2007-05-16  3:16                     ` Eli Zaretskii
2007-05-15 22:39                   ` [PATCH/Now RFA] " Nick Roberts
2007-05-16  3:24                     ` Eli Zaretskii
2007-05-16  3:54                       ` Nick Roberts
2007-05-16 10:00                         ` [RFA] " Nick Roberts
2007-05-16 18:19                           ` Eli Zaretskii
2007-05-16 21:46                             ` Nick Roberts
2007-05-17  3:24                               ` Eli Zaretskii
2007-05-17  3:54                                 ` Nick Roberts
2007-05-17 14:59                                   ` Stefan Monnier
2007-05-17 20:29                                     ` Eli Zaretskii
2007-05-17 22:29                                     ` Nick Roberts
2007-05-17 20:14                                   ` Eli Zaretskii
2007-05-17 22:34                                     ` Nick Roberts
2007-05-18 14:33                                       ` Eli Zaretskii
2007-05-18 21:09                                         ` Nick Roberts
2007-05-19  7:25                                           ` Eli Zaretskii
2007-05-19  8:15                                             ` Nick Roberts
2007-05-19  8:46                                               ` Eli Zaretskii
2007-05-20  6:00                                                 ` Nick Roberts
2007-05-20  9:37                                                   ` Johan Bockgård
2007-05-20  9:51                                                     ` Nick Roberts
2007-05-22 15:54                                                       ` Johan Bockgård
2007-05-22 21:36                                                         ` Nick Roberts
2007-05-30  5:41                                                           ` Nick Roberts
2007-06-03  1:12                                                         ` Nick Roberts
2007-06-03 21:27                                                           ` Richard Stallman
2007-06-03 22:15                                                             ` Drew Adams
2007-06-03 23:31                                                             ` Nick Roberts
2007-06-04  3:24                                                               ` Eli Zaretskii
2007-05-20 18:54                                                   ` Eli Zaretskii
2007-05-20 20:12                                                     ` Renaming NEWS [was: [RFA] Console based mouse face highlighting.] Glenn Morris
2007-05-20 20:42                                                       ` Nick Roberts
2007-05-20 21:31                                                       ` Renaming NEWS Miles Bader
2007-05-21  8:09                                                         ` Glenn Morris
2007-05-21  8:42                                                           ` David Kastrup
2007-05-22  6:46                                                             ` Glenn Morris
2007-05-22  7:12                                                               ` Miles Bader
2007-05-22 17:08                                                                 ` Glenn Morris
2007-05-22  8:30                                                           ` Richard Stallman
2007-05-22 17:09                                                             ` Glenn Morris
2007-05-21 10:33                                                       ` Renaming NEWS [was: [RFA] Console based mouse face highlighting.] Richard Stallman
2007-05-19 22:31                                               ` [RFA] Console based mouse face highlighting Richard Stallman
2007-05-14 16:57     ` [PATCH] " Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=uejlheqlb.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=nickrob@snap.net.nz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.