[PD-dev] toxy - woah

Krzysztof Czaja czaja at chopin.edu.pl
Sat Jan 24 13:53:34 CET 2004


hi Ben,

toxy widget stuff ``proves the concept'' more than does anything
else, currently (although I do use it in my work).  Or... even
worse -- what is it going to prove most likely, unless a set of
well-integrated widget types is defined, is the common wisdom of
tcl/tk being a nostalgic toy for old-style hackers...  Now, about
the text widget --

B. Bogart wrote:
...
> I'm having some troubles with text entry though. I've hacked the example
> using an entry widget and replaced it with a text widget, which works great,
> except for a couple issues, multiple spaces and carrige returns are not
> preserved, and the result is wrapped in {} braces. I'd like to use this with
...
> PS: What exactly does: eval .<[.- get ].> do? I'm trying to add a string

it evaluates the contents of .<.> brackets, and sends the result
to the pd side.  That result is parsed into atoms, and comes out
of the left outlet of a widget, or any of its tows.

Actually, ".<xxx.>" should be equivalent to "pd .| _cb xxx .`.:",
but in case of a multi-word result it is not, due to an extra
level of grouping, which is a bug.

(The sequence .| above is resolved to the pd target bound to the
widget object, and its tows).

Since .- is resolved as the widget's pathname, the contents in
the entry widget example (.- get) specifies the Tk command
"pathName get", without arguments.  Which works for the entry,
but a text widget needs explicit indices (e.g. ".- get 1.0 end"
for the entire text, or even ".- get 0.end end", to prevent pd
from parsing 1.0 as the number 1).

One way of dealing with line breaks could be defining a @float
handler and getting each line separately by sending a float to
the widget or its tow.  The "string map" command may be used to
glue the space chars, preventing pd from parsing them as atom
separators.  Thus this line

@float pd .| _cb [string map .(" " ".`.` ".) [.- get .#1.0 .#1.end]] .`.:

would be the simplest definition of a handler, to be put in a .wid
file, or triggered by a loadbang.

In order to get the current number of lines, through [r nlines],
the widget object (or, better, its tow), should be sent:

tot pd nlines [expr [.- index end] - 1] .`.:

Obviously, text widget does not integrate well into toxy, without
much more effort:  one has to disable special chars, define
a mechanism for preserving state across unmap/map events, etc.

Krzysztof





More information about the Pd-dev mailing list