From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20474 invoked from network); 17 Oct 2007 17:52:52 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 17 Oct 2007 17:52:52 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 6946 invoked from network); 17 Oct 2007 17:52:46 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 17 Oct 2007 17:52:46 -0000 Received: (qmail 16769 invoked by alias); 17 Oct 2007 17:52:44 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23978 Received: (qmail 16749 invoked from network); 17 Oct 2007 17:52:43 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 17 Oct 2007 17:52:43 -0000 Received: (qmail 6696 invoked from network); 17 Oct 2007 17:52:43 -0000 Received: from cluster-g.mailcontrol.com (85.115.41.190) by a.mx.sunsite.dk with SMTP; 17 Oct 2007 17:52:37 -0000 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly14g.srv.mailcontrol.com (MailControl) with ESMTP id l9HHqRjb008678 for ; Wed, 17 Oct 2007 18:52:32 +0100 Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Wed, 17 Oct 2007 18:52:30 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.14.1/8.13.4) with ESMTP id l9HHqUhT007872 for ; Wed, 17 Oct 2007 18:52:30 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.14.1/8.14.1/Submit) with ESMTP id l9HHqU4t007869 for ; Wed, 17 Oct 2007 18:52:30 +0100 X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: PATCH: zcurses -s X-Mailer: MH-E 8.0.3; nmh 1.2-20070115cvs; GNU Emacs 22.1.1 Date: Wed, 17 Oct 2007 18:52:30 +0100 Message-ID: <7868.1192643550@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 17 Oct 2007 17:52:30.0691 (UTC) FILETIME=[7D11F330:01C810E6] X-Scanned-By: MailControl A-07-08-10 (www.mailcontrol.com) on 10.71.0.124 This looks about the neatest way of doing zcurses -s, as long as we don't have separate character attributes (waddwstr() does the cchar_t conversion internally). Otherwise I think you just have to loop over the setcchar() for each wide character and pass that to wadd_wchstr()---however, that doesn't advance the cursor so isn't compatible with the other output routines, for some reason. So then it looks like you're stuck with looping over wadd_wch(), too, which probably isn't a disaster. Index: configure.ac =================================================================== RCS file: /cvsroot/zsh/zsh/configure.ac,v retrieving revision 1.71 diff -u -r1.71 configure.ac --- configure.ac 12 Oct 2007 10:18:58 -0000 1.71 +++ configure.ac 17 Oct 2007 17:47:17 -0000 @@ -1134,7 +1134,7 @@ brk sbrk \ pathconf sysconf \ tgetent tigetflag tigetnum tigetstr setupterm initscr \ - setcchar \ + setcchar waddwstr \ pcre_compile pcre_study pcre_exec \ nl_langinfo \ erand48 open_memstream \ Index: Src/Modules/curses.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Modules/curses.c,v retrieving revision 1.9 diff -u -r1.9 curses.c --- Src/Modules/curses.c 17 Oct 2007 13:11:11 -0000 1.9 +++ Src/Modules/curses.c 17 Oct 2007 17:47:17 -0000 @@ -30,6 +30,11 @@ #define _XOPEN_SOURCE_EXTENDED 1 #include +#ifndef MULTIBYTE_SUPPORT +# undef HAVE_SETCCHAR +# undef HAVE_WADDWSTR +#endif + #ifdef HAVE_SETCCHAR # include #endif @@ -279,10 +284,11 @@ LinkNode node; ZCWin w; -#ifdef HAVE_SETCCHAR - wchar_t *ws; - cchar_t *wcc; - size_t sl; +#ifdef HAVE_WADDWSTR + int clen; + wint_t wc; + wchar_t *wstr, *wptr; + char *str = args[1]; #endif node = zcurses_validate_window(args[0], ZCURSES_USED); @@ -293,34 +299,20 @@ w = (ZCWin)getdata(node); -#ifdef HAVE_SETCCHAR - sl = strlen(args[1]); - - if (sl == 0) { - return 0; - } - - ws = malloc(sl * sizeof(wchar_t)); - - if (mbstowcs(ws, args[1], sl) < 1) { - free(ws); - return 1; - } - - wcc = malloc(wcslen(ws) * sizeof(cchar_t)); - - if (setcchar(wcc, ws, A_NORMAL, 0, NULL)==ERR) { - return 1; +#ifdef HAVE_WADDWSTR + mb_metacharinit(); + wptr = wstr = zhalloc((strlen(str)+1) * sizeof(cchar_t)); + + while (*str && (clen = mb_metacharlenconv(str, &wc))) { + str += clen; + if (wc == WEOF) /* TODO: replace with space? nicen? */ + continue; + *wptr++ = wc; } - - free(ws); - - if (wadd_wchstr(w->win, wcc)!=OK) { - free(wcc); + *wptr++ = L'\0'; + if (waddwstr(w->win, wstr)!=OK) { return 1; } - - free(wcc); #else if (waddstr(w->win, args[1])!=OK) return 1; -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070