From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nick Roberts Newsgroups: gmane.emacs.devel Subject: Re: [RFA] Console based mouse face highlighting. Date: Thu, 17 May 2007 09:46:00 +1200 Message-ID: <17995.31640.399794.621018@kahikatea.snap.net.nz> References: <17989.37070.393150.565546@kahikatea.snap.net.nz> <17990.21422.577087.305723@kahikatea.snap.net.nz> <17990.37305.657724.344516@kahikatea.snap.net.nz> <17992.53379.953892.751275@kahikatea.snap.net.nz> <17993.11948.400368.430713@kahikatea.snap.net.nz> <17994.14013.614407.875104@kahikatea.snap.net.nz> <17994.32856.216525.50726@kahikatea.snap.net.nz> <17994.54868.931947.611990@kahikatea.snap.net.nz> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1179352013 14672 80.91.229.12 (16 May 2007 21:46:53 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 16 May 2007 21:46:53 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 16 23:46:52 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HoRKc-0002Yt-R8 for ged-emacs-devel@m.gmane.org; Wed, 16 May 2007 23:46:51 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HoRSe-0008E8-5v for ged-emacs-devel@m.gmane.org; Wed, 16 May 2007 17:55:08 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HoRRz-0007ql-4m for emacs-devel@gnu.org; Wed, 16 May 2007 17:54:27 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HoRRx-0007px-N8 for emacs-devel@gnu.org; Wed, 16 May 2007 17:54:26 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HoRRx-0007po-Hj for emacs-devel@gnu.org; Wed, 16 May 2007 17:54:25 -0400 Original-Received: from viper.snap.net.nz ([202.37.101.8]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HoRJt-00039N-T7; Wed, 16 May 2007 17:46:06 -0400 Original-Received: from kahikatea.snap.net.nz (29.63.255.123.dynamic.snap.net.nz [123.255.63.29]) by viper.snap.net.nz (Postfix) with ESMTP id D91B53D924C; Thu, 17 May 2007 09:46:02 +1200 (NZST) Original-Received: by kahikatea.snap.net.nz (Postfix, from userid 1000) id 350FA8F92B; Thu, 17 May 2007 09:46:01 +1200 (NZST) In-Reply-To: X-Mailer: VM 7.19 under Emacs 22.1.50.249 X-detected-kernel: Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:71196 Archived-At: > 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;