Keyboard bindings
David Shaffer
cdshaffer at acm.org
Sun Oct 2 16:10:57 UTC 2005
Tony Garnock-Jones wrote:
> Romain Robbes wrote:
>
>> some people still need it). I'd really like to remove the mode,
>> but finding a good keystroke+clicking combination is tough. The same
>> thing applies to keyboard shortcuts by the way.
>
>
> How might we *emacsify* the keyboard bindings?
>
> One of my favourite things about emacs is being able to
>
> (defun word-count nil "Count words in buffer"
> (interactive)
> (shell-command-on-region (point-min) (point-max) "wc -w"))
>
> ...and, by virtue of the "(interactive)" subform, my brand new
> function is suddenly available for user-configurable keybinding and/or
> execution via M-x.
>
> How can we do a similar thing in Squeak?
>
> Could method annotations help here?
>
> Regards,
> Tony
>
Tony,
Romain suggested that you can provide a "word count service". As he
noted it is a bit more work than a ELISP function. Also, if all you
want is a keyboard shortcut you could simply create a class to house
your favorite ones and then use Keymapping to activate the methods.
This is a bit shorter than services but also less capable. I'll code up
your example just to prove that it isn't much harder than ELISP:
Object subclass: #MyShortcuts
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Keymapping-Examples'
" clas side "
countWords: event forMorph: aMorph
| words |
(aMorph isKindOf: TextMorph) ifFalse: [^nil].
words := (aMorph contents asString findTokens: {Character space.
Character cr. Character lf. Character tab}) size.
self inform: 'Words: ' , words printString
Then, in a TextMorph press <c-k> to raise the keymap editor. Select the
"TextMorph" tab, press <m-a> (or use the popup menu) to add an entry
(see attached image).
That should do it. Press <c-o> in any TextMorph and you get a word
count. You can, of course, save your keymap so that you can use it in
all of your images.
David
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Squeak.1.gif
Type: image/gif
Size: 5682 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20051002/0b8b68d5/Squeak.1.gif
More information about the Squeak-dev
mailing list
|