Subject: [sup-talk] ncurses hack

From: [email-masked] (Edward Z. Yang)
Date: Mon, 17 Aug 2009 15:54:45 -0400

Today, I decided to throw in the towel and patch my copy of ncurses
to have the appropriate fix for international characters + tabs.  Does
anyone know of a list of instructions for carrying this out?

Cheers,
Edward

---

From: [email-masked] (William Morgan)
Date: Mon, 17 Aug 2009 19:43:18 -0700

Reformatted excerpts from Edward Z. Yang's message of 2009-08-17:
> Today, I decided to throw in the towel and patch my copy of ncurses to
> have the appropriate fix for international characters + tabs.  Does

Try http://sup.rubyforge.org/wiki/wiki.pl?UTF8. If you're running Sup
git, I've made a nice branch for this:

  $ git branch --track ncursesw origin/ncursesw
  $ git checkout ncursesw
  $ cd ncurses-0.9.1/
  $ ./run-this-for-sup.sh

Which will generate an ncurses.so file in lib/. You can then switch back
to master or next and it should pick it up.

This should fix many wide-character issues but it won't fix all of them,
because there's still no way of determining the display width of a
unicode character (e.g. Chinese characters take two columns to display).
So the display still ends up funny.

Ruby 1.9 has better encoding support but I don't know if it fixes this.
-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (Dusan)
Date: Tue, 18 Aug 2009 09:42:48 +0200

> Ruby 1.9 has better encoding support but I don't know if it fixes this.

I am new sup user and love it very much.

Not being able to fix search/save and other edits is huge show-stopper.
I do what I read somewhere:

-start search, get garbage results
-kill that buffer with 'x'
-start another search but instead of typing search term again first
repeat: press up, delete search garbage, press up, delete search
garbage, repeat until there is nothing to delete
-type another search term and search now works 100%

This works for searches but edits like save still fail (or save X((%^1X file
so if you can find it you can rename it).

Looks like fixable bug to simulate what I did for searches? Repeat in
code ten times 'up arrow', '50 x delete char'? Sorry if I am wrong.

Using sup and not being able to properly search or save is too wrong.

If there is any config/version I should report to get this fixed just
let me know. Without waiting for new ruby of course -- I do have proper
results when I repeat deleting ritual.

Thanks

---

From: [email-masked] (Benoît PIERRE)
Date: Tue, 18 Aug 2009 20:24:45 +0200

Excerpts from Dusan's message of Tue Aug 18 09:42:48 +0200 2009:
> [...]

Hi, can you try the following patch and tell me if it fix the problem?

diff --git a/lib/sup/textfield.rb b/lib/sup/textfield.rb
index b8dec59..ccc8533 100644
--- a/lib/sup/textfield.rb
+++ b/lib/sup/textfield.rb
@@ -36,8 +36,9 @@ class TextField
     @field = Ncurses::Form.new_field 1, @width - question.length, @y,
@x + question.length, 256, 0
     @form = Ncurses::Form.new_form [@field]
     @value = default
+    @value ||= ''
     Ncurses::Form.post_form @form
-    set_cursed_value default if default
+    set_cursed_value @value
   end

   def position_cursor

-- 
A: Because it destroys the flow of conversation.
Q: Why is top posting dumb?

---

From: [email-masked] (Dusan)
Date: Tue, 18 Aug 2009 20:46:52 +0200

> +    set_cursed_value @value

I will, just give me day or two. I am using gem version, not svn or git.
I did some stuff with them but never with ruby. Can you give me two
lines help what to install and where? Latest svn?

Sorry I am not _that_ helpful but ruby is new thing to me. I should be
able to test this soon enough with some help.

Thanks,
Dusan

---

From: [email-masked] (Benoît PIERRE)
Date: Tue, 18 Aug 2009 20:59:20 +0200

> lines help what to install and where? Latest svn?

You can probably directly patch the sources in the gem. For example on
Ubuntu, the sources should be somewhere in /var/lib/gems/1.8/gems/sup-xxx.

Use 'gem environment' to get the installation directory.

Another option is to follow the wiki to get the latest git version:
http://sup.rubyforge.org/wiki/wiki.pl?Contributing
-- 
A: Because it destroys the flow of conversation.
Q: Why is top posting dumb?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://rubyforge.org/pipermail/sup-talk/attachments/20090818/302eaeb0/attachment.bin>

---

From: [email-masked] (Dusan)
Date: Tue, 18 Aug 2009 21:04:16 +0200

> http://sup.rubyforge.org/wiki/wiki.pl?Contributing

Everything but git, thanks :)
Of course, ruby is interpreter, I keep forgetting that.
I am using ArchLinux and should be fairly skilled to do some changing. Reporting
back tomorrow.

---

From: [email-masked] (Dusan)
Date: Tue, 18 Aug 2009 21:24:44 +0200

> http://sup.rubyforge.org/wiki/wiki.pl?Contributing

Bah, I could not wait till tomorrow and it's not _that_ late...

This fix WORKS :) Every time so far. Please include this into release
asap, this is what prevents a lot of people from using sup.

I patched source with vim, diff is too automatic :)

Here is func that works:

  activate window, y, x, width, question, default=nil, &block
    @w, @y, @x, @width = window, y, x, width
    @question = question
    @completion_block = block
    @field = Ncurses::Form.new_field 1, @width - question.length, @y, @x
+ question.length, 256, 0
    @form = Ncurses::Form.new_form [@field]
    @value = default
    @value ||= ''
    Ncurses::Form.post_form @form
    # set_cursed_value default if default
    set_cursed_value @value
  end 

Probably @value=default can go too, not sure since I don't know ruby?

Thanks a lot!

---

From: [email-masked] (Jörg-Hendrik Bach)
Date: Tue, 18 Aug 2009 21:31:35 +0200

2009/8/18 Beno?t PIERRE <benoit.pierre at gmail.com>:
> ? ? @field = Ncurses::Form.new_field 1, @width - question.length, @y,
> ? ? @form = Ncurses::Form.new_form [@field]
> ? ? @value = default
> + ? ?@value ||= ''
> ? ? Ncurses::Form.post_form @form
> - ? ?set_cursed_value default if default
> + ? ?set_cursed_value @value
> ? end
>
> ? def position_cursor

Thanks a lot. I don't know what this does exactly, but the first added
line of that patch was sufficient to get searches with utf-8 running
well from startup, without the need to go for a dummy search each time
i restarted sup.

The full patch (including the replacement at line 41) broke searching
altogether, on hitting '\' it throws:

--- TypeError from thread: main
can't convert nil into String
/usr/lib/ruby/gems/1.8/gems/sup-0.8.1/lib/sup/textfield.rb:159:in
`set_field_buffer'
/usr/lib/ruby/gems/1.8/gems/sup-0.8.1/lib/sup/textfield.rb:159:in
`set_cursed_value'
/usr/lib/ruby/gems/1.8/gems/sup-0.8.1/lib/sup/textfield.rb:42:in `activate'
/usr/lib/ruby/gems/1.8/gems/sup-0.8.1/lib/sup/buffer.rb:537:in `ask'
/usr/lib/ruby/gems/1.8/gems/sup-0.8.1/lib/sup/buffer.rb:26:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/sup-0.8.1/lib/sup/buffer.rb:26:in `sync'
/usr/lib/ruby/gems/1.8/gems/sup-0.8.1/lib/sup/buffer.rb:536:in `ask'
/usr/lib/ruby/gems/1.8/gems/sup-0.8.1/lib/sup/util.rb:513:in `send'
/usr/lib/ruby/gems/1.8/gems/sup-0.8.1/lib/sup/util.rb:513:in `method_missing'
/usr/lib/ruby/gems/1.8/gems/sup-0.8.1/bin/sup:268
/usr/bin/sup:19:in `load'
/usr/bin/sup:19

- J?rg-Hendrik