[Pharo-project] [ANN]: Vim Shortcuts for Nautilus (Proof-of-concept)

Sean P. DeNigris sean at clipperadams.com
Mon Jul 9 08:54:08 EDT 2012


Guillermo Polito wrote
> 
>> * a way to register shortcuts/categories to be attached to a Morph class
>> by default
> 
> Nope :)... aBuilder attachShortcutCategory: #Window to: SystemWindow.
> 
Okay, I see them. The limitation of that approach is that it doesn't attach
them to the appropriate domain, but to all instances of a morph. For
example, Vim bindings should only be attached to morphs whose editor is
aSmalltalkEditor, but replacing SystemWindow above with SmalltalkEditor
doesn't work because the PluggableTextMorphXxx delegates to SmalltalkEditor
which only attaches the #SmalltalkEditor category to the Morph.


Guillermo Polito wrote
> 
> I'll integrate them again.
Already done, slice incoming...


Guillermo Polito wrote
> 
> You mean... to ban a shortcut from a morph?
Yes, here's the use case:
* To toggle vim modes between insert and command, I need "code-editing text
morphs" [2] to respond by default to Character escape asShortcut by
"entering command mode" [1].
* When they enter command mode, the Character escape shortcut should be
disabled only for that morph, and a new $i shortcut should be added to
return to insert mode, again only for that morph instance

And here's what I tried so far:
* include [1] in the #SmalltalkEditor category. This works, but then how do
I disable it for just one morph? I tried changing the shortcut to $i (return
to insert mode) [3], but that changes it for all instances. I though of a
hack to try to send the keystroke event to the morph if we're in command
mode, but that's ugly and requires digging into Morphic internals
* put [1] in a #VimInsertMode category. Then I could remove it from just one
instance, but I don't see how to attach it to just [2] i.e. "only morphs
where SmalltalkEditor is the editor". It looks like I can only attach it
per-class. If we were attaching the categories to the editor instead of the
morph (which I think you mentioned in a previous post), it would be more
flexible.

[3] buildInsertModeKeymappingsOn: aBuilder
	<keymap>

	(aBuilder shortcut: #toggleMode) 
		category: #SmalltalkEditor "#VimInsertModeShortcuts"
		default: Character escape asShortcut
		do: [ :target |  | me isInsertMode |
			isInsertMode := Editor dumbbellCursor not.
			me := KMRepository default keymapNamed: #toggleMode inCategory:
#SmalltalkEditor.
			isInsertMode
				ifTrue: [ 
					me shortcut: $i asShortcut.
					target attachKeymapCategory: #VimCommandModeShortcuts ]
				ifFalse: [ 
					me shortcut: Character escape asShortcut.
					target detachKeymapCategory: #VimCommandModeShortcuts ].
					
			Editor dumbbellCursor: Editor dumbbellCursor not.
			target changed ].


--
View this message in context: http://forum.world.st/ANN-Vim-Shortcuts-for-Nautilus-Proof-of-concept-tp4638987p4639177.html
Sent from the Pharo Smalltalk mailing list archive at Nabble.com.




More information about the Pharo-dev mailing list