Wednesday, December 27, 2006

Yow

OK, I am teh Smalltalk n00b, but this is very cool.

There's a class in Seaside, in the Scriptaculous libraries, in the Scriptaculous-Testing library specifically, called SUAutocompleterTest. Guess what it does.

I'll give you a hint.

renderContentOn: html
 html paragraph: 'Start to type a Smalltalk class-name:'.
 html paragraph: [
 html textInput
  id: 'text';
  value: text;
  callback: [ :value | text := value ].
 html div
  class: 'autocomplete';
  script: (html autocompleter
   element: 'text';
   onSelected: (html request
    triggerFormElement: 'text');
   on: #renderListOn: of: self) ]

renderListOn: html
 | items |
 items := Smalltalk allClasses select:
  [ :each | each name includesSubString: text ].
 html unorderedList list: (items first: (items size min: 10))


This creates an Ajax autocompleter with Scriptaculous and Prototype which gets automatically populated with all Smalltalk classes matching whatever you've typed.

Is that cool or what?

I'm not sure if Smalltalk allClasses evaluates to a list of all classes within Smalltalk, or all classes within your Smalltalk image -- in which case, it would include everything from Seaside and Magritte as well -- but either way, wow.

(Update: it does include Seaside, and anything else in the image. Nice.)

By the way, I don't know if I've said this before, but SqueakMap puts RubyGems to shame. Imagine RubyGems with Google built in. (Or at least a searchable RDoc.) That's SqueakMap. Even simpler install, built-in search and documentation. Madness.

One more interesting Smalltalk tidbit. I looked into Objective-C on a whim, which is the language used for developing Mac OS X apps, and it's C with Smalltalk blended in. (It seems like a weird combination, but it's good to know.)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.