Subject: Re: [sup-devel] use-console-gem branch

From: William Morgan <[email-masked]>
Date: Mon, 24 Jan 2011 12:25:51 -0500

Reformatted excerpts from Pi's message of 2011-01-23:
> It seems to work well, excepting some artifacting in the rightmost
> column of the screen: http://dl.dropbox.com/u/129462/consolegem.png

This should be fixed. Still haven't found the source of that nasty black
square that pops up when thread-index-mode is drawn afresh.
-- 
William <[email-masked]>
_______________________________________________
Sup-devel mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-devel

---

From: Tero Tilus <[email-masked]>
Date: Tue, 25 Jan 2011 02:39:06 +0200

William Morgan, 2011-01-23 06:30:
> If anyone wants to give it a go, I'd love to hear your
> results. Please report Ruby version and OS as well.

Debian 5.0.8
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]

--- NoMethodError from thread: load threads for thread-index-mode
undefined method `force_encoding' for nil:NilClass
/home/terotil/src/sup/lib/sup/person.rb:18:in `force_encoding'
/home/terotil/src/sup/lib/sup/message.rb:154:in `load_from_index!'
/home/terotil/src/sup/lib/sup/message.rb:154:in `map'
/home/terotil/src/sup/lib/sup/message.rb:154:in `load_from_index!'
/home/terotil/src/sup/lib/sup/index.rb:219:in `build_message'
/home/terotil/src/sup/lib/sup/index.rb:155:in `each_id_by_date'
/home/terotil/src/sup/lib/sup/thread.rb:338:in `call'
/home/terotil/src/sup/lib/sup/thread.rb:338:in `load_n_threads'
/home/terotil/src/sup/lib/sup/index.rb:155:in `each_id_by_date'
/home/terotil/src/sup/lib/sup/index.rb:250:in `each_id'
/home/terotil/src/sup/lib/sup/index.rb:250:in `each'
/home/terotil/src/sup/lib/sup/index.rb:250:in `each_id'
/home/terotil/src/sup/lib/sup/index.rb:155:in `each_id_by_date'
/home/terotil/src/sup/lib/sup/thread.rb:334:in `load_n_threads'
/home/terotil/src/sup/lib/sup/modes/thread-index-mode.rb:640:in `__unprotected_load_n_threads'
(eval):12:in `load_n_threads'
/home/terotil/src/sup/lib/sup/modes/thread-index-mode.rb:624:in `load_n_threads_background'
/home/terotil/src/sup/lib/sup.rb:81:in `reporting_thread'
/home/terotil/src/sup/lib/sup.rb:79:in `initialize'
/home/terotil/src/sup/lib/sup.rb:79:in `new'
/home/terotil/src/sup/lib/sup.rb:79:in `reporting_thread'
/home/terotil/src/sup/lib/sup/modes/thread-index-mode.rb:623:in `load_n_threads_background'
/home/terotil/src/sup/lib/sup/modes/thread-index-mode.rb:694:in `__unprotected_load_threads'
(eval):12:in `load_threads'
/home/terotil/src/sup/bin/sup:195

This was due to Person#name being set to nil on some cases.  I got rid
of it like this

diff --git a/lib/sup/person.rb b/lib/sup/person.rb
index ee23fc5..83fc60f 100644
--- a/lib/sup/person.rb
+++ b/lib/sup/person.rb
@@ -9,6 +9,8 @@ class Person
     @name = if name
       name = name.strip.gsub(/\s+/, " ")
       name =~ /^(['"]\s*)(.*?)(\s*["'])$/ ? $2 : name
+    else
+      ""
     end

     @email = email.strip.gsub(/\s+/, " ").downcase
@@ -103,7 +105,7 @@ class Person
       when /((\S+?)@\S+)/
         [$2, $1]
       else
-        [nil, s]
+        ["", s]
       end

     Person.new name, email

Only to have it crash later on.  ;)

--- ArgumentError from thread: load threads for thread-index-mode
malformed string: invalid multibyte character at position 79
/usr/lib/ruby/gems/1.8/gems/console-0.3/lib/console/string.rb:27:in `display_width'
/usr/lib/ruby/gems/1.8/gems/console-0.3/lib/console/string.rb:27:in `display_width'
/home/terotil/src/sup/lib/sup/modes/scroll-mode.rb:226:in `draw_line_from_array'
/home/terotil/src/sup/lib/sup/util.rb:608:in `each_with_index'
/home/terotil/src/sup/lib/sup/modes/scroll-mode.rb:224:in `each'
/home/terotil/src/sup/lib/sup/modes/scroll-mode.rb:224:in `each_with_index'
/home/terotil/src/sup/lib/sup/modes/scroll-mode.rb:224:in `draw_line_from_array'
/home/terotil/src/sup/lib/sup/modes/scroll-mode.rb:199:in `draw_line'
/home/terotil/src/sup/lib/sup/modes/line-cursor-mode.rb:52:in `draw_line'
/home/terotil/src/sup/lib/sup/modes/scroll-mode.rb:46:in `draw'
/home/terotil/src/sup/lib/sup/modes/scroll-mode.rb:46:in `each'
/home/terotil/src/sup/lib/sup/modes/scroll-mode.rb:46:in `draw'
/home/terotil/src/sup/lib/sup/modes/line-cursor-mode.rb:37:in `draw'
/home/terotil/src/sup/lib/sup/buffer.rb:119:in `draw'
/home/terotil/src/sup/lib/sup/buffer.rb:103:in `redraw'
/home/terotil/src/sup/lib/sup/buffer.rb:336:in `draw_screen'
/home/terotil/src/sup/lib/sup/buffer.rb:766:in `clear'
/home/terotil/src/sup/lib/sup/util.rb:611:in `send'
/home/terotil/src/sup/lib/sup/util.rb:611:in `method_missing'
/home/terotil/src/sup/lib/sup/modes/thread-index-mode.rb:653:in `__unprotected_load_n_threads'
(eval):12:in `load_n_threads'
/home/terotil/src/sup/lib/sup/modes/thread-index-mode.rb:624:in `load_n_threads_background'
/home/terotil/src/sup/lib/sup.rb:81:in `reporting_thread'
/home/terotil/src/sup/lib/sup.rb:79:in `initialize'
/home/terotil/src/sup/lib/sup.rb:79:in `new'
/home/terotil/src/sup/lib/sup.rb:79:in `reporting_thread'
/home/terotil/src/sup/lib/sup/modes/thread-index-mode.rb:623:in `load_n_threads_background'
/home/terotil/src/sup/lib/sup/modes/thread-index-mode.rb:694:in `__unprotected_load_threads'
(eval):12:in `load_threads'
/home/terotil/src/sup/bin/sup:195

-- 
Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/
_______________________________________________
Sup-devel mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-devel

---

From: William Morgan <[email-masked]>
Date: Wed, 26 Jan 2011 10:33:42 -0500

> malformed string: invalid multibyte character at position 79

Thanks for the report. I think I'm going to release a new version that
doesn't raise exceptions if the strings are "corrupt"---too frequent an
occurrence to break the entire application.
-- 
William <[email-masked]>
_______________________________________________
Sup-devel mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-devel

---

From: William Morgan <[email-masked]>
Date: Sat, 22 Jan 2011 23:30:07 -0500

Hi guys,

I've published a branch that uses the console gem and should properly
display CJK text (finally!) on both Ruby 1.8 and 1.9.  It's
'use-console-gem'. If anyone wants to give it a go, I'd love to hear
your results. Please report Ruby version and OS as well.

Here's some Chinese text. You can ensure that scrolling left and right
doesn't corrupt the characters, that the cursor highlights the
appropriate line, etc.

《李太白集》，舊稱《草堂集》，僅十卷，唐李陽冰編並序。宋真宗咸平中（998年－
1003年），樂史別得李白詩歌十卷，合為《李翰林集》二十卷，凡七百七十六篇，又
纂雜著為《別集》十卷，皆已失傳。宋英宗治平中（1064年－1067年），宋敏求
（次道）得王溥（文獻）及唐魏顥所纂李白詩，又集唐類書及石刻所傳，和李陽冰集
所編，共一千一篇（四庫藏本），曾鞏乃考其先後而編次之。今本三十卷，當即曾鞏
所編本。
今本《李太白集》三十卷。《四部叢刊》影印明刊本，為元楊齊賢集注、蕭士斌補注。
新興書局影印本《李太白詩文集》三十卷同前本。又清王琦注《李太白集》三十卷
（附錄六卷），有原刻本及光緒卅四年上海掃葉山房石印本。台灣台北有河洛出版社
影印王琦本。今人瞿兌園《李白集校注》，集校勘、注釋、評箋為一編，最為完善，
有里仁書局影印本。
-- 
William <[email-masked]>
_______________________________________________
Sup-devel mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-devel

---

From: Pi <[email-masked]>
Date: Sun, 23 Jan 2011 15:10:53 -0800

> your results. Please report Ruby version and OS as well.

It seems to work well, excepting some artifacting in the rightmost column of the
screen: http://dl.dropbox.com/u/129462/consolegem.png

It goes away with a Ctrl-L, but I figured I'd report it anyway.

-- 
Theory is when you know something, but it doesn't work. Practice is when
something works, but you don't know why. Programmers combine theory and
practice: Nothing works and they don't know why.
_______________________________________________
Sup-devel mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-devel