Keyboard bindings

Romain Robbes romain.robbes at lu.unisi.ch
Fri Sep 30 12:30:02 UTC 2005


Hi Tony,

When you use services and keymapping you can do that.
The process is a bit longer though, since we want more information,
such as the name and description of the action, where it can fit in  
menus,
which keyboard shortcut to define ... possibly a condition to enable  
or disable it based
on context.

You have to:
- Subclass ServiceProvider for your application (you usually want to  
define several of those in a row, so it makes sense
to group them in a dedicated class)
- Define a method returning a ServiceAction object, in the 'services'  
method protocol.

anExampleOfAService
     ^ ServiceAction
             text: 'service example'
             button: 'ex'
             condition: [:r | "code fits here, the argument is an  
object so that you fetch the data needed"]
             action: [:r | "same thing"]

- describe in the "categories" method where your new action would fit  
(method menu, world menu ...), and it's keyboard shortcut. Thanks to  
keymapping, it can be something like "<m-x><c-c>r2d2" if you enjoy  
the emacs way ;-) (Actually, it is the only way to define new  
keyboard shortcuts in squeak, the keymap being quite crowded already).

then you can try it.

Note that in an earlier version of services, I had a kind of command  
line which worked like the emacs
one, featuring auto-completion of service names. Right now it is  
removed to keep the code base smaller,
but it could be implemented again.

Concerning annotations, it could be done in the same way, but the  
annotations will be quite big,
since there is a bit of description to do. so right now it is not  
implemented.

Cheers,
     Romain

On Sep 30, 2005, at 12:14 PM, 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
>
>

--
     Romain Robbes
     http://www.inf.unisi.ch/~robbes/





More information about the Squeak-dev mailing list