From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.216.65.18 with SMTP id e18cs97507wed; Tue, 11 May 2010 11:56:57 -0700 (PDT) Received: by 10.141.213.22 with SMTP id p22mr4122550rvq.131.1273604216026; Tue, 11 May 2010 11:56:56 -0700 (PDT) Return-Path: Received: from rubyforge.org (rubyforge.org [205.234.109.19]) by mx.google.com with ESMTP id 17si30224qyk.116.2010.05.11.11.56.55; Tue, 11 May 2010 11:56:55 -0700 (PDT) Received-SPF: pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) client-ip=205.234.109.19; Authentication-Results: mx.google.com; spf=pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=sup-devel-bounces@rubyforge.org; dkim=neutral (body hash did not verify) header.i=@gmail.com Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 54D171858350; Tue, 11 May 2010 14:56:55 -0400 (EDT) Received: from mail-fx0-f50.google.com (mail-fx0-f50.google.com [209.85.161.50]) by rubyforge.org (Postfix) with ESMTP id BD54E1858349 for ; Tue, 11 May 2010 14:56:50 -0400 (EDT) Received: by fxm1 with SMTP id 1so1293135fxm.23 for ; Tue, 11 May 2010 11:56:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=VgiANORaKayYt1MMcj6DbpjRRGfOukUrFAaqpmfE69Y=; b=Cw+/7k0c15xWxde9RtwG6WqpAmRoKhr9uTiD7iEl3bf1ZgwxyDAhbM1NWPr4T/D7Gr njy8MYOsnGfxnpRS435Sd+YU66JGbiefAlqBFF6PRcNCzzFn4/k+aKwdNRDY/WLjGy1D V3caPrTdqBuBDmbnDigFMzGrhVzItZXddzlOA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=oPYuxsxXFKr/tNyFxXAombJMBED/XrpvS2If6gqMBgfrj9lu7dfbMdzZm6shNaEVpX 4X6k3zurIgQAiydIfFcrr33k3rMViEATvTacvcY3T8h/nHWI15dM5xCOaAfDF3uJCmAZ su7yfFAj+rtBpKxfQVbB3ZpT2ZFq66trzQNGk= MIME-Version: 1.0 Received: by 10.239.189.12 with SMTP id r12mr602919hbh.129.1273603817240; Tue, 11 May 2010 11:50:17 -0700 (PDT) Received: by 10.239.151.18 with HTTP; Tue, 11 May 2010 11:50:17 -0700 (PDT) In-Reply-To: <1273250528-sup-9662@zyrg.net> References: <1273250528-sup-9662@zyrg.net> Date: Tue, 11 May 2010 21:50:17 +0300 Message-ID: From: Matti Eiden To: sup-devel Subject: Re: [sup-devel] Arch utf8 vs UTF-8 fix and wide character support X-BeenThere: sup-devel@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: Sup developer discussion List-Id: Sup developer discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: sup-devel-bounces@rubyforge.org Errors-To: sup-devel-bounces@rubyforge.org > > It's actually the multiple screen cells that causes problems, not > multiple bytes [1]. Sup currently thinks all characters are 1 cell wide. > The right thing is probably a C extension that uses wcswidth. > > [1] http://mid.gmane.org/1264629880-sup-9232%40zyrg.net > So okay, I sent my previous answer accidentally only to Rich. In this mail I mentioned a Ruby library called terminfo ( http://www.a-k-r.org/ruby-terminfo/ ), which contains a function wcswidth. I downloaded terminfo and installed it, and edited lib/sup/util.rb slightly. 1) Added of course "require 'terminfo'" on the top. 2) Modified the display_length function of "nasty multibyte hack" to use TermInfo.wcswidth instead of native "size" Results: Everything seems to work now. I don't know what is the opinion of other sup users, whether adding a new dependency (to terminfo) is desirable, as the current list of dependencies is already rather high.. Discuss. If somebody with some C skills knows how to move that wcswidth function to the ruby-ncursesw (Rich? :D) would that be a more favourable option? Here's the actual patch of what I did to keep it clear (I notice there has been an earlier utf8 patch here, for pre Ruby 1.9.1 versions. I don't know how many of you use some earlier Ruby version still, of course this would also solve the "nasty" utf scan patch.): --- util-old.rb 2010-05-11 21:38:55.736596584 +0300 +++ util.rb 2010-05-11 21:36:12.653281044 +0300 @@ -3,6 +3,7 @@ require 'mime/types' require 'pathname' require 'set' +require 'terminfo' ## time for some monkeypatching! class Lockfile def gen_lock_id @@ -183,7 +184,7 @@ if RUBY_VERSION < '1.9.1' && ($encoding == "UTF-8" || $encoding == "utf8") scan(/./u).size else - size + TermInfo.wcswidth(self) end end _______________________________________________ Sup-devel mailing list Sup-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-devel