On Tue, Mar 19, 2013 at 6:05 PM, Damien Pollet <damien.pollet@gmail.com> wrote:
On 18 March 2013 21:45, Guillermo Polito <guillermopolito@gmail.com> wrote:
- Keymappings 101 tuto in blog (for 2.0, cause in 3.0 the api coould change a bit :)

I just read your post� question: is it possible to define semi-modal sequences?

Not easy I think... The problem is that VM does not raise events for every key pressed.. And those that does not work are for example ctrl, cmd, shift... Try modifying the following method:

signalEvent: eventBuffer
"Signal the event buffer to all registered event handlers.
Handlers need make sure to copy the buffer or extract the data otherwise, as the buffer will be reused."
--> Transcript show: eventBuffer asString;cr.
self eventHandlers do: [:handler |
handler handleEvent: eventBuffer]

Add the remarked line, open a transcript and press ctrl alone.

It is impossible to know right now if ctrl is being pressed or not by itself :(.�


Let me explain: modes are (hidden) states in the system that influence how it interprets inputs. Typical example is capslock: depending on its state, pressing the A key will give you a or A.

Having too many or unclear modes is bad, because you have to track their state in your mind, or take a specific action to know which mode you're in. In contrast, a semi-mode is when you need continuous physical action to maintain it; typical example is the modifier keys like shift alt ctrl� Semi-modes are a much better compromise (ideally there would be no modes anywhere, but that's not very realistic in practice).

To get back to my point, a semi-modal sequence would be:

($a asShortcut, $b asShortcut) ctrl "[press ctrl] a b [release ctrl]"

as opposed to:
$a asShortcut ctrl, $b asShortcut ctrl "maybe release ctrl in the middle"

where if you press ctrl-a and get interrupted, you're going to be confused when ctrl-b does not do what it's supposed to do as a standalone shortcut� if you're an emacs user, think ctrl-G, if you're a vim user, think spurious i's in your files��

--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet