From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14347 invoked from network); 6 May 2008 09:15:58 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 6 May 2008 09:15:58 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 48116 invoked from network); 6 May 2008 09:15:56 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 6 May 2008 09:15:56 -0000 Received: (qmail 15604 invoked by alias); 6 May 2008 09:15:53 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24932 Received: (qmail 15587 invoked from network); 6 May 2008 09:15:53 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 6 May 2008 09:15:53 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [217.69.20.190]) by bifrost.dotsrc.org (Postfix) with ESMTP id 2832880ED172 for ; Tue, 6 May 2008 11:15:49 +0200 (CEST) Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly51d.srv.mailcontrol.com (MailControl) with ESMTP id m469FgAZ015839 for ; Tue, 6 May 2008 10:15:47 +0100 Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Tue, 6 May 2008 10:15:40 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.14.2/8.13.4) with ESMTP id m469Ffhq017554 for ; Tue, 6 May 2008 10:15:41 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.14.2/8.14.2/Submit) with ESMTP id m469FeJP017551 for ; Tue, 6 May 2008 10:15:40 +0100 Message-Id: <200805060915.m469FeJP017551@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: PATCH: random attribute stuff X-Mailer: MH-E 8.0.3; nmh 1.2-20070115cvs; GNU Emacs 22.1.1 Date: Tue, 06 May 2008 10:15:40 +0100 From: Peter Stephenson X-OriginalArrivalTime: 06 May 2008 09:15:41.0032 (UTC) FILETIME=[C150FE80:01C8AF59] X-Scanned-By: MailControl A-08-50-00 (www.mailcontrol.com) on 10.68.0.161 X-Virus-Scanned: ClamAV 0.91.2/7040/Tue May 6 03:52:15 2008 on bifrost X-Virus-Status: Clean This is supposed to replace ad hoc code that fixes up text attributes after the right prompt to use the usual settextattributes() function. However, having seen the change, it's more ad hoc than I hoped... still, that's mostly because it now handles changes in colour which it didn't before. I'm not completely convinced of the utility of this chunk of code. It seems to be designed so that after a right prompt is output everything is the same as after the normal prompt. But both before and after this patch if I let the right prompt leave, say, underline turned on then when I play with history lines the main line appears underlined, too. I don't think it's ever been a good idea to leave effects turned on after prompts. Index: Src/zsh.h =================================================================== RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v retrieving revision 1.129 diff -u -r1.129 zsh.h --- Src/zsh.h 2 May 2008 22:48:58 -0000 1.129 +++ Src/zsh.h 6 May 2008 09:06:02 -0000 @@ -1983,6 +1983,8 @@ #define TXT_ATTR_OFF_ON_SHIFT 6 #define TXT_ATTR_OFF_FROM_ON(attr) \ (((attr) & TXT_ATTR_ON_MASK) << TXT_ATTR_OFF_ON_SHIFT) +#define TXT_ATTR_ON_FROM_OFF(attr) \ + (((attr) & TXT_ATTR_OFF_MASK) >> TXT_ATTR_OFF_ON_SHIFT) /* * Indicates to zle_refresh.c that the character entry is an * index into the list of multiword symbols. Index: Src/Zle/zle_refresh.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_refresh.c,v retrieving revision 1.65 diff -u -r1.65 zle_refresh.c --- Src/Zle/zle_refresh.c 1 May 2008 10:58:25 -0000 1.65 +++ Src/Zle/zle_refresh.c 6 May 2008 09:06:03 -0000 @@ -1869,29 +1869,44 @@ /* output the right-prompt if appropriate */ if (put_rpmpt && !iln && !oput_rpmpt) { + int attrchange; + moveto(0, winw - 1 - rpromptw); zputs(rpromptbuf, shout); vcs = winw - 1; /* reset character attributes to that set by the main prompt */ txtchange = pmpt_attr; - if (txtchangeisset(txtchange, TXTNOBOLDFACE) && - (rpmpt_attr & TXTBOLDFACE)) - tsetcap(TCALLATTRSOFF, 0); - if (txtchangeisset(txtchange, TXTNOSTANDOUT) && - (rpmpt_attr & TXTSTANDOUT)) - tsetcap(TCSTANDOUTEND, 0); - if (txtchangeisset(txtchange, TXTNOUNDERLINE) && - (rpmpt_attr & TXTUNDERLINE)) - tsetcap(TCUNDERLINEEND, 0); - if (txtchangeisset(txtchange, TXTBOLDFACE) && - (rpmpt_attr & TXTNOBOLDFACE)) - tsetcap(TCBOLDFACEBEG, 0); - if (txtchangeisset(txtchange, TXTSTANDOUT) && - (rpmpt_attr & TXTNOSTANDOUT)) - tsetcap(TCSTANDOUTBEG, 0); - if (txtchangeisset(txtchange, TXTUNDERLINE) && - (rpmpt_attr & TXTNOUNDERLINE)) - tsetcap(TCUNDERLINEBEG, 0); + /* + * Keep attributes that have actually changed, + * which are ones off in rpmpt_attr and on in + * pmpt_attr, and vice versa. + */ + attrchange = txtchange & + (TXT_ATTR_OFF_FROM_ON(rpmpt_attr) | + TXT_ATTR_ON_FROM_OFF(rpmpt_attr)); + /* + * Careful in case the colour changed. + */ + if (txtchangeisset(txtchange, TXTFGCOLOUR) && + (!txtchangeisset(rpmpt_attr, TXTFGCOLOUR) || + ((txtchange ^ rpmpt_attr) & TXT_ATTR_FG_COL_MASK))) + { + attrchange |= + txtchange & (TXTFGCOLOUR | TXT_ATTR_FG_COL_MASK); + } + if (txtchangeisset(txtchange, TXTBGCOLOUR) && + (!txtchangeisset(rpmpt_attr, TXTBGCOLOUR) || + ((txtchange ^ rpmpt_attr) & TXT_ATTR_BG_COL_MASK))) + { + attrchange |= + txtchange & (TXTBGCOLOUR | TXT_ATTR_BG_COL_MASK); + } + /* + * Now feed these changes into the usual function, + * if necessary. + */ + if (attrchange) + settextattributes(attrchange); } } -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070