> > 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