Administrator
|
Now that we have Keymapping, why not, right?!
In Pharo 2.0: Gofer new url: 'http://ss3.gemstone.com/ss/VimPharo'; package: 'ConfigurationOfVimPharo'; load ConfigurationOfVimPharo project development load. 1. open a Nautilus browser 2. In the code pane, press escape to enter Vim command mode 3. Press the d key twice to delete the current line Two current bugs - Cursor changed globally when toggling command/insert mode. I don't know if/how you can change the cursor for just one morph/editor - Once you enter command mode, that morph will always have the command mode shortcuts Two Keymapping questions (help, guille!!): - how do I remove an individual shortcut or shortcut category from a morph? (so I can toggle the command/insert mode shortcuts) - how can I restore a morph's shortcuts to the defaults? Also, for the time being, I'm using the dumbbell cursor to indicate command mode because it was an easy hack. I'll check SVI to see how they made a block cursor, but if anyone has any pointers, I'm all ears. I'll be adding shortcuts as I need them and contributions are welcome. Also, I installed it for Nautilus arbitrarily. We'll probably be able to have them for all the tools... Cheers, Sean
Cheers,
Sean |
Hehe!
On Sat, Jul 7, 2012 at 4:46 PM, Sean P. DeNigris <[hidden email]> wrote: Now that we have Keymapping, why not, right?! To attach a category to a morph, you have the attachKeymapCategory* methods in morph (there are several flavors...). For dettaching, Ben did add some methods as nautilus extensions, but I'm not seeing them in latest 2.0... - how can I restore a morph's shortcuts to the defaults? try KMRepository reset That cleans the shortcut cache and recreates the shortcuts from the specs again.
|
Administrator
|
I just want to do it for one Morph instance
Cheers,
Sean |
On Sat, Jul 7, 2012 at 5:52 PM, Sean P. DeNigris <[hidden email]> wrote:
The thing is what you understand by default :). Because if you are adding shortcuts dinamically to morphs like: morph := SomeMorph new. morph attachKeymapCategory: #someShortcuts. morph attachKeymapCategory: #someShortcuts2. morph attachKeymapCategory: #someShortcuts3. morph attachKeymapCategory: #someShortcuts4. ... morph attachKeymapCategory: #VIMShortcuts. when will you consider the default? Maybe a default is with no shortcuts at all... Then you may need a static configuration... Or a more intelligent way to store shortcut configurations per morph. Or the capability to freeze them at some point in time and then go back to that state? But then you have to decide if you can override state, or storing all the checkpoints... I think we need to find some use cases that need this kind of behavior, so we build the right abstraction...
|
Administrator
|
Ah, yes! I was thinking that there was some standard set that PluggableXxxTextMorphYyy's got by default that could be distinguished from my modifications. Let me play with the shortcut removal methods (if we can find them, hee hee). That might be enough for now as long as I can hold onto the removed shortcuts/categories and reattach them when I'm done... Sean
Cheers,
Sean |
In reply to this post by Guillermo Polito
Those methods detach* has been moved from extension directly into KM.
It should be in the latest image, let me check Ben On Jul 7, 2012, at 5:49 PM, Guillermo Polito wrote: Hehe! |
Administrator
|
They are still extension methods in 20193 (and seem to be broken) Issue 6300: Detach keymaping shortcuts http://code.google.com/p/pharo/issues/detail?id=6300 Nautilus has Morph>>detach*KeymapCategory* extension methods. These are generally useful and should be moved from Nautilus to KM Also, they are broken... Morph>>detachKeymapCategory: signals MessageNotUnderstood: KMDispatcher>>detachKeymapCategory:
Cheers,
Sean |
Administrator
|
In reply to this post by Sean P. DeNigris
I'm having trouble toggling insert mode... Right now I have AbstractNautilusUI class>>buildInsertModeKeymappingsOn: aBuilder <keymap> (aBuilder shortcut: #commandMode) category: #NautilusSourceCodeShortcuts "#VimInsertModeShortcuts" default: Character escape asShortcut do: [ :target | Editor dumbbellCursor: true. target sourceTextArea changed. target sourceTextArea attachKeymapCategory: #VimCommandModeShortcuts ]. The problem is that: * I think I have to put these shortcuts into #NautilusSourceCodeShortcuts to have them load without overriding anything * If I don't put them in their own category (i.e. #VimInsertModeShortcuts), I don't know how to remove them when entering command mode (I only see a way to remove whole categories) Guille, Ben - are those assumptions correct and how should I proceed? Thanks, Sean
Cheers,
Sean |
If I were you, I would have put all the VIM shortcut in one class, instead of putting them around but :)
For the attachment, the solution could be to attach simultaneously several shortcuts category. Like that, you could add yours in a specific context, and remove them. An ugly solution right now could be to duplicate all the NautilusSourceCodeShortcuts entries, and to switch between NautilusSourceCodeShortcuts and VIMShortcuts. A kind of hack could be: AbstractNautilusUI class>>buildInsertModeKeymappingsOn: aBuilder <keymap> (KMRepository default categoryForName: #NautilusSourceCodeShortcuts) keymaps do: [:km | (aBuilder shortcut: (km name, 'VIM') asSymbol) category: VimInsertModeShortcuts default: km shortcut do: km action ]. (aBuilder shortcut: #commandMode) category: #NautilusSourceCodeShortcuts "#VimInsertModeShortcuts" default: Character escape asShortcut do: [ :target | Editor dumbbellCursor: true. target sourceTextArea changed. target sourceTextArea attachKeymapCategory: #VimCommandModeShortcuts ]. It's kind of a hack, but like that you ensure to have the same shortcuts in the midtime Ben On Jul 8, 2012, at 3:13 AM, Sean P. DeNigris wrote:
|
Administrator
|
I'll keep that in mind once I get it working ;-) Any luck finding those detach* methods? Googling/Nabbling "detachKeymapCategory" turned up nothing. Also, I think of my use case here for the "enter command mode" shortcut as "Change the default shortcuts for a Morph class". It seems that what's required for this type of use is a registration mechanism more like the world menu. For the world menu, I can insert an entry at any level, not just an existing one, without overriding anything. In KM currently, in order to do this, it seems we're forced to hitch a ride on an existing category. Maybe a special pragma indicating that certain categories should be attached for the class by default. In summary, I'm still unclear on the relationship between the class-side <keymap> defaults methods and changing shortcuts on the fly, but what seems to be missing are: * a way to register shortcuts/categories to be attached to a Morph class by default * a way to detach categories * a way to detach individual shortcuts Thanks, this is very exciting. We're *so* close to having this work... Sean
Cheers,
Sean |
Here is the detach methods filed out.
They are still extensions here, but they should be moved directly into KM We will succeed :P Ben On Jul 8, 2012, at 2:52 PM, Sean P. DeNigris wrote: > > Benjamin Van Ryseghem-2 wrote >> >> If I were you, I would have put all the VIM shortcut in one class, instead >> of putting them around but :) >> > I'll keep that in mind once I get it working ;-) > > > Benjamin Van Ryseghem-2 wrote >> >> Like that, you could add yours in a specific context, and remove them. >> > Any luck finding those detach* methods? Googling/Nabbling > "detachKeymapCategory" turned up nothing. > > Also, I think of my use case here for the "enter command mode" shortcut as > "Change the default shortcuts for a Morph class". It seems that what's > required for this type of use is a registration mechanism more like the > world menu. For the world menu, I can insert an entry at any level, not just > an existing one, without overriding anything. In KM currently, in order to > do this, it seems we're forced to hitch a ride on an existing category. > Maybe a special pragma indicating that certain categories should be attached > for the class by default. > > In summary, I'm still unclear on the relationship between the class-side > <keymap> defaults methods and changing shortcuts on the fly, but what seems > to be missing are: > * a way to register shortcuts/categories to be attached to a Morph class by > default > * a way to detach categories > * a way to detach individual shortcuts > > Thanks, this is very exciting. We're *so* close to having this work... > Sean > > -- > View this message in context: http://forum.world.st/ANN-Vim-Shortcuts-for-Nautilus-Proof-of-concept-tp4638987p4639088.html > Sent from the Pharo Smalltalk mailing list archive at Nabble.com. > Morph-*NautilusCommon-KeyMappingExtensions.st (894 bytes) Download Attachment KMDispatcher-*NautilusCommon-KeyMappingExtensions.st (952 bytes) Download Attachment |
In reply to this post by Sean P. DeNigris
On Sun, Jul 8, 2012 at 2:52 PM, Sean P. DeNigris <[hidden email]> wrote:
Nope :). Look at http://www.smalltalkhub.com/mc/Guille/Keymappings/main, in Keymapping-Morphic, KMWindowsKeymaps class>>buildGlobalKeymappingsOn:. The last line: aBuilder attachShortcutCategory: #Window to: SystemWindow. Those are static keybindings, and they were the first ones. I think I have to spend some hours in providing examples... * a way to detach categories I'll integrate them again. Ben, somehow the dettach* methods dissapeared from KMDispatcher in latest 2.0 :/. I'll have a look and integrate all of them in latest Keymapping version. * a way to detach individual shortcuts You mean removing a shortcut from a category? Or to ban a shortcut from a morph? Because here, I will be a bit strict with the nomenclature so we understand each other :) : - Static category keymappings: you attach a category to a class. ( The one in the example above ) - Dynamic category keymappings: you attach dinamically a category to an object. (the one you've used so far) - Dynamic object keymappings: you attach a single shortcut to an object, sending the #on:do: message So, were you using the third one? Removing a keymap from a category, which removes it from all the objects who use it, is easy but removing just for one object is not there, because the keymaps are looked up in the configuration, not flattened on the object.
|
Administrator
|
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. Already done, slice incoming... 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 ].
Cheers,
Sean |
Administrator
|
In reply to this post by Sean P. DeNigris
Version 0.2 (proof-of-concept)... Normal (ESC)/insert (i) toggle working. Still only one normal mode shortcut (dd), but they should mostly be easy to add (see below)...
* Disable toggling text cursor with mode. Paragraph will have to be refactored to allow per-Morph cursor styles * Fix normal/insert mode toggling. Now works per-morph The only normal mode shortcut so far is dd (delete line), but it should be simple to add most of them. The only ones I'm not sure about are multiples, like 3dd. I'm not sure if you can do regex shortcuts with Keymapping (e.g. '\d*' asRegexShortcut, $d asShortcut, $d asShortcut) * Load Pharo Slice 6300, if not present 1. open a Nautilus browser 2. In the code pane, press escape to enter Vim command mode 3. Press the d key twice to delete the current line 4. Press the i key and you will be back in insert mode (the usual Pharo mode)
Cheers,
Sean |
Free forum by Nabble | Edit this page |