I’ve tried to boil this down to be as meaningful as possible. I’m
guessing this is a Tk issue, but since I’m using Ruby (1.8.0) I thought
I’d start here.
Type any English text character into the entry box, and the target proc
sees the character as typed (e.g. type an a and it sees an “a”, type a b
and it sees the field contains “ab”).
The exception is the “{” (left brace). Type one in and the entry box has
one “{”, but The TkVariable @myText displays it as empty (the TkComm
object sees that as an escaped character “{” ). Type a second left
brace and the entry field has 2 braces and the TkVariable @myText still
extracts an empty string.
Type a 3rd brace and now the @myText.to_s gives back 1 brace (all right
of the first 2?).
From: Mac webrg.ruby-talk.com@Panscend.com
Subject: TkEntry with { (left brace) characters
Date: Mon, 9 Feb 2004 03:54:59 +0900
Message-ID: <C3uVb.251427$xy6.1311894@attbi_s02>
The exception is the “{” (left brace). Type one in and the entry box has
one “{”, but The TkVariable @myText displays it as empty (the TkComm
object sees that as an escaped character “{” ). Type a second left
brace and the entry field has 2 braces and the TkVariable @myText still
extracts an empty string.
Sorry. It’s a bug of TkVariable#to_s (TkComm::string).
Please use TkVariable#value instead of TkVariable#to_s.
Sorry. It’s a bug of TkVariable#to_s (TkComm::string).
Please use TkVariable#value instead of TkVariable#to_s.
I committed the following patch to CVS head.
It makes TkVariable#to_s to call TkVariable#value.
At the same time, I think it will fix the bug to treat a
Tcl/Tk’s string with escaping special characters.
However, I remain ambivalence about backporting to Ruby 1.8.x.
Although the patch fixes some problems (e.g. A validatecommand
of TkEntry cannot acquire a right string when the entry box has
a string which has unbalanced braces such as “a {”), Ruby/Tk
loses backward compatibility.
An easily understandable example of incompatibility is a return
value of TkComm::Event#char. When a key event about a left brace
occurs, Ruby/Tk without the patch returns an escaped left brace
“{”. But with the patch, returns only a left brace “{”. Of cource,
it is a bug to return “{”. Though a bug, some scripts may presume
an escaped left brace.
However, I remain ambivalence about backporting to Ruby 1.8.x.
Although the patch fixes some problems (e.g. A validatecommand
of TkEntry cannot acquire a right string when the entry box has
a string which has unbalanced braces such as “a {”), Ruby/Tk
loses backward compatibility.
snip
Your comments on the patch are welcome.
I don’t mind if you dont’ backport the patch. I went ahead with 1.8.1
and applied the patch (final version ) to that. I figured if I was
going to recompile I’d have the next stable release. I need to retest
anyway. Might as well get caught up.
I do think that anyone that coded around the escaped left brace could be
just as surprised when they move on to a new version as they would have
been if they found it in a supposedly “same” version.
But I might not backport it just because of needing to draw a line
somewhere. How many versions back would you go with a backport? 1.8.0?
1.6.1? ??? I’d just leave well enough alone and make sure it’s documented.
Sorry, again. The patch has some bugs.
I fixed on CVS head. Please get the newest version from CVS.
Just got the patch and applied it to ruby 1.8.1 . It works well so far.
Got both my bugs and doesn’t seem to have detrimental side effects. I’ll
keep an eye on it as I continue working with it.