Addition of virtual events.
iogf opened this issue · comments
It may be better to implement custom keymaps for plugins
to use virtual events like:
class ExampleEvent(object):
def __init__(self, area):
self.area = area
area.install(('BETA', '<<ExampleEvent.OutputData>>', self.output_data))
area.event_add('<<ExampleEvent.OutputData>>', '<Key-h>')
def output_data(self, e):
self.area.insert('end', 'This is nice')
install = ExampleEvent
or it could be.
"""
Overview
========
Just a test to demonstrate virtual events.
Keycommands
===========
Mode: BETA
Event: <<ExampleEvent.OutputData>>, <Key-h>
Description: insert the text 'This is nice' on the focused
areavi.
"""
class ExampleEvent(object):
def __init__(self, area):
self.area = area
area.install(('BETA', ('<<ExampleEvent.OutputData>>', '<Key-h>', ...), self.output_data))
# area.event_add('<<ExampleEvent.OutputData>>', '<Key-h>')
def output_data(self, e):
self.area.insert('end', 'This is nice')
install = ExampleEvent
I do prefer the first one, but I don't get why going for this.
Is it a shortcut to bind multiple keys to the same function?
Like
<< VirtualEvent >> -> my_pretty_function
Key-a -> << VirtualEvent >>
Key-b -> << VirtualEvent >>
?
The main goal would be turning it easier for users to remap functionalities. Instead of having to remap a key to a key, one could just remap a custom event to a keypress. The custom event would be documented by the plugin. Basicly, you would do something like:
remap('<SomeFunctionality>', '<Key-x>')
Instead of
remap('<Key-y>', '<Key-x>')
Where Key-y is linked to some function. It is much more meaningful to have
'<Somefunctionality>'
rather than
'<Key-y>'
when having to remap keys.
Definetly true.
Although it could also be done the other way around by having a way to pass plugins params from vyrc where you could specify the keys you desires (as well other configurations some plugins might need, like where to find a language server if a plugin needs one) and, only if not found, fallback to default.
I still think remap is a cool feature to keep, but I do think it should not be the default for plugins key.